Upgrade to ExtJS 3.0.0 - Released 07/06/2009
[extjs.git] / examples / ux / SpinnerField.js
diff --git a/examples/ux/SpinnerField.js b/examples/ux/SpinnerField.js
new file mode 100644 (file)
index 0000000..7711bed
--- /dev/null
@@ -0,0 +1,71 @@
+/*!
+ * Ext JS Library 3.0.0
+ * Copyright(c) 2006-2009 Ext JS, LLC
+ * licensing@extjs.com
+ * http://www.extjs.com/license
+ */
+Ext.ns('Ext.ux.form');\r
+\r
+/**\r
+ * @class Ext.ux.form.SpinnerField\r
+ * @extends Ext.form.NumberField\r
+ * Creates a field utilizing Ext.ux.Spinner\r
+ * @xtype spinnerfield\r
+ */\r
+Ext.ux.form.SpinnerField = Ext.extend(Ext.form.NumberField, {\r
+    deferHeight: true,\r
+    autoSize: Ext.emptyFn,\r
+    onBlur: Ext.emptyFn,\r
+    adjustSize: Ext.BoxComponent.prototype.adjustSize,\r
+\r
+       constructor: function(config) {\r
+               var spinnerConfig = Ext.copyTo({}, config, 'incrementValue,alternateIncrementValue,accelerate,defaultValue,triggerClass,splitterClass');\r
+\r
+               var spl = this.spinner = new Ext.ux.Spinner(spinnerConfig);\r
+\r
+               var plugins = config.plugins\r
+                       ? (Ext.isArray(config.plugins)\r
+                               ? config.plugins.push(spl)\r
+                               : [config.plugins, spl])\r
+                       : spl;\r
+\r
+               Ext.ux.form.SpinnerField.superclass.constructor.call(this, Ext.apply(config, {plugins: plugins}));\r
+       },\r
+\r
+    onShow: function(){\r
+        if (this.wrap) {\r
+            this.wrap.dom.style.display = '';\r
+            this.wrap.dom.style.visibility = 'visible';\r
+        }\r
+    },\r
+\r
+    onHide: function(){\r
+        this.wrap.dom.style.display = 'none';\r
+    },\r
+\r
+    // private\r
+    getResizeEl: function(){\r
+        return this.wrap;\r
+    },\r
+\r
+    // private\r
+    getPositionEl: function(){\r
+        return this.wrap;\r
+    },\r
+\r
+    // private\r
+    alignErrorIcon: function(){\r
+        if (this.wrap) {\r
+            this.errorIcon.alignTo(this.wrap, 'tl-tr', [2, 0]);\r
+        }\r
+    },\r
+\r
+    validateBlur: function(){\r
+        return true;\r
+    }\r
+});\r
+\r
+Ext.reg('spinnerfield', Ext.ux.form.SpinnerField);\r
+\r
+//backwards compat\r
+Ext.form.SpinnerField = Ext.ux.form.SpinnerField;\r