1 // Copyright (c) 2012 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 Preferences = options.Preferences; 7 var DetailsInternetPage = options.internet.DetailsInternetPage; 8 9 /** 10 * DOMContentLoaded handler, sets up the page. 11 */ 12 function load() { 13 if (cr.isChromeOS) 14 document.documentElement.setAttribute('os', 'chromeos'); 15 16 // Decorate the existing elements in the document. 17 cr.ui.decorate('input[pref][type=checkbox]', options.PrefCheckbox); 18 cr.ui.decorate('input[pref][type=number]', options.PrefNumber); 19 cr.ui.decorate('input[pref][type=radio]', options.PrefRadio); 20 cr.ui.decorate('input[pref][type=range]', options.PrefRange); 21 cr.ui.decorate('select[pref]', options.PrefSelect); 22 cr.ui.decorate('input[pref][type=text]', options.PrefTextField); 23 cr.ui.decorate('input[pref][type=url]', options.PrefTextField); 24 25 DetailsInternetPage.initializeProxySettings(); 26 27 // TODO(ivankr): remove when http://crosbug.com/20660 is resolved. 28 var inputs = document.querySelectorAll('input[pref]'); 29 for (var i = 0, el; el = inputs[i]; i++) { 30 el.addEventListener('keyup', function(e) { 31 cr.dispatchSimpleEvent(this, 'change'); 32 }); 33 } 34 35 Preferences.getInstance().initialize(); 36 chrome.send('coreOptionsInitialize'); 37 38 var params = parseQueryParams(window.location); 39 var network = params.network; 40 if (!network) { 41 console.error('Error: No network argument provided!'); 42 network = ''; 43 } 44 chrome.send('selectNetwork', [network]); 45 46 DetailsInternetPage.showProxySettings(); 47 } 48 49 disableTextSelectAndDrag(function(e) { 50 var src = e.target; 51 return src instanceof HTMLTextAreaElement || 52 src instanceof HTMLInputElement && 53 /text|url/.test(src.type); 54 }); 55 56 document.addEventListener('DOMContentLoaded', load); 57