1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/**
* @fileoverview
* 'cr-settings-main' displays the selected settings page.
*
* Example:
*
* <cr-settings-main pages="[[pages]]" selected-page-id="{{selectedId}}">
* </cr-settings-main>
*
* See cr-settings-drawer for example of use in 'paper-drawer-panel'.
*
* @group Chrome Settings Elements
* @element cr-settings-main
*/
Polymer({
is: 'cr-settings-main',
properties: {
/**
* Preferences state.
*
* @type {?CrSettingsPrefsElement}
*/
prefs: {
type: Object,
notify: true,
},
/**
* The current active route.
*/
currentRoute: {
type: Object,
notify: true,
observer: 'currentRouteChanged_',
},
},
listeners: {
'expand-animation-complete': 'onExpandAnimationComplete_',
},
/** @private */
currentRouteChanged_: function(newRoute, oldRoute) {
var pageContainer = this.$.pageContainer;
if (!oldRoute) {
pageContainer.classList.toggle('expanded', newRoute.section);
return;
}
// For contraction only, apply new styling immediately.
if (!newRoute.section && oldRoute.section) {
pageContainer.classList.remove('expanded');
// TODO(tommycli): Save and restore scroll position. crbug.com/537359.
pageContainer.scrollTop = 0;
}
},
/** @private */
onExpandAnimationComplete_: function() {
if (this.currentRoute.section) {
var pageContainer = this.$.pageContainer;
pageContainer.classList.add('expanded');
pageContainer.scrollTop = 0;
}
},
/** @private */
getSelectedPage_: function(currentRoute) {
return currentRoute.page || 'basic';
},
});
|