| 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 28 matching lines...) Expand all Loading... |
| 39 type: String, | 39 type: String, |
| 40 value: 'Placeholder, e.g. English (United States)', | 40 value: 'Placeholder, e.g. English (United States)', |
| 41 }, | 41 }, |
| 42 | 42 |
| 43 /** | 43 /** |
| 44 * The language to display the details for. | 44 * The language to display the details for. |
| 45 * @type {!LanguageState|undefined} | 45 * @type {!LanguageState|undefined} |
| 46 * @private | 46 * @private |
| 47 */ | 47 */ |
| 48 detailLanguage_: Object, | 48 detailLanguage_: Object, |
| 49 |
| 50 /** @private */ |
| 51 showAddLanguagesDialog_: Boolean, |
| 49 }, | 52 }, |
| 50 | 53 |
| 51 /** | 54 /** |
| 52 * Handler for clicking a language on the main page, which selects the | 55 * Handler for clicking a language on the main page, which selects the |
| 53 * language as the prospective UI language on Chrome OS and Windows. | 56 * language as the prospective UI language on Chrome OS and Windows. |
| 54 * @param {!Event} e The tap event. | 57 * @param {!Event} e The tap event. |
| 55 */ | 58 */ |
| 56 onLanguageTap_: function(e) { | 59 onLanguageTap_: function(e) { |
| 57 // Only change the UI language on platforms that allow it. | 60 // Only change the UI language on platforms that allow it. |
| 58 if ((!cr.isChromeOS && !cr.isWindows) || loadTimeData.getBoolean('isGuest')) | 61 if ((!cr.isChromeOS && !cr.isWindows) || loadTimeData.getBoolean('isGuest')) |
| (...skipping 23 matching lines...) Expand all Loading... |
| 82 this.languageHelper.toggleSpellCheck(e.model.item.language.code, | 85 this.languageHelper.toggleSpellCheck(e.model.item.language.code, |
| 83 e.target.checked); | 86 e.target.checked); |
| 84 }, | 87 }, |
| 85 | 88 |
| 86 /** @private */ | 89 /** @private */ |
| 87 onBackTap_: function() { | 90 onBackTap_: function() { |
| 88 this.$.pages.back(); | 91 this.$.pages.back(); |
| 89 }, | 92 }, |
| 90 | 93 |
| 91 /** | 94 /** |
| 92 * Opens the Manage Languages page. | 95 * Stamps and opens the Add Languages dialog, registering a listener to |
| 96 * disable the dialog's dom-if again on close. |
| 93 * @private | 97 * @private |
| 94 */ | 98 */ |
| 95 onManageLanguagesTap_: function() { | 99 onAddLanguagesTap_: function() { |
| 96 settings.navigateTo(settings.Route.MANAGE_LANGUAGES); | 100 this.showAddLanguagesDialog_ = true; |
| 97 this.forceRenderList_('settings-manage-languages-page'); | 101 this.async(function() { |
| 102 var dialog = this.$$('settings-add-languages-dialog'); |
| 103 dialog.addEventListener('close', function() { |
| 104 this.showAddLanguagesDialog_ = false; |
| 105 }.bind(this)); |
| 106 }); |
| 98 }, | 107 }, |
| 99 | 108 |
| 100 /** | 109 /** |
| 101 * @param {number} index Index of the language in the list of languages. | 110 * @param {number} index Index of the language in the list of languages. |
| 102 * @param {!Object} change Polymer change object for languages.enabled.*. | 111 * @param {!Object} change Polymer change object for languages.enabled.*. |
| 103 * @return {boolean} True if the given language is the first one in the list | 112 * @return {boolean} True if the given language is the first one in the list |
| 104 * of languages. | 113 * of languages. |
| 105 * @private | 114 * @private |
| 106 */ | 115 */ |
| 107 isFirstLanguage_: function(index, change) { | 116 isFirstLanguage_: function(index, change) { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 /** | 148 /** |
| 140 * Moves the language down in the list. | 149 * Moves the language down in the list. |
| 141 * @param {!{model: !{item: !LanguageState}}} e | 150 * @param {!{model: !{item: !LanguageState}}} e |
| 142 * @private | 151 * @private |
| 143 */ | 152 */ |
| 144 onMoveDownTap_: function(e) { | 153 onMoveDownTap_: function(e) { |
| 145 this.languageHelper.moveLanguage(e.model.item.language.code, 1); | 154 this.languageHelper.moveLanguage(e.model.item.language.code, 1); |
| 146 }, | 155 }, |
| 147 | 156 |
| 148 /** | 157 /** |
| 158 * Disables the language. |
| 159 * @param {!{model: !{item: !LanguageState}}} e |
| 160 * @private |
| 161 */ |
| 162 onRemoveLanguageTap_: function(e) { |
| 163 this.languageHelper.disableLanguage(e.model.item.language.code); |
| 164 }, |
| 165 |
| 166 /** |
| 149 * Opens the Language Detail page for the language. | 167 * Opens the Language Detail page for the language. |
| 150 * @param {!{model: !{item: !LanguageState}}} e | 168 * @param {!{model: !{item: !LanguageState}}} e |
| 151 * @private | 169 * @private |
| 152 */ | 170 */ |
| 153 onShowLanguageDetailTap_: function(e) { | 171 onShowLanguageDetailTap_: function(e) { |
| 154 this.detailLanguage_ = e.model.item; | 172 this.detailLanguage_ = e.model.item; |
| 155 settings.navigateTo(settings.Route.LANGUAGES_DETAIL); | 173 settings.navigateTo(settings.Route.LANGUAGES_DETAIL); |
| 156 }, | 174 }, |
| 157 | 175 |
| 158 /** | 176 /** |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 * HACK(michaelpg): This is necessary to show the list when navigating to | 343 * HACK(michaelpg): This is necessary to show the list when navigating to |
| 326 * the sub-page. Remove this function when PolymerElements/neon-animation#60 | 344 * the sub-page. Remove this function when PolymerElements/neon-animation#60 |
| 327 * is fixed. | 345 * is fixed. |
| 328 * @param {string} tagName Name of the element containing the <iron-list>. | 346 * @param {string} tagName Name of the element containing the <iron-list>. |
| 329 */ | 347 */ |
| 330 forceRenderList_: function(tagName) { | 348 forceRenderList_: function(tagName) { |
| 331 this.$$(tagName).$$('iron-list').fire('iron-resize'); | 349 this.$$(tagName).$$('iron-list').fire('iron-resize'); |
| 332 }, | 350 }, |
| 333 }); | 351 }); |
| 334 })(); | 352 })(); |
| OLD | NEW |