| 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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.unshift('words_', word); | 124 this.unshift('words_', word); |
| 125 if (this.words_.length == 1) { |
| 126 // When adding a word to an _empty_ list, the template is expanded. This |
| 127 // is a workaround to resize the iron-list as well. |
| 128 // TODO(dschuyler): Remove this hack after iron-list no longer needs |
| 129 // this workaround to update the list at the same time the template |
| 130 // wrapping the list is expanded. |
| 131 Polymer.dom.flush(); |
| 132 this.$$('#list').notifyResize(); |
| 133 } |
| 125 } | 134 } |
| 126 }, | 135 }, |
| 127 | 136 |
| 128 /** | 137 /** |
| 129 * Checks if any words exists in the dictionary. | 138 * Checks if any words exists in the dictionary. |
| 130 * @private | 139 * @private |
| 131 * @return {boolean} | 140 * @return {boolean} |
| 132 */ | 141 */ |
| 133 hasWords_: function() { | 142 hasWords_: function() { |
| 134 return this.words_.length > 0; | 143 return this.words_.length > 0; |
| 135 } | 144 } |
| 136 }); | 145 }); |
| OLD | NEW |