OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 cr.define('sectioned', function() { |
| 6 'use strict'; |
| 7 |
| 8 function onContinue() { |
| 9 chrome.send('handleContinue'); |
| 10 } |
| 11 |
| 12 function onOpenSettings() { |
| 13 chrome.send('handleSetDefaultBrowser'); |
| 14 } |
| 15 |
| 16 function onToggle(app) { |
| 17 if (app.isCombined) { |
| 18 // Toggle sections. |
| 19 var sections = document.querySelectorAll('.section.expandable'); |
| 20 sections.forEach(function(section) { |
| 21 section.classList.toggle('expanded'); |
| 22 }); |
| 23 // Toggle screenshots. |
| 24 var screenshots = document.querySelectorAll('.screenshot-image'); |
| 25 screenshots.forEach(function(screenshot) { |
| 26 screenshot.classList.toggle('hidden'); |
| 27 }); |
| 28 } |
| 29 } |
| 30 |
| 31 function computeClasses(isCombined) { |
| 32 if (isCombined) |
| 33 return 'section expandable expanded'; |
| 34 return 'section'; |
| 35 } |
| 36 |
| 37 function initialize() { |
| 38 var app = $('sectioned-app'); |
| 39 |
| 40 app.isCombined = window.location.href.includes('variant=combined'); |
| 41 |
| 42 // Set handlers. |
| 43 app.computeClasses = computeClasses; |
| 44 app.onContinue = onContinue; |
| 45 app.onOpenSettings = onOpenSettings; |
| 46 app.onToggle = onToggle.bind(this, app); |
| 47 } |
| 48 |
| 49 return { |
| 50 initialize: initialize |
| 51 }; |
| 52 }); |
| 53 |
| 54 document.addEventListener('DOMContentLoaded', sectioned.initialize); |
OLD | NEW |