| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // TODO(kochi): Generalize the notification as a component and put it | 5 // TODO(kochi): Generalize the notification as a component and put it |
| 6 // in js/cr/ui/notification.js . | 6 // in js/cr/ui/notification.js . |
| 7 | 7 |
| 8 cr.define('options', function() { | 8 cr.define('options', function() { |
| 9 /** @const */ var Page = cr.ui.pageManager.Page; | 9 /** @const */ var Page = cr.ui.pageManager.Page; |
| 10 /** @const */ var PageManager = cr.ui.pageManager.PageManager; | 10 /** @const */ var PageManager = cr.ui.pageManager.PageManager; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 */ | 59 */ |
| 60 var SPELL_CHECK_DICTIONARIES_PREF = 'spellcheck.dictionaries'; | 60 var SPELL_CHECK_DICTIONARIES_PREF = 'spellcheck.dictionaries'; |
| 61 | 61 |
| 62 /** | 62 /** |
| 63 * The preference that indicates if the Translate feature is enabled. | 63 * The preference that indicates if the Translate feature is enabled. |
| 64 * @type {string} | 64 * @type {string} |
| 65 * @const | 65 * @const |
| 66 */ | 66 */ |
| 67 var ENABLE_TRANSLATE = 'translate.enabled'; | 67 var ENABLE_TRANSLATE = 'translate.enabled'; |
| 68 | 68 |
| 69 /** |
| 70 * The preference is a boolean that activates/deactivates IME menu on shelf. |
| 71 * @type {string} |
| 72 * @const |
| 73 */ |
| 74 var ACTIVATE_IME_MENU_PREF = 'settings.language.ime_menu_activated'; |
| 75 |
| 69 ///////////////////////////////////////////////////////////////////////////// | 76 ///////////////////////////////////////////////////////////////////////////// |
| 70 // LanguageOptions class: | 77 // LanguageOptions class: |
| 71 | 78 |
| 72 /** | 79 /** |
| 73 * Encapsulated handling of ChromeOS language options page. | 80 * Encapsulated handling of ChromeOS language options page. |
| 74 * @constructor | 81 * @constructor |
| 75 * @extends {cr.ui.pageManager.Page} | 82 * @extends {cr.ui.pageManager.Page} |
| 76 */ | 83 */ |
| 77 function LanguageOptions(model) { | 84 function LanguageOptions(model) { |
| 78 Page.call(this, 'languages', | 85 Page.call(this, 'languages', |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 chrome.send('uiLanguageRestart'); | 270 chrome.send('uiLanguageRestart'); |
| 264 }; | 271 }; |
| 265 } | 272 } |
| 266 | 273 |
| 267 $('language-confirm').onclick = | 274 $('language-confirm').onclick = |
| 268 PageManager.closeOverlay.bind(PageManager); | 275 PageManager.closeOverlay.bind(PageManager); |
| 269 | 276 |
| 270 // Public session users cannot change the locale. | 277 // Public session users cannot change the locale. |
| 271 if (cr.isChromeOS && UIAccountTweaks.loggedInAsPublicAccount()) | 278 if (cr.isChromeOS && UIAccountTweaks.loggedInAsPublicAccount()) |
| 272 $('language-options-ui-language-section').hidden = true; | 279 $('language-options-ui-language-section').hidden = true; |
| 280 |
| 281 // IME menu (CrOS only). |
| 282 if (cr.isChromeOS) { |
| 283 // Show the 'activate-ime-menu' checkbox if the flag is tured on. |
| 284 if (loadTimeData.getBoolean('enableLanguageOptionsImeMenu')) |
| 285 $('language-options-ime-menu-template').hidden = false; |
| 286 |
| 287 // Listen to check on 'activate-ime-menu' checkbox. |
| 288 var checkboxImeMenu = $('activate-ime-menu'); |
| 289 checkboxImeMenu.addEventListener('click', |
| 290 this.handleActivateImeMenuCheckboxClick_.bind(this)); |
| 291 } |
| 273 }, | 292 }, |
| 274 | 293 |
| 275 /** | 294 /** |
| 276 * Initializes the input method list. | 295 * Initializes the input method list. |
| 277 */ | 296 */ |
| 278 initializeInputMethodList_: function() { | 297 initializeInputMethodList_: function() { |
| 279 var inputMethodList = $('language-options-input-method-list'); | 298 var inputMethodList = $('language-options-input-method-list'); |
| 280 var inputMethodPrototype = $('language-options-input-method-template'); | 299 var inputMethodPrototype = $('language-options-input-method-template'); |
| 281 | 300 |
| 282 // Add all input methods, but make all of them invisible here. We'll | 301 // Add all input methods, but make all of them invisible here. We'll |
| (...skipping 1128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1411 if (main in synonyms) { | 1430 if (main in synonyms) { |
| 1412 return synonyms[main]; | 1431 return synonyms[main]; |
| 1413 } else if (main == 'zh') { | 1432 } else if (main == 'zh') { |
| 1414 // In Translation, general Chinese is not used, and the sub code is | 1433 // In Translation, general Chinese is not used, and the sub code is |
| 1415 // necessary as a language code for Translate server. | 1434 // necessary as a language code for Translate server. |
| 1416 return languageCode; | 1435 return languageCode; |
| 1417 } | 1436 } |
| 1418 | 1437 |
| 1419 return main; | 1438 return main; |
| 1420 }, | 1439 }, |
| 1440 |
| 1441 /** |
| 1442 * Handles activate-ime-menu checkbox's click event. |
| 1443 * @param {Event} e Click event. |
| 1444 * @private |
| 1445 */ |
| 1446 handleActivateImeMenuCheckboxClick_: function(e) { |
| 1447 if (cr.isChromeOS) { |
| 1448 var checkbox = e.target; |
| 1449 Preferences.setBooleanPref(ACTIVATE_IME_MENU_PREF, |
| 1450 checkbox.checked, true); |
| 1451 } |
| 1452 }, |
| 1421 }; | 1453 }; |
| 1422 | 1454 |
| 1423 /** | 1455 /** |
| 1424 * Shows the node at |index| in |nodes|, hides all others. | 1456 * Shows the node at |index| in |nodes|, hides all others. |
| 1425 * @param {Array<HTMLElement>} nodes The nodes to be shown or hidden. | 1457 * @param {Array<HTMLElement>} nodes The nodes to be shown or hidden. |
| 1426 * @param {number} index The index of |nodes| to show. | 1458 * @param {number} index The index of |nodes| to show. |
| 1427 */ | 1459 */ |
| 1428 function showMutuallyExclusiveNodes(nodes, index) { | 1460 function showMutuallyExclusiveNodes(nodes, index) { |
| 1429 assert(index >= 0 && index < nodes.length); | 1461 assert(index >= 0 && index < nodes.length); |
| 1430 for (var i = 0; i < nodes.length; ++i) { | 1462 for (var i = 0; i < nodes.length; ++i) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1447 | 1479 |
| 1448 LanguageOptions.onDictionaryDownloadFailure = function(languageCode) { | 1480 LanguageOptions.onDictionaryDownloadFailure = function(languageCode) { |
| 1449 LanguageOptions.getInstance().onDictionaryDownloadFailure_(languageCode); | 1481 LanguageOptions.getInstance().onDictionaryDownloadFailure_(languageCode); |
| 1450 }; | 1482 }; |
| 1451 | 1483 |
| 1452 // Export | 1484 // Export |
| 1453 return { | 1485 return { |
| 1454 LanguageOptions: LanguageOptions | 1486 LanguageOptions: LanguageOptions |
| 1455 }; | 1487 }; |
| 1456 }); | 1488 }); |
| OLD | NEW |