|
65 | 65 | */
|
66 | 66 | this.captionsButton = document.querySelector(this.options.captionsButton);
|
67 | 67 |
|
68 |
| - if (null === this.captionsButton) |
| 68 | + if (null !== this.captionsButton) |
69 | 69 | {
|
70 |
| - return; |
71 |
| - } |
72 |
| - |
73 |
| - this.captionsButtonClick = function() |
74 |
| - { |
75 |
| - this.captionsMuted = !this.captionsMuted; |
76 |
| - }.bind(this); |
| 70 | + this.captionsButtonClick = function() |
| 71 | + { |
| 72 | + this.captionsMuted = !this.captionsMuted; |
| 73 | + }.bind(this); |
77 | 74 |
|
78 |
| - this.captionsButton.addEventListener('click', this.captionsButtonClick); |
| 75 | + this.captionsButton.addEventListener('click', this.captionsButtonClick); |
| 76 | + } |
79 | 77 |
|
80 | 78 | /**
|
81 | 79 | * Set the captions are enabled or not
|
|
194 | 192 | // Handle the features request
|
195 | 193 | this.on('features', function(features)
|
196 | 194 | {
|
197 |
| - this.captionsButton.style.display = 'none'; |
198 |
| - if (features.captions) this.captionsButton.style.display = 'inline-block'; |
| 195 | + if (null !== this.captionsButton) |
| 196 | + { |
| 197 | + this.captionsButton.style.display = 'none'; |
| 198 | + if (features.captions) this.captionsButton.style.display = 'inline-block'; |
| 199 | + } |
199 | 200 | });
|
200 | 201 |
|
201 | 202 | //Set the defaults if we have none for the controls
|
|
207 | 208 |
|
208 | 209 | plugin.opened = function()
|
209 | 210 | {
|
210 |
| - if (null === this.captionsButton) |
| 211 | + if (null !== this.captionsButton) |
211 | 212 | {
|
212 |
| - return; |
| 213 | + this.captionsButton.classList.remove('disabled'); |
213 | 214 | }
|
214 | 215 |
|
215 |
| - this.captionsButton.classList.remove('disabled'); |
216 | 216 | this.captionsMuted = !!SavedData.read(CAPTIONS_MUTED);
|
217 | 217 | this.setCaptionsStyles(SavedData.read(CAPTIONS_STYLES));
|
218 | 218 | };
|
219 | 219 |
|
220 | 220 | plugin.close = function()
|
221 | 221 | {
|
222 |
| - if (null === this.captionsButton) |
| 222 | + if (null !== this.captionsButton) |
223 | 223 | {
|
224 |
| - return; |
| 224 | + this._disableButton(this.captionsButton); |
225 | 225 | }
|
226 |
| - |
227 |
| - this._disableButton(this.captionsButton); |
228 | 226 | };
|
229 | 227 |
|
230 | 228 | plugin.teardown = function()
|
231 | 229 | {
|
232 |
| - if (null === this.captionsButton) |
| 230 | + if (null !== this.captionsButton) |
233 | 231 | {
|
234 |
| - return; |
| 232 | + this.captionsButton.removeEventListener('click', this.captionsButtonClick); |
| 233 | + delete this.captionsButton; |
235 | 234 | }
|
236 | 235 |
|
237 |
| - this.captionsButton.removeEventListener('click', this.captionsButtonClick); |
238 |
| - delete this.captionsButton; |
239 | 236 | delete this._captionsStyles;
|
240 | 237 | delete this.getCaptionsStyles;
|
241 | 238 | delete this.setCaptionsStyles;
|
|
0 commit comments