not really known
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

202 lines
6.3 KiB

  1. /**
  2. _enyo.LeftRightArranger_ is an <a href="#enyo.Arranger">enyo.Arranger</a>
  3. that displays the active control and some of the previous and next controls.
  4. The active control is centered horizontally in the container, and the
  5. previous and next controls are laid out to the left and right, respectively.
  6. Transitions between arrangements are handled by sliding the new control
  7. in from the right and sliding the active control out to the left.
  8. */
  9. enyo.kind({
  10. name: "enyo.LeftRightArranger",
  11. kind: "Arranger",
  12. //* The margin width (i.e., how much of the previous and next controls
  13. //* are visible) in pixels
  14. margin: 40,
  15. //* @protected
  16. axisSize: "width",
  17. offAxisSize: "height",
  18. axisPosition: "left",
  19. constructor: function() {
  20. this.inherited(arguments);
  21. this.margin = this.container.margin != null ? this.container.margin : this.margin;
  22. },
  23. //* @public
  24. size: function() {
  25. var c$ = this.container.getPanels();
  26. var port = this.containerBounds[this.axisSize];
  27. var box = port - this.margin -this.margin;
  28. for (var i=0, b, c; c=c$[i]; i++) {
  29. b = {};
  30. b[this.axisSize] = box;
  31. b[this.offAxisSize] = "100%";
  32. c.setBounds(b);
  33. }
  34. },
  35. arrange: function(inC, inIndex) {
  36. var o = Math.floor(this.container.getPanels().length/2);
  37. var c$ = this.getOrderedControls(Math.floor(inIndex)-o);
  38. var box = this.containerBounds[this.axisSize] - this.margin -this.margin;
  39. var e = this.margin - box * o;
  40. var m = (c$.length - 1) / 2;
  41. for (var i=0, c, b, v; c=c$[i]; i++) {
  42. b = {};
  43. b[this.axisPosition] = e;
  44. b.opacity = (i == 0 || i == c$.length-1) ? 0 : 1;
  45. this.arrangeControl(c, b);
  46. e += box;
  47. }
  48. },
  49. calcArrangementDifference: function(inI0, inA0, inI1, inA1) {
  50. var i = Math.abs(inI0 % this.c$.length);
  51. //enyo.log(inI0, inI1);
  52. return inA0[i][this.axisPosition] - inA1[i][this.axisPosition];
  53. },
  54. destroy: function() {
  55. var c$ = this.container.getPanels();
  56. for (var i=0, c; c=c$[i]; i++) {
  57. enyo.Arranger.positionControl(c, {left: null, top: null});
  58. enyo.Arranger.opacifyControl(c, 1);
  59. c.applyStyle("left", null);
  60. c.applyStyle("top", null);
  61. c.applyStyle("height", null);
  62. c.applyStyle("width", null);
  63. }
  64. this.inherited(arguments);
  65. }
  66. });
  67. /**
  68. _enyo.TopBottomArranger_ is an <a href="#enyo.Arranger">enyo.Arranger</a>
  69. that displays the active control and some of the previous and next controls.
  70. The active control is centered vertically in the container, and the previous
  71. and next controls are laid out above and below, respectively.
  72. Transitions between arrangements are handled by sliding the new control
  73. in from the bottom and sliding the active control out the top.
  74. */
  75. enyo.kind({
  76. name: "enyo.TopBottomArranger",
  77. kind: "LeftRightArranger",
  78. dragProp: "ddy",
  79. dragDirectionProp: "yDirection",
  80. canDragProp: "vertical",
  81. //* @protected
  82. axisSize: "height",
  83. offAxisSize: "width",
  84. axisPosition: "top"
  85. });
  86. /**
  87. _enyo.SpiralArranger_ is an <a href="#enyo.Arranger">enyo.Arranger</a> that
  88. arranges controls in a spiral. The active control is positioned on top and
  89. the other controls are laid out in a spiral pattern below.
  90. Transitions between arrangements are handled by rotating the new control
  91. up from below and rotating the active control down to the end of the spiral.
  92. */
  93. enyo.kind({
  94. name: "enyo.SpiralArranger",
  95. kind: "Arranger",
  96. //* Always go through incremental arrangements when transitioning
  97. incrementalPoints: true,
  98. //* The amount of space between successive controls
  99. inc: 20,
  100. size: function() {
  101. var c$ = this.container.getPanels();
  102. var b = this.containerBounds;
  103. var w = this.controlWidth = b.width/3;
  104. var h = this.controlHeight = b.height/3;
  105. for (var i=0, c; c=c$[i]; i++) {
  106. c.setBounds({width: w, height: h});
  107. }
  108. },
  109. arrange: function(inC, inName) {
  110. var s = this.inc;
  111. for (var i=0, l=inC.length, c; c=inC[i]; i++) {
  112. var x = Math.cos(i/l * 2*Math.PI) * i * s + this.controlWidth;
  113. var y = Math.sin(i/l * 2*Math.PI) * i * s + this.controlHeight;
  114. this.arrangeControl(c, {left: x, top: y});
  115. }
  116. },
  117. start: function() {
  118. this.inherited(arguments);
  119. var c$ = this.getOrderedControls(this.container.toIndex);
  120. for (var i=0, c; c=c$[i]; i++) {
  121. c.applyStyle("z-index", c$.length - i);
  122. }
  123. },
  124. calcArrangementDifference: function(inI0, inA0, inI1, inA1) {
  125. return this.controlWidth;
  126. },
  127. destroy: function() {
  128. var c$ = this.container.getPanels();
  129. for (var i=0, c; c=c$[i]; i++) {
  130. c.applyStyle("z-index", null);
  131. enyo.Arranger.positionControl(c, {left: null, top: null});
  132. c.applyStyle("left", null);
  133. c.applyStyle("top", null);
  134. c.applyStyle("height", null);
  135. c.applyStyle("width", null);
  136. }
  137. this.inherited(arguments);
  138. }
  139. });
  140. /**
  141. _enyo.GridArranger_ is an <a href="#enyo.Arranger">enyo.Arranger</a> that
  142. arranges controls in a grid. The active control is positioned at the
  143. top-left of the grid and the other controls are laid out from left to right
  144. and then from top to bottom.
  145. Transitions between arrangements are handled by moving the active control to
  146. the end of the grid and shifting the other controls to the left, or up to
  147. the previous row, to fill the space.
  148. */
  149. enyo.kind({
  150. name: "enyo.GridArranger",
  151. kind: "Arranger",
  152. //* Always go through incremental arrangements when transitioning
  153. incrementalPoints: true,
  154. //* @public
  155. //* Column width
  156. colWidth: 100,
  157. //* Column height
  158. colHeight: 100,
  159. size: function() {
  160. var c$ = this.container.getPanels();
  161. var w=this.colWidth, h=this.colHeight;
  162. for (var i=0, c; c=c$[i]; i++) {
  163. c.setBounds({width: w, height: h});
  164. }
  165. },
  166. arrange: function(inC, inIndex) {
  167. var w=this.colWidth, h=this.colHeight;
  168. var cols = Math.floor(this.containerBounds.width / w);
  169. var c;
  170. for (var y=0, i=0; i<inC.length; y++) {
  171. for (var x=0; (x<cols) && (c=inC[i]); x++, i++) {
  172. this.arrangeControl(c, {left: w*x, top: h*y});
  173. }
  174. }
  175. },
  176. flowControl: function(inControl, inA) {
  177. this.inherited(arguments);
  178. enyo.Arranger.opacifyControl(inControl, inA.top % this.colHeight != 0 ? 0.25 : 1);
  179. },
  180. calcArrangementDifference: function(inI0, inA0, inI1, inA1) {
  181. return this.colWidth;
  182. },
  183. destroy: function() {
  184. var c$ = this.container.getPanels();
  185. for (var i=0, c; c=c$[i]; i++) {
  186. enyo.Arranger.positionControl(c, {left: null, top: null});
  187. c.applyStyle("left", null);
  188. c.applyStyle("top", null);
  189. c.applyStyle("height", null);
  190. c.applyStyle("width", null);
  191. }
  192. this.inherited(arguments);
  193. }
  194. });