Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / devtools / front_end / StatusBarButton.js
index fa0676f..35675dd 100644 (file)
 /**
  * @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 = {
@@ -59,6 +60,19 @@ 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
 }
 
@@ -70,7 +84,7 @@ WebInspector.StatusBarItem.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);
@@ -89,6 +103,39 @@ WebInspector.StatusBarText.prototype = {
     __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
@@ -99,7 +146,7 @@ WebInspector.StatusBarText.prototype = {
  */
 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);
 
@@ -122,7 +169,6 @@ WebInspector.StatusBarButton = function(title, className, states)
 
     this.title = title;
     this.className = className;
-    this._visible = true;
 }
 
 WebInspector.StatusBarButton.prototype = {
@@ -202,20 +248,6 @@ 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);
@@ -398,7 +430,7 @@ WebInspector.StatusBarButton.prototype = {
  */
 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");
@@ -516,7 +548,7 @@ WebInspector.StatusBarComboBox.prototype = {
  */
 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";