Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(237)

Side by Side Diff: chrome/browser/resources/welcome/win10/inline.js

Issue 2733433002: [Win10 FRE] Make inlined-image more Polymer-friendly to fix <action-link> CSS inclusion. (Closed)
Patch Set: Fix indentations for CSS and comments. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 cr.define('inline', function() { 5 Polymer({
6 'use strict'; 6 is: 'welcome-win10-inline',
7 7
8 function computeClasses(isCombined) { 8 receivePinnedState: function(isPinnedToTaskbar) {
9 this.isCombined = !isPinnedToTaskbar;
10 // Allow overriding of the result via a query parameter.
11 // TODO(pmonette): Remove these checks when they are no longer needed.
12 /** @const */
13 var VARIANT_KEY = 'variant';
14 var VariantType = {
15 DEFAULT_ONLY: 'defaultonly',
16 COMBINED: 'combined'
17 };
18 var params = new URLSearchParams(location.search.slice(1));
19 if (params.has(VARIANT_KEY)) {
20 if (params.get(VARIANT_KEY) === VariantType.DEFAULT_ONLY)
21 this.isCombined = false;
22 else if (params.get(VARIANT_KEY) === VariantType.COMBINED)
23 this.isCombined = true;
24 }
25 },
26
27 ready: function() {
28 this.isCombined = false;
29 // Asynchronously check if Chrome is pinned to the taskbar.
30 cr.sendWithPromise('getPinnedToTaskbarState').then(
31 this.receivePinnedState.bind(this));
32 },
33
34 computeClasses: function(isCombined) {
9 if (isCombined) 35 if (isCombined)
10 return 'section expandable expanded'; 36 return 'section expandable expanded';
11 return 'section'; 37 return 'section';
12 } 38 },
13 39
14 function onContinue() { 40 onContinue: function() {
15 chrome.send('handleContinue'); 41 chrome.send('handleContinue');
16 } 42 },
17 43
18 function onOpenSettings() { 44 onOpenSettings: function() {
19 chrome.send('handleSetDefaultBrowser'); 45 chrome.send('handleSetDefaultBrowser');
20 } 46 },
21 47
22 function onToggle(app) { 48 onToggle: function() {
23 if (app.isCombined) { 49 if (this.isCombined) {
24 var sections = document.querySelectorAll('.section.expandable'); 50 var sections = this.shadowRoot.querySelectorAll('.section.expandable');
25 sections.forEach(function(section) { 51 sections.forEach(function(section) {
26 section.classList.toggle('expanded'); 52 section.classList.toggle('expanded');
27 }); 53 });
28 } 54 }
29 } 55 },
30 56
31 function initialize() { 57 properties: {
tommycli 2017/03/02 23:30:54 Normally we put properties as the first item in th
huangs 2017/03/02 23:57:17 Done (after "is").
32 var app = $('inline-app');
33
34 // Set variables.
35 // Determines if the combined variant should be displayed. The combined 58 // Determines if the combined variant should be displayed. The combined
36 // variant includes instructions on how to pin Chrome to the taskbar. 59 // variant includes instructions on how to pin Chrome to the taskbar.
37 app.isCombined = false; 60 isCombined: Boolean
38
39 // Set handlers.
40 app.computeClasses = computeClasses;
41 app.onContinue = onContinue;
42 app.onOpenSettings = onOpenSettings;
43 app.onToggle = onToggle.bind(this, app);
44
45 // Asynchronously check if Chrome is pinned to the taskbar.
46 cr.sendWithPromise('getPinnedToTaskbarState').then(
47 function(isPinnedToTaskbar) {
48 // Allow overriding of the result via a query parameter.
49 // TODO(pmonette): Remove these checks when they are no longer needed.
50 /** @const */ var VARIANT_KEY = 'variant';
51 var VariantType = {
52 DEFAULT_ONLY: 'defaultonly',
53 COMBINED: 'combined'
54 };
55 var params = new URLSearchParams(location.search.slice(1));
56 if (params.has(VARIANT_KEY)) {
57 if (params.get(VARIANT_KEY) === VariantType.DEFAULT_ONLY)
58 app.isCombined = false;
59 else if (params.get(VARIANT_KEY) === VariantType.COMBINED)
60 app.isCombined = true;
61 } else {
62 app.isCombined = !isPinnedToTaskbar;
63 }
64 });
65 } 61 }
66
67 return {
68 initialize: initialize
69 };
70 }); 62 });
71
72 document.addEventListener('DOMContentLoaded', inline.initialize);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698