| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 * @param {string} title | 157 * @param {string} title |
| 158 * @param {string} className | 158 * @param {string} className |
| 159 * @param {number=} states | 159 * @param {number=} states |
| 160 */ | 160 */ |
| 161 WebInspector.StatusBarButton = function(title, className, states) | 161 WebInspector.StatusBarButton = function(title, className, states) |
| 162 { | 162 { |
| 163 WebInspector.StatusBarItem.call(this, "button"); | 163 WebInspector.StatusBarItem.call(this, "button"); |
| 164 this.element.className = className + " status-bar-item"; | 164 this.element.className = className + " status-bar-item"; |
| 165 this.element.addEventListener("click", this._clicked.bind(this), false); | 165 this.element.addEventListener("click", this._clicked.bind(this), false); |
| 166 | 166 |
| 167 this.glyph = document.createElement("div"); | 167 this.glyph = this.element.createChild("div", "glyph"); |
| 168 this.glyph.className = "glyph"; | 168 this.glyphShadow = this.element.createChild("div", "glyph shadow"); |
| 169 this.element.appendChild(this.glyph); | |
| 170 | |
| 171 this.glyphShadow = document.createElement("div"); | |
| 172 this.glyphShadow.className = "glyph shadow"; | |
| 173 this.element.appendChild(this.glyphShadow); | |
| 174 | 169 |
| 175 this.states = states; | 170 this.states = states; |
| 176 if (!states) | 171 if (!states) |
| 177 this.states = 2; | 172 this.states = 2; |
| 178 | 173 |
| 179 if (states == 2) | 174 if (states == 2) |
| 180 this._state = false; | 175 this._state = false; |
| 181 else | 176 else |
| 182 this._state = 0; | 177 this._state = 0; |
| 183 | 178 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 get state() | 226 get state() |
| 232 { | 227 { |
| 233 return this._state; | 228 return this._state; |
| 234 }, | 229 }, |
| 235 | 230 |
| 236 set state(x) | 231 set state(x) |
| 237 { | 232 { |
| 238 if (this._state === x) | 233 if (this._state === x) |
| 239 return; | 234 return; |
| 240 | 235 |
| 241 if (this.states === 2) | 236 if (this.states === 2) { |
| 242 this.element.classList.toggle("toggled-on", x); | 237 this.element.classList.toggle("toggled-on", x); |
| 243 else { | 238 } else { |
| 244 this.element.classList.remove("toggled-" + this._state); | 239 this.element.classList.remove("toggled-" + this._state); |
| 245 if (x !== 0) | 240 if (x !== 0) |
| 246 this.element.classList.add("toggled-" + x); | 241 this.element.classList.add("toggled-" + x); |
| 247 } | 242 } |
| 248 this._state = x; | 243 this._state = x; |
| 249 }, | 244 }, |
| 250 | 245 |
| 251 get toggled() | 246 get toggled() |
| 252 { | 247 { |
| 253 if (this.states !== 2) | 248 if (this.states !== 2) |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 | 318 |
| 324 /** | 319 /** |
| 325 * @param {?function():!Array.<!WebInspector.StatusBarButton>} buttonsProvid
er | 320 * @param {?function():!Array.<!WebInspector.StatusBarButton>} buttonsProvid
er |
| 326 */ | 321 */ |
| 327 setLongClickOptionsEnabled: function(buttonsProvider) | 322 setLongClickOptionsEnabled: function(buttonsProvider) |
| 328 { | 323 { |
| 329 if (buttonsProvider) { | 324 if (buttonsProvider) { |
| 330 if (!this._longClickOptionsData) { | 325 if (!this._longClickOptionsData) { |
| 331 this.makeLongClickEnabled(); | 326 this.makeLongClickEnabled(); |
| 332 | 327 |
| 333 this.longClickGlyph = document.createElement("div"); | 328 this.longClickGlyph = this.element.createChild("div", "fill long
-click-glyph"); |
| 334 this.longClickGlyph.className = "fill long-click-glyph"; | 329 this.longClickGlyphShadow = this.element.createChild("div", "fil
l long-click-glyph shadow"); |
| 335 this.element.appendChild(this.longClickGlyph); | |
| 336 | |
| 337 this.longClickGlyphShadow = document.createElement("div"); | |
| 338 this.longClickGlyphShadow.className = "fill long-click-glyph sha
dow"; | |
| 339 this.element.appendChild(this.longClickGlyphShadow); | |
| 340 | 330 |
| 341 var longClickDownListener = this._showOptions.bind(this); | 331 var longClickDownListener = this._showOptions.bind(this); |
| 342 this.addEventListener("longClickDown", longClickDownListener, th
is); | 332 this.addEventListener("longClickDown", longClickDownListener, th
is); |
| 343 | 333 |
| 344 this._longClickOptionsData = { | 334 this._longClickOptionsData = { |
| 345 glyphElement: this.longClickGlyph, | 335 glyphElement: this.longClickGlyph, |
| 346 glyphShadowElement: this.longClickGlyphShadow, | 336 glyphShadowElement: this.longClickGlyphShadow, |
| 347 longClickDownListener: longClickDownListener | 337 longClickDownListener: longClickDownListener |
| 348 }; | 338 }; |
| 349 } | 339 } |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 var options = []; | 669 var options = []; |
| 680 for (var index = 0; index < this._states.length; index++) { | 670 for (var index = 0; index < this._states.length; index++) { |
| 681 if (this._states[index] !== this.state && this._states[index] !== th
is._currentState) | 671 if (this._states[index] !== this.state && this._states[index] !== th
is._currentState) |
| 682 options.push(this._buttons[index]); | 672 options.push(this._buttons[index]); |
| 683 } | 673 } |
| 684 return options; | 674 return options; |
| 685 }, | 675 }, |
| 686 | 676 |
| 687 __proto__: WebInspector.StatusBarButton.prototype | 677 __proto__: WebInspector.StatusBarButton.prototype |
| 688 } | 678 } |
| OLD | NEW |