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 Polymer({ | 5 Polymer({ |
6 is: 'welcome-win10-inline', | 6 is: 'welcome-win10-inline', |
7 | 7 |
8 properties: { | 8 properties: { |
9 // Determines if the combined variant should be displayed. The combined | 9 // Determines if the combined variant should be displayed. The combined |
10 // variant includes instructions on how to pin Chrome to the taskbar. | 10 // variant includes instructions on how to pin Chrome to the taskbar. |
11 isCombined: Boolean | 11 isCombined: Boolean |
12 }, | 12 }, |
13 | 13 |
14 receivePinnedState_: function(isPinnedToTaskbar) { | 14 receivePinnedState_: function(isPinnedToTaskbar) { |
15 // Allow overriding of the result via a query parameter. | 15 // Allow overriding of the result via a query parameter. |
16 // TODO(pmonette): Remove these checks when they are no longer needed. | 16 // TODO(pmonette): Remove these checks when they are no longer needed. |
17 /** @const */ | 17 /** @const */ |
18 var VARIANT_KEY = 'variant'; | 18 var VARIANT_KEY = 'variant'; |
19 var VariantTypeMap = { 'defaultonly': false, 'combined': true }; | 19 var VariantTypeMap = {'defaultonly': false, 'combined': true}; |
20 var params = new URLSearchParams(location.search.slice(1)); | 20 var params = new URLSearchParams(location.search.slice(1)); |
21 if (params.has(VARIANT_KEY) && params.get(VARIANT_KEY) in VariantTypeMap) | 21 if (params.has(VARIANT_KEY) && params.get(VARIANT_KEY) in VariantTypeMap) |
22 this.isCombined = VariantTypeMap[params.get(VARIANT_KEY)]; | 22 this.isCombined = VariantTypeMap[params.get(VARIANT_KEY)]; |
23 else | 23 else |
24 this.isCombined = !isPinnedToTaskbar; | 24 this.isCombined = !isPinnedToTaskbar; |
25 | 25 |
26 // Show the module. | 26 // Show the module. |
27 this.style.opacity = 1; | 27 this.style.opacity = 1; |
28 }, | 28 }, |
29 | 29 |
30 ready: function() { | 30 ready: function() { |
31 this.isCombined = false; | 31 this.isCombined = false; |
32 // Asynchronously check if Chrome is pinned to the taskbar. | 32 // Asynchronously check if Chrome is pinned to the taskbar. |
33 cr.sendWithPromise('getPinnedToTaskbarState').then( | 33 cr.sendWithPromise('getPinnedToTaskbarState') |
34 this.receivePinnedState_.bind(this)); | 34 .then(this.receivePinnedState_.bind(this)); |
35 }, | 35 }, |
36 | 36 |
37 computeClasses: function(isCombined) { | 37 computeClasses: function(isCombined) { |
38 return isCombined ? 'section expandable expanded' : 'section'; | 38 return isCombined ? 'section expandable expanded' : 'section'; |
39 }, | 39 }, |
40 | 40 |
41 onContinue: function() { | 41 onContinue: function() { |
42 chrome.send('handleContinue'); | 42 chrome.send('handleContinue'); |
43 }, | 43 }, |
44 | 44 |
45 onOpenSettings: function() { | 45 onOpenSettings: function() { |
46 chrome.send('handleSetDefaultBrowser'); | 46 chrome.send('handleSetDefaultBrowser'); |
47 }, | 47 }, |
48 | 48 |
49 onToggle: function() { | 49 onToggle: function() { |
50 if (!this.isCombined) | 50 if (!this.isCombined) |
51 return; | 51 return; |
52 var sections = this.shadowRoot.querySelectorAll('.section.expandable'); | 52 var sections = this.shadowRoot.querySelectorAll('.section.expandable'); |
53 sections.forEach(function(section) { | 53 sections.forEach(function(section) { |
54 var isExpanded = section.classList.toggle('expanded'); | 54 var isExpanded = section.classList.toggle('expanded'); |
55 section.querySelector('[role~="button"]').setAttribute( | 55 section.querySelector('[role~="button"]') |
56 'aria-expanded', isExpanded); | 56 .setAttribute('aria-expanded', isExpanded); |
57 }); | 57 }); |
58 } | 58 } |
59 }); | 59 }); |
OLD | NEW |