| 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-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 Loading... |
| 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 }); |
| OLD | NEW |