| Left: | ||
| Right: | 
| LEFT | RIGHT | 
|---|---|
| 1 /* | 1 /* | 
| 2 * This Source Code is subject to the terms of the Mozilla Public License | 2 * This Source Code is subject to the terms of the Mozilla Public License | 
| 3 * version 2.0 (the "License"). You can obtain a copy of the License at | 3 * version 2.0 (the "License"). You can obtain a copy of the License at | 
| 4 * http://mozilla.org/MPL/2.0/. | 4 * http://mozilla.org/MPL/2.0/. | 
| 5 */ | 5 */ | 
| 6 | 6 | 
| 7 let {Prefs} = require("prefs"); | 7 let {Prefs} = require("prefs"); | 
| 8 | 8 | 
| 9 let TypoActions = | 9 let TypoActions = | 
| 10 { | 10 { | 
| 11 init: function() | 11 init: function() | 
| 12 { | 12 { | 
| 13 TypoActions.updateState(); | 13 TypoActions.updateState(); | 
| 14 TypoActions.updateList(); | 14 TypoActions.updateList(); | 
| 15 | 15 | 
| 16 Prefs.addListener(TypoActions.onPrefChange); | 16 Prefs.addListener(TypoActions.onPrefChange); | 
| 17 window.addEventListener("unload", function() Prefs.removeListener(TypoAction s.onPrefChange), false); | 17 window.addEventListener("unload", function() Prefs.removeListener(TypoAction s.onPrefChange), false); | 
| 18 }, | 18 }, | 
| 19 | 19 | 
| 20 onPrefChange: function(name) | 20 onPrefChange: function(name) | 
| 21 { | 21 { | 
| 22 if (name == "whitelist") | 22 if (name == "whitelist") | 
| 23 TypoActions.updateList(); | 23 TypoActions.updateList(); | 
| 24 else if (name == "correctTypos") | 24 else if (name == "correctTypos") | 
| 25 TypoActions.updateState(); | 25 TypoActions.updateState(); | 
| 26 else if (name == "whitelist") | |
| 27 TypoActions.updateList(); | |
| 
 
Wladimir Palant
2012/11/09 13:20:51
Are you making extra sure to handle the whitelist
 
 | |
| 28 }, | 26 }, | 
| 29 | 27 | 
| 30 setEnabled: function(checked) | 28 setEnabled: function(checked) | 
| 31 { | 29 { | 
| 32 Prefs.correctTypos = checked; | 30 Prefs.correctTypos = checked; | 
| 33 }, | 31 }, | 
| 34 | 32 | 
| 35 onItemSelected: function(list) | 33 onItemSelected: function(list) | 
| 36 { | 34 { | 
| 37 let button = E(list.getAttribute("_removeButton")); | 35 let button = E(list.getAttribute("_removeButton")); | 
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 88 option.setAttribute("label", whitelistElement.getAttribute("_emptyLabel")) ; | 86 option.setAttribute("label", whitelistElement.getAttribute("_emptyLabel")) ; | 
| 89 | 87 | 
| 90 whitelistElement.appendChild(option); | 88 whitelistElement.appendChild(option); | 
| 91 } | 89 } | 
| 92 }, | 90 }, | 
| 93 | 91 | 
| 94 updateState: function() | 92 updateState: function() | 
| 95 { | 93 { | 
| 96 let enabled = Prefs.correctTypos; | 94 let enabled = Prefs.correctTypos; | 
| 97 E("typo_enable").checked = enabled; | 95 E("typo_enable").checked = enabled; | 
| 98 E("typo_whitelist_container").style.visibility = (enabled) ? "visible" : "hi dden"; | 96 E("typo_whitelist_container").hidden = !enabled; | 
| 
 
Wladimir Palant
2012/11/09 13:20:51
Please use .hidden property here, forgot to note t
 
 | |
| 99 } | 97 } | 
| 100 }; | 98 }; | 
| 101 | 99 | 
| 102 window.addEventListener("load", function() | 100 window.addEventListener("load", function() | 
| 103 { | 101 { | 
| 104 TypoActions.init(); | 102 TypoActions.init(); | 
| 105 }, false); | 103 }, false); | 
| LEFT | RIGHT |