Issue #23853: Stable check-in of widget refactor
[xtuple] / lib / enyo-x / source / widgets / toggle_button.js
index e094c27..d266be3 100644 (file)
@@ -5,15 +5,17 @@ regexp:true, undef:true, trailing:true, white:true */
 (function () {
 
   /**
-    @name XV.ToggleButton
-    @class A control that looks like a switch with labels for two states.<br />
-    Derived from <a href="http://enyojs.com/api/#onyx.ToggleButton">onyx.ToggleButton</a>.
-    @extends onyx.ToggleButton
+    @name XV.ToggleButtonWidget
+    @class An input control consisting of fittable columns:
+     label, decorator, and toggle button.<br />
+    Use to implement a toggle button, a switch with labels for two states.<br />
+    Creates an HTML input element.
+    @extends XV.Input
    */
-  enyo.kind(
-    /** @lends XV.ToggleButton# */{
-    name: "XV.ToggleButton",
-    kind: "onyx.ToggleButton",
+  enyo.kind({
+    name: "XV.ToggleButtonWidget",
+    kind: "XV.InputWidget",
+    classes: "xv-inputwidget xv-checkboxwidget",
     published: {
       attr: null
     },
@@ -23,12 +25,15 @@ regexp:true, undef:true, trailing:true, white:true */
     handlers: {
       onChange: "changed"
     },
-    /**
-     @todo Document the clear method.
-     */
-    clear: function (options) {
-      this.setValue(false, options);
-    },
+    components: [
+      {kind: "FittableColumns", components: [
+        {name: "label", content: "", classes: "xv-label"},
+        {kind: "onyx.InputDecorator", classes: "xv-input-decorator",
+          components: [
+          {name: "input", kind: "onyx.ToggleButton", onChange: "inputChanged"}
+        ]}
+      ]}
+    ],
     /**
      @todo Document the setValue method.
      */
@@ -46,33 +51,7 @@ regexp:true, undef:true, trailing:true, white:true */
         inEvent.value = this.getValue();
         this.doValueChange(inEvent);
       }
-    }
-  });
-
-  /**
-    @name XV.ToggleButtonWidget
-    @class An input control consisting of fittable columns:
-     label, decorator, and toggle button.<br />
-    Use to implement a toggle button, a switch with labels for two states.<br />
-    Creates an HTML input element.
-    @extends XV.Input
-   */
-  enyo.kind(/** @lends XV.ToggleButtonWidget# */{
-    name: "XV.ToggleButtonWidget",
-    kind: "XV.Input",
-    classes: "xv-inputwidget xv-checkboxwidget",
-    published: {
-      label: ""
     },
-    components: [
-      {kind: "FittableColumns", components: [
-        {name: "label", content: "", classes: "xv-label"},
-        {kind: "onyx.InputDecorator", classes: "xv-input-decorator",
-          components: [
-          {name: "input", kind: "onyx.ToggleButton", onChange: "inputChanged"}
-        ]}
-      ]}
-    ],
     /**
      @todo Document the clear method.
      */
@@ -89,10 +68,6 @@ regexp:true, undef:true, trailing:true, white:true */
       var options = {silent: true};
       this.valueChanged(this.getValue(), options);
     },
-    disabledChanged: function () {
-      this.inherited(arguments);
-      this.$.label.addRemoveClass("disabled", this.getDisabled());
-    },
     /**
      @todo Document the inputChanged method.
      */
@@ -100,20 +75,6 @@ regexp:true, undef:true, trailing:true, white:true */
       var input = this.$.input.getValue();
       this.setValue(input);
     },
-    /**
-     @todo Document the labelChanged method.
-     */
-    labelChanged: function () {
-      var label = (this.getLabel() || ("_" + this.attr || "").loc()) + ":";
-      this.$.label.setContent(label);
-    },
-    /**
-      Not applicable in the context of a toggle button,
-      even though it is available to input widgets generally.
-     */
-    placeholderChanged: function () {
-      // Not applicable
-    },
     /**
      @todo Document the valueChanged method.
      */