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 this._counters = []; | |
apavlov
2014/07/21 13:34:06
This should be annotated at least with a @typedef
dgozman
2014/07/21 14:24:34
Nice catch. Done.
| |
93 for (var i = 0; i < counters.length; i++) { | |
apavlov
2014/07/21 13:34:06
++i for consistency
dgozman
2014/07/21 14:24:34
Done.
| |
94 var element = this.element.createChild("span", "status-bar-counter-item" ); | |
95 element.createChild("div", counters[i]); | |
96 element.createChild("span"); | |
97 this._counters.push({counter: counters[i], element: element, value: 0, t itle: ""}); | |
98 } | |
99 this._update(); | |
100 } | |
101 | |
102 WebInspector.StatusBarCounter.prototype = { | |
103 /** | |
104 * @param {string} counter | |
105 * @param {number} value | |
106 * @param {string} title | |
107 */ | |
108 setCounter: function(counter, value, title) | |
109 { | |
110 for (var i = 0; i < this._counters.length; ++i) { | |
111 if (this._counters[i].counter == counter) { | |
apavlov
2014/07/21 13:34:06
===
dgozman
2014/07/21 14:24:34
Done.
| |
112 this._counters[i].value = value; | |
113 this._counters[i].title = title; | |
114 this._update(); | |
115 return; | |
116 } | |
117 } | |
118 }, | |
119 | |
120 _update: function() | |
121 { | |
122 var total = 0; | |
123 var title = ""; | |
124 for (var i = 0; i < this._counters.length; ++i) { | |
125 if (!this._counters[i].value) { | |
apavlov
2014/07/21 13:34:06
this._counters[i].value can be extracted into a va
dgozman
2014/07/21 14:24:34
Done.
| |
126 this._counters[i].element.classList.add("hidden"); | |
127 continue; | |
128 } | |
129 this._counters[i].element.style.marginLeft = total ? "6px" : "0"; | |
apavlov
2014/07/21 13:34:06
can we implement this using classes? This seems a
dgozman
2014/07/21 14:24:35
Done.
| |
130 this._counters[i].element.classList.remove("hidden"); | |
131 this._counters[i].element.querySelector("span").textContent = this._ counters[i].value; | |
132 total += this._counters[i].value; | |
133 if (this._counters[i].title) { | |
134 if (title) | |
135 title += ", "; | |
136 title += this._counters[i].title; | |
137 } | |
138 } | |
139 this.element.classList.toggle("hidden", !total); | |
140 this.element.title = title; | |
141 }, | |
142 | |
143 /** | |
144 * @param {!Event} event | |
145 */ | |
146 _clicked: function(event) | |
147 { | |
148 this.dispatchEventToListeners("click"); | |
149 }, | |
150 | |
151 __proto__: WebInspector.StatusBarItem.prototype | |
152 } | |
153 | |
154 /** | |
155 * @constructor | |
156 * @extends {WebInspector.StatusBarItem} | |
82 * @param {string} text | 157 * @param {string} text |
83 * @param {string=} className | 158 * @param {string=} className |
84 */ | 159 */ |
85 WebInspector.StatusBarText = function(text, className) | 160 WebInspector.StatusBarText = function(text, className) |
86 { | 161 { |
87 WebInspector.StatusBarItem.call(this, "span"); | 162 WebInspector.StatusBarItem.call(this, "span"); |
88 this.element.className = "status-bar-item status-bar-text"; | 163 this.element.className = "status-bar-item status-bar-text"; |
89 if (className) | 164 if (className) |
90 this.element.classList.add(className); | 165 this.element.classList.add(className); |
91 this.element.textContent = text; | 166 this.element.textContent = text; |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
419 } | 494 } |
420 } | 495 } |
421 }, | 496 }, |
422 | 497 |
423 __proto__: WebInspector.StatusBarItem.prototype | 498 __proto__: WebInspector.StatusBarItem.prototype |
424 } | 499 } |
425 | 500 |
426 /** | 501 /** |
427 * @interface | 502 * @interface |
428 */ | 503 */ |
429 WebInspector.StatusBarButton.Provider = function() | 504 WebInspector.StatusBarItem.Provider = function() |
430 { | 505 { |
431 } | 506 } |
432 | 507 |
433 WebInspector.StatusBarButton.Provider.prototype = { | 508 WebInspector.StatusBarItem.Provider.prototype = { |
434 /** | 509 /** |
435 * @return {?WebInspector.StatusBarButton} | 510 * @return {?WebInspector.StatusBarItem} |
436 */ | 511 */ |
437 button: function() {} | 512 item: function() {} |
438 } | 513 } |
439 | 514 |
440 /** | 515 /** |
441 * @constructor | 516 * @constructor |
442 * @extends {WebInspector.StatusBarItem} | 517 * @extends {WebInspector.StatusBarItem} |
443 * @param {?function(!Event)} changeHandler | 518 * @param {?function(!Event)} changeHandler |
444 * @param {string=} className | 519 * @param {string=} className |
445 */ | 520 */ |
446 WebInspector.StatusBarComboBox = function(changeHandler, className) | 521 WebInspector.StatusBarComboBox = function(changeHandler, className) |
447 { | 522 { |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
669 var options = []; | 744 var options = []; |
670 for (var index = 0; index < this._states.length; index++) { | 745 for (var index = 0; index < this._states.length; index++) { |
671 if (this._states[index] !== this.state && this._states[index] !== th is._currentState) | 746 if (this._states[index] !== this.state && this._states[index] !== th is._currentState) |
672 options.push(this._buttons[index]); | 747 options.push(this._buttons[index]); |
673 } | 748 } |
674 return options; | 749 return options; |
675 }, | 750 }, |
676 | 751 |
677 __proto__: WebInspector.StatusBarButton.prototype | 752 __proto__: WebInspector.StatusBarButton.prototype |
678 } | 753 } |
OLD | NEW |