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, title : string}>} */ | |
apavlov
2014/07/22 16:18:37
This should be !Array.<!{element:...}>
dgozman
2014/07/24 14:55:09
Done.
| |
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); | |
apavlov
2014/07/22 16:18:36
Should this be !i for the semantics sake?
dgozman
2014/07/24 14:55:09
There may be some zero counters at the start which
| |
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} | |
82 * @param {string} text | 160 * @param {string} text |
83 * @param {string=} className | 161 * @param {string=} className |
84 */ | 162 */ |
85 WebInspector.StatusBarText = function(text, className) | 163 WebInspector.StatusBarText = function(text, className) |
86 { | 164 { |
87 WebInspector.StatusBarItem.call(this, "span"); | 165 WebInspector.StatusBarItem.call(this, "span"); |
88 this.element.className = "status-bar-item status-bar-text"; | 166 this.element.className = "status-bar-item status-bar-text"; |
89 if (className) | 167 if (className) |
90 this.element.classList.add(className); | 168 this.element.classList.add(className); |
91 this.element.textContent = text; | 169 this.element.textContent = text; |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
419 } | 497 } |
420 } | 498 } |
421 }, | 499 }, |
422 | 500 |
423 __proto__: WebInspector.StatusBarItem.prototype | 501 __proto__: WebInspector.StatusBarItem.prototype |
424 } | 502 } |
425 | 503 |
426 /** | 504 /** |
427 * @interface | 505 * @interface |
428 */ | 506 */ |
429 WebInspector.StatusBarButton.Provider = function() | 507 WebInspector.StatusBarItem.Provider = function() |
430 { | 508 { |
431 } | 509 } |
432 | 510 |
433 WebInspector.StatusBarButton.Provider.prototype = { | 511 WebInspector.StatusBarItem.Provider.prototype = { |
434 /** | 512 /** |
435 * @return {?WebInspector.StatusBarButton} | 513 * @return {?WebInspector.StatusBarItem} |
436 */ | 514 */ |
437 button: function() {} | 515 item: function() {} |
438 } | 516 } |
439 | 517 |
440 /** | 518 /** |
441 * @constructor | 519 * @constructor |
442 * @extends {WebInspector.StatusBarItem} | 520 * @extends {WebInspector.StatusBarItem} |
443 * @param {?function(!Event)} changeHandler | 521 * @param {?function(!Event)} changeHandler |
444 * @param {string=} className | 522 * @param {string=} className |
445 */ | 523 */ |
446 WebInspector.StatusBarComboBox = function(changeHandler, className) | 524 WebInspector.StatusBarComboBox = function(changeHandler, className) |
447 { | 525 { |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
669 var options = []; | 747 var options = []; |
670 for (var index = 0; index < this._states.length; index++) { | 748 for (var index = 0; index < this._states.length; index++) { |
671 if (this._states[index] !== this.state && this._states[index] !== th is._currentState) | 749 if (this._states[index] !== this.state && this._states[index] !== th is._currentState) |
672 options.push(this._buttons[index]); | 750 options.push(this._buttons[index]); |
673 } | 751 } |
674 return options; | 752 return options; |
675 }, | 753 }, |
676 | 754 |
677 __proto__: WebInspector.StatusBarButton.prototype | 755 __proto__: WebInspector.StatusBarButton.prototype |
678 } | 756 } |
OLD | NEW |