Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(64)

Unified Diff: ui/accessibility/extensions/caretbrowsing/options.js

Issue 593293002: Initial checkin of accessibility extensions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix license issues Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/accessibility/extensions/caretbrowsing/options.js
diff --git a/ui/accessibility/extensions/caretbrowsing/options.js b/ui/accessibility/extensions/caretbrowsing/options.js
new file mode 100644
index 0000000000000000000000000000000000000000..cd9a601fce8796e8f8750d0d9e5efbfe5fba2dff
--- /dev/null
+++ b/ui/accessibility/extensions/caretbrowsing/options.js
@@ -0,0 +1,63 @@
+/* Copyright (c) 2014 The Chromium Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file. */
+
+function setRadio(name, defaultValue) {
+ chrome.storage.sync.get(name, function(result) {
+ var value = result[name];
+ if (value === undefined) {
+ value = defaultValue;
+ var obj = {};
+ obj[name] = value;
+ chrome.storage.sync.set(obj);
+ }
+ var controls = document.querySelectorAll(
+ 'input[type="radio"][name="' + name + '"]');
+ for (var i = 0; i < controls.length; i++) {
+ var c = controls[i];
+ if (c.value == value) {
+ c.checked = true;
+ }
+ c.addEventListener('change', function(evt) {
+ if (evt.target.checked) {
+ var obj = {};
+ obj[evt.target.name] = evt.target.value;
+ chrome.storage.sync.set(obj);
+ }
+ }, false);
+ }
+ });
+}
+
+function load() {
+ var isMac = (navigator.appVersion.indexOf("Mac") != -1);
+ if (isMac) {
+ document.body.classList.add('mac');
+ } else {
+ document.body.classList.add('nonmac');
+ }
+
+ var isCros = (navigator.appVersion.indexOf("CrOS") != -1);
+ if (isCros) {
+ document.body.classList.add('cros');
+ } else {
+ document.body.classList.add('noncros');
+ }
+
+ setRadio('onenable', 'anim');
+ setRadio('onjump', 'flash');
+
+ var heading = document.querySelector('h1');
+ var sel = window.getSelection();
+ sel.setBaseAndExtent(heading, 0, heading, 0);
+
+ document.title = chrome.i18n.getMessage('caretBrowsingOptions');
+ var i18nElements = document.querySelectorAll('*[i18n-content]');
+ for (var i = 0; i < i18nElements.length; i++) {
+ var elem = i18nElements[i];
+ var msg = elem.getAttribute('i18n-content');
+ elem.innerHTML = chrome.i18n.getMessage(msg);
+ }
+}
+
+window.addEventListener('load', load, false);
« no previous file with comments | « ui/accessibility/extensions/caretbrowsing/options.html ('k') | ui/accessibility/extensions/caretbrowsing/traverse_util.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698