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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 this.element.classList.toggle("hidden", !x); | 72 this.element.classList.toggle("hidden", !x); |
73 this._visible = x; | 73 this._visible = x; |
74 }, | 74 }, |
75 | 75 |
76 __proto__: WebInspector.Object.prototype | 76 __proto__: WebInspector.Object.prototype |
77 } | 77 } |
78 | 78 |
79 /** | 79 /** |
80 * @constructor | 80 * @constructor |
81 * @extends {WebInspector.StatusBarItem} | 81 * @extends {WebInspector.StatusBarItem} |
82 * @param {!Array.<string>} counters | |
83 * @param {string=} className | |
84 */ | |
85 WebInspector.StatusBarCounter = function(counters, className) | |
86 { | |
87 WebInspector.StatusBarItem.call(this, "div"); | |
88 this.element.className = "status-bar-item status-bar-counter hidden"; | |
89 if (className) | |
90 this.element.classList.add(className); | |
91 this.element.addEventListener("click", this._clicked.bind(this), false); | |
92 /** @type {!Array.<!{element: !Element, counter: string, value: number, titl
e: string}>} */ | |
93 this._counters = []; | |
94 for (var i = 0; i < counters.length; ++i) { | |
95 var element = this.element.createChild("span", "status-bar-counter-item"
); | |
96 element.createChild("div", counters[i]); | |
97 element.createChild("span"); | |
98 this._counters.push({counter: counters[i], element: element, value: 0, t
itle: ""}); | |
99 } | |
100 this._update(); | |
101 } | |
102 | |
103 WebInspector.StatusBarCounter.prototype = { | |
104 /** | |
105 * @param {string} counter | |
106 * @param {number} value | |
107 * @param {string} title | |
108 */ | |
109 setCounter: function(counter, value, title) | |
110 { | |
111 for (var i = 0; i < this._counters.length; ++i) { | |
112 if (this._counters[i].counter === counter) { | |
113 this._counters[i].value = value; | |
114 this._counters[i].title = title; | |
115 this._update(); | |
116 return; | |
117 } | |
118 } | |
119 }, | |
120 | |
121 _update: function() | |
122 { | |
123 var total = 0; | |
124 var title = ""; | |
125 for (var i = 0; i < this._counters.length; ++i) { | |
126 var counter = this._counters[i]; | |
127 var value = counter.value; | |
128 if (!counter.value) { | |
129 counter.element.classList.add("hidden"); | |
130 continue; | |
131 } | |
132 counter.element.classList.remove("hidden"); | |
133 counter.element.classList.toggle("status-bar-counter-item-first", !t
otal); | |
134 counter.element.querySelector("span").textContent = value; | |
135 total += value; | |
136 if (counter.title) { | |
137 if (title) | |
138 title += ", "; | |
139 title += counter.title; | |
140 } | |
141 } | |
142 this.element.classList.toggle("hidden", !total); | |
143 this.element.title = title; | |
144 }, | |
145 | |
146 /** | |
147 * @param {!Event} event | |
148 */ | |
149 _clicked: function(event) | |
150 { | |
151 this.dispatchEventToListeners("click"); | |
152 }, | |
153 | |
154 __proto__: WebInspector.StatusBarItem.prototype | |
155 } | |
156 | |
157 /** | |
158 * @constructor | |
159 * @extends {WebInspector.StatusBarItem} | |
160 * @param {string} text | 82 * @param {string} text |
161 * @param {string=} className | 83 * @param {string=} className |
162 */ | 84 */ |
163 WebInspector.StatusBarText = function(text, className) | 85 WebInspector.StatusBarText = function(text, className) |
164 { | 86 { |
165 WebInspector.StatusBarItem.call(this, "span"); | 87 WebInspector.StatusBarItem.call(this, "span"); |
166 this.element.className = "status-bar-item status-bar-text"; | 88 this.element.className = "status-bar-item status-bar-text"; |
167 if (className) | 89 if (className) |
168 this.element.classList.add(className); | 90 this.element.classList.add(className); |
169 this.element.textContent = text; | 91 this.element.textContent = text; |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 } | 419 } |
498 } | 420 } |
499 }, | 421 }, |
500 | 422 |
501 __proto__: WebInspector.StatusBarItem.prototype | 423 __proto__: WebInspector.StatusBarItem.prototype |
502 } | 424 } |
503 | 425 |
504 /** | 426 /** |
505 * @interface | 427 * @interface |
506 */ | 428 */ |
507 WebInspector.StatusBarItem.Provider = function() | 429 WebInspector.StatusBarButton.Provider = function() |
508 { | 430 { |
509 } | 431 } |
510 | 432 |
511 WebInspector.StatusBarItem.Provider.prototype = { | 433 WebInspector.StatusBarButton.Provider.prototype = { |
512 /** | 434 /** |
513 * @return {?WebInspector.StatusBarItem} | 435 * @return {?WebInspector.StatusBarButton} |
514 */ | 436 */ |
515 item: function() {} | 437 button: function() {} |
516 } | 438 } |
517 | 439 |
518 /** | 440 /** |
519 * @constructor | 441 * @constructor |
520 * @extends {WebInspector.StatusBarItem} | 442 * @extends {WebInspector.StatusBarItem} |
521 * @param {?function(!Event)} changeHandler | 443 * @param {?function(!Event)} changeHandler |
522 * @param {string=} className | 444 * @param {string=} className |
523 */ | 445 */ |
524 WebInspector.StatusBarComboBox = function(changeHandler, className) | 446 WebInspector.StatusBarComboBox = function(changeHandler, className) |
525 { | 447 { |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
747 var options = []; | 669 var options = []; |
748 for (var index = 0; index < this._states.length; index++) { | 670 for (var index = 0; index < this._states.length; index++) { |
749 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) |
750 options.push(this._buttons[index]); | 672 options.push(this._buttons[index]); |
751 } | 673 } |
752 return options; | 674 return options; |
753 }, | 675 }, |
754 | 676 |
755 __proto__: WebInspector.StatusBarButton.prototype | 677 __proto__: WebInspector.StatusBarButton.prototype |
756 } | 678 } |
OLD | NEW |