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 the | |
71 * system shelf. | |
72 * @type {string} | |
73 * @const | |
74 */ | |
75 var ACTIVATE_IME_MENU_PREF = 'settings.language.activate_ime_menu'; | |
76 | |
69 ///////////////////////////////////////////////////////////////////////////// | 77 ///////////////////////////////////////////////////////////////////////////// |
70 // LanguageOptions class: | 78 // LanguageOptions class: |
71 | 79 |
72 /** | 80 /** |
73 * Encapsulated handling of ChromeOS language options page. | 81 * Encapsulated handling of ChromeOS language options page. |
74 * @constructor | 82 * @constructor |
75 * @extends {cr.ui.pageManager.Page} | 83 * @extends {cr.ui.pageManager.Page} |
76 */ | 84 */ |
77 function LanguageOptions(model) { | 85 function LanguageOptions(model) { |
78 Page.call(this, 'languages', | 86 Page.call(this, 'languages', |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
263 chrome.send('uiLanguageRestart'); | 271 chrome.send('uiLanguageRestart'); |
264 }; | 272 }; |
265 } | 273 } |
266 | 274 |
267 $('language-confirm').onclick = | 275 $('language-confirm').onclick = |
268 PageManager.closeOverlay.bind(PageManager); | 276 PageManager.closeOverlay.bind(PageManager); |
269 | 277 |
270 // Public session users cannot change the locale. | 278 // Public session users cannot change the locale. |
271 if (cr.isChromeOS && UIAccountTweaks.loggedInAsPublicAccount()) | 279 if (cr.isChromeOS && UIAccountTweaks.loggedInAsPublicAccount()) |
272 $('language-options-ui-language-section').hidden = true; | 280 $('language-options-ui-language-section').hidden = true; |
281 | |
282 // Listen to check on 'activate-system-ime-menu' checkbox | |
283 var checkboxImeMenu = $('activate-system-ime-menu'); | |
Shu Chen
2015/12/28 16:41:47
pls put this behind a flag.
Azure Wei
2016/01/04 06:30:38
Done.
| |
284 checkboxImeMenu.addEventListener('click', | |
285 this.handleActivateSystemImeMenuCheckboxClick_.bind(this)); | |
273 }, | 286 }, |
274 | 287 |
275 /** | 288 /** |
276 * Initializes the input method list. | 289 * Initializes the input method list. |
277 */ | 290 */ |
278 initializeInputMethodList_: function() { | 291 initializeInputMethodList_: function() { |
279 var inputMethodList = $('language-options-input-method-list'); | 292 var inputMethodList = $('language-options-input-method-list'); |
280 var inputMethodPrototype = $('language-options-input-method-template'); | 293 var inputMethodPrototype = $('language-options-input-method-template'); |
281 | 294 |
282 // Add all input methods, but make all of them invisible here. We'll | 295 // 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) { | 1422 if (main in synonyms) { |
1410 return synonyms[main]; | 1423 return synonyms[main]; |
1411 } else if (main == 'zh') { | 1424 } else if (main == 'zh') { |
1412 // In Translation, general Chinese is not used, and the sub code is | 1425 // In Translation, general Chinese is not used, and the sub code is |
1413 // necessary as a language code for Translate server. | 1426 // necessary as a language code for Translate server. |
1414 return languageCode; | 1427 return languageCode; |
1415 } | 1428 } |
1416 | 1429 |
1417 return main; | 1430 return main; |
1418 }, | 1431 }, |
1432 | |
1433 /** | |
1434 * Handles activate-system-ime-menu checkbox's click event. | |
1435 * @param {Event} e Click event. | |
1436 * @private | |
1437 */ | |
1438 handleActivateSystemImeMenuCheckboxClick_: function(e) { | |
1439 var checkbox = e.target; | |
1440 Preferences.setBooleanPref(ACTIVATE_IME_MENU_PREF, | |
1441 checkbox.checked, true); | |
1442 }, | |
1419 }; | 1443 }; |
1420 | 1444 |
1421 /** | 1445 /** |
1422 * Shows the node at |index| in |nodes|, hides all others. | 1446 * Shows the node at |index| in |nodes|, hides all others. |
1423 * @param {Array<HTMLElement>} nodes The nodes to be shown or hidden. | 1447 * @param {Array<HTMLElement>} nodes The nodes to be shown or hidden. |
1424 * @param {number} index The index of |nodes| to show. | 1448 * @param {number} index The index of |nodes| to show. |
1425 */ | 1449 */ |
1426 function showMutuallyExclusiveNodes(nodes, index) { | 1450 function showMutuallyExclusiveNodes(nodes, index) { |
1427 assert(index >= 0 && index < nodes.length); | 1451 assert(index >= 0 && index < nodes.length); |
1428 for (var i = 0; i < nodes.length; ++i) { | 1452 for (var i = 0; i < nodes.length; ++i) { |
(...skipping 16 matching lines...) Expand all Loading... | |
1445 | 1469 |
1446 LanguageOptions.onDictionaryDownloadFailure = function(languageCode) { | 1470 LanguageOptions.onDictionaryDownloadFailure = function(languageCode) { |
1447 LanguageOptions.getInstance().onDictionaryDownloadFailure_(languageCode); | 1471 LanguageOptions.getInstance().onDictionaryDownloadFailure_(languageCode); |
1448 }; | 1472 }; |
1449 | 1473 |
1450 // Export | 1474 // Export |
1451 return { | 1475 return { |
1452 LanguageOptions: LanguageOptions | 1476 LanguageOptions: LanguageOptions |
1453 }; | 1477 }; |
1454 }); | 1478 }); |
OLD | NEW |