| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 /** | 5 /** |
| 6 * @fileoverview 'settings-languages-page' is the settings page | 6 * @fileoverview 'settings-languages-page' is the settings page |
| 7 * for language and input method settings. | 7 * for language and input method settings. |
| 8 * | 8 * |
| 9 * @group Chrome Settings Elements | 9 * @group Chrome Settings Elements |
| 10 * @element settings-languages-page | 10 * @element settings-languages-page |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 * Read-only reference to the languages model provided by the | 36 * Read-only reference to the languages model provided by the |
| 37 * 'settings-languages' instance. | 37 * 'settings-languages' instance. |
| 38 * @type {LanguagesModel|undefined} | 38 * @type {LanguagesModel|undefined} |
| 39 */ | 39 */ |
| 40 languages: { | 40 languages: { |
| 41 type: Object, | 41 type: Object, |
| 42 notify: true, | 42 notify: true, |
| 43 }, | 43 }, |
| 44 }, | 44 }, |
| 45 | 45 |
| 46 /** @private {LanguageSettingsHelper} */ |
| 47 languageHelper_: settings.LanguageHelper.getInstance(), |
| 48 |
| 46 /** | 49 /** |
| 47 * Handler for clicking a language on the main page, which selects the | 50 * Handler for clicking a language on the main page, which selects the |
| 48 * language as the prospective UI language on Chrome OS and Windows. | 51 * language as the prospective UI language on Chrome OS and Windows. |
| 49 * @param {!{model: !{item: !LanguageInfo}}} e | 52 * @param {!{model: !{item: !LanguageInfo}}} e |
| 50 */ | 53 */ |
| 51 onLanguageTap_: function(e) { | 54 onLanguageTap_: function(e) { |
| 52 // Taps on the paper-icon-button are handled in onShowLanguageDetailTap_. | 55 // Taps on the paper-icon-button are handled in onShowLanguageDetailTap_. |
| 53 if (e.target.tagName == 'PAPER-ICON-BUTTON') | 56 if (e.target.tagName == 'PAPER-ICON-BUTTON') |
| 54 return; | 57 return; |
| 55 | 58 |
| 56 // Set the prospective UI language. This won't take effect until a restart. | 59 // Set the prospective UI language. This won't take effect until a restart. |
| 57 if (e.model.item.language.supportsUI) | 60 if (e.model.item.language.supportsUI) |
| 58 this.$.languages.setUILanguage(e.model.item.language.code); | 61 this.languageHelper_.setUILanguage(e.model.item.language.code); |
| 59 }, | 62 }, |
| 60 | 63 |
| 61 /** | 64 /** |
| 62 * Handler for enabling or disabling spell check. | 65 * Handler for enabling or disabling spell check. |
| 63 * @param {!{target: Element, model: !{item: !LanguageInfo}}} e | 66 * @param {!{target: Element, model: !{item: !LanguageInfo}}} e |
| 64 */ | 67 */ |
| 65 onSpellCheckChange_: function(e) { | 68 onSpellCheckChange_: function(e) { |
| 66 this.$.languages.toggleSpellCheck(e.model.item.language.code, | 69 this.languageHelper_.toggleSpellCheck(e.model.item.language.code, |
| 67 e.target.checked); | 70 e.target.checked); |
| 68 }, | 71 }, |
| 69 | 72 |
| 70 /** @private */ | 73 /** @private */ |
| 71 onBackTap_: function() { | 74 onBackTap_: function() { |
| 72 this.$.pages.back(); | 75 this.$.pages.back(); |
| 73 }, | 76 }, |
| 74 | 77 |
| 75 /** | 78 /** |
| 76 * Opens the Manage Languages page. | 79 * Opens the Manage Languages page. |
| 77 * @private | 80 * @private |
| (...skipping 25 matching lines...) Expand all Loading... |
| 103 </if> | 106 </if> |
| 104 | 107 |
| 105 /** | 108 /** |
| 106 * @param {string} languageCode The language code identifying a language. | 109 * @param {string} languageCode The language code identifying a language. |
| 107 * @param {string} prospectiveUILanguage The prospective UI language. | 110 * @param {string} prospectiveUILanguage The prospective UI language. |
| 108 * @return {boolean} True if the given language matches the prospective UI | 111 * @return {boolean} True if the given language matches the prospective UI |
| 109 * pref (which may be different from the actual UI language). | 112 * pref (which may be different from the actual UI language). |
| 110 * @private | 113 * @private |
| 111 */ | 114 */ |
| 112 isUILanguage_: function(languageCode, prospectiveUILanguage) { | 115 isUILanguage_: function(languageCode, prospectiveUILanguage) { |
| 113 return languageCode == this.$.languages.getProspectiveUILanguage(); | 116 return (cr.isWindows || cr.isChromeOS) && |
| 117 languageCode == this.languageHelper_.getProspectiveUILanguage(); |
| 114 }, | 118 }, |
| 115 | 119 |
| 116 /** | 120 /** |
| 117 * @param {string} id The input method ID. | 121 * @param {string} id The input method ID. |
| 118 * @param {string} currentId The ID of the currently enabled input method. | 122 * @param {string} currentId The ID of the currently enabled input method. |
| 119 * @return {boolean} True if the IDs match. | 123 * @return {boolean} True if the IDs match. |
| 120 * @private | 124 * @private |
| 121 */ | 125 */ |
| 122 isCurrentInputMethod_: function(id, currentId) { | 126 isCurrentInputMethod_: function(id, currentId) { |
| 123 assert(cr.isChromeOS); | 127 assert(cr.isChromeOS); |
| 124 return id == currentId; | 128 return id == currentId; |
| 125 }, | 129 }, |
| 126 | 130 |
| 127 /** | 131 /** |
| 128 * HACK(michaelpg): This is necessary to show the list when navigating to | 132 * HACK(michaelpg): This is necessary to show the list when navigating to |
| 129 * the sub-page. Remove this function when PolymerElements/neon-animation#60 | 133 * the sub-page. Remove this function when PolymerElements/neon-animation#60 |
| 130 * is fixed. | 134 * is fixed. |
| 131 * @param {string} tagName Name of the element containing the <iron-list>. | 135 * @param {string} tagName Name of the element containing the <iron-list>. |
| 132 */ | 136 */ |
| 133 forceRenderList_: function(tagName) { | 137 forceRenderList_: function(tagName) { |
| 134 this.$$(tagName).$$('iron-list').fire('iron-resize'); | 138 this.$$(tagName).$$('iron-list').fire('iron-resize'); |
| 135 }, | 139 }, |
| 136 }); | 140 }); |
| 137 })(); | 141 })(); |
| OLD | NEW |