| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. | |
| 3 * Copyright (C) 2009 Joseph Pecoraro | |
| 4 * | |
| 5 * Redistribution and use in source and binary forms, with or without | |
| 6 * modification, are permitted provided that the following conditions | |
| 7 * are met: | |
| 8 * | |
| 9 * 1. Redistributions of source code must retain the above copyright | |
| 10 * notice, this list of conditions and the following disclaimer. | |
| 11 * 2. Redistributions in binary form must reproduce the above copyright | |
| 12 * notice, this list of conditions and the following disclaimer in the | |
| 13 * documentation and/or other materials provided with the distribution. | |
| 14 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of | |
| 15 * its contributors may be used to endorse or promote products derived | |
| 16 * from this software without specific prior written permission. | |
| 17 * | |
| 18 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY | |
| 19 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | |
| 20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
| 21 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY | |
| 22 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
| 23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
| 24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |
| 25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
| 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 28 */ | |
| 29 | |
| 30 WebInspector.Drawer = function() | |
| 31 { | |
| 32 WebInspector.View.call(this, document.getElementById("drawer")); | |
| 33 | |
| 34 this.mainStatusBar = document.getElementById("main-status-bar"); | |
| 35 this.mainStatusBar.addEventListener("mousedown", this._startStatusBarDraggin
g.bind(this), true); | |
| 36 this.viewStatusBar = document.getElementById("other-drawer-status-bar-items"
); | |
| 37 } | |
| 38 | |
| 39 WebInspector.Drawer.prototype = { | |
| 40 get visibleView() | |
| 41 { | |
| 42 return this._visibleView; | |
| 43 }, | |
| 44 | |
| 45 set visibleView(x) | |
| 46 { | |
| 47 if (this._visibleView === x) { | |
| 48 this.visible = !this.visible; | |
| 49 return; | |
| 50 } | |
| 51 | |
| 52 var firstTime = !this._visibleView; | |
| 53 if (this._visibleView) | |
| 54 this._visibleView.hide(); | |
| 55 | |
| 56 this._visibleView = x; | |
| 57 | |
| 58 if (x && !firstTime) { | |
| 59 this._safelyRemoveChildren(); | |
| 60 this.viewStatusBar.removeChildren(); // optimize this? call old.deta
ch() | |
| 61 x.attach(this.element, this.viewStatusBar); | |
| 62 x.show(); | |
| 63 this.visible = true; | |
| 64 } | |
| 65 }, | |
| 66 | |
| 67 showView: function(view) | |
| 68 { | |
| 69 if (!this.visible || this.visibleView !== view) | |
| 70 this.visibleView = view; | |
| 71 }, | |
| 72 | |
| 73 show: function() | |
| 74 { | |
| 75 if (this._animating || this.visible) | |
| 76 return; | |
| 77 | |
| 78 if (this.visibleView) | |
| 79 this.visibleView.show(); | |
| 80 | |
| 81 WebInspector.View.prototype.show.call(this); | |
| 82 | |
| 83 this._animating = true; | |
| 84 | |
| 85 document.body.addStyleClass("drawer-visible"); | |
| 86 | |
| 87 var anchoredItems = document.getElementById("anchored-status-bar-items")
; | |
| 88 | |
| 89 var animations = [ | |
| 90 {element: document.getElementById("main"), end: {bottom: this.elemen
t.offsetHeight}}, | |
| 91 {element: document.getElementById("main-status-bar"), start: {"paddi
ng-left": anchoredItems.offsetWidth - 1}, end: {"padding-left": 0}}, | |
| 92 {element: document.getElementById("other-drawer-status-bar-items"),
start: {opacity: 0}, end: {opacity: 1}} | |
| 93 ]; | |
| 94 | |
| 95 var consoleStatusBar = document.getElementById("drawer-status-bar"); | |
| 96 consoleStatusBar.insertBefore(anchoredItems, consoleStatusBar.firstChild
); | |
| 97 | |
| 98 function animationFinished() | |
| 99 { | |
| 100 if ("updateStatusBarItems" in WebInspector.currentPanel) | |
| 101 WebInspector.currentPanel.updateStatusBarItems(); | |
| 102 if (this.visibleView.afterShow) | |
| 103 this.visibleView.afterShow(); | |
| 104 delete this._animating; | |
| 105 } | |
| 106 | |
| 107 WebInspector.animateStyle(animations, window.event && window.event.shift
Key ? 2000 : 250, animationFinished.bind(this)); | |
| 108 }, | |
| 109 | |
| 110 hide: function() | |
| 111 { | |
| 112 if (this._animating || !this.visible) | |
| 113 return; | |
| 114 | |
| 115 WebInspector.View.prototype.hide.call(this); | |
| 116 | |
| 117 if (this.visibleView) | |
| 118 this.visibleView.hide(); | |
| 119 | |
| 120 this._animating = true; | |
| 121 | |
| 122 if (this.element === WebInspector.currentFocusElement || this.element.is
Ancestor(WebInspector.currentFocusElement)) | |
| 123 WebInspector.currentFocusElement = WebInspector.previousFocusElement
; | |
| 124 | |
| 125 var anchoredItems = document.getElementById("anchored-status-bar-items")
; | |
| 126 | |
| 127 // Temporally set properties and classes to mimic the post-animation val
ues so panels | |
| 128 // like Elements in their updateStatusBarItems call will size things to
fit the final location. | |
| 129 document.getElementById("main-status-bar").style.setProperty("padding-le
ft", (anchoredItems.offsetWidth - 1) + "px"); | |
| 130 document.body.removeStyleClass("drawer-visible"); | |
| 131 if ("updateStatusBarItems" in WebInspector.currentPanel) | |
| 132 WebInspector.currentPanel.updateStatusBarItems(); | |
| 133 document.body.addStyleClass("drawer-visible"); | |
| 134 | |
| 135 var animations = [ | |
| 136 {element: document.getElementById("main"), end: {bottom: 0}}, | |
| 137 {element: document.getElementById("main-status-bar"), start: {"paddi
ng-left": 0}, end: {"padding-left": anchoredItems.offsetWidth - 1}}, | |
| 138 {element: document.getElementById("other-drawer-status-bar-items"),
start: {opacity: 1}, end: {opacity: 0}} | |
| 139 ]; | |
| 140 | |
| 141 function animationFinished() | |
| 142 { | |
| 143 var mainStatusBar = document.getElementById("main-status-bar"); | |
| 144 mainStatusBar.insertBefore(anchoredItems, mainStatusBar.firstChild); | |
| 145 mainStatusBar.style.removeProperty("padding-left"); | |
| 146 document.body.removeStyleClass("drawer-visible"); | |
| 147 delete this._animating; | |
| 148 } | |
| 149 | |
| 150 WebInspector.animateStyle(animations, window.event && window.event.shift
Key ? 2000 : 250, animationFinished.bind(this)); | |
| 151 }, | |
| 152 | |
| 153 _safelyRemoveChildren: function() | |
| 154 { | |
| 155 var child = this.element.firstChild; | |
| 156 while (child) { | |
| 157 if (child.id !== "drawer-status-bar") { | |
| 158 var moveTo = child.nextSibling; | |
| 159 this.element.removeChild(child); | |
| 160 child = moveTo; | |
| 161 } else | |
| 162 child = child.nextSibling; | |
| 163 } | |
| 164 }, | |
| 165 | |
| 166 _startStatusBarDragging: function(event) | |
| 167 { | |
| 168 if (!this.visible || event.target !== document.getElementById("main-stat
us-bar")) | |
| 169 return; | |
| 170 | |
| 171 WebInspector.elementDragStart(document.getElementById("main-status-bar")
, this._statusBarDragging.bind(this), this._endStatusBarDragging.bind(this), eve
nt, "row-resize"); | |
| 172 | |
| 173 this._statusBarDragOffset = event.pageY - this.element.totalOffsetTop; | |
| 174 | |
| 175 event.stopPropagation(); | |
| 176 }, | |
| 177 | |
| 178 _statusBarDragging: function(event) | |
| 179 { | |
| 180 var mainElement = document.getElementById("main"); | |
| 181 | |
| 182 var height = window.innerHeight - event.pageY + this._statusBarDragOffse
t; | |
| 183 height = Number.constrain(height, Preferences.minConsoleHeight, window.i
nnerHeight - mainElement.totalOffsetTop - Preferences.minConsoleHeight); | |
| 184 | |
| 185 mainElement.style.bottom = height + "px"; | |
| 186 this.element.style.height = height + "px"; | |
| 187 | |
| 188 event.preventDefault(); | |
| 189 event.stopPropagation(); | |
| 190 }, | |
| 191 | |
| 192 _endStatusBarDragging: function(event) | |
| 193 { | |
| 194 WebInspector.elementDragEnd(event); | |
| 195 | |
| 196 delete this._statusBarDragOffset; | |
| 197 | |
| 198 event.stopPropagation(); | |
| 199 } | |
| 200 } | |
| 201 | |
| 202 WebInspector.Drawer.prototype.__proto__ = WebInspector.View.prototype; | |
| OLD | NEW |