OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright (C) 2007 Apple Inc. All rights reserved. |
| 3 * |
| 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions |
| 6 * are met: |
| 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright |
| 11 * notice, this list of conditions and the following disclaimer in the |
| 12 * documentation and/or other materials provided with the distribution. |
| 13 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of |
| 14 * its contributors may be used to endorse or promote products derived |
| 15 * from this software without specific prior written permission. |
| 16 * |
| 17 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY |
| 18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 20 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY |
| 21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 */ |
| 28 |
| 29 WebInspector.SidebarPane = function(title) |
| 30 { |
| 31 this.element = document.createElement("div"); |
| 32 this.element.className = "pane"; |
| 33 |
| 34 this.titleElement = document.createElement("div"); |
| 35 this.titleElement.className = "title"; |
| 36 this.titleElement.addEventListener("click", this.toggleExpanded.bind(this),
false); |
| 37 |
| 38 this.bodyElement = document.createElement("div"); |
| 39 this.bodyElement.className = "body"; |
| 40 |
| 41 this.element.appendChild(this.titleElement); |
| 42 this.element.appendChild(this.bodyElement); |
| 43 |
| 44 this.title = title; |
| 45 this.growbarVisible = false; |
| 46 this.expanded = false; |
| 47 } |
| 48 |
| 49 WebInspector.SidebarPane.prototype = { |
| 50 get title() |
| 51 { |
| 52 return this._title; |
| 53 }, |
| 54 |
| 55 set title(x) |
| 56 { |
| 57 if (this._title === x) |
| 58 return; |
| 59 this._title = x; |
| 60 this.titleElement.textContent = x; |
| 61 }, |
| 62 |
| 63 get growbarVisible() |
| 64 { |
| 65 return this._growbarVisible; |
| 66 }, |
| 67 |
| 68 set growbarVisible(x) |
| 69 { |
| 70 if (this._growbarVisible === x) |
| 71 return; |
| 72 |
| 73 this._growbarVisible = x; |
| 74 |
| 75 if (x && !this._growbarElement) { |
| 76 this._growbarElement = document.createElement("div"); |
| 77 this._growbarElement.className = "growbar"; |
| 78 this.element.appendChild(this._growbarElement); |
| 79 } else if (!x && this._growbarElement) { |
| 80 if (this._growbarElement.parentNode) |
| 81 this._growbarElement.parentNode(this._growbarElement); |
| 82 delete this._growbarElement; |
| 83 } |
| 84 }, |
| 85 |
| 86 get expanded() |
| 87 { |
| 88 return this._expanded; |
| 89 }, |
| 90 |
| 91 set expanded(x) |
| 92 { |
| 93 if (x) |
| 94 this.expand(); |
| 95 else |
| 96 this.collapse(); |
| 97 }, |
| 98 |
| 99 expand: function() |
| 100 { |
| 101 if (this._expanded) |
| 102 return; |
| 103 this._expanded = true; |
| 104 this.element.addStyleClass("expanded"); |
| 105 if (this.onexpand) |
| 106 this.onexpand(this); |
| 107 }, |
| 108 |
| 109 collapse: function() |
| 110 { |
| 111 if (!this._expanded) |
| 112 return; |
| 113 this._expanded = false; |
| 114 this.element.removeStyleClass("expanded"); |
| 115 if (this.oncollapse) |
| 116 this.oncollapse(this); |
| 117 }, |
| 118 |
| 119 toggleExpanded: function() |
| 120 { |
| 121 this.expanded = !this.expanded; |
| 122 } |
| 123 } |
| 124 |
| 125 WebInspector.SidebarPane.prototype.__proto__ = WebInspector.Object.prototype; |
OLD | NEW |