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

Unified Diff: chrome/browser/resources/options/language_dictionary_overlay_word_list.js

Issue 11362063: Editing the custom spelling dictionary (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 1 month 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/options/language_dictionary_overlay_word_list.js
diff --git a/chrome/browser/resources/options/language_dictionary_overlay_word_list.js b/chrome/browser/resources/options/language_dictionary_overlay_word_list.js
new file mode 100644
index 0000000000000000000000000000000000000000..7b9ccda4b69ce99fa11f238ecf6f4208e0697078
--- /dev/null
+++ b/chrome/browser/resources/options/language_dictionary_overlay_word_list.js
@@ -0,0 +1,78 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+cr.define('options.dictionary_words', function() {
+ var ControlledSettingIndicator = options.ControlledSettingIndicator;
+ var InlineEditableItemList = options.InlineEditableItemList;
+ var InlineEditableItem = options.InlineEditableItem;
+ var ListSelectionController = cr.ui.ListSelectionController;
+
+ function DictionaryWordsListItem(dictionaryWord) {
+ var el = cr.doc.createElement('div');
+ el.dictionaryWord_ = dictionaryWord;
+ DictionaryWordsListItem.decorate(el);
+ return el;
+ }
+
+ DictionaryWordsListItem.decorate = function(el) {
+ el.__proto__ = DictionaryWordsListItem.prototype;
+ el.decorate();
+ };
+
+ DictionaryWordsListItem.prototype = {
+ __proto__: InlineEditableItem.prototype,
+
+ wordField_: null,
+
+ decorate: function() {
+ InlineEditableItem.prototype.decorate.call(this);
+ if (this.dictionaryWord_ == '')
+ this.isPlaceholder = true;
+
+ var wordEl = this.createEditableTextCell(this.dictionaryWord_);
+ wordEl.classList.add('weakrtl');
+ wordEl.classList.add('dictionary-word-list-item');
+ this.contentElement.appendChild(wordEl);
+
+ this.wordField_ = wordEl.querySelector('input');
+ this.wordField_.classList.add('dictionary-word-list-item');
+ if (this.isPlaceholder) {
+ this.wordField_.placeholder =
+ loadTimeData.getString('languageDictionaryOverlayAddWordLabel');
+ }
+
+
+ this.addEventListener('commitedit', this.onEditCommitted_.bind(this));
+ },
+
+ get hasBeenEdited() {
+ return this.wordField_.value != this.dictionaryWord_;
+ },
+
+ onEditCommitted_: function(e) {
+ chrome.send('editDictionaryWord',
+ [this.dictionaryWord_, this.wordField_.value]);
+ },
+ };
+
+ var DictionaryWordsList = cr.ui.define('list');
+
+ DictionaryWordsList.prototype = {
+ __proto__: InlineEditableItemList.prototype,
+
+ createItem: function(dictionaryWord) {
+ return new DictionaryWordsListItem(dictionaryWord);
+ },
+
+ deleteItemAtIndex: function(index) {
+ chrome.send('editDictionaryWord', [this.dataModel.item(index), '']);
+ },
+ };
+
+ return {
+ DictionaryWordsList: DictionaryWordsList
+ };
+
+});
+

Powered by Google App Engine
This is Rietveld 408576698