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

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

Issue 2797133007: [MD settings] add custom spelling words to top of list (Closed)
Patch Set: Created 3 years, 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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-edit-dictionary-page' is a sub-page for editing 6 * @fileoverview 'settings-edit-dictionary-page' is a sub-page for editing
7 * the "dictionary" of custom words used for spell check. 7 * the "dictionary" of custom words used for spell check.
8 */ 8 */
9 Polymer({ 9 Polymer({
10 is: 'settings-edit-dictionary-page', 10 is: 'settings-edit-dictionary-page',
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 addWordFromInput_: function() { 114 addWordFromInput_: function() {
115 // Spaces are allowed, but removing leading and trailing whitespace. 115 // Spaces are allowed, but removing leading and trailing whitespace.
116 var word = this.newWordValue_.trim(); 116 var word = this.newWordValue_.trim();
117 this.newWordValue_ = ''; 117 this.newWordValue_ = '';
118 if (!word) 118 if (!word)
119 return; 119 return;
120 120
121 var index = this.words_.indexOf(word); 121 var index = this.words_.indexOf(word);
122 if (index == -1) { 122 if (index == -1) {
123 this.languageSettingsPrivate.addSpellcheckWord(word); 123 this.languageSettingsPrivate.addSpellcheckWord(word);
124 this.push('words_', word); 124 this.unshift('words_', word);
125 index = this.words_.length - 1;
126 } 125 }
127
128 // Scroll to the word (usually the bottom, or to the index if the word
129 // is already present).
130 this.async(function(){
131 this.root.querySelector('#list').scrollToIndex(index);
132 });
133 }, 126 },
134 127
135 /** 128 /**
136 * Checks if any words exists in the dictionary. 129 * Checks if any words exists in the dictionary.
137 * @private 130 * @private
138 * @return {boolean} 131 * @return {boolean}
139 */ 132 */
140 hasWords_: function() { 133 hasWords_: function() {
141 return this.words_.length > 0; 134 return this.words_.length > 0;
142 } 135 }
143 }); 136 });
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698