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

Unified Diff: chrome/browser/resources/settings/languages_page/edit_dictionary_page.js

Issue 2690263002: MD Settings: add empty list message for spell-check edit page. (Closed)
Patch Set: use comparison instead of boolean conversion Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/settings/languages_page/edit_dictionary_page.js
diff --git a/chrome/browser/resources/settings/languages_page/edit_dictionary_page.js b/chrome/browser/resources/settings/languages_page/edit_dictionary_page.js
index 421e78056ef2aadfda373c505ada3e9ee8c781a6..c8c3939de95c0f005991d606028e46ab3c85d682 100644
--- a/chrome/browser/resources/settings/languages_page/edit_dictionary_page.js
+++ b/chrome/browser/resources/settings/languages_page/edit_dictionary_page.js
@@ -20,14 +20,21 @@ Polymer({
},
},
+ /** @type {LanguageSettingsPrivate} */
+ languageSettingsPrivate: null,
+
ready: function() {
- chrome.languageSettingsPrivate.getSpellcheckWords(function(words) {
+ this.languageSettingsPrivate =
+ settings.languageSettingsPrivateApiForTest ||
+ /** @type {!LanguageSettingsPrivate} */(chrome.languageSettingsPrivate);
+
+ this.languageSettingsPrivate.getSpellcheckWords(function(words) {
this.words_ = words;
}.bind(this));
// Updates are applied locally so they appear immediately, but we should
// listen for changes in case they come from elsewhere.
- chrome.languageSettingsPrivate.onCustomDictionaryChanged.addListener(
+ this.languageSettingsPrivate.onCustomDictionaryChanged.addListener(
this.onCustomDictionaryChanged_.bind(this));
// Add a key handler for the paper-input.
@@ -85,7 +92,7 @@ Polymer({
* @param {!{model: !{item: string}}} e
*/
onRemoveWordTap_: function(e) {
- chrome.languageSettingsPrivate.removeSpellcheckWord(e.model.item);
+ this.languageSettingsPrivate.removeSpellcheckWord(e.model.item);
this.arrayDelete('words_', e.model.item);
},
@@ -102,12 +109,24 @@ Polymer({
var index = this.words_.indexOf(word);
if (index == -1) {
- chrome.languageSettingsPrivate.addSpellcheckWord(word);
+ this.languageSettingsPrivate.addSpellcheckWord(word);
this.push('words_', word);
+ index = this.words_.length - 1;
}
// Scroll to the word (usually the bottom, or to the index if the word
// is already present).
- this.$.list.scrollToIndex(index);
+ this.async(function(){
+ this.root.querySelector('#list').scrollToIndex(index);
+ });
},
+
+ /**
+ * Checks if any words exists in the dictionary.
+ * @private
+ * @return {boolean}
+ */
+ hasWords_: function() {
+ return this.words_.length > 0;
+ }
});

Powered by Google App Engine
This is Rietveld 408576698