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 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 input.imeProvider = inputMethod.extensionName; | 328 input.imeProvider = inputMethod.extensionName; |
329 var span = element.querySelector('span'); | 329 var span = element.querySelector('span'); |
330 span.textContent = inputMethod.displayName; | 330 span.textContent = inputMethod.displayName; |
331 | 331 |
332 if (inputMethod.optionsPage) { | 332 if (inputMethod.optionsPage) { |
333 var button = document.createElement('button'); | 333 var button = document.createElement('button'); |
334 button.textContent = loadTimeData.getString('configure'); | 334 button.textContent = loadTimeData.getString('configure'); |
335 button.inputMethodId = inputMethod.id; | 335 button.inputMethodId = inputMethod.id; |
336 button.onclick = function(inputMethodId, e) { | 336 button.onclick = function(inputMethodId, e) { |
337 chrome.send('inputMethodOptionsOpen', [inputMethodId]); | 337 chrome.send('inputMethodOptionsOpen', [inputMethodId]); |
338 }; | 338 }.bind(this, inputMethod.id); |
339 button.onclick = button.onclick.bind(this, inputMethod.id); | |
340 element.appendChild(button); | 339 element.appendChild(button); |
341 } | 340 } |
342 | 341 |
343 // Listen to user clicks. | 342 // Listen to user clicks. |
344 input.addEventListener('click', | 343 input.addEventListener('click', |
345 this.handleCheckboxClick_.bind(this)); | 344 this.handleCheckboxClick_.bind(this)); |
346 inputMethodList.appendChild(element); | 345 inputMethodList.appendChild(element); |
347 } | 346 } |
348 }, | 347 }, |
349 | 348 |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
746 $('language-options-input-method-none').hidden = | 745 $('language-options-input-method-none').hidden = |
747 (languageCode in this.languageCodeToInputMethodIdsMap_); | 746 (languageCode in this.languageCodeToInputMethodIdsMap_); |
748 | 747 |
749 if (focusInputMethodId == 'add') { | 748 if (focusInputMethodId == 'add') { |
750 $('language-options-add-button').focus(); | 749 $('language-options-add-button').focus(); |
751 } | 750 } |
752 }, | 751 }, |
753 | 752 |
754 /** | 753 /** |
755 * Updates the language list in the add language overlay. | 754 * Updates the language list in the add language overlay. |
756 * @param {string} languageCode Language code (ex. "fr"). | |
757 * @private | 755 * @private |
758 */ | 756 */ |
759 updateLanguageListInAddLanguageOverlay_: function(languageCode) { | 757 updateLanguageListInAddLanguageOverlay_: function() { |
760 // Change the visibility of the language list in the add language | 758 // Change the visibility of the language list in the add language |
761 // overlay. Languages that are already active will become invisible, | 759 // overlay. Languages that are already active will become invisible, |
762 // so that users don't add the same language twice. | 760 // so that users don't add the same language twice. |
763 var languageOptionsList = $('language-options-list'); | 761 var languageOptionsList = $('language-options-list'); |
764 var languageCodes = languageOptionsList.getLanguageCodes(); | 762 var languageCodes = languageOptionsList.getLanguageCodes(); |
765 var languageCodeSet = {}; | 763 var languageCodeSet = {}; |
766 for (var i = 0; i < languageCodes.length; i++) { | 764 for (var i = 0; i < languageCodes.length; i++) { |
767 languageCodeSet[languageCodes[i]] = true; | 765 languageCodeSet[languageCodes[i]] = true; |
768 } | 766 } |
769 | 767 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
823 else | 821 else |
824 this.addBlockedLanguage_(selectedLanguageCode); | 822 this.addBlockedLanguage_(selectedLanguageCode); |
825 }, | 823 }, |
826 | 824 |
827 /** | 825 /** |
828 * Handles input method checkbox's click event. | 826 * Handles input method checkbox's click event. |
829 * @param {Event} e Click event. | 827 * @param {Event} e Click event. |
830 * @private | 828 * @private |
831 */ | 829 */ |
832 handleCheckboxClick_: function(e) { | 830 handleCheckboxClick_: function(e) { |
833 var checkbox = e.target; | 831 var checkbox = assertInstanceof(e.target, Element); |
834 | 832 |
835 // Third party IMEs require additional confirmation prior to enabling due | 833 // Third party IMEs require additional confirmation prior to enabling due |
836 // to privacy risk. | 834 // to privacy risk. |
837 if (/^_ext_ime_/.test(checkbox.inputMethodId) && checkbox.checked) { | 835 if (/^_ext_ime_/.test(checkbox.inputMethodId) && checkbox.checked) { |
838 var confirmationCallback = this.handleCheckboxUpdate_.bind(this, | 836 var confirmationCallback = this.handleCheckboxUpdate_.bind(this, |
839 checkbox); | 837 checkbox); |
840 var cancellationCallback = function() { | 838 var cancellationCallback = function() { |
841 checkbox.checked = false; | 839 checkbox.checked = false; |
842 }; | 840 }; |
843 ThirdPartyImeConfirmOverlay.showConfirmationDialog({ | 841 ThirdPartyImeConfirmOverlay.showConfirmationDialog({ |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
910 }, | 908 }, |
911 | 909 |
912 /** | 910 /** |
913 * Handles browse.enable_spellchecking change. | 911 * Handles browse.enable_spellchecking change. |
914 * @param {Event} e Change event. | 912 * @param {Event} e Change event. |
915 * @private | 913 * @private |
916 */ | 914 */ |
917 updateEnableSpellCheck_: function(e) { | 915 updateEnableSpellCheck_: function(e) { |
918 var value = !$('enable-spell-check').checked; | 916 var value = !$('enable-spell-check').checked; |
919 $('language-options-spell-check-language-button').disabled = value; | 917 $('language-options-spell-check-language-button').disabled = value; |
920 if (!cr.IsMac) | 918 if (!cr.isMac) |
921 $('edit-dictionary-button').hidden = value; | 919 $('edit-dictionary-button').hidden = value; |
922 }, | 920 }, |
923 | 921 |
924 /** | 922 /** |
925 * Handles translateBlockedLanguagesPref change. | 923 * Handles translateBlockedLanguagesPref change. |
926 * @param {Event} e Change event. | 924 * @param {Event} e Change event. |
927 * @private | 925 * @private |
928 */ | 926 */ |
929 handleTranslateBlockedLanguagesPrefChange_: function(e) { | 927 handleTranslateBlockedLanguagesPrefChange_: function(e) { |
930 this.translateBlockedLanguages_ = e.value.value; | 928 this.translateBlockedLanguages_ = e.value.value; |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1164 seen[preloadEngines[i]] = true; | 1162 seen[preloadEngines[i]] = true; |
1165 } | 1163 } |
1166 } | 1164 } |
1167 return enabledPreloadEngines; | 1165 return enabledPreloadEngines; |
1168 }, | 1166 }, |
1169 | 1167 |
1170 // TODO(kochi): This is an adapted copy from new_tab.js. | 1168 // TODO(kochi): This is an adapted copy from new_tab.js. |
1171 // If this will go as final UI, refactor this to share the component with | 1169 // If this will go as final UI, refactor this to share the component with |
1172 // new new tab page. | 1170 // new new tab page. |
1173 /** | 1171 /** |
1174 * Shows notification | |
1175 * @private | 1172 * @private |
1176 */ | 1173 */ |
1177 notificationTimeout_: null, | 1174 notificationTimeout_: null, |
| 1175 |
| 1176 /** |
| 1177 * Shows notification. |
| 1178 * @param {string} text |
| 1179 * @param {string} actionText |
| 1180 * @param {number=} opt_delay |
| 1181 * @private |
| 1182 */ |
1178 showNotification_: function(text, actionText, opt_delay) { | 1183 showNotification_: function(text, actionText, opt_delay) { |
1179 var notificationElement = $('notification'); | 1184 var notificationElement = $('notification'); |
1180 var actionLink = notificationElement.querySelector('.link-color'); | 1185 var actionLink = notificationElement.querySelector('.link-color'); |
1181 var delay = opt_delay || 10000; | 1186 var delay = opt_delay || 10000; |
1182 | 1187 |
1183 function show() { | 1188 function show() { |
1184 window.clearTimeout(this.notificationTimeout_); | 1189 window.clearTimeout(this.notificationTimeout_); |
1185 notificationElement.classList.add('show'); | 1190 notificationElement.classList.add('show'); |
1186 document.body.classList.add('notification-shown'); | 1191 document.body.classList.add('notification-shown'); |
1187 } | 1192 } |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1358 | 1363 |
1359 LanguageOptions.onDictionaryDownloadFailure = function(languageCode) { | 1364 LanguageOptions.onDictionaryDownloadFailure = function(languageCode) { |
1360 LanguageOptions.getInstance().onDictionaryDownloadFailure_(languageCode); | 1365 LanguageOptions.getInstance().onDictionaryDownloadFailure_(languageCode); |
1361 }; | 1366 }; |
1362 | 1367 |
1363 // Export | 1368 // Export |
1364 return { | 1369 return { |
1365 LanguageOptions: LanguageOptions | 1370 LanguageOptions: LanguageOptions |
1366 }; | 1371 }; |
1367 }); | 1372 }); |
OLD | NEW |