OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Fast out, slow in. | 5 // Fast out, slow in. |
6 var EASING_FUNCTION = 'cubic-bezier(0.4, 0, 0.2, 1)'; | 6 var EASING_FUNCTION = 'cubic-bezier(0.4, 0, 0.2, 1)'; |
7 var EXPAND_DURATION = 350; | 7 var EXPAND_DURATION = 350; |
8 | 8 |
9 /** | 9 /** |
10 * Calls |readyTest| repeatedly until it returns true, then calls | 10 * Calls |readyTest| repeatedly until it returns true, then calls |
(...skipping 12 matching lines...) Expand all Loading... |
23 }, 10); | 23 }, 10); |
24 } | 24 } |
25 | 25 |
26 /** | 26 /** |
27 * Provides animations to expand and collapse individual sections in a page. | 27 * Provides animations to expand and collapse individual sections in a page. |
28 * Expanded sections take up the full height of the container. At most one | 28 * Expanded sections take up the full height of the container. At most one |
29 * section should be expanded at any given time. | 29 * section should be expanded at any given time. |
30 * @polymerBehavior Polymer.MainPageBehavior | 30 * @polymerBehavior Polymer.MainPageBehavior |
31 */ | 31 */ |
32 var MainPageBehaviorImpl = { | 32 var MainPageBehaviorImpl = { |
33 /** | |
34 * @type {string} Selector to get the sections. Derived elements | |
35 * must override. | |
36 */ | |
37 sectionSelector: '', | |
38 | |
39 /** @type {?Element} The scrolling container. */ | 33 /** @type {?Element} The scrolling container. */ |
40 scroller: null, | 34 scroller: null, |
41 | 35 |
42 /** @override */ | 36 /** @override */ |
43 attached: function() { | 37 attached: function() { |
44 if (this.domHost && this.domHost.parentNode.tagName == 'PAPER-HEADER-PANEL') | 38 if (this.domHost && this.domHost.parentNode.tagName == 'PAPER-HEADER-PANEL') |
45 this.scroller = this.domHost.parentNode.$.mainContainer; | 39 this.scroller = this.domHost.parentNode.$.mainContainer; |
46 else | 40 else |
47 this.scroller = document.body; // Used in unit tests. | 41 this.scroller = document.body; // Used in unit tests. |
48 }, | 42 }, |
49 | 43 |
50 /** | 44 /** |
51 * Hides or unhides the sections not being expanded. | 45 * Hides or unhides the sections not being expanded. |
52 * @param {string} sectionName The section to keep visible. | 46 * @param {string} sectionName The section to keep visible. |
53 * @param {boolean} hidden Whether the sections should be hidden. | 47 * @param {boolean} hidden Whether the sections should be hidden. |
54 * @private | 48 * @private |
55 */ | 49 */ |
56 toggleOtherSectionsHidden_: function(sectionName, hidden) { | 50 toggleOtherSectionsHidden_: function(sectionName, hidden) { |
57 var sections = Polymer.dom(this.root).querySelectorAll( | 51 var sections = Polymer.dom(this.root).querySelectorAll( |
58 this.sectionSelector); | 52 'settings-section'); |
59 for (var section of sections) | 53 for (var section of sections) |
60 section.hidden = hidden && (section.section != sectionName); | 54 section.hidden = hidden && (section.section != sectionName); |
61 }, | 55 }, |
62 | 56 |
63 /** | 57 /** |
64 * Animates the card in |section|, expanding it to fill the page. | 58 * Animates the card in |section|, expanding it to fill the page. |
65 * @param {!SettingsSectionElement} section | 59 * @param {!SettingsSectionElement} section |
66 */ | 60 */ |
67 expandSection: function(section) { | 61 expandSection: function(section) { |
68 // If another section's card is expanding, cancel that animation first. | 62 // If another section's card is expanding, cancel that animation first. |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 this.$$('[section=' + section + ']')); | 421 this.$$('[section=' + section + ']')); |
428 }, | 422 }, |
429 }; | 423 }; |
430 | 424 |
431 | 425 |
432 /** @polymerBehavior */ | 426 /** @polymerBehavior */ |
433 var RoutableBehavior = [ | 427 var RoutableBehavior = [ |
434 MainPageBehavior, | 428 MainPageBehavior, |
435 RoutableBehaviorImpl | 429 RoutableBehaviorImpl |
436 ]; | 430 ]; |
OLD | NEW |