|
1975 | 1975 | */
|
1976 | 1976 | this.captionsButton = document.querySelector(this.options.captionsButton);
|
1977 | 1977 |
|
1978 |
| - if (null === this.captionsButton) |
| 1978 | + if (null !== this.captionsButton) |
1979 | 1979 | {
|
1980 |
| - return; |
1981 |
| - } |
1982 |
| - |
1983 |
| - this.captionsButtonClick = function() |
1984 |
| - { |
1985 |
| - this.captionsMuted = !this.captionsMuted; |
1986 |
| - }.bind(this); |
| 1980 | + this.captionsButtonClick = function() |
| 1981 | + { |
| 1982 | + this.captionsMuted = !this.captionsMuted; |
| 1983 | + }.bind(this); |
1987 | 1984 |
|
1988 |
| - this.captionsButton.addEventListener('click', this.captionsButtonClick); |
| 1985 | + this.captionsButton.addEventListener('click', this.captionsButtonClick); |
| 1986 | + } |
1989 | 1987 |
|
1990 | 1988 | /**
|
1991 | 1989 | * Set the captions are enabled or not
|
|
2104 | 2102 | // Handle the features request
|
2105 | 2103 | this.on('features', function(features)
|
2106 | 2104 | {
|
2107 |
| - this.captionsButton.style.display = 'none'; |
2108 |
| - if (features.captions) this.captionsButton.style.display = 'inline-block'; |
| 2105 | + if (null !== this.captionsButton) |
| 2106 | + { |
| 2107 | + this.captionsButton.style.display = 'none'; |
| 2108 | + if (features.captions) this.captionsButton.style.display = 'inline-block'; |
| 2109 | + } |
2109 | 2110 | });
|
2110 | 2111 |
|
2111 | 2112 | //Set the defaults if we have none for the controls
|
|
2117 | 2118 |
|
2118 | 2119 | plugin.opened = function()
|
2119 | 2120 | {
|
2120 |
| - if (null === this.captionsButton) |
| 2121 | + if (null !== this.captionsButton) |
2121 | 2122 | {
|
2122 |
| - return; |
| 2123 | + this.captionsButton.classList.remove('disabled'); |
2123 | 2124 | }
|
2124 | 2125 |
|
2125 |
| - this.captionsButton.classList.remove('disabled'); |
2126 | 2126 | this.captionsMuted = !!SavedData.read(CAPTIONS_MUTED);
|
2127 | 2127 | this.setCaptionsStyles(SavedData.read(CAPTIONS_STYLES));
|
2128 | 2128 | };
|
2129 | 2129 |
|
2130 | 2130 | plugin.close = function()
|
2131 | 2131 | {
|
2132 |
| - if (null === this.captionsButton) |
| 2132 | + if (null !== this.captionsButton) |
2133 | 2133 | {
|
2134 |
| - return; |
| 2134 | + this._disableButton(this.captionsButton); |
2135 | 2135 | }
|
2136 |
| - |
2137 |
| - this._disableButton(this.captionsButton); |
2138 | 2136 | };
|
2139 | 2137 |
|
2140 | 2138 | plugin.teardown = function()
|
2141 | 2139 | {
|
2142 |
| - if (null === this.captionsButton) |
| 2140 | + if (null !== this.captionsButton) |
2143 | 2141 | {
|
2144 |
| - return; |
| 2142 | + this.captionsButton.removeEventListener('click', this.captionsButtonClick); |
| 2143 | + delete this.captionsButton; |
2145 | 2144 | }
|
2146 | 2145 |
|
2147 |
| - this.captionsButton.removeEventListener('click', this.captionsButtonClick); |
2148 |
| - delete this.captionsButton; |
2149 | 2146 | delete this._captionsStyles;
|
2150 | 2147 | delete this.getCaptionsStyles;
|
2151 | 2148 | delete this.setCaptionsStyles;
|
|
0 commit comments