OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
tmartino
2016/10/12 22:06:40
We have a lot of dupe code between these JS files
Patrick Monette
2016/10/13 21:30:05
I tried something. What do you think now?
| |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 cr.define('welcome', function() { | |
6 'use strict'; | |
7 | |
8 function injectLocalizedStrings() { | |
9 $('section-steps--click-edge').innerHTML = | |
10 loadTimeData.getString('clickEdgeText'); | |
11 $('section-steps--select-chrome').innerHTML = | |
12 loadTimeData.getString('clickSelectChrome'); | |
13 $('section-steps--right-click').innerHTML = | |
14 loadTimeData.getString('rightClickText'); | |
15 $('section-steps--pin-taskbar').innerHTML = | |
16 loadTimeData.getString('pinInstructionText'); | |
17 } | |
18 | |
19 function toggleSections(sections, screenshotImages) { | |
tmartino
2016/10/12 22:06:40
|screenshotImages| unused?
Patrick Monette
2016/10/13 21:30:05
Good catch. Removed.
| |
20 sections.forEach(function(section) { | |
21 section.classList.toggle('section--expanded'); | |
22 }); | |
23 } | |
24 | |
25 function onSetDefaultBrowser(e) { | |
26 chrome.send('handleSetDefaultBrowser'); | |
27 } | |
28 | |
29 function onContinue(e) { | |
30 chrome.send('handleContinue'); | |
31 } | |
32 | |
33 function initialize() { | |
34 injectLocalizedStrings(); | |
35 | |
36 var sections = document.querySelectorAll('.section'); | |
37 var screenshotImages = document.querySelectorAll('.screenshot-image'); | |
38 sections.forEach(function(section) { | |
39 var sectionHeading = section.querySelector('.section-heading'); | |
40 sectionHeading.addEventListener('click', function() { | |
41 toggleSections(sections, screenshotImages); | |
42 }); | |
43 }); | |
44 | |
45 $('set-default-button').addEventListener('click', onSetDefaultBrowser); | |
46 $('continue-button').addEventListener('click', onContinue); | |
47 } | |
48 | |
49 return { | |
50 initialize: initialize | |
51 }; | |
52 }); | |
53 | |
54 document.addEventListener('DOMContentLoaded', welcome.initialize); | |
OLD | NEW |