/**
* @constructor
* @extends {WebInspector.Object}
- * @param {!Element} element
+ * @param {string} elementType
*/
-WebInspector.StatusBarItem = function(element)
+WebInspector.StatusBarItem = function(elementType)
{
- this.element = element;
+ this.element = document.createElement(elementType);
this._enabled = true;
+ this._visible = true;
}
WebInspector.StatusBarItem.prototype = {
this.element.disabled = !this._enabled;
},
+ get visible()
+ {
+ return this._visible;
+ },
+
+ set visible(x)
+ {
+ if (this._visible === x)
+ return;
+ this.element.enableStyleClass("hidden", !x);
+ this._visible = x;
+ },
+
__proto__: WebInspector.Object.prototype
}
*/
WebInspector.StatusBarText = function(text, className)
{
- WebInspector.StatusBarItem.call(this, document.createElement("span"));
+ WebInspector.StatusBarItem.call(this, "span");
this.element.className = "status-bar-item status-bar-text";
if (className)
this.element.classList.add(className);
__proto__: WebInspector.StatusBarItem.prototype
}
+/**
+ * @constructor
+ * @extends {WebInspector.StatusBarItem}
+ * @param {string=} placeholder
+ * @param {number=} width
+ */
+WebInspector.StatusBarInput = function(placeholder, width)
+{
+ WebInspector.StatusBarItem.call(this, "input");
+ this.element.className = "status-bar-item";
+ this.element.addEventListener("input", this._onChangeCallback.bind(this), false);
+ if (width)
+ this.element.style.width = width + "px";
+ if (placeholder)
+ this.element.setAttribute("placeholder", placeholder);
+}
+
+WebInspector.StatusBarInput.prototype = {
+ /**
+ * @param {?function(string)} handler
+ */
+ setOnChangeHandler: function(handler)
+ {
+ this._onChangeHandler = handler;
+ },
+
+ _onChangeCallback: function()
+ {
+ this._onChangeHandler && this._onChangeHandler(this.element.value);
+ },
+
+ __proto__: WebInspector.StatusBarItem.prototype
+}
/**
* @constructor
*/
WebInspector.StatusBarButton = function(title, className, states)
{
- WebInspector.StatusBarItem.call(this, document.createElement("button"));
+ WebInspector.StatusBarItem.call(this, "button");
this.element.className = className + " status-bar-item";
this.element.addEventListener("click", this._clicked.bind(this), false);
this.title = title;
this.className = className;
- this._visible = true;
}
WebInspector.StatusBarButton.prototype = {
this.state = x;
},
- get visible()
- {
- return this._visible;
- },
-
- set visible(x)
- {
- if (this._visible === x)
- return;
-
- this.element.enableStyleClass("hidden", !x);
- this._visible = x;
- },
-
makeLongClickEnabled: function()
{
var boundMouseDown = mouseDown.bind(this);
*/
WebInspector.StatusBarComboBox = function(changeHandler, className)
{
- WebInspector.StatusBarItem.call(this, document.createElement("span"));
+ WebInspector.StatusBarItem.call(this, "span");
this.element.className = "status-bar-select-container";
this._selectElement = this.element.createChild("select", "status-bar-item");
*/
WebInspector.StatusBarCheckbox = function(title)
{
- WebInspector.StatusBarItem.call(this, document.createElement("label"));
+ WebInspector.StatusBarItem.call(this, "label");
this.element.classList.add("status-bar-item", "checkbox");
this._checkbox = this.element.createChild("input");
this._checkbox.type = "checkbox";