Upgrade to ExtJS 3.2.0 - Released 03/30/2010
[extjs.git] / examples / ux / FieldReplicator.js
index 0f2c67e..19fe4e9 100644 (file)
@@ -1,84 +1,84 @@
 /*!
- * Ext JS Library 3.1.1
- * Copyright(c) 2006-2010 Ext JS, LLC
+ * Ext JS Library 3.2.0
+ * Copyright(c) 2006-2010 Ext JS, Inc.
  * licensing@extjs.com
  * http://www.extjs.com/license
  */
-Ext.ns("Ext.ux");\r
-\r
-/**\r
- * @class Ext.ux.FieldReplicator\r
- * <p>A plugin for Field Components which creates clones of the Field for as\r
- * long as the user keeps filling them. Leaving the final one blank ends the repeating series.</p>\r
- * <p>Usage:</p>\r
- * <pre><code>\r
-    {\r
-        xtype: 'combo',\r
-        plugins: [ Ext.ux.FieldReplicator ],\r
-        triggerAction: 'all',\r
-        fieldLabel: 'Select recipient',\r
-        store: recipientStore\r
-    }\r
- * </code></pre>\r
- */\r
-Ext.ux.FieldReplicator = {\r
-    init: function(f) {\r
-        f.replicator = this;\r
-        f.enableKeyEvents = true;\r
-        f.on('change', this.onChange, this);\r
-        f.onKeyDown = f.onKeyDown.createInterceptor(this.onKeyDown);\r
-    },\r
-\r
-//  If tabbing out and the change event will be fired, flag that\r
-//  the change handler must focus the correct sibling Field.\r
-    onKeyDown: function(e) {\r
-        if ((e.getKey() == Ext.EventObject.TAB) && (String(this.startValue) !== String(this.getValue()))) {\r
-            if (e.shiftKey) {\r
-                this.focusPrev = true;\r
-            } else if (!e.shiftKey && !e.altKey) {\r
-                this.focusNext = true;\r
-            }\r
-        }\r
-    },\r
-\r
-//  Handle the field either being changed to blank or from blank.\r
-    onChange: function(f, n, o) {\r
-\r
-//             Ensure that "change" is only fired once.\r
-       f.startValue = n;\r
-\r
-        var c = f.ownerCt, l,\r
-            ps = f.previousSibling(),\r
-            ns = f.nextSibling();\r
-        if (Ext.isEmpty(n)) {\r
-            if (!Ext.isEmpty(o)) {\r
-//              The Field has been blanked, and it is not the only one left, remove it\r
-                if ((ps && (ps.replicator === this)) || (ns && (ns.replicator === this))) {\r
-                    l = f.findParentBy(function(p) {\r
-                        return !Ext.isDefined(p.ownerCt);\r
-                    });\r
-                    c.remove(f);\r
-                    l.doLayout();\r
-                }\r
-            }\r
-        } else {\r
-            if (Ext.isEmpty(o)) {\r
-//              Field filled, insert a clone as the next sibling\r
-                ns = new f.constructor(f.cloneConfig());\r
-                c.insert(c.items.indexOf(f) + 1, ns);\r
-                c.doLayout();\r
-                l = f.findParentBy(function(p) {\r
-                    return !Ext.isDefined(p.ownerCt);\r
-                });\r
-                l.doLayout();\r
-            }\r
-        }\r
-        if (f.focusPrev) {\r
-            delete f.focusPrev;\r
-            ps.focus(false, true);\r
-        } else  if (f.focusNext) {\r
-            delete f.focusNext;\r
-            ns.focus(false, true);\r
-        }\r
-    }\r
+Ext.ns("Ext.ux");
+
+/**
+ * @class Ext.ux.FieldReplicator
+ * <p>A plugin for Field Components which creates clones of the Field for as
+ * long as the user keeps filling them. Leaving the final one blank ends the repeating series.</p>
+ * <p>Usage:</p>
+ * <pre><code>
+    {
+        xtype: 'combo',
+        plugins: [ Ext.ux.FieldReplicator ],
+        triggerAction: 'all',
+        fieldLabel: 'Select recipient',
+        store: recipientStore
+    }
+ * </code></pre>
+ */
+Ext.ux.FieldReplicator = {
+    init: function(f) {
+        f.replicator = this;
+        f.enableKeyEvents = true;
+        f.on('change', this.onChange, this);
+        f.onKeyDown = f.onKeyDown.createInterceptor(this.onKeyDown);
+    },
+
+//  If tabbing out and the change event will be fired, flag that
+//  the change handler must focus the correct sibling Field.
+    onKeyDown: function(e) {
+        if ((e.getKey() == Ext.EventObject.TAB) && (String(this.startValue) !== String(this.getValue()))) {
+            if (e.shiftKey) {
+                this.focusPrev = true;
+            } else if (!e.shiftKey && !e.altKey) {
+                this.focusNext = true;
+            }
+        }
+    },
+
+//  Handle the field either being changed to blank or from blank.
+    onChange: function(f, n, o) {
+
+//             Ensure that "change" is only fired once.
+       f.startValue = n;
+
+        var c = f.ownerCt, l,
+            ps = f.previousSibling(),
+            ns = f.nextSibling();
+        if (Ext.isEmpty(n)) {
+            if (!Ext.isEmpty(o)) {
+//              The Field has been blanked, and it is not the only one left, remove it
+                if ((ps && (ps.replicator === this)) || (ns && (ns.replicator === this))) {
+                    l = f.findParentBy(function(p) {
+                        return !Ext.isDefined(p.ownerCt);
+                    });
+                    c.remove(f);
+                    l.doLayout();
+                }
+            }
+        } else {
+            if (Ext.isEmpty(o)) {
+//              Field filled, insert a clone as the next sibling
+                ns = new f.constructor(f.cloneConfig());
+                c.insert(c.items.indexOf(f) + 1, ns);
+                c.doLayout();
+                l = f.findParentBy(function(p) {
+                    return !Ext.isDefined(p.ownerCt);
+                });
+                l.doLayout();
+            }
+        }
+        if (f.focusPrev) {
+            delete f.focusPrev;
+            ps.focus(false, true);
+        } else  if (f.focusNext) {
+            delete f.focusNext;
+            ns.focus(false, true);
+        }
+    }
 };
\ No newline at end of file