| Index: Source/devtools/front_end/ui/StatusBarButton.js
|
| diff --git a/Source/devtools/front_end/ui/StatusBarButton.js b/Source/devtools/front_end/ui/StatusBarButton.js
|
| index c2b092e2113bc656f9c46eab3bf5340a2868ef84..df8d69b9aeb2245042a695b6ee4e32a22bd5605e 100644
|
| --- a/Source/devtools/front_end/ui/StatusBarButton.js
|
| +++ b/Source/devtools/front_end/ui/StatusBarButton.js
|
| @@ -79,6 +79,84 @@ WebInspector.StatusBarItem.prototype = {
|
| /**
|
| * @constructor
|
| * @extends {WebInspector.StatusBarItem}
|
| + * @param {!Array.<string>} counters
|
| + * @param {string=} className
|
| + */
|
| +WebInspector.StatusBarCounter = function(counters, className)
|
| +{
|
| + WebInspector.StatusBarItem.call(this, "div");
|
| + this.element.className = "status-bar-item status-bar-counter hidden";
|
| + if (className)
|
| + this.element.classList.add(className);
|
| + this.element.addEventListener("click", this._clicked.bind(this), false);
|
| + /** @type {!Array.<!{element: !Element, counter: string, value: number, title: string}>} */
|
| + this._counters = [];
|
| + for (var i = 0; i < counters.length; ++i) {
|
| + var element = this.element.createChild("span", "status-bar-counter-item");
|
| + element.createChild("div", counters[i]);
|
| + element.createChild("span");
|
| + this._counters.push({counter: counters[i], element: element, value: 0, title: ""});
|
| + }
|
| + this._update();
|
| +}
|
| +
|
| +WebInspector.StatusBarCounter.prototype = {
|
| + /**
|
| + * @param {string} counter
|
| + * @param {number} value
|
| + * @param {string} title
|
| + */
|
| + setCounter: function(counter, value, title)
|
| + {
|
| + for (var i = 0; i < this._counters.length; ++i) {
|
| + if (this._counters[i].counter === counter) {
|
| + this._counters[i].value = value;
|
| + this._counters[i].title = title;
|
| + this._update();
|
| + return;
|
| + }
|
| + }
|
| + },
|
| +
|
| + _update: function()
|
| + {
|
| + var total = 0;
|
| + var title = "";
|
| + for (var i = 0; i < this._counters.length; ++i) {
|
| + var counter = this._counters[i];
|
| + var value = counter.value;
|
| + if (!counter.value) {
|
| + counter.element.classList.add("hidden");
|
| + continue;
|
| + }
|
| + counter.element.classList.remove("hidden");
|
| + counter.element.classList.toggle("status-bar-counter-item-first", !total);
|
| + counter.element.querySelector("span").textContent = value;
|
| + total += value;
|
| + if (counter.title) {
|
| + if (title)
|
| + title += ", ";
|
| + title += counter.title;
|
| + }
|
| + }
|
| + this.element.classList.toggle("hidden", !total);
|
| + this.element.title = title;
|
| + },
|
| +
|
| + /**
|
| + * @param {!Event} event
|
| + */
|
| + _clicked: function(event)
|
| + {
|
| + this.dispatchEventToListeners("click");
|
| + },
|
| +
|
| + __proto__: WebInspector.StatusBarItem.prototype
|
| +}
|
| +
|
| +/**
|
| + * @constructor
|
| + * @extends {WebInspector.StatusBarItem}
|
| * @param {string} text
|
| * @param {string=} className
|
| */
|
| @@ -426,15 +504,15 @@ WebInspector.StatusBarButton.prototype = {
|
| /**
|
| * @interface
|
| */
|
| -WebInspector.StatusBarButton.Provider = function()
|
| +WebInspector.StatusBarItem.Provider = function()
|
| {
|
| }
|
|
|
| -WebInspector.StatusBarButton.Provider.prototype = {
|
| +WebInspector.StatusBarItem.Provider.prototype = {
|
| /**
|
| - * @return {?WebInspector.StatusBarButton}
|
| + * @return {?WebInspector.StatusBarItem}
|
| */
|
| - button: function() {}
|
| + item: function() {}
|
| }
|
|
|
| /**
|
|
|