| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2010 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('options', function() { | |
| 6 const OptionsPage = options.OptionsPage; | |
| 7 const ArrayDataModel = cr.ui.ArrayDataModel; | |
| 8 const ListSingleSelectionModel = cr.ui.ListSingleSelectionModel; | |
| 9 | |
| 10 /** | |
| 11 * Encapsulated handling of startup page management page. | |
| 12 * @constructor | |
| 13 */ | |
| 14 function StartupPageManager() { | |
| 15 this.activeNavTab = null; | |
| 16 OptionsPage.call(this, 'startupPages', | |
| 17 templateData.StartupPageManagerPage, | |
| 18 'startupPageManagerPage'); | |
| 19 } | |
| 20 | |
| 21 cr.addSingletonGetter(StartupPageManager); | |
| 22 | |
| 23 StartupPageManager.prototype = { | |
| 24 __proto__: OptionsPage.prototype, | |
| 25 list_: null, | |
| 26 | |
| 27 initializePage: function() { | |
| 28 OptionsPage.prototype.initializePage.call(this); | |
| 29 | |
| 30 var list = $('startupPagesFullList'); | |
| 31 options.browser_options.StartupPageList.decorate(list); | |
| 32 list.autoExpands = true; | |
| 33 list.selectionModel = new ListSingleSelectionModel; | |
| 34 | |
| 35 // Wire up controls. | |
| 36 $('startupAddButton').onclick = function(event) { | |
| 37 OptionsPage.showOverlay('addStartupPageOverlay'); | |
| 38 }; | |
| 39 | |
| 40 // Remove Windows-style accelerators from button labels. | |
| 41 // TODO(stuartmorgan): Remove this once the strings are updated. | |
| 42 $('startupAddButton').textContent = | |
| 43 localStrings.getStringWithoutAccelerator('startupAddButton'); | |
| 44 }, | |
| 45 | |
| 46 /** | |
| 47 * Updates the startup pages list with the given entries. | |
| 48 * @param {Array} pages List of startup pages. | |
| 49 * @private | |
| 50 */ | |
| 51 updateStartupPages_: function(pages) { | |
| 52 $('startupPagesFullList').dataModel = new ArrayDataModel(pages); | |
| 53 }, | |
| 54 | |
| 55 /** | |
| 56 * Adds the given startup page at the current selection point. | |
| 57 * @private | |
| 58 */ | |
| 59 addStartupPage_: function(url) { | |
| 60 var firstSelection = | |
| 61 $('startupPagesFullList').selectionModel.selectedIndex; | |
| 62 chrome.send('addStartupPage', [url, String(firstSelection)]); | |
| 63 }, | |
| 64 }; | |
| 65 | |
| 66 StartupPageManager.updateStartupPages = function(pages) { | |
| 67 StartupPageManager.getInstance().updateStartupPages_(pages); | |
| 68 }; | |
| 69 | |
| 70 StartupPageManager.addStartupPage = function(url) { | |
| 71 StartupPageManager.getInstance().addStartupPage_(url); | |
| 72 }; | |
| 73 | |
| 74 // Export | |
| 75 return { | |
| 76 StartupPageManager: StartupPageManager | |
| 77 }; | |
| 78 | |
| 79 }); | |
| 80 | |
| OLD | NEW |