Chromium Code Reviews| 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 94 * @constructor | 94 * @constructor |
| 95 * @extends {WebInspector.StatusBarItem} | 95 * @extends {WebInspector.StatusBarItem} |
| 96 * @param {string} title | 96 * @param {string} title |
| 97 * @param {string} className | 97 * @param {string} className |
| 98 * @param {number=} states | 98 * @param {number=} states |
| 99 */ | 99 */ |
| 100 WebInspector.StatusBarButton = function(title, className, states) | 100 WebInspector.StatusBarButton = function(title, className, states) |
| 101 { | 101 { |
| 102 WebInspector.StatusBarItem.call(this, document.createElement("button")); | 102 WebInspector.StatusBarItem.call(this, document.createElement("button")); |
| 103 this.element.className = className + " status-bar-item"; | 103 this.element.className = className + " status-bar-item"; |
| 104 this.element.addEventListener("click", this._clicked.bind(this), false); | 104 this.element.addEventListener("click", this._clicked.bind(this, false), fals e); |
| 105 | 105 |
| 106 this.glyph = document.createElement("div"); | 106 this.glyph = document.createElement("div"); |
| 107 this.glyph.className = "glyph"; | 107 this.glyph.className = "glyph"; |
| 108 this.element.appendChild(this.glyph); | 108 this.element.appendChild(this.glyph); |
| 109 | 109 |
| 110 this.glyphShadow = document.createElement("div"); | 110 this.glyphShadow = document.createElement("div"); |
| 111 this.glyphShadow.className = "glyph shadow"; | 111 this.glyphShadow.className = "glyph shadow"; |
| 112 this.element.appendChild(this.glyphShadow); | 112 this.element.appendChild(this.glyphShadow); |
| 113 | 113 |
| 114 this.states = states; | 114 this.states = states; |
| 115 if (!states) | 115 if (!states) |
| 116 this.states = 2; | 116 this.states = 2; |
| 117 | 117 |
| 118 if (states == 2) | 118 if (states == 2) |
| 119 this._state = false; | 119 this._state = false; |
| 120 else | 120 else |
| 121 this._state = 0; | 121 this._state = 0; |
| 122 | 122 |
| 123 this.title = title; | 123 this.title = title; |
| 124 this.className = className; | 124 this.className = className; |
| 125 this._visible = true; | 125 this._visible = true; |
| 126 } | 126 } |
| 127 | 127 |
| 128 WebInspector.StatusBarButton.prototype = { | 128 WebInspector.StatusBarButton.prototype = { |
| 129 _clicked: function() | 129 /** |
| 130 * @param {boolean} fromLongClick | |
| 131 */ | |
| 132 _clicked: function(fromLongClick) | |
| 130 { | 133 { |
| 131 this.dispatchEventToListeners("click"); | 134 this.dispatchEventToListeners("click", fromLongClick); |
| 132 if (this._longClickInterval) { | 135 if (this._longClickInterval) { |
| 133 clearInterval(this._longClickInterval); | 136 clearInterval(this._longClickInterval); |
| 134 delete this._longClickInterval; | 137 delete this._longClickInterval; |
| 135 } | 138 } |
| 136 }, | 139 }, |
| 137 | 140 |
| 138 /** | 141 /** |
| 139 * @override | 142 * @override |
| 140 */ | 143 */ |
| 141 _applyEnabledState: function() | 144 _applyEnabledState: function() |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 312 delete this._longClickOptionsData; | 315 delete this._longClickOptionsData; |
| 313 | 316 |
| 314 this.unmakeLongClickEnabled(); | 317 this.unmakeLongClickEnabled(); |
| 315 } | 318 } |
| 316 }, | 319 }, |
| 317 | 320 |
| 318 _showOptions: function() | 321 _showOptions: function() |
| 319 { | 322 { |
| 320 var buttons = this._longClickOptionsData.buttonsProvider(); | 323 var buttons = this._longClickOptionsData.buttonsProvider(); |
| 321 var mainButtonClone = new WebInspector.StatusBarButton(this.title, this. className, this.states); | 324 var mainButtonClone = new WebInspector.StatusBarButton(this.title, this. className, this.states); |
| 322 mainButtonClone.addEventListener("click", this._clicked, this); | 325 mainButtonClone.addEventListener("click", this._clicked.bind(this, true) , this); |
| 323 mainButtonClone.state = this.state; | 326 mainButtonClone.state = this.state; |
| 324 buttons.push(mainButtonClone); | 327 buttons.unshift(mainButtonClone); |
|
aandrey
2013/12/23 09:04:10
if it is a refactoring that has nothing to do with
eustas
2013/12/26 07:35:37
It is essential. Without this change order of "add
| |
| 325 | 328 |
| 326 var mouseUpListener = mouseUp.bind(this); | 329 var mouseUpListener = mouseUp.bind(this); |
| 327 document.documentElement.addEventListener("mouseup", mouseUpListener, fa lse); | 330 document.documentElement.addEventListener("mouseup", mouseUpListener, fa lse); |
| 328 | 331 |
| 329 var optionsGlassPane = new WebInspector.GlassPane(); | 332 var optionsGlassPane = new WebInspector.GlassPane(); |
| 330 var optionsBarElement = optionsGlassPane.element.createChild("div", "alt ernate-status-bar-buttons-bar"); | 333 var optionsBarElement = optionsGlassPane.element.createChild("div", "alt ernate-status-bar-buttons-bar"); |
| 331 const buttonHeight = 23; | 334 const buttonHeight = 23; |
| 332 | 335 |
| 333 var hostButtonPosition = this.element.totalOffset(); | 336 var hostButtonPosition = this.element.totalOffset(); |
| 334 | 337 |
| 335 var topNotBottom = hostButtonPosition.top + buttonHeight * buttons.lengt h < document.documentElement.offsetHeight; | 338 var topNotBottom = hostButtonPosition.top + buttonHeight * buttons.lengt h < document.documentElement.offsetHeight; |
| 336 | 339 |
| 337 if (topNotBottom) | 340 if (!topNotBottom) |
| 338 buttons = buttons.reverse(); | 341 buttons = buttons.reverse(); |
| 339 | 342 |
| 340 optionsBarElement.style.height = (buttonHeight * buttons.length) + "px"; | 343 optionsBarElement.style.height = (buttonHeight * buttons.length) + "px"; |
| 341 if (topNotBottom) | 344 if (topNotBottom) |
| 342 optionsBarElement.style.top = (hostButtonPosition.top + 1) + "px"; | 345 optionsBarElement.style.top = (hostButtonPosition.top + 1) + "px"; |
| 343 else | 346 else |
| 344 optionsBarElement.style.top = (hostButtonPosition.top - (buttonHeigh t * (buttons.length - 1))) + "px"; | 347 optionsBarElement.style.top = (hostButtonPosition.top - (buttonHeigh t * (buttons.length - 1))) + "px"; |
| 345 optionsBarElement.style.left = (hostButtonPosition.left + 1) + "px"; | 348 optionsBarElement.style.left = (hostButtonPosition.left + 1) + "px"; |
| 346 | 349 |
| 347 var boundMouseOver = mouseOver.bind(this); | 350 var boundMouseOver = mouseOver.bind(this); |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 373 function mouseUp(e) | 376 function mouseUp(e) |
| 374 { | 377 { |
| 375 if (e.which !== 1) | 378 if (e.which !== 1) |
| 376 return; | 379 return; |
| 377 optionsGlassPane.dispose(); | 380 optionsGlassPane.dispose(); |
| 378 document.documentElement.removeEventListener("mouseup", mouseUpListe ner, false); | 381 document.documentElement.removeEventListener("mouseup", mouseUpListe ner, false); |
| 379 | 382 |
| 380 for (var i = 0; i < buttons.length; ++i) { | 383 for (var i = 0; i < buttons.length; ++i) { |
| 381 if (buttons[i].element.classList.contains("emulate-active")) { | 384 if (buttons[i].element.classList.contains("emulate-active")) { |
| 382 buttons[i].element.classList.remove("emulate-active"); | 385 buttons[i].element.classList.remove("emulate-active"); |
| 383 buttons[i]._clicked(); | 386 buttons[i]._clicked(true); |
| 384 break; | 387 break; |
| 385 } | 388 } |
| 386 } | 389 } |
| 387 } | 390 } |
| 388 }, | 391 }, |
| 389 | 392 |
| 390 __proto__: WebInspector.StatusBarItem.prototype | 393 __proto__: WebInspector.StatusBarItem.prototype |
| 391 } | 394 } |
| 392 | 395 |
| 393 /** | 396 /** |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 527 /** | 530 /** |
| 528 * @return {boolean} | 531 * @return {boolean} |
| 529 */ | 532 */ |
| 530 checked: function() | 533 checked: function() |
| 531 { | 534 { |
| 532 return this._checkbox.checked; | 535 return this._checkbox.checked; |
| 533 }, | 536 }, |
| 534 | 537 |
| 535 __proto__: WebInspector.StatusBarItem.prototype | 538 __proto__: WebInspector.StatusBarItem.prototype |
| 536 } | 539 } |
| OLD | NEW |