Chromium Code Reviews| 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 if (loadTimeData.getBoolean('enableLanguageOptionsImeMenu')) { | |
| 282 $('language-options-ime-menu-template').hidden = false; | |
| 283 } | |
| 284 | |
| 285 // Listen to check on 'activate-ime-menu' checkbox | |
| 286 var checkboxImeMenu = $('activate-ime-menu'); | |
| 287 checkboxImeMenu.addEventListener('click', | |
| 288 this.handleActivateImeMenuCheckboxClick_.bind(this)); | |
| 273 }, | 289 }, |
| 274 | 290 |
| 275 /** | 291 /** |
| 276 * Initializes the input method list. | 292 * Initializes the input method list. |
| 277 */ | 293 */ |
| 278 initializeInputMethodList_: function() { | 294 initializeInputMethodList_: function() { |
| 279 var inputMethodList = $('language-options-input-method-list'); | 295 var inputMethodList = $('language-options-input-method-list'); |
| 280 var inputMethodPrototype = $('language-options-input-method-template'); | 296 var inputMethodPrototype = $('language-options-input-method-template'); |
| 281 | 297 |
| 282 // Add all input methods, but make all of them invisible here. We'll | 298 // Add all input methods, but make all of them invisible here. We'll |
| (...skipping 1126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1409 if (main in synonyms) { | 1425 if (main in synonyms) { |
| 1410 return synonyms[main]; | 1426 return synonyms[main]; |
| 1411 } else if (main == 'zh') { | 1427 } else if (main == 'zh') { |
| 1412 // In Translation, general Chinese is not used, and the sub code is | 1428 // In Translation, general Chinese is not used, and the sub code is |
| 1413 // necessary as a language code for Translate server. | 1429 // necessary as a language code for Translate server. |
| 1414 return languageCode; | 1430 return languageCode; |
| 1415 } | 1431 } |
| 1416 | 1432 |
| 1417 return main; | 1433 return main; |
| 1418 }, | 1434 }, |
| 1435 | |
| 1436 /** | |
| 1437 * Handles activate-ime-menu checkbox's click event. | |
| 1438 * @param {Event} e Click event. | |
| 1439 * @private | |
| 1440 */ | |
| 1441 handleActivateImeMenuCheckboxClick_: function(e) { | |
| 1442 var checkbox = e.target; | |
| 1443 Preferences.setBooleanPref(ACTIVATE_IME_MENU_PREF, | |
| 1444 checkbox.checked, true); | |
|
stevenjb
2016/01/05 17:31:13
The preferred format is to align the arguments, i.
Azure Wei
2016/01/07 03:04:57
Done.
| |
| 1445 }, | |
| 1419 }; | 1446 }; |
| 1420 | 1447 |
| 1421 /** | 1448 /** |
| 1422 * Shows the node at |index| in |nodes|, hides all others. | 1449 * Shows the node at |index| in |nodes|, hides all others. |
| 1423 * @param {Array<HTMLElement>} nodes The nodes to be shown or hidden. | 1450 * @param {Array<HTMLElement>} nodes The nodes to be shown or hidden. |
| 1424 * @param {number} index The index of |nodes| to show. | 1451 * @param {number} index The index of |nodes| to show. |
| 1425 */ | 1452 */ |
| 1426 function showMutuallyExclusiveNodes(nodes, index) { | 1453 function showMutuallyExclusiveNodes(nodes, index) { |
| 1427 assert(index >= 0 && index < nodes.length); | 1454 assert(index >= 0 && index < nodes.length); |
| 1428 for (var i = 0; i < nodes.length; ++i) { | 1455 for (var i = 0; i < nodes.length; ++i) { |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 1445 | 1472 |
| 1446 LanguageOptions.onDictionaryDownloadFailure = function(languageCode) { | 1473 LanguageOptions.onDictionaryDownloadFailure = function(languageCode) { |
| 1447 LanguageOptions.getInstance().onDictionaryDownloadFailure_(languageCode); | 1474 LanguageOptions.getInstance().onDictionaryDownloadFailure_(languageCode); |
| 1448 }; | 1475 }; |
| 1449 | 1476 |
| 1450 // Export | 1477 // Export |
| 1451 return { | 1478 return { |
| 1452 LanguageOptions: LanguageOptions | 1479 LanguageOptions: LanguageOptions |
| 1453 }; | 1480 }; |
| 1454 }); | 1481 }); |
| OLD | NEW |