| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 cr.define('options', function() { | 5 cr.define('options', function() { |
| 6 /** @const */ var DictionaryWordsList = | 6 /** @const */ var DictionaryWordsList = |
| 7 options.dictionary_words.DictionaryWordsList; | 7 options.dictionary_words.DictionaryWordsList; |
| 8 /** @const */ var OptionsPage = options.OptionsPage; | 8 /** @const */ var Page = cr.ui.pageManager.Page; |
| 9 /** @const */ var PageManager = cr.ui.pageManager.PageManager; |
| 9 | 10 |
| 10 /** | 11 /** |
| 11 * Adding and removing words in custom spelling dictionary. | 12 * Adding and removing words in custom spelling dictionary. |
| 12 * @constructor | 13 * @constructor |
| 13 * @extends {options.OptionsPage} | 14 * @extends {cr.ui.Page} |
| 14 */ | 15 */ |
| 15 function EditDictionaryOverlay() { | 16 function EditDictionaryOverlay() { |
| 16 OptionsPage.call(this, 'editDictionary', | 17 Page.call(this, 'editDictionary', |
| 17 loadTimeData.getString('languageDictionaryOverlayPage'), | 18 loadTimeData.getString('languageDictionaryOverlayPage'), |
| 18 'language-dictionary-overlay-page'); | 19 'language-dictionary-overlay-page'); |
| 19 } | 20 } |
| 20 | 21 |
| 21 cr.addSingletonGetter(EditDictionaryOverlay); | 22 cr.addSingletonGetter(EditDictionaryOverlay); |
| 22 | 23 |
| 23 EditDictionaryOverlay.prototype = { | 24 EditDictionaryOverlay.prototype = { |
| 24 __proto__: OptionsPage.prototype, | 25 __proto__: Page.prototype, |
| 25 | 26 |
| 26 /** | 27 /** |
| 27 * A list of words in the dictionary. | 28 * A list of words in the dictionary. |
| 28 * @type {DictionaryWordsList} | 29 * @type {DictionaryWordsList} |
| 29 * @private | 30 * @private |
| 30 */ | 31 */ |
| 31 wordList_: null, | 32 wordList_: null, |
| 32 | 33 |
| 33 /** | 34 /** |
| 34 * The input field for searching for words in the dictionary. | 35 * The input field for searching for words in the dictionary. |
| 35 * @type {HTMLElement} | 36 * @type {HTMLElement} |
| 36 * @private | 37 * @private |
| 37 */ | 38 */ |
| 38 searchField_: null, | 39 searchField_: null, |
| 39 | 40 |
| 40 /** | 41 /** |
| 41 * The paragraph of text that indicates that search returned no results. | 42 * The paragraph of text that indicates that search returned no results. |
| 42 * @type {HTMLElement} | 43 * @type {HTMLElement} |
| 43 * @private | 44 * @private |
| 44 */ | 45 */ |
| 45 noMatchesLabel_: null, | 46 noMatchesLabel_: null, |
| 46 | 47 |
| 47 /** | 48 /** |
| 48 * Initializes the edit dictionary overlay. | 49 * Initializes the edit dictionary overlay. |
| 49 * @override | 50 * @override |
| 50 */ | 51 */ |
| 51 initializePage: function() { | 52 initializePage: function() { |
| 52 OptionsPage.prototype.initializePage.call(this); | 53 Page.prototype.initializePage.call(this); |
| 53 | 54 |
| 54 this.wordList_ = $('language-dictionary-overlay-word-list'); | 55 this.wordList_ = $('language-dictionary-overlay-word-list'); |
| 55 DictionaryWordsList.decorate(this.wordList_); | 56 DictionaryWordsList.decorate(this.wordList_); |
| 56 this.wordList_.onWordListChanged = function() { | 57 this.wordList_.onWordListChanged = function() { |
| 57 this.onWordListChanged_(); | 58 this.onWordListChanged_(); |
| 58 }.bind(this); | 59 }.bind(this); |
| 59 | 60 |
| 60 this.searchField_ = $('language-dictionary-overlay-search-field'); | 61 this.searchField_ = $('language-dictionary-overlay-search-field'); |
| 61 this.searchField_.onsearch = function(e) { | 62 this.searchField_.onsearch = function(e) { |
| 62 this.wordList_.search(e.currentTarget.value); | 63 this.wordList_.search(e.currentTarget.value); |
| 63 }.bind(this); | 64 }.bind(this); |
| 64 this.searchField_.onkeydown = function(e) { | 65 this.searchField_.onkeydown = function(e) { |
| 65 // Don't propagate enter key events. Otherwise the default button will | 66 // Don't propagate enter key events. Otherwise the default button will |
| 66 // activate. | 67 // activate. |
| 67 if (e.keyIdentifier == 'Enter') | 68 if (e.keyIdentifier == 'Enter') |
| 68 e.stopPropagation(); | 69 e.stopPropagation(); |
| 69 }; | 70 }; |
| 70 | 71 |
| 71 this.noMatchesLabel_ = getRequiredElement( | 72 this.noMatchesLabel_ = getRequiredElement( |
| 72 'language-dictionary-overlay-no-matches'); | 73 'language-dictionary-overlay-no-matches'); |
| 73 | 74 |
| 74 $('language-dictionary-overlay-done-button').onclick = function(e) { | 75 $('language-dictionary-overlay-done-button').onclick = function(e) { |
| 75 OptionsPage.closeOverlay(); | 76 PageManager.closeOverlay(); |
| 76 }; | 77 }; |
| 77 }, | 78 }, |
| 78 | 79 |
| 79 /** | 80 /** |
| 80 * Refresh the dictionary words when the page is displayed. | 81 * Refresh the dictionary words when the page is displayed. |
| 81 * @override | 82 * @override |
| 82 */ | 83 */ |
| 83 didShowPage: function() { | 84 didShowPage: function() { |
| 84 chrome.send('refreshDictionaryWords'); | 85 chrome.send('refreshDictionaryWords'); |
| 85 }, | 86 }, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 109 }; | 110 }; |
| 110 | 111 |
| 111 EditDictionaryOverlay.getWordListForTesting = function() { | 112 EditDictionaryOverlay.getWordListForTesting = function() { |
| 112 return EditDictionaryOverlay.getInstance().wordList_; | 113 return EditDictionaryOverlay.getInstance().wordList_; |
| 113 }; | 114 }; |
| 114 | 115 |
| 115 return { | 116 return { |
| 116 EditDictionaryOverlay: EditDictionaryOverlay | 117 EditDictionaryOverlay: EditDictionaryOverlay |
| 117 }; | 118 }; |
| 118 }); | 119 }); |
| OLD | NEW |