aboutsummaryrefslogtreecommitdiff
path: root/js/panels/Timeline/Collapser.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/panels/Timeline/Collapser.js')
-rw-r--r--js/panels/Timeline/Collapser.js94
1 files changed, 47 insertions, 47 deletions
diff --git a/js/panels/Timeline/Collapser.js b/js/panels/Timeline/Collapser.js
index d793ac88..e3d425ad 100644
--- a/js/panels/Timeline/Collapser.js
+++ b/js/panels/Timeline/Collapser.js
@@ -38,16 +38,16 @@ POSSIBILITY OF SUCH DAMAGE.
38 * Can be manually set as well. 38 * Can be manually set as well.
39 * collapsibleClass: The CSS class to apply to the content and the clicker when collapsed. Defaults to "collapsible-collapsed". 39 * collapsibleClass: The CSS class to apply to the content and the clicker when collapsed. Defaults to "collapsible-collapsed".
40 * isAnimated: Set to true to apply a transition to expand/collapse (defaults to false). 40 * isAnimated: Set to true to apply a transition to expand/collapse (defaults to false).
41 * transitionClass: If isAnimated is set to true, the component will apply transitionClass to the content during the 41 * transitionClass: If isAnimated is set to true, the component will apply transitionClass to the content during the
42 * collapse process. You can then define transitionClass in your style sheet with the desired CSS transitions. 42 * collapse process. You can then define transitionClass in your style sheet with the desired CSS transitions.
43 * Defaults to "collapsible-transition". 43 * Defaults to "collapsible-transition".
44 * contentHeight: If both isAnimated and isCollapsedAtStart are set to true, set contentHeight to the height of the content 44 * contentHeight: If both isAnimated and isCollapsedAtStart are set to true, set contentHeight to the height of the content
45 * (in pixels, but without the "px") when not collapsed. If this value is not set, the first time the content is expanded 45 * (in pixels, but without the "px") when not collapsed. If this value is not set, the first time the content is expanded
46 * the transition will not work. Subsequent collapses (and expansions) will transition as expected. 46 * the transition will not work. Subsequent collapses (and expansions) will transition as expected.
47 * isLabelClickable: Boolean that indicates whether or not the clicker should have listener events. Defaults to true; set to 47 * isLabelClickable: Boolean that indicates whether or not the clicker should have listener events. Defaults to true; set to
48 * false for collapsers that will only be operated remotely. 48 * false for collapsers that will only be operated remotely.
49 * isToggling: Set this anually toggle the expand/collapse of the content. 49 * isToggling: Set this anually toggle the expand/collapse of the content.
50 * 50 *
51 */ 51 */
52var Montage = require("montage/core/core").Montage, 52var Montage = require("montage/core/core").Montage,
53 Component = require("montage/ui/component").Component, 53 Component = require("montage/ui/component").Component,
@@ -57,9 +57,9 @@ var Montage = require("montage/core/core").Montage,
57 hasTemplate:{ 57 hasTemplate:{
58 value: false 58 value: false
59 }, 59 },
60 60
61 /* === BEGIN: Models === */ 61 /* === BEGIN: Models === */
62 62
63 // contentHeight: Stores the height of the content just before collapse. 63 // contentHeight: Stores the height of the content just before collapse.
64 _contentHeight: { 64 _contentHeight: {
65 value: 0 65 value: 0
@@ -73,13 +73,13 @@ var Montage = require("montage/core/core").Montage,
73 this._contentHeight = newVal; 73 this._contentHeight = newVal;
74 } 74 }
75 }, 75 },
76 76
77 // isCollapsing: true if the collapser is collapsing (or expanding); used in the draw cycle. 77 // isCollapsing: true if the collapser is collapsing (or expanding); used in the draw cycle.
78 _isCollapsing: { 78 _isCollapsing: {
79 value: false 79 value: false
80 }, 80 },
81 81
82 // isAnimated: boolean to apply transition to expand/collapse 82 // isAnimated: boolean to apply transition to expand/collapse
83 _isAnimated : { 83 _isAnimated : {
84 value: false 84 value: false
85 }, 85 },
@@ -92,7 +92,7 @@ var Montage = require("montage/core/core").Montage,
92 this._isAnimated = newVal; 92 this._isAnimated = newVal;
93 } 93 }
94 }, 94 },
95 95
96 _bypassAnimation : { 96 _bypassAnimation : {
97 value: true 97 value: true
98 }, 98 },
@@ -109,7 +109,7 @@ var Montage = require("montage/core/core").Montage,
109 _oldAnimated : { 109 _oldAnimated : {
110 value: false 110 value: false
111 }, 111 },
112 112
113 // transitionClass: The CSS class to apply to the content during collapse to provide CSS transition. 113 // transitionClass: The CSS class to apply to the content during collapse to provide CSS transition.
114 // Note that this CSS class must be defined in your style sheet with the desired transitions. 114 // Note that this CSS class must be defined in your style sheet with the desired transitions.
115 _transitionClass : { 115 _transitionClass : {
@@ -123,7 +123,7 @@ var Montage = require("montage/core/core").Montage,
123 this._transitionClass = newVal; 123 this._transitionClass = newVal;
124 } 124 }
125 }, 125 },
126 126
127 // isCollapsed: is the content actually collapsed at this moment 127 // isCollapsed: is the content actually collapsed at this moment
128 _isCollapsed: { 128 _isCollapsed: {
129 value: "" 129 value: ""
@@ -140,7 +140,7 @@ var Montage = require("montage/core/core").Montage,
140 } 140 }
141 } 141 }
142 }, 142 },
143 143
144 // collapsedClass: the class to apply to the clicker and content when the content is collapsed. 144 // collapsedClass: the class to apply to the clicker and content when the content is collapsed.
145 _collapsedClass : { 145 _collapsedClass : {
146 value: "collapsible-collapsed" 146 value: "collapsible-collapsed"
@@ -153,14 +153,14 @@ var Montage = require("montage/core/core").Montage,
153 this._collapsedClass = newVal; 153 this._collapsedClass = newVal;
154 } 154 }
155 }, 155 },
156 156
157 // _origOverflowValue: Stores the original overflow value of the collapsible element. 157 // _origOverflowValue: Stores the original overflow value of the collapsible element.
158 // Why store the value? While the collapsible element is collapsed, obviously we will need overflow: hidden. 158 // Why store the value? While the collapsible element is collapsed, obviously we will need overflow: hidden.
159 // But when the collapsible element is open, we will need overflow to return to its original value. 159 // But when the collapsible element is open, we will need overflow to return to its original value.
160 _origOverflowValue : { 160 _origOverflowValue : {
161 value: false 161 value: false
162 }, 162 },
163 163
164 // isLabelClickable: Boolean for whether or not the label is clickable. If set to false, 164 // isLabelClickable: Boolean for whether or not the label is clickable. If set to false,
165 // the label click listener is never applied. For collapsibles that will only be operated remotely. 165 // the label click listener is never applied. For collapsibles that will only be operated remotely.
166 // Defaults to true. 166 // Defaults to true.
@@ -217,7 +217,7 @@ var Montage = require("montage/core/core").Montage,
217 set: function(newVal) { 217 set: function(newVal) {
218 if (newVal !== this._isToggling) { 218 if (newVal !== this._isToggling) {
219 this._isToggling = newVal; 219 this._isToggling = newVal;
220 220
221 if (this.bypassAnimation === true) { 221 if (this.bypassAnimation === true) {
222 this._oldAnimated = this.isAnimated; 222 this._oldAnimated = this.isAnimated;
223 this.isAnimated = false; 223 this.isAnimated = false;
@@ -227,11 +227,11 @@ var Montage = require("montage/core/core").Montage,
227 } 227 }
228 } 228 }
229 }, 229 },
230 230
231 /* === END: Models === */ 231 /* === END: Models === */
232 232
233 /* === BEGIN: Draw cycle === */ 233 /* === BEGIN: Draw cycle === */
234 234
235 prepareForDraw: { 235 prepareForDraw: {
236 value: function() { 236 value: function() {
237 // Get the original value of the overflow property: 237 // Get the original value of the overflow property:
@@ -239,7 +239,7 @@ var Montage = require("montage/core/core").Montage,
239 if (this.isCollapsed === false) { 239 if (this.isCollapsed === false) {
240 this.myContent.style.height = "auto"; 240 this.myContent.style.height = "auto";
241 } 241 }
242 242
243 243
244 // If the content area is supposed to start out collapsed: 244 // If the content area is supposed to start out collapsed:
245 if (this.isCollapsed) { 245 if (this.isCollapsed) {
@@ -259,19 +259,19 @@ var Montage = require("montage/core/core").Montage,
259 }, 259 },
260 draw: { 260 draw: {
261 value: function() { 261 value: function() {
262 // Is the content area expanding/collapsing? 262 // Is the content area expanding/collapsing?
263 this.myContent.classList.remove(this.transitionClass); 263 this.myContent.classList.remove(this.transitionClass);
264 if (this._isCollapsing) { 264 if (this._isCollapsing) {
265 265
266 if (this.isAnimated) { 266 if (this.isAnimated) {
267 // Apply the transition class to the content. 267 // Apply the transition class to the content.
268 this.myContent.classList.add(this.transitionClass); 268 this.myContent.classList.add(this.transitionClass);
269 269
270 // Add a handler for the end of the transition, so we can tidy things up after 270 // Add a handler for the end of the transition, so we can tidy things up after
271 // the transition completes 271 // the transition completes
272 this.myContent.identifier = "myContent"; 272 this.myContent.identifier = "myContent";
273 this.myContent.addEventListener("webkitTransitionEnd", this, false); 273 this.myContent.addEventListener("webkitTransitionEnd", this, false);
274 274
275 this.myContent.style.overflow = "hidden"; 275 this.myContent.style.overflow = "hidden";
276 } 276 }
277 277
@@ -280,24 +280,24 @@ var Montage = require("montage/core/core").Montage,
280 // It's already collapsed so we are expanding 280 // It's already collapsed so we are expanding
281 this.myContent.style.height = this.contentHeight + "px"; 281 this.myContent.style.height = this.contentHeight + "px";
282 this.isCollapsed = false; 282 this.isCollapsed = false;
283 283
284 } else { 284 } else {
285 // It's expanded so we are collapsing 285 // It's expanded so we are collapsing
286 this.myContent.style.height = "0px"; 286 this.myContent.style.height = "0px";
287 this.isCollapsed = true; 287 this.isCollapsed = true;
288 288
289 // Set the overflow to hidden if it isn't already 289 // Set the overflow to hidden if it isn't already
290 if (this._origOverflowValue !== "hidden") { 290 if (this._origOverflowValue !== "hidden") {
291 this.myContent.style.overflow = "hidden"; 291 this.myContent.style.overflow = "hidden";
292 } 292 }
293 } 293 }
294 294
295 // Toggle the CSS class and deactivate the collapsing flag because we are now done. 295 // Toggle the CSS class and deactivate the collapsing flag because we are now done.
296 this.myContent.classList.toggle(this.collapsedClass); 296 this.myContent.classList.toggle(this.collapsedClass);
297 this.clicker.classList.toggle(this.collapsedClass); 297 this.clicker.classList.toggle(this.collapsedClass);
298 this._isCollapsing = false; 298 this._isCollapsing = false;
299 299
300 // Special cases: If transition does not happen (in th