1 // Copyright (c) 2013 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 var OptionsPage = options.OptionsPage; 6 var BluetoothPairing = options.BluetoothPairing; 7 var FakeBluetoothOverlayParent = options.FakeBluetoothOverlayParent; 8 9 /** @override */ 10 OptionsPage.closeOverlay = function() { 11 chrome.send('DialogClose'); 12 }; 13 14 /** 15 * Listener for the |beforeunload| event. 16 */ 17 window.onbeforeunload = function() { 18 OptionsPage.willClose(); 19 }; 20 21 /** 22 * DOMContentLoaded handler, sets up the page. 23 */ 24 function load() { 25 if (cr.isChromeOS) 26 document.documentElement.setAttribute('os', 'chromeos'); 27 28 // Decorate the existing elements in the document. 29 cr.ui.decorate('input[pref][type=checkbox]', options.PrefCheckbox); 30 cr.ui.decorate('input[pref][type=number]', options.PrefNumber); 31 cr.ui.decorate('input[pref][type=radio]', options.PrefRadio); 32 cr.ui.decorate('input[pref][type=range]', options.PrefRange); 33 cr.ui.decorate('select[pref]', options.PrefSelect); 34 cr.ui.decorate('input[pref][type=text]', options.PrefTextField); 35 cr.ui.decorate('input[pref][type=url]', options.PrefTextField); 36 37 // TODO(ivankr): remove when http://crosbug.com/20660 is resolved. 38 var inputs = document.querySelectorAll('input[pref]'); 39 for (var i = 0, el; el = inputs[i]; i++) { 40 el.addEventListener('keyup', function(e) { 41 cr.dispatchSimpleEvent(this, 'change'); 42 }); 43 } 44 45 chrome.send('coreOptionsInitialize'); 46 47 OptionsPage.register(FakeBluetoothOverlayParent.getInstance()); 48 OptionsPage.registerOverlay(BluetoothPairing.getInstance(), 49 FakeBluetoothOverlayParent.getInstance()); 50 51 var device = {}; 52 var args = JSON.parse(chrome.getVariableValue('dialogArguments')); 53 device = args; 54 device.pairing = 'bluetoothStartConnecting'; 55 BluetoothPairing.showDialog(device); 56 chrome.send('updateBluetoothDevice', [device.address, 'connect']); 57 } 58 59 document.addEventListener('DOMContentLoaded', load); 60