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 * DOMContentLoaded handler, sets up the page.
26 document
.documentElement
.setAttribute('os', 'chromeos');
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
);
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');
45 chrome
.send('coreOptionsInitialize');
47 PageManager
.register(FakeBluetoothOverlayParent
.getInstance());
48 PageManager
.registerOverlay(BluetoothPairing
.getInstance(),
49 FakeBluetoothOverlayParent
.getInstance());
52 var args
= JSON
.parse(chrome
.getVariableValue('dialogArguments'));
54 device
.pairing
= 'bluetoothStartConnecting';
55 BluetoothPairing
.showDialog(device
);
56 chrome
.send('updateBluetoothDevice', [device
.address
, 'connect']);
59 document
.addEventListener('DOMContentLoaded', load
);