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