| 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 (function() { | 9 (function() { |
| 10 'use strict'; | 10 'use strict'; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 /** | 64 /** |
| 65 * Handler for clicking a language on the main page, which selects the | 65 * Handler for clicking a language on the main page, which selects the |
| 66 * language as the prospective UI language on Chrome OS and Windows. | 66 * language as the prospective UI language on Chrome OS and Windows. |
| 67 * @param {!{model: !{item: !LanguageState}}} e | 67 * @param {!{model: !{item: !LanguageState}}} e |
| 68 */ | 68 */ |
| 69 onLanguageTap_: function(e) { | 69 onLanguageTap_: function(e) { |
| 70 // Only change the UI language on platforms that allow it. | 70 // Only change the UI language on platforms that allow it. |
| 71 if (!cr.isChromeOS && !cr.isWindows) | 71 if (!cr.isChromeOS && !cr.isWindows) |
| 72 return; | 72 return; |
| 73 | 73 |
| 74 // Taps on the paper-icon-button are handled in onShowLanguageDetailTap_. | |
| 75 if (e.target.tagName == 'PAPER-ICON-BUTTON') | |
| 76 return; | |
| 77 | |
| 78 // Set the prospective UI language. This won't take effect until a restart. | 74 // Set the prospective UI language. This won't take effect until a restart. |
| 79 if (e.model.item.language.supportsUI) | 75 if (e.model.item.language.supportsUI) |
| 80 this.languageHelper_.setUILanguage(e.model.item.language.code); | 76 this.languageHelper_.setUILanguage(e.model.item.language.code); |
| 81 }, | 77 }, |
| 82 | 78 |
| 83 /** | 79 /** |
| 84 * Handler for enabling or disabling spell check. | 80 * Handler for enabling or disabling spell check. |
| 85 * @param {!{target: Element, model: !{item: !LanguageState}}} e | 81 * @param {!{target: Element, model: !{item: !LanguageState}}} e |
| 86 */ | 82 */ |
| 87 onSpellCheckChange_: function(e) { | 83 onSpellCheckChange_: function(e) { |
| 88 this.languageHelper_.toggleSpellCheck(e.model.item.language.code, | 84 this.languageHelper_.toggleSpellCheck(e.model.item.language.code, |
| 89 e.target.checked); | 85 e.target.checked); |
| 90 }, | 86 }, |
| 91 | 87 |
| 92 /** @private */ | 88 /** @private */ |
| 93 onBackTap_: function() { | 89 onBackTap_: function() { |
| 94 this.$.pages.back(); | 90 this.$.pages.back(); |
| 95 }, | 91 }, |
| 96 | 92 |
| 97 /** | 93 /** |
| 98 * Opens the Manage Languages page. | 94 * Opens the Manage Languages page. |
| 99 * @private | 95 * @private |
| 100 */ | 96 */ |
| 101 onManageLanguagesTap_: function() { | 97 onManageLanguagesTap_: function() { |
| 102 this.$.pages.setSubpageChain(['manage-languages']); | 98 this.$.pages.setSubpageChain(['manage-languages']); |
| 103 this.forceRenderList_('settings-manage-languages-page'); | 99 this.forceRenderList_('settings-manage-languages-page'); |
| 104 }, | 100 }, |
| 105 | 101 |
| 106 /** | 102 /** |
| 103 * @param {number} index Index of the language in the list of languages. |
| 104 * @param {!Object} change Polymer change object for languages.enabled.*. |
| 105 * @return {boolean} True if the given language is the first one in the list |
| 106 * of languages. |
| 107 * @private |
| 108 */ |
| 109 isFirstLanguage_: function(index, change) { |
| 110 return index == 0; |
| 111 }, |
| 112 |
| 113 /** |
| 114 * @param {number} index Index of the language in the list of languages. |
| 115 * @param {!Object} change Polymer change object for languages.enabled.*. |
| 116 * @return {boolean} True if the given language is the last one in the list of |
| 117 * languages. |
| 118 * @private |
| 119 */ |
| 120 isLastLanguage_: function(index, change) { |
| 121 return index == this.languages.enabled.length - 1; |
| 122 }, |
| 123 |
| 124 /** |
| 125 * @param {!Object} change Polymer change object for languages.enabled.*. |
| 126 * @return {boolean} True if there are less than 2 languages. |
| 127 */ |
| 128 isHelpTextHidden_: function(change) { |
| 129 return this.languages.enabled.length <= 1; |
| 130 }, |
| 131 |
| 132 /** |
| 133 * Moves the language up in the list. |
| 134 * @param {!{model: !{item: !LanguageState}}} e |
| 135 * @private |
| 136 */ |
| 137 onMoveUpTap_: function(e) { |
| 138 this.languageHelper_.moveLanguage(e.model.item.language.code, -1); |
| 139 }, |
| 140 |
| 141 /** |
| 142 * Moves the language down in the list. |
| 143 * @param {!{model: !{item: !LanguageState}}} e |
| 144 * @private |
| 145 */ |
| 146 onMoveDownTap_: function(e) { |
| 147 this.languageHelper_.moveLanguage(e.model.item.language.code, 1); |
| 148 }, |
| 149 |
| 150 /** |
| 107 * Opens the Language Detail page for the language. | 151 * Opens the Language Detail page for the language. |
| 108 * @param {!{model: !{item: !LanguageState}}} e | 152 * @param {!{model: !{item: !LanguageState}}} e |
| 109 * @private | 153 * @private |
| 110 */ | 154 */ |
| 111 onShowLanguageDetailTap_: function(e) { | 155 onShowLanguageDetailTap_: function(e) { |
| 112 this.detailLanguage_ = e.model.item; | 156 this.detailLanguage_ = e.model.item; |
| 113 this.$.pages.setSubpageChain(['language-detail']); | 157 this.$.pages.setSubpageChain(['language-detail']); |
| 114 }, | 158 }, |
| 115 | 159 |
| 116 /** | 160 /** |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 * HACK(michaelpg): This is necessary to show the list when navigating to | 318 * HACK(michaelpg): This is necessary to show the list when navigating to |
| 275 * the sub-page. Remove this function when PolymerElements/neon-animation#60 | 319 * the sub-page. Remove this function when PolymerElements/neon-animation#60 |
| 276 * is fixed. | 320 * is fixed. |
| 277 * @param {string} tagName Name of the element containing the <iron-list>. | 321 * @param {string} tagName Name of the element containing the <iron-list>. |
| 278 */ | 322 */ |
| 279 forceRenderList_: function(tagName) { | 323 forceRenderList_: function(tagName) { |
| 280 this.$$(tagName).$$('iron-list').fire('iron-resize'); | 324 this.$$(tagName).$$('iron-list').fire('iron-resize'); |
| 281 }, | 325 }, |
| 282 }); | 326 }); |
| 283 })(); | 327 })(); |
| OLD | NEW |