| 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.pageManager.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 /** @override */ | 48 /** @override */ |
| 48 initializePage: function() { | 49 initializePage: function() { |
| 49 OptionsPage.prototype.initializePage.call(this); | 50 Page.prototype.initializePage.call(this); |
| 50 | 51 |
| 51 this.wordList_ = $('language-dictionary-overlay-word-list'); | 52 this.wordList_ = $('language-dictionary-overlay-word-list'); |
| 52 DictionaryWordsList.decorate(this.wordList_); | 53 DictionaryWordsList.decorate(this.wordList_); |
| 53 this.wordList_.onWordListChanged = function() { | 54 this.wordList_.onWordListChanged = function() { |
| 54 this.onWordListChanged_(); | 55 this.onWordListChanged_(); |
| 55 }.bind(this); | 56 }.bind(this); |
| 56 | 57 |
| 57 this.searchField_ = $('language-dictionary-overlay-search-field'); | 58 this.searchField_ = $('language-dictionary-overlay-search-field'); |
| 58 this.searchField_.onsearch = function(e) { | 59 this.searchField_.onsearch = function(e) { |
| 59 this.wordList_.search(e.currentTarget.value); | 60 this.wordList_.search(e.currentTarget.value); |
| 60 }.bind(this); | 61 }.bind(this); |
| 61 this.searchField_.onkeydown = function(e) { | 62 this.searchField_.onkeydown = function(e) { |
| 62 // Don't propagate enter key events. Otherwise the default button will | 63 // Don't propagate enter key events. Otherwise the default button will |
| 63 // activate. | 64 // activate. |
| 64 if (e.keyIdentifier == 'Enter') | 65 if (e.keyIdentifier == 'Enter') |
| 65 e.stopPropagation(); | 66 e.stopPropagation(); |
| 66 }; | 67 }; |
| 67 | 68 |
| 68 this.noMatchesLabel_ = getRequiredElement( | 69 this.noMatchesLabel_ = getRequiredElement( |
| 69 'language-dictionary-overlay-no-matches'); | 70 'language-dictionary-overlay-no-matches'); |
| 70 | 71 |
| 71 $('language-dictionary-overlay-done-button').onclick = function(e) { | 72 $('language-dictionary-overlay-done-button').onclick = function(e) { |
| 72 OptionsPage.closeOverlay(); | 73 PageManager.closeOverlay(); |
| 73 }; | 74 }; |
| 74 }, | 75 }, |
| 75 | 76 |
| 76 /** | 77 /** |
| 77 * Refresh the dictionary words when the page is displayed. | 78 * Refresh the dictionary words when the page is displayed. |
| 78 * @override | 79 * @override |
| 79 */ | 80 */ |
| 80 didShowPage: function() { | 81 didShowPage: function() { |
| 81 chrome.send('refreshDictionaryWords'); | 82 chrome.send('refreshDictionaryWords'); |
| 82 }, | 83 }, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 106 }; | 107 }; |
| 107 | 108 |
| 108 EditDictionaryOverlay.getWordListForTesting = function() { | 109 EditDictionaryOverlay.getWordListForTesting = function() { |
| 109 return EditDictionaryOverlay.getInstance().wordList_; | 110 return EditDictionaryOverlay.getInstance().wordList_; |
| 110 }; | 111 }; |
| 111 | 112 |
| 112 return { | 113 return { |
| 113 EditDictionaryOverlay: EditDictionaryOverlay | 114 EditDictionaryOverlay: EditDictionaryOverlay |
| 114 }; | 115 }; |
| 115 }); | 116 }); |
| OLD | NEW |