Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(376)

Side by Side Diff: chrome/browser/resources/settings/languages_page/languages_page.js

Issue 2231153002: MD Settings: Checks the event target in the language tap event handler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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';
11 11
12 /**
13 * Regular expression used for filtering out tap events not originating from the
14 * language list item based on the event target's class name.
15 * e.g. 'dropdown-trigger'
16 * @const {!RegExp}
17 */
18 var EVENT_TARGET_REGEX = new RegExp('^dropdown-(trigger|content|item)');
19
12 Polymer({ 20 Polymer({
13 is: 'settings-languages-page', 21 is: 'settings-languages-page',
14 22
15 properties: { 23 properties: {
16 /** 24 /**
17 * Preferences state. 25 * Preferences state.
18 */ 26 */
19 prefs: { 27 prefs: {
20 type: Object, 28 type: Object,
21 notify: true, 29 notify: true,
(...skipping 27 matching lines...) Expand all
49 }, 57 },
50 58
51 /** @override */ 59 /** @override */
52 created: function() { 60 created: function() {
53 this.languageHelper_ = LanguageHelperImpl.getInstance(); 61 this.languageHelper_ = LanguageHelperImpl.getInstance();
54 }, 62 },
55 63
56 /** 64 /**
57 * 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
58 * language as the prospective UI language on Chrome OS and Windows. 66 * language as the prospective UI language on Chrome OS and Windows.
59 * @param {!{model: !{item: !LanguageState}}} e 67 * @param {!Event} e The tap event.
60 */ 68 */
61 onLanguageTap_: function(e) { 69 onLanguageTap_: function(e) {
70 // Make sure the event comes from tapping the language itself and not the
71 // options menu, its trigger, or its items.
72 if (EVENT_TARGET_REGEX.test(Polymer.dom(e).localTarget.className))
73 return;
74
62 // Only change the UI language on platforms that allow it. 75 // Only change the UI language on platforms that allow it.
63 if ((!cr.isChromeOS && !cr.isWindows) || loadTimeData.getBoolean('isGuest')) 76 if ((!cr.isChromeOS && !cr.isWindows) || loadTimeData.getBoolean('isGuest'))
64 return; 77 return;
65 78
66 // Set the prospective UI language. This won't take effect until a restart. 79 // Set the prospective UI language. This won't take effect until a restart.
67 if (e.model.item.language.supportsUI) 80 var tapEvent = /** @type {!{model: !{item: !LanguageState}}} */(e);
68 this.languageHelper_.setUILanguage(e.model.item.language.code); 81 if (tapEvent.model.item.language.supportsUI)
82 this.languageHelper_.setUILanguage(tapEvent.model.item.language.code);
69 }, 83 },
70 84
71 /** 85 /**
72 * Handler for enabling or disabling spell check. 86 * Handler for enabling or disabling spell check.
73 * @param {!{target: Element, model: !{item: !LanguageState}}} e 87 * @param {!{target: Element, model: !{item: !LanguageState}}} e
74 */ 88 */
75 onSpellCheckChange_: function(e) { 89 onSpellCheckChange_: function(e) {
76 this.languageHelper_.toggleSpellCheck(e.model.item.language.code, 90 this.languageHelper_.toggleSpellCheck(e.model.item.language.code,
77 e.target.checked); 91 e.target.checked);
78 }, 92 },
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 * HACK(michaelpg): This is necessary to show the list when navigating to 333 * HACK(michaelpg): This is necessary to show the list when navigating to
320 * the sub-page. Remove this function when PolymerElements/neon-animation#60 334 * the sub-page. Remove this function when PolymerElements/neon-animation#60
321 * is fixed. 335 * is fixed.
322 * @param {string} tagName Name of the element containing the <iron-list>. 336 * @param {string} tagName Name of the element containing the <iron-list>.
323 */ 337 */
324 forceRenderList_: function(tagName) { 338 forceRenderList_: function(tagName) {
325 this.$$(tagName).$$('iron-list').fire('iron-resize'); 339 this.$$(tagName).$$('iron-list').fire('iron-resize');
326 }, 340 },
327 }); 341 });
328 })(); 342 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698