X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/6a7e4474cba9d8be4b2ec445e10f1691f7277c50..b37ceabb82336ee82757cd32efe353cfab8ec267:/pkgs/pkg-forms-debug.js diff --git a/pkgs/pkg-forms-debug.js b/pkgs/pkg-forms-debug.js index eb8d2857..2a315621 100644 --- a/pkgs/pkg-forms-debug.js +++ b/pkgs/pkg-forms-debug.js @@ -1,5 +1,5 @@ /*! - * Ext JS Library 3.2.0 + * Ext JS Library 3.2.2 * Copyright(c) 2006-2010 Ext JS, Inc. * licensing@extjs.com * http://www.extjs.com/license @@ -1184,13 +1184,22 @@ var myField = new Ext.form.NumberField({ value = value || this.processValue(this.getRawValue()); - if(Ext.isFunction(this.validator)){ + if (Ext.isFunction(this.validator)) { var msg = this.validator(value); if (msg !== true) { errors.push(msg); } } + if (value.length < 1 || value === this.emptyText) { + if (this.allowBlank) { + //if value is blank and allowBlank is true, there cannot be any additional errors + return errors; + } else { + errors.push(this.blankText); + } + } + if (!this.allowBlank && (value.length < 1 || value === this.emptyText)) { // if it's blank errors.push(this.blankText); } @@ -1598,10 +1607,25 @@ Ext.form.TwinTriggerField = Ext.extend(Ext.form.TriggerField, { getTrigger : function(index){ return this.triggers[index]; }, + + afterRender: function(){ + Ext.form.TwinTriggerField.superclass.afterRender.call(this); + var triggers = this.triggers, + i = 0, + len = triggers.length; + + for(; i < len; ++i){ + if(this['hideTrigger' + (i + 1)]){ + triggers[i].hide(); + } + + } + }, initTrigger : function(){ - var ts = this.trigger.select('.x-form-trigger', true); - var triggerField = this; + var ts = this.trigger.select('.x-form-trigger', true), + triggerField = this; + ts.each(function(t, all, index){ var triggerIndex = 'Trigger'+(index+1); t.hide = function(){ @@ -1616,11 +1640,6 @@ Ext.form.TwinTriggerField = Ext.extend(Ext.form.TriggerField, { triggerField.el.setWidth(w-triggerField.trigger.getWidth()); this['hidden' + triggerIndex] = false; }; - - if(this['hide'+triggerIndex]){ - t.dom.style.display = 'none'; - this['hidden' + triggerIndex] = true; - } this.mon(t, 'click', this['on'+triggerIndex+'Click'], this, {preventDefault:true}); t.addClassOnOver('x-form-trigger-over'); t.addClassOnClick('x-form-trigger-click'); @@ -1888,6 +1907,7 @@ Ext.form.NumberField = Ext.extend(Ext.form.TextField, { }, setValue : function(v){ + v = this.fixPrecision(v); v = Ext.isNumber(v) ? v : parseFloat(String(v).replace(this.decimalSeparator, ".")); v = isNaN(v) ? '' : String(v).replace(".", this.decimalSeparator); return Ext.form.NumberField.superclass.setValue.call(this, v); @@ -1927,7 +1947,7 @@ Ext.form.NumberField = Ext.extend(Ext.form.TextField, { beforeBlur : function(){ var v = this.parseValue(this.getRawValue()); if(!Ext.isEmpty(v)){ - this.setValue(this.fixPrecision(v)); + this.setValue(v); } } }); @@ -2058,7 +2078,7 @@ disabledDates: ["^03"] } else { // set time to 12 noon, then clear the time var parsedDate = Date.parseDate(value + ' ' + this.initTime, format + ' ' + this.initTimeFormat); - + if (parsedDate) return parsedDate.clearTime(); } }, @@ -2161,7 +2181,7 @@ disabledDates: ["^03"] this.menu.picker.setMaxDate(this.maxValue); } }, - + /** * Runs all of NumberFields validations and returns an array of any errors. Note that this first * runs TextField's validations, so the returned array is an amalgamation of all field errors. @@ -2173,32 +2193,32 @@ disabledDates: ["^03"] */ getErrors: function(value) { var errors = Ext.form.DateField.superclass.getErrors.apply(this, arguments); - + value = this.formatDate(value || this.processValue(this.getRawValue())); - + if (value.length < 1) { // if it's blank and textfield didn't flag it then it's valid return errors; } - + var svalue = value; value = this.parseDate(value); if (!value) { errors.push(String.format(this.invalidText, svalue, this.format)); return errors; } - + var time = value.getTime(); - if (this.minValue && time < this.minValue.getTime()) { + if (this.minValue && time < this.minValue.clearTime().getTime()) { errors.push(String.format(this.minText, this.formatDate(this.minValue))); } - - if (this.maxValue && time > this.maxValue.getTime()) { + + if (this.maxValue && time > this.maxValue.clearTime().getTime()) { errors.push(String.format(this.maxText, this.formatDate(this.maxValue))); } - + if (this.disabledDays) { var day = value.getDay(); - + for(var i = 0; i < this.disabledDays.length; i++) { if (day === this.disabledDays[i]) { errors.push(this.disabledDaysText); @@ -2206,12 +2226,12 @@ disabledDates: ["^03"] } } } - + var fvalue = this.formatDate(value); if (this.disabledDatesRE && this.disabledDatesRE.test(fvalue)) { errors.push(String.format(this.disabledDatesText, fvalue)); } - + return errors; }, @@ -2360,7 +2380,8 @@ dateField.setValue('2006-05-04'); * @method autoSize */ }); -Ext.reg('datefield', Ext.form.DateField);/** +Ext.reg('datefield', Ext.form.DateField); +/** * @class Ext.form.DisplayField * @extends Ext.form.Field * A display-only text field which is not validated and not submitted. @@ -2972,24 +2993,28 @@ var combo = new Ext.form.ComboBox({ } return zindex; }, + + getZIndex : function(listParent){ + listParent = listParent || Ext.getDom(this.getListParent() || Ext.getBody()); + var zindex = parseInt(Ext.fly(listParent).getStyle('z-index'), 10); + if(!zindex){ + zindex = this.getParentZIndex(); + } + return (zindex || 12000) + 5; + }, // private initList : function(){ if(!this.list){ var cls = 'x-combo-list', - listParent = Ext.getDom(this.getListParent() || Ext.getBody()), - zindex = parseInt(Ext.fly(listParent).getStyle('z-index'), 10); - - if (!zindex) { - zindex = this.getParentZIndex(); - } + listParent = Ext.getDom(this.getListParent() || Ext.getBody()); this.list = new Ext.Layer({ parentEl: listParent, shadow: this.shadow, cls: [cls, this.listClass].join(' '), constrain:false, - zindex: (zindex || 12000) + 5 + zindex: this.getZIndex(listParent) }); var lw = this.listWidth || Math.max(this.wrap.getWidth(), this.minListWidth); @@ -3191,7 +3216,23 @@ var menu = new Ext.menu.Menu({ initEvents : function(){ Ext.form.ComboBox.superclass.initEvents.call(this); - + /** + * @property keyNav + * @type Ext.KeyNav + *

A {@link Ext.KeyNav KeyNav} object which handles navigation keys for this ComboBox. This performs actions + * based on keystrokes typed when the input field is focused.

+ *

After the ComboBox has been rendered, you may override existing navigation key functionality, + * or add your own based upon key names as specified in the {@link Ext.KeyNav KeyNav} class.

+ *

The function is executed in the scope (this reference of the ComboBox. Example:


+myCombo.keyNav.esc = function(e) {  // Override ESC handling function
+    this.collapse();                // Standard behaviour of Ext's ComboBox.
+    this.setValue(this.startValue); // We reset to starting value on ESC
+};
+myCombo.keyNav.tab = function() {   // Override TAB handling function
+    this.onViewClick(false);        // Select the currently highlighted row
+};
+
+ */ this.keyNav = new Ext.KeyNav(this.el, { "up" : function(e){ this.inKeyMode = true; @@ -3730,14 +3771,7 @@ var menu = new Ext.menu.Menu({ this.list.alignTo.apply(this.list, [this.el].concat(this.listAlign)); // zindex can change, re-check it and set it if necessary - var listParent = Ext.getDom(this.getListParent() || Ext.getBody()), - zindex = parseInt(Ext.fly(listParent).getStyle('z-index') ,10); - if (!zindex){ - zindex = this.getParentZIndex(); - } - if (zindex) { - this.list.setZIndex(zindex + 5); - } + this.list.setZIndex(this.getZIndex()); this.list.show(); if(Ext.isGecko2){ this.innerList.setOverflow('auto'); // necessary for FF 2.0/Mac @@ -3904,7 +3938,7 @@ Ext.form.Checkbox = Ext.extend(Ext.form.Field, { this.checked = this.el.dom.checked; } // Need to repaint for IE, otherwise positioning is broken - if(Ext.isIE){ + if (Ext.isIE && !Ext.isStrict) { this.wrap.repaint(); } this.resizeEl = this.positionEl = this.wrap; @@ -4518,6 +4552,11 @@ Ext.form.CompositeField = Ext.extend(Ext.form.Field, { * True to combine errors from the individual fields into a single error message at the CompositeField level (defaults to true) */ combineErrors: true, + + /** + * @cfg {String} labelConnector The string to use when joining segments of the built label together (defaults to ', ') + */ + labelConnector: ', ', //inherit docs //Builds the composite field label @@ -4760,7 +4799,7 @@ Ext.form.CompositeField = Ext.extend(Ext.form.Field, { * @return {String} The built label */ buildLabel: function(segments) { - return segments.join(", "); + return Ext.clean(segments).join(this.labelConnector); }, /** @@ -5644,7 +5683,7 @@ myFormPanel.getForm().submit({ if (f.dataIndex == id || f.id == id || f.getName() == id) { field = f; return false; - } else if (f.isComposite) { + } else if (f.isComposite && f.rendered) { return f.items.each(findMatchingField); } } @@ -5820,6 +5859,13 @@ myFormPanel.getForm().submit({ return this; }, + /** + * Removes all fields from the collection that have been destroyed. + */ + cleanDestroyed : function() { + this.items.filterBy(function(o) { return !!o.isDestroyed; }).each(this.remove, this); + }, + /** * Iterates through the {@link Ext.form.Field Field}s which have been {@link #add add}ed to this BasicForm, * checks them for an id attribute, and calls {@link Ext.form.Field#applyToMarkup} on the existing dom element with that id. @@ -6137,6 +6183,9 @@ Ext.FormPanel = Ext.extend(Ext.Panel, { // If a Container, its already destroyed by the time it gets here. Remove any references to destroyed fields. }else if (c.findBy){ Ext.each(c.findBy(this.isField), this.form.remove, this.form); + if (c.isDestroyed) { + this.form.cleanDestroyed(); + } } } }, @@ -6217,7 +6266,8 @@ Ext.FormPanel = Ext.extend(Ext.Panel, { }); Ext.reg('form', Ext.FormPanel); -Ext.form.FormPanel = Ext.FormPanel;/** +Ext.form.FormPanel = Ext.FormPanel; +/** * @class Ext.form.FieldSet * @extends Ext.Panel * Standard container used for grouping items within a {@link Ext.form.FormPanel form}. @@ -6881,7 +6931,11 @@ Ext.form.HtmlEditor = Ext.extend(Ext.form.Field, { Ext.form.HtmlEditor.superclass.setReadOnly.call(this, readOnly); if(this.initialized){ - this.setDesignMode(!readOnly); + if(Ext.isIE){ + this.getEditorBody().contentEditable = !readOnly; + }else{ + this.setDesignMode(!readOnly); + } var bd = this.getEditorBody(); if(bd){ bd.style.cursor = this.readOnly ? 'default' : 'text'; @@ -7060,22 +7114,24 @@ Ext.form.HtmlEditor = Ext.extend(Ext.form.Field, { * @param {Boolean} sourceEdit (optional) True for source edit, false for standard */ toggleSourceEdit : function(sourceEditMode){ - var iframeHeight, elHeight; - if(sourceEditMode === undefined){ + var iframeHeight, + elHeight; + + if (sourceEditMode === undefined) { sourceEditMode = !this.sourceEditMode; } this.sourceEditMode = sourceEditMode === true; var btn = this.tb.getComponent('sourceedit'); - if(btn.pressed !== this.sourceEditMode){ + if (btn.pressed !== this.sourceEditMode) { btn.toggle(this.sourceEditMode); - if(!btn.xtbHidden){ + if (!btn.xtbHidden) { return; } } - if(this.sourceEditMode){ + if (this.sourceEditMode) { // grab the height of the containing panel before we hide the iframe - ls = this.getSize(); + this.previousSize = this.getSize(); iframeHeight = Ext.get(this.iframe).getHeight(); @@ -7086,9 +7142,10 @@ Ext.form.HtmlEditor = Ext.extend(Ext.form.Field, { this.el.dom.removeAttribute('tabIndex'); this.el.focus(); this.el.dom.style.height = iframeHeight + 'px'; - }else{ + } + else { elHeight = parseInt(this.el.dom.style.height, 10); - if(this.initialized){ + if (this.initialized) { this.disableItems(this.readOnly); } this.pushValue(); @@ -7097,14 +7154,15 @@ Ext.form.HtmlEditor = Ext.extend(Ext.form.Field, { this.el.dom.setAttribute('tabIndex', -1); this.deferFocus(); - this.setSize(ls); + this.setSize(this.previousSize); + delete this.previousSize; this.iframe.style.height = elHeight + 'px'; } this.fireEvent('editmodechange', this, this.sourceEditMode); }, // private used internally - createLink : function(){ + createLink : function() { var url = prompt(this.createLinkText, this.defaultLinkValue); if(url && url != 'http:/'+'/'){ this.relayCmd('createlink', url); @@ -7202,9 +7260,8 @@ Ext.form.HtmlEditor = Ext.extend(Ext.form.Field, { if(Ext.isGecko){ // Gecko hack, see: https://bugzilla.mozilla.org/show_bug.cgi?id=232791#c8 this.setDesignMode(false); //toggle off first - + this.setDesignMode(true); } - this.setDesignMode(true); this.fireEvent('push', this, v); } @@ -7759,7 +7816,8 @@ Ext.form.HtmlEditor = Ext.extend(Ext.form.Field, { * @hide */ }); -Ext.reg('htmleditor', Ext.form.HtmlEditor);/** +Ext.reg('htmleditor', Ext.form.HtmlEditor); +/** * @class Ext.form.TimeField * @extends Ext.form.ComboBox * Provides a time input field with a time dropdown and automatic time validation. Example usage: @@ -8001,6 +8059,7 @@ Ext.form.SliderField = Ext.extend(Ext.form.Field, { }; Ext.form.SliderField.superclass.onRender.call(this, ct, position); this.wrap = this.el.wrap({cls: 'x-form-field-wrap'}); + this.resizeEl = this.positionEl = this.wrap; this.slider.render(this.wrap); }, @@ -8960,7 +9019,7 @@ Ext.apply(Ext.form.VTypes, { timeMask: /[\d\s:amp]/i }); * - * Another example: + * Another example: *

 // custom Vtype for vtype:'IPAddress'
 Ext.apply(Ext.form.VTypes, {
@@ -8986,7 +9045,7 @@ Ext.form.VTypes = function(){
          * The function used to validate email addresses.  Note that this is a very basic validation -- complete
          * validation per the email RFC specifications is very complex and beyond the scope of this class, although
          * this function can be overridden if a more comprehensive validation scheme is desired.  See the validation
-         * section of the Wikipedia article on email addresses 
+         * section of the Wikipedia article on email addresses
          * for additional information.  This implementation is intended to validate the following emails:
          * 'barney@example.de', 'barney.rubble@example.com', 'barney-rubble@example.coop', 'barney+rubble@example.com'
          * .
@@ -9003,12 +9062,12 @@ Ext.form.VTypes = function(){
          */
         'emailText' : 'This field should be an e-mail address in the format "user@example.com"',
         /**
-         * The keystroke filter mask to be applied on email input.  See the {@link #email} method for 
+         * The keystroke filter mask to be applied on email input.  See the {@link #email} method for
          * information about more complex email validation. Defaults to:
          * /[a-z0-9_\.\-@]/i
          * @type RegExp
          */
-        'emailMask' : /[a-z0-9_\.\-@]/i,
+        'emailMask' : /[a-z0-9_\.\-@\+]/i,
 
         /**
          * The function used to validate URLs
@@ -9024,7 +9083,7 @@ Ext.form.VTypes = function(){
          * @type String
          */
         'urlText' : 'This field should be a URL in the format "http:/'+'/www.example.com"',
-        
+
         /**
          * The function used to validate alpha values
          * @param {String} value The value
@@ -9067,4 +9126,4 @@ Ext.form.VTypes = function(){
          */
         'alphanumMask' : /[a-z0-9_]/i
     };
-}();
\ No newline at end of file
+}();