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.
5 var PageManager = cr.ui.pageManager.PageManager;
6 var BluetoothPairing = options.BluetoothPairing;
7 var FakeBluetoothOverlayParent = options.FakeBluetoothOverlayParent;
10 PageManager.closeOverlay = function() {
11 chrome.send('dialogClose');
15 * Listener for the |beforeunload| event.
17 window.onbeforeunload = function() {
18 PageManager.willClose();
22 * Override calls from BluetoothOptionsHandler.
24 cr.define('options', function() {
25 function BluetoothOptions() {}
27 BluetoothOptions.startDeviceDiscovery = function() {};
28 BluetoothOptions.updateDiscoveryState = function() {};
29 BluetoothOptions.dismissOverlay = function() {
30 PageManager.closeOverlay();
34 BluetoothOptions: BluetoothOptions
39 * DOMContentLoaded handler, sets up the page.
43 document.documentElement.setAttribute('os', 'chromeos');
45 // Decorate the existing elements in the document.
46 cr.ui.decorate('input[pref][type=checkbox]', options.PrefCheckbox);
47 cr.ui.decorate('input[pref][type=number]', options.PrefNumber);
48 cr.ui.decorate('input[pref][type=radio]', options.PrefRadio);
49 cr.ui.decorate('input[pref][type=range]', options.PrefRange);
50 cr.ui.decorate('select[pref]', options.PrefSelect);
51 cr.ui.decorate('input[pref][type=text]', options.PrefTextField);
52 cr.ui.decorate('input[pref][type=url]', options.PrefTextField);
54 // TODO(ivankr): remove when http://crosbug.com/20660 is resolved.
55 var inputs = document.querySelectorAll('input[pref]');
56 for (var i = 0, el; el = inputs[i]; i++) {
57 el.addEventListener('keyup', function(e) {
58 cr.dispatchSimpleEvent(this, 'change');
62 chrome.send('coreOptionsInitialize');
64 PageManager.register(FakeBluetoothOverlayParent.getInstance());
65 PageManager.registerOverlay(BluetoothPairing.getInstance(),
66 FakeBluetoothOverlayParent.getInstance());
69 var args = JSON.parse(chrome.getVariableValue('dialogArguments'));
71 device.pairing = 'bluetoothStartConnecting';
72 BluetoothPairing.showDialog(device);
73 chrome.send('updateBluetoothDevice', [device.address, 'connect']);
76 document.addEventListener('DOMContentLoaded', load);