OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 /** | 5 /** |
6 * @fileoverview | 6 * @fileoverview |
7 * 'settings-animated-pages' is a container for a page and animated subpages. | 7 * 'settings-animated-pages' is a container for a page and animated subpages. |
8 * It provides a set of common behaviors and animations. | 8 * It provides a set of common behaviors and animations. |
9 * | 9 * |
10 * The section name must match the name specified in settings_router.js. | |
11 * Otherwise, settings-animated-pages will not transition between subpages. | |
12 * | |
10 * Example: | 13 * Example: |
11 * | 14 * |
12 * <settings-animated-pages current-route="{{currentRoute}}" | 15 * <settings-animated-pages current-route="{{currentRoute}}" |
13 route-root="advanced/privacy" redirect-root-route-to="advanced"> | 16 * section="privacy"> |
14 * <!-- Insert your section controls here --> | 17 * <!-- Insert your section controls here --> |
15 * </settings-animated-pages> | 18 * </settings-animated-pages> |
16 * | 19 * |
17 * @group Chrome Settings Elements | 20 * @group Chrome Settings Elements |
18 * @element settings-animated-pages | 21 * @element settings-animated-pages |
19 */ | 22 */ |
20 Polymer({ | 23 Polymer({ |
21 is: 'settings-animated-pages', | 24 is: 'settings-animated-pages', |
22 | 25 |
23 properties: { | 26 properties: { |
24 /** | 27 /** |
25 * Contains the current route. | 28 * Contains the current route. |
26 */ | 29 */ |
27 currentRoute: { | 30 currentRoute: { |
28 type: Object, | 31 type: Object, |
29 notify: true, | 32 notify: true, |
30 observer: 'currentRouteChanged_', | 33 observer: 'currentRouteChanged_', |
31 }, | 34 }, |
32 | 35 |
33 /** | 36 /** |
34 * Routes with this section activate this element. For instance, if this | 37 * Routes with this section activate this element. For instance, if this |
35 * property is 'search', and currentRoute.section is also set to 'search', | 38 * property is 'search', and currentRoute.section is also set to 'search', |
36 * this element will display the subpage in currentRoute.subpage. | 39 * this element will display the subpage in currentRoute.subpage. |
37 */ | 40 */ |
michaelpg
2015/12/10 00:23:44
Could you consider adding the comment here instead
tommycli
2015/12/10 01:59:51
Done.
| |
38 section: { | 41 section: { |
39 type: String, | 42 type: String, |
40 }, | 43 }, |
41 }, | 44 }, |
42 | 45 |
43 /** @override */ | 46 /** @override */ |
44 created: function() { | 47 created: function() { |
45 this.addEventListener('subpage-back', function() { | 48 this.addEventListener('subpage-back', function() { |
46 assert(this.currentRoute.section == this.section); | 49 assert(this.currentRoute.section == this.section); |
47 assert(this.currentRoute.subpage.length >= 1); | 50 assert(this.currentRoute.subpage.length >= 1); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
83 * Buttons in this pageset should use this method to transition to subpages. | 86 * Buttons in this pageset should use this method to transition to subpages. |
84 */ | 87 */ |
85 setSubpageChain: function(subpage) { | 88 setSubpageChain: function(subpage) { |
86 this.currentRoute = { | 89 this.currentRoute = { |
87 page: this.currentRoute.page, | 90 page: this.currentRoute.page, |
88 section: subpage.length > 0 ? this.section : '', | 91 section: subpage.length > 0 ? this.section : '', |
89 subpage: subpage, | 92 subpage: subpage, |
90 }; | 93 }; |
91 }, | 94 }, |
92 }); | 95 }); |
OLD | NEW |