ext-all-debug.js
资源名称:ext-3.1.0.zip [点击查看]
上传用户:dawnssy
上传日期:2022-08-06
资源大小:9345k
文件大小:1167k
源码类别:
JavaScript
开发平台:
JavaScript
- this.focus();
- }
- },
- autoSize : function(){
- if(!this.grow || !this.rendered){
- return;
- }
- if(!this.metrics){
- this.metrics = Ext.util.TextMetrics.createInstance(this.el);
- }
- var el = this.el;
- var v = el.dom.value;
- var d = document.createElement('div');
- d.appendChild(document.createTextNode(v));
- v = d.innerHTML;
- Ext.removeNode(d);
- d = null;
- v += ' ';
- var w = Math.min(this.growMax, Math.max(this.metrics.getWidth(v) + 10, this.growMin));
- this.el.setWidth(w);
- this.fireEvent('autosize', this, w);
- },
- onDestroy: function(){
- if(this.validationTask){
- this.validationTask.cancel();
- this.validationTask = null;
- }
- Ext.form.TextField.superclass.onDestroy.call(this);
- }
- });
- Ext.reg('textfield', Ext.form.TextField);
- Ext.form.TriggerField = Ext.extend(Ext.form.TextField, {
- defaultAutoCreate : {tag: "input", type: "text", size: "16", autocomplete: "off"},
- hideTrigger:false,
- editable: true,
- readOnly: false,
- wrapFocusClass: 'x-trigger-wrap-focus',
- autoSize: Ext.emptyFn,
- monitorTab : true,
- deferHeight : true,
- mimicing : false,
- actionMode: 'wrap',
- removeMode: 'container',
- defaultTriggerWidth: 17,
- onResize : function(w, h){
- Ext.form.TriggerField.superclass.onResize.call(this, w, h);
- var tw = this.getTriggerWidth();
- if(Ext.isNumber(w)){
- this.el.setWidth(w - tw);
- }
- this.wrap.setWidth(this.el.getWidth() + tw);
- },
- getTriggerWidth: function(){
- var tw = this.trigger.getWidth();
- if(!this.hideTrigger && tw === 0){
- tw = this.defaultTriggerWidth;
- }
- return tw;
- },
- alignErrorIcon : function(){
- if(this.wrap){
- this.errorIcon.alignTo(this.wrap, 'tl-tr', [2, 0]);
- }
- },
- onRender : function(ct, position){
- this.doc = Ext.isIE ? Ext.getBody() : Ext.getDoc();
- Ext.form.TriggerField.superclass.onRender.call(this, ct, position);
- this.wrap = this.el.wrap({cls: 'x-form-field-wrap x-form-field-trigger-wrap'});
- this.trigger = this.wrap.createChild(this.triggerConfig ||
- {tag: "img", src: Ext.BLANK_IMAGE_URL, cls: "x-form-trigger " + this.triggerClass});
- this.initTrigger();
- if(!this.width){
- this.wrap.setWidth(this.el.getWidth()+this.trigger.getWidth());
- }
- this.resizeEl = this.positionEl = this.wrap;
- this.updateEditState();
- },
- updateEditState: function(){
- if(this.rendered){
- if (this.readOnly) {
- this.el.dom.readOnly = true;
- this.el.addClass('x-trigger-noedit');
- this.mun(this.el, 'click', this.onTriggerClick, this);
- this.trigger.setDisplayed(false);
- } else {
- if (!this.editable) {
- this.el.dom.readOnly = true;
- this.el.addClass('x-trigger-noedit');
- this.mon(this.el, 'click', this.onTriggerClick, this);
- } else {
- this.el.dom.readOnly = false;
- this.el.removeClass('x-trigger-noedit');
- this.mun(this.el, 'click', this.onTriggerClick, this);
- }
- this.trigger.setDisplayed(!this.hideTrigger);
- }
- this.onResize(this.width || this.wrap.getWidth());
- }
- },
- setHideTrigger: function(hideTrigger){
- if(hideTrigger != this.hideTrigger){
- this.hideTrigger = hideTrigger;
- this.updateEditState();
- }
- },
- setEditable: function(editable){
- if(editable != this.editable){
- this.editable = editable;
- this.updateEditState();
- }
- },
- setReadOnly: function(readOnly){
- if(readOnly != this.readOnly){
- this.readOnly = readOnly;
- this.updateEditState();
- }
- },
- afterRender : function(){
- Ext.form.TriggerField.superclass.afterRender.call(this);
- },
- initTrigger : function(){
- this.mon(this.trigger, 'click', this.onTriggerClick, this, {preventDefault:true});
- this.trigger.addClassOnOver('x-form-trigger-over');
- this.trigger.addClassOnClick('x-form-trigger-click');
- },
- onDestroy : function(){
- Ext.destroy(this.trigger, this.wrap);
- if (this.mimicing){
- this.doc.un('mousedown', this.mimicBlur, this);
- }
- delete this.doc;
- Ext.form.TriggerField.superclass.onDestroy.call(this);
- },
- onFocus : function(){
- Ext.form.TriggerField.superclass.onFocus.call(this);
- if(!this.mimicing){
- this.wrap.addClass(this.wrapFocusClass);
- this.mimicing = true;
- this.doc.on('mousedown', this.mimicBlur, this, {delay: 10});
- if(this.monitorTab){
- this.on('specialkey', this.checkTab, this);
- }
- }
- },
- checkTab : function(me, e){
- if(e.getKey() == e.TAB){
- this.triggerBlur();
- }
- },
- onBlur : Ext.emptyFn,
- mimicBlur : function(e){
- if(!this.isDestroyed && !this.wrap.contains(e.target) && this.validateBlur(e)){
- this.triggerBlur();
- }
- },
- triggerBlur : function(){
- this.mimicing = false;
- this.doc.un('mousedown', this.mimicBlur, this);
- if(this.monitorTab && this.el){
- this.un('specialkey', this.checkTab, this);
- }
- Ext.form.TriggerField.superclass.onBlur.call(this);
- if(this.wrap){
- this.wrap.removeClass(this.wrapFocusClass);
- }
- },
- beforeBlur : Ext.emptyFn,
- validateBlur : function(e){
- return true;
- },
- onTriggerClick : Ext.emptyFn
- });
- Ext.form.TwinTriggerField = Ext.extend(Ext.form.TriggerField, {
- initComponent : function(){
- Ext.form.TwinTriggerField.superclass.initComponent.call(this);
- this.triggerConfig = {
- tag:'span', cls:'x-form-twin-triggers', cn:[
- {tag: "img", src: Ext.BLANK_IMAGE_URL, cls: "x-form-trigger " + this.trigger1Class},
- {tag: "img", src: Ext.BLANK_IMAGE_URL, cls: "x-form-trigger " + this.trigger2Class}
- ]};
- },
- getTrigger : function(index){
- return this.triggers[index];
- },
- initTrigger : function(){
- var ts = this.trigger.select('.x-form-trigger', true);
- var triggerField = this;
- ts.each(function(t, all, index){
- var triggerIndex = 'Trigger'+(index+1);
- t.hide = function(){
- var w = triggerField.wrap.getWidth();
- this.dom.style.display = 'none';
- triggerField.el.setWidth(w-triggerField.trigger.getWidth());
- this['hidden' + triggerIndex] = true;
- };
- t.show = function(){
- var w = triggerField.wrap.getWidth();
- this.dom.style.display = '';
- 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');
- }, this);
- this.triggers = ts.elements;
- },
- getTriggerWidth: function(){
- var tw = 0;
- Ext.each(this.triggers, function(t, index){
- var triggerIndex = 'Trigger' + (index + 1),
- w = t.getWidth();
- if(w === 0 && !this['hidden' + triggerIndex]){
- tw += this.defaultTriggerWidth;
- }else{
- tw += w;
- }
- }, this);
- return tw;
- },
- onDestroy : function() {
- Ext.destroy(this.triggers);
- Ext.form.TwinTriggerField.superclass.onDestroy.call(this);
- },
- onTrigger1Click : Ext.emptyFn,
- onTrigger2Click : Ext.emptyFn
- });
- Ext.reg('trigger', Ext.form.TriggerField);
- Ext.form.TextArea = Ext.extend(Ext.form.TextField, {
- growMin : 60,
- growMax: 1000,
- growAppend : ' n ',
- enterIsSpecial : false,
- preventScrollbars: false,
- onRender : function(ct, position){
- if(!this.el){
- this.defaultAutoCreate = {
- tag: "textarea",
- style:"width:100px;height:60px;",
- autocomplete: "off"
- };
- }
- Ext.form.TextArea.superclass.onRender.call(this, ct, position);
- if(this.grow){
- this.textSizeEl = Ext.DomHelper.append(document.body, {
- tag: "pre", cls: "x-form-grow-sizer"
- });
- if(this.preventScrollbars){
- this.el.setStyle("overflow", "hidden");
- }
- this.el.setHeight(this.growMin);
- }
- },
- onDestroy : function(){
- Ext.removeNode(this.textSizeEl);
- Ext.form.TextArea.superclass.onDestroy.call(this);
- },
- fireKey : function(e){
- if(e.isSpecialKey() && (this.enterIsSpecial || (e.getKey() != e.ENTER || e.hasModifier()))){
- this.fireEvent("specialkey", this, e);
- }
- },
- doAutoSize : function(e){
- return !e.isNavKeyPress() || e.getKey() == e.ENTER;
- },
- autoSize: function(){
- if(!this.grow || !this.textSizeEl){
- return;
- }
- var el = this.el,
- v = Ext.util.Format.htmlEncode(el.dom.value),
- ts = this.textSizeEl,
- h;
- Ext.fly(ts).setWidth(this.el.getWidth());
- if(v.length < 1){
- v = "  ";
- }else{
- v += this.growAppend;
- if(Ext.isIE){
- v = v.replace(/n/g, ' <br />');
- }
- }
- ts.innerHTML = v;
- h = Math.min(this.growMax, Math.max(ts.offsetHeight, this.growMin));
- if(h != this.lastHeight){
- this.lastHeight = h;
- this.el.setHeight(h);
- this.fireEvent("autosize", this, h);
- }
- }
- });
- Ext.reg('textarea', Ext.form.TextArea);
- Ext.form.NumberField = Ext.extend(Ext.form.TextField, {
- fieldClass: "x-form-field x-form-num-field",
- allowDecimals : true,
- decimalSeparator : ".",
- decimalPrecision : 2,
- allowNegative : true,
- minValue : Number.NEGATIVE_INFINITY,
- maxValue : Number.MAX_VALUE,
- minText : "The minimum value for this field is {0}",
- maxText : "The maximum value for this field is {0}",
- nanText : "{0} is not a valid number",
- baseChars : "0123456789",
- initEvents : function(){
- var allowed = this.baseChars + '';
- if (this.allowDecimals) {
- allowed += this.decimalSeparator;
- }
- if (this.allowNegative) {
- allowed += '-';
- }
- this.maskRe = new RegExp('[' + Ext.escapeRe(allowed) + ']');
- Ext.form.NumberField.superclass.initEvents.call(this);
- },
- validateValue : function(value){
- if(!Ext.form.NumberField.superclass.validateValue.call(this, value)){
- return false;
- }
- if(value.length < 1){
- return true;
- }
- value = String(value).replace(this.decimalSeparator, ".");
- if(isNaN(value)){
- this.markInvalid(String.format(this.nanText, value));
- return false;
- }
- var num = this.parseValue(value);
- if(num < this.minValue){
- this.markInvalid(String.format(this.minText, this.minValue));
- return false;
- }
- if(num > this.maxValue){
- this.markInvalid(String.format(this.maxText, this.maxValue));
- return false;
- }
- return true;
- },
- getValue : function(){
- return this.fixPrecision(this.parseValue(Ext.form.NumberField.superclass.getValue.call(this)));
- },
- setValue : function(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);
- },
- setMinValue : function(value){
- this.minValue = Ext.num(value, Number.NEGATIVE_INFINITY);
- },
- setMaxValue : function(value){
- this.maxValue = Ext.num(value, Number.MAX_VALUE);
- },
- parseValue : function(value){
- value = parseFloat(String(value).replace(this.decimalSeparator, "."));
- return isNaN(value) ? '' : value;
- },
- fixPrecision : function(value){
- var nan = isNaN(value);
- if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){
- return nan ? '' : value;
- }
- return parseFloat(parseFloat(value).toFixed(this.decimalPrecision));
- },
- beforeBlur : function(){
- var v = this.parseValue(this.getRawValue());
- if(!Ext.isEmpty(v)){
- this.setValue(this.fixPrecision(v));
- }
- }
- });
- Ext.reg('numberfield', Ext.form.NumberField);
- Ext.form.DateField = Ext.extend(Ext.form.TriggerField, {
- format : "m/d/Y",
- altFormats : "m/d/Y|n/j/Y|n/j/y|m/j/y|n/d/y|m/j/Y|n/d/Y|m-d-y|m-d-Y|m/d|m-d|md|mdy|mdY|d|Y-m-d",
- disabledDaysText : "Disabled",
- disabledDatesText : "Disabled",
- minText : "The date in this field must be equal to or after {0}",
- maxText : "The date in this field must be equal to or before {0}",
- invalidText : "{0} is not a valid date - it must be in the format {1}",
- triggerClass : 'x-form-date-trigger',
- showToday : true,
- defaultAutoCreate : {tag: "input", type: "text", size: "10", autocomplete: "off"},
- initComponent : function(){
- Ext.form.DateField.superclass.initComponent.call(this);
- this.addEvents(
- 'select'
- );
- if(Ext.isString(this.minValue)){
- this.minValue = this.parseDate(this.minValue);
- }
- if(Ext.isString(this.maxValue)){
- this.maxValue = this.parseDate(this.maxValue);
- }
- this.disabledDatesRE = null;
- this.initDisabledDays();
- },
- initEvents: function() {
- Ext.form.DateField.superclass.initEvents.call(this);
- this.keyNav = new Ext.KeyNav(this.el, {
- "down": function(e) {
- this.onTriggerClick();
- },
- scope: this,
- forceKeyDown: true
- });
- },
- initDisabledDays : function(){
- if(this.disabledDates){
- var dd = this.disabledDates,
- len = dd.length - 1,
- re = "(?:";
- Ext.each(dd, function(d, i){
- re += Ext.isDate(d) ? '^' + Ext.escapeRe(d.dateFormat(this.format)) + '$' : dd[i];
- if(i != len){
- re += '|';
- }
- }, this);
- this.disabledDatesRE = new RegExp(re + ')');
- }
- },
- setDisabledDates : function(dd){
- this.disabledDates = dd;
- this.initDisabledDays();
- if(this.menu){
- this.menu.picker.setDisabledDates(this.disabledDatesRE);
- }
- },
- setDisabledDays : function(dd){
- this.disabledDays = dd;
- if(this.menu){
- this.menu.picker.setDisabledDays(dd);
- }
- },
- setMinValue : function(dt){
- this.minValue = (Ext.isString(dt) ? this.parseDate(dt) : dt);
- if(this.menu){
- this.menu.picker.setMinDate(this.minValue);
- }
- },
- setMaxValue : function(dt){
- this.maxValue = (Ext.isString(dt) ? this.parseDate(dt) : dt);
- if(this.menu){
- this.menu.picker.setMaxDate(this.maxValue);
- }
- },
- validateValue : function(value){
- value = this.formatDate(value);
- if(!Ext.form.DateField.superclass.validateValue.call(this, value)){
- return false;
- }
- if(value.length < 1){
- return true;
- }
- var svalue = value;
- value = this.parseDate(value);
- if(!value){
- this.markInvalid(String.format(this.invalidText, svalue, this.format));
- return false;
- }
- var time = value.getTime();
- if(this.minValue && time < this.minValue.getTime()){
- this.markInvalid(String.format(this.minText, this.formatDate(this.minValue)));
- return false;
- }
- if(this.maxValue && time > this.maxValue.getTime()){
- this.markInvalid(String.format(this.maxText, this.formatDate(this.maxValue)));
- return false;
- }
- if(this.disabledDays){
- var day = value.getDay();
- for(var i = 0; i < this.disabledDays.length; i++) {
- if(day === this.disabledDays[i]){
- this.markInvalid(this.disabledDaysText);
- return false;
- }
- }
- }
- var fvalue = this.formatDate(value);
- if(this.disabledDatesRE && this.disabledDatesRE.test(fvalue)){
- this.markInvalid(String.format(this.disabledDatesText, fvalue));
- return false;
- }
- return true;
- },
- validateBlur : function(){
- return !this.menu || !this.menu.isVisible();
- },
- getValue : function(){
- return this.parseDate(Ext.form.DateField.superclass.getValue.call(this)) || "";
- },
- setValue : function(date){
- return Ext.form.DateField.superclass.setValue.call(this, this.formatDate(this.parseDate(date)));
- },
- parseDate : function(value){
- if(!value || Ext.isDate(value)){
- return value;
- }
- var v = Date.parseDate(value, this.format);
- if(!v && this.altFormats){
- if(!this.altFormatsArray){
- this.altFormatsArray = this.altFormats.split("|");
- }
- for(var i = 0, len = this.altFormatsArray.length; i < len && !v; i++){
- v = Date.parseDate(value, this.altFormatsArray[i]);
- }
- }
- return v;
- },
- onDestroy : function(){
- Ext.destroy(this.menu, this.keyNav);
- Ext.form.DateField.superclass.onDestroy.call(this);
- },
- formatDate : function(date){
- return Ext.isDate(date) ? date.dateFormat(this.format) : date;
- },
- onTriggerClick : function(){
- if(this.disabled){
- return;
- }
- if(this.menu == null){
- this.menu = new Ext.menu.DateMenu({
- hideOnClick: false,
- focusOnSelect: false
- });
- }
- this.onFocus();
- Ext.apply(this.menu.picker, {
- minDate : this.minValue,
- maxDate : this.maxValue,
- disabledDatesRE : this.disabledDatesRE,
- disabledDatesText : this.disabledDatesText,
- disabledDays : this.disabledDays,
- disabledDaysText : this.disabledDaysText,
- format : this.format,
- showToday : this.showToday,
- minText : String.format(this.minText, this.formatDate(this.minValue)),
- maxText : String.format(this.maxText, this.formatDate(this.maxValue))
- });
- this.menu.picker.setValue(this.getValue() || new Date());
- this.menu.show(this.el, "tl-bl?");
- this.menuEvents('on');
- },
- menuEvents: function(method){
- this.menu[method]('select', this.onSelect, this);
- this.menu[method]('hide', this.onMenuHide, this);
- this.menu[method]('show', this.onFocus, this);
- },
- onSelect: function(m, d){
- this.setValue(d);
- this.fireEvent('select', this, d);
- this.menu.hide();
- },
- onMenuHide: function(){
- this.focus(false, 60);
- this.menuEvents('un');
- },
- beforeBlur : function(){
- var v = this.parseDate(this.getRawValue());
- if(v){
- this.setValue(v);
- }
- }
- });
- Ext.reg('datefield', Ext.form.DateField);
- Ext.form.DisplayField = Ext.extend(Ext.form.Field, {
- validationEvent : false,
- validateOnBlur : false,
- defaultAutoCreate : {tag: "div"},
- fieldClass : "x-form-display-field",
- htmlEncode: false,
- initEvents : Ext.emptyFn,
- isValid : function(){
- return true;
- },
- validate : function(){
- return true;
- },
- getRawValue : function(){
- var v = this.rendered ? this.el.dom.innerHTML : Ext.value(this.value, '');
- if(v === this.emptyText){
- v = '';
- }
- if(this.htmlEncode){
- v = Ext.util.Format.htmlDecode(v);
- }
- return v;
- },
- getValue : function(){
- return this.getRawValue();
- },
- getName: function() {
- return this.name;
- },
- setRawValue : function(v){
- if(this.htmlEncode){
- v = Ext.util.Format.htmlEncode(v);
- }
- return this.rendered ? (this.el.dom.innerHTML = (Ext.isEmpty(v) ? '' : v)) : (this.value = v);
- },
- setValue : function(v){
- this.setRawValue(v);
- return this;
- }
- });
- Ext.reg('displayfield', Ext.form.DisplayField);
- Ext.form.ComboBox = Ext.extend(Ext.form.TriggerField, {
- defaultAutoCreate : {tag: "input", type: "text", size: "24", autocomplete: "off"},
- listClass : '',
- selectedClass : 'x-combo-selected',
- listEmptyText: '',
- triggerClass : 'x-form-arrow-trigger',
- shadow : 'sides',
- listAlign : 'tl-bl?',
- maxHeight : 300,
- minHeight : 90,
- triggerAction : 'query',
- minChars : 4,
- typeAhead : false,
- queryDelay : 500,
- pageSize : 0,
- selectOnFocus : false,
- queryParam : 'query',
- loadingText : 'Loading...',
- resizable : false,
- handleHeight : 8,
- allQuery: '',
- mode: 'remote',
- minListWidth : 70,
- forceSelection : false,
- typeAheadDelay : 250,
- lazyInit : true,
- clearFilterOnReset : true,
- submitValue: undefined,
- initComponent : function(){
- Ext.form.ComboBox.superclass.initComponent.call(this);
- this.addEvents(
- 'expand',
- 'collapse',
- 'beforeselect',
- 'select',
- 'beforequery'
- );
- if(this.transform){
- var s = Ext.getDom(this.transform);
- if(!this.hiddenName){
- this.hiddenName = s.name;
- }
- if(!this.store){
- this.mode = 'local';
- var d = [], opts = s.options;
- for(var i = 0, len = opts.length;i < len; i++){
- var o = opts[i],
- value = (o.hasAttribute ? o.hasAttribute('value') : o.getAttributeNode('value').specified) ? o.value : o.text;
- if(o.selected && Ext.isEmpty(this.value, true)) {
- this.value = value;
- }
- d.push([value, o.text]);
- }
- this.store = new Ext.data.ArrayStore({
- 'id': 0,
- fields: ['value', 'text'],
- data : d,
- autoDestroy: true
- });
- this.valueField = 'value';
- this.displayField = 'text';
- }
- s.name = Ext.id();
- if(!this.lazyRender){
- this.target = true;
- this.el = Ext.DomHelper.insertBefore(s, this.autoCreate || this.defaultAutoCreate);
- this.render(this.el.parentNode, s);
- }
- Ext.removeNode(s);
- }
- else if(this.store){
- this.store = Ext.StoreMgr.lookup(this.store);
- if(this.store.autoCreated){
- this.displayField = this.valueField = 'field1';
- if(!this.store.expandData){
- this.displayField = 'field2';
- }
- this.mode = 'local';
- }
- }
- this.selectedIndex = -1;
- if(this.mode == 'local'){
- if(!Ext.isDefined(this.initialConfig.queryDelay)){
- this.queryDelay = 10;
- }
- if(!Ext.isDefined(this.initialConfig.minChars)){
- this.minChars = 0;
- }
- }
- },
- onRender : function(ct, position){
- if(this.hiddenName && !Ext.isDefined(this.submitValue)){
- this.submitValue = false;
- }
- Ext.form.ComboBox.superclass.onRender.call(this, ct, position);
- if(this.hiddenName){
- this.hiddenField = this.el.insertSibling({tag:'input', type:'hidden', name: this.hiddenName,
- id: (this.hiddenId||this.hiddenName)}, 'before', true);
- }
- if(Ext.isGecko){
- this.el.dom.setAttribute('autocomplete', 'off');
- }
- if(!this.lazyInit){
- this.initList();
- }else{
- this.on('focus', this.initList, this, {single: true});
- }
- },
- initValue : function(){
- Ext.form.ComboBox.superclass.initValue.call(this);
- if(this.hiddenField){
- this.hiddenField.value =
- Ext.isDefined(this.hiddenValue) ? this.hiddenValue :
- Ext.isDefined(this.value) ? this.value : '';
- }
- },
- initList : function(){
- if(!this.list){
- var cls = 'x-combo-list';
- this.list = new Ext.Layer({
- parentEl: this.getListParent(),
- shadow: this.shadow,
- cls: [cls, this.listClass].join(' '),
- constrain:false,
- zindex: 12000
- });
- var lw = this.listWidth || Math.max(this.wrap.getWidth(), this.minListWidth);
- this.list.setSize(lw, 0);
- this.list.swallowEvent('mousewheel');
- this.assetHeight = 0;
- if(this.syncFont !== false){
- this.list.setStyle('font-size', this.el.getStyle('font-size'));
- }
- if(this.title){
- this.header = this.list.createChild({cls:cls+'-hd', html: this.title});
- this.assetHeight += this.header.getHeight();
- }
- this.innerList = this.list.createChild({cls:cls+'-inner'});
- this.mon(this.innerList, 'mouseover', this.onViewOver, this);
- this.mon(this.innerList, 'mousemove', this.onViewMove, this);
- this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
- if(this.pageSize){
- this.footer = this.list.createChild({cls:cls+'-ft'});
- this.pageTb = new Ext.PagingToolbar({
- store: this.store,
- pageSize: this.pageSize,
- renderTo:this.footer
- });
- this.assetHeight += this.footer.getHeight();
- }
- if(!this.tpl){
- this.tpl = '<tpl for="."><div class="'+cls+'-item">{' + this.displayField + '}</div></tpl>';
- }
- this.view = new Ext.DataView({
- applyTo: this.innerList,
- tpl: this.tpl,
- singleSelect: true,
- selectedClass: this.selectedClass,
- itemSelector: this.itemSelector || '.' + cls + '-item',
- emptyText: this.listEmptyText
- });
- this.mon(this.view, 'click', this.onViewClick, this);
- this.bindStore(this.store, true);
- if(this.resizable){
- this.resizer = new Ext.Resizable(this.list, {
- pinned:true, handles:'se'
- });
- this.mon(this.resizer, 'resize', function(r, w, h){
- this.maxHeight = h-this.handleHeight-this.list.getFrameWidth('tb')-this.assetHeight;
- this.listWidth = w;
- this.innerList.setWidth(w - this.list.getFrameWidth('lr'));
- this.restrictHeight();
- }, this);
- this[this.pageSize?'footer':'innerList'].setStyle('margin-bottom', this.handleHeight+'px');
- }
- }
- },
- getListParent : function() {
- return document.body;
- },
- getStore : function(){
- return this.store;
- },
- bindStore : function(store, initial){
- if(this.store && !initial){
- if(this.store !== store && this.store.autoDestroy){
- this.store.destroy();
- }else{
- this.store.un('beforeload', this.onBeforeLoad, this);
- this.store.un('load', this.onLoad, this);
- this.store.un('exception', this.collapse, this);
- }
- if(!store){
- this.store = null;
- if(this.view){
- this.view.bindStore(null);
- }
- if(this.pageTb){
- this.pageTb.bindStore(null);
- }
- }
- }
- if(store){
- if(!initial) {
- this.lastQuery = null;
- if(this.pageTb) {
- this.pageTb.bindStore(store);
- }
- }
- this.store = Ext.StoreMgr.lookup(store);
- this.store.on({
- scope: this,
- beforeload: this.onBeforeLoad,
- load: this.onLoad,
- exception: this.collapse
- });
- if(this.view){
- this.view.bindStore(store);
- }
- }
- },
- reset : function(){
- Ext.form.ComboBox.superclass.reset.call(this);
- if(this.clearFilterOnReset && this.mode == 'local'){
- this.store.clearFilter();
- }
- },
- initEvents : function(){
- Ext.form.ComboBox.superclass.initEvents.call(this);
- this.keyNav = new Ext.KeyNav(this.el, {
- "up" : function(e){
- this.inKeyMode = true;
- this.selectPrev();
- },
- "down" : function(e){
- if(!this.isExpanded()){
- this.onTriggerClick();
- }else{
- this.inKeyMode = true;
- this.selectNext();
- }
- },
- "enter" : function(e){
- this.onViewClick();
- },
- "esc" : function(e){
- this.collapse();
- },
- "tab" : function(e){
- this.onViewClick(false);
- return true;
- },
- scope : this,
- doRelay : function(e, h, hname){
- if(hname == 'down' || this.scope.isExpanded()){
- var relay = Ext.KeyNav.prototype.doRelay.apply(this, arguments);
- if(!Ext.isIE && Ext.EventManager.useKeydown){
- this.scope.fireKey(e);
- }
- return relay;
- }
- return true;
- },
- forceKeyDown : true,
- defaultEventAction: 'stopEvent'
- });
- this.queryDelay = Math.max(this.queryDelay || 10,
- this.mode == 'local' ? 10 : 250);
- this.dqTask = new Ext.util.DelayedTask(this.initQuery, this);
- if(this.typeAhead){
- this.taTask = new Ext.util.DelayedTask(this.onTypeAhead, this);
- }
- if(!this.enableKeyEvents){
- this.mon(this.el, 'keyup', this.onKeyUp, this);
- }
- },
- onDestroy : function(){
- if (this.dqTask){
- this.dqTask.cancel();
- this.dqTask = null;
- }
- this.bindStore(null);
- Ext.destroy(
- this.resizer,
- this.view,
- this.pageTb,
- this.list
- );
- Ext.destroyMembers(this, 'hiddenField');
- Ext.form.ComboBox.superclass.onDestroy.call(this);
- },
- fireKey : function(e){
- if (!this.isExpanded()) {
- Ext.form.ComboBox.superclass.fireKey.call(this, e);
- }
- },
- onResize : function(w, h){
- Ext.form.ComboBox.superclass.onResize.apply(this, arguments);
- if(this.isVisible() && this.list){
- this.doResize(w);
- }else{
- this.bufferSize = w;
- }
- },
- doResize: function(w){
- if(!Ext.isDefined(this.listWidth)){
- var lw = Math.max(w, this.minListWidth);
- this.list.setWidth(lw);
- this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
- }
- },
- onEnable : function(){
- Ext.form.ComboBox.superclass.onEnable.apply(this, arguments);
- if(this.hiddenField){
- this.hiddenField.disabled = false;
- }
- },
- onDisable : function(){
- Ext.form.ComboBox.superclass.onDisable.apply(this, arguments);
- if(this.hiddenField){
- this.hiddenField.disabled = true;
- }
- },
- onBeforeLoad : function(){
- if(!this.hasFocus){
- return;
- }
- this.innerList.update(this.loadingText ?
- '<div class="loading-indicator">'+this.loadingText+'</div>' : '');
- this.restrictHeight();
- this.selectedIndex = -1;
- },
- onLoad : function(){
- if(!this.hasFocus){
- return;
- }
- if(this.store.getCount() > 0 || this.listEmptyText){
- this.expand();
- this.restrictHeight();
- if(this.lastQuery == this.allQuery){
- if(this.editable){
- this.el.dom.select();
- }
- if(!this.selectByValue(this.value, true)){
- this.select(0, true);
- }
- }else{
- this.selectNext();
- if(this.typeAhead && this.lastKey != Ext.EventObject.BACKSPACE && this.lastKey != Ext.EventObject.DELETE){
- this.taTask.delay(this.typeAheadDelay);
- }
- }
- }else{
- this.onEmptyResults();
- }
- },
- onTypeAhead : function(){
- if(this.store.getCount() > 0){
- var r = this.store.getAt(0);
- var newValue = r.data[this.displayField];
- var len = newValue.length;
- var selStart = this.getRawValue().length;
- if(selStart != len){
- this.setRawValue(newValue);
- this.selectText(selStart, newValue.length);
- }
- }
- },
- onSelect : function(record, index){
- if(this.fireEvent('beforeselect', this, record, index) !== false){
- this.setValue(record.data[this.valueField || this.displayField]);
- this.collapse();
- this.fireEvent('select', this, record, index);
- }
- },
- getName: function(){
- var hf = this.hiddenField;
- return hf && hf.name ? hf.name : this.hiddenName || Ext.form.ComboBox.superclass.getName.call(this);
- },
- getValue : function(){
- if(this.valueField){
- return Ext.isDefined(this.value) ? this.value : '';
- }else{
- return Ext.form.ComboBox.superclass.getValue.call(this);
- }
- },
- clearValue : function(){
- if(this.hiddenField){
- this.hiddenField.value = '';
- }
- this.setRawValue('');
- this.lastSelectionText = '';
- this.applyEmptyText();
- this.value = '';
- },
- setValue : function(v){
- var text = v;
- if(this.valueField){
- var r = this.findRecord(this.valueField, v);
- if(r){
- text = r.data[this.displayField];
- }else if(Ext.isDefined(this.valueNotFoundText)){
- text = this.valueNotFoundText;
- }
- }
- this.lastSelectionText = text;
- if(this.hiddenField){
- this.hiddenField.value = v;
- }
- Ext.form.ComboBox.superclass.setValue.call(this, text);
- this.value = v;
- return this;
- },
- findRecord : function(prop, value){
- var record;
- if(this.store.getCount() > 0){
- this.store.each(function(r){
- if(r.data[prop] == value){
- record = r;
- return false;
- }
- });
- }
- return record;
- },
- onViewMove : function(e, t){
- this.inKeyMode = false;
- },
- onViewOver : function(e, t){
- if(this.inKeyMode){
- return;
- }
- var item = this.view.findItemFromChild(t);
- if(item){
- var index = this.view.indexOf(item);
- this.select(index, false);
- }
- },
- onViewClick : function(doFocus){
- var index = this.view.getSelectedIndexes()[0],
- s = this.store,
- r = s.getAt(index);
- if(r){
- this.onSelect(r, index);
- }else if(s.getCount() === 0){
- this.onEmptyResults();
- }
- if(doFocus !== false){
- this.el.focus();
- }
- },
- restrictHeight : function(){
- this.innerList.dom.style.height = '';
- var inner = this.innerList.dom,
- pad = this.list.getFrameWidth('tb') + (this.resizable ? this.handleHeight : 0) + this.assetHeight,
- h = Math.max(inner.clientHeight, inner.offsetHeight, inner.scrollHeight),
- ha = this.getPosition()[1]-Ext.getBody().getScroll().top,
- hb = Ext.lib.Dom.getViewHeight()-ha-this.getSize().height,
- space = Math.max(ha, hb, this.minHeight || 0)-this.list.shadowOffset-pad-5;
- h = Math.min(h, space, this.maxHeight);
- this.innerList.setHeight(h);
- this.list.beginUpdate();
- this.list.setHeight(h+pad);
- this.list.alignTo(this.wrap, this.listAlign);
- this.list.endUpdate();
- },
- onEmptyResults : function(){
- this.collapse();
- },
- isExpanded : function(){
- return this.list && this.list.isVisible();
- },
- selectByValue : function(v, scrollIntoView){
- if(!Ext.isEmpty(v, true)){
- var r = this.findRecord(this.valueField || this.displayField, v);
- if(r){
- this.select(this.store.indexOf(r), scrollIntoView);
- return true;
- }
- }
- return false;
- },
- select : function(index, scrollIntoView){
- this.selectedIndex = index;
- this.view.select(index);
- if(scrollIntoView !== false){
- var el = this.view.getNode(index);
- if(el){
- this.innerList.scrollChildIntoView(el, false);
- }
- }
- },
- selectNext : function(){
- var ct = this.store.getCount();
- if(ct > 0){
- if(this.selectedIndex == -1){
- this.select(0);
- }else if(this.selectedIndex < ct-1){
- this.select(this.selectedIndex+1);
- }
- }
- },
- selectPrev : function(){
- var ct = this.store.getCount();
- if(ct > 0){
- if(this.selectedIndex == -1){
- this.select(0);
- }else if(this.selectedIndex !== 0){
- this.select(this.selectedIndex-1);
- }
- }
- },
- onKeyUp : function(e){
- var k = e.getKey();
- if(this.editable !== false && this.readOnly !== true && (k == e.BACKSPACE || !e.isSpecialKey())){
- this.lastKey = k;
- this.dqTask.delay(this.queryDelay);
- }
- Ext.form.ComboBox.superclass.onKeyUp.call(this, e);
- },
- validateBlur : function(){
- return !this.list || !this.list.isVisible();
- },
- initQuery : function(){
- this.doQuery(this.getRawValue());
- },
- beforeBlur : function(){
- var val = this.getRawValue(),
- rec = this.findRecord(this.displayField, val);
- if(!rec && this.forceSelection){
- if(val.length > 0 && val != this.emptyText){
- this.el.dom.value = Ext.isEmpty(this.lastSelectionText) ? '' : this.lastSelectionText;
- this.applyEmptyText();
- }else{
- this.clearValue();
- }
- }else{
- if(rec){
- val = rec.get(this.valueField || this.displayField);
- }
- this.setValue(val);
- }
- },
- doQuery : function(q, forceAll){
- q = Ext.isEmpty(q) ? '' : q;
- var qe = {
- query: q,
- forceAll: forceAll,
- combo: this,
- cancel:false
- };
- if(this.fireEvent('beforequery', qe)===false || qe.cancel){
- return false;
- }
- q = qe.query;
- forceAll = qe.forceAll;
- if(forceAll === true || (q.length >= this.minChars)){
- if(this.lastQuery !== q){
- this.lastQuery = q;
- if(this.mode == 'local'){
- this.selectedIndex = -1;
- if(forceAll){
- this.store.clearFilter();
- }else{
- this.store.filter(this.displayField, q);
- }
- this.onLoad();
- }else{
- this.store.baseParams[this.queryParam] = q;
- this.store.load({
- params: this.getParams(q)
- });
- this.expand();
- }
- }else{
- this.selectedIndex = -1;
- this.onLoad();
- }
- }
- },
- getParams : function(q){
- var p = {};
- if(this.pageSize){
- p.start = 0;
- p.limit = this.pageSize;
- }
- return p;
- },
- collapse : function(){
- if(!this.isExpanded()){
- return;
- }
- this.list.hide();
- Ext.getDoc().un('mousewheel', this.collapseIf, this);
- Ext.getDoc().un('mousedown', this.collapseIf, this);
- this.fireEvent('collapse', this);
- },
- collapseIf : function(e){
- if(!e.within(this.wrap) && !e.within(this.list)){
- this.collapse();
- }
- },
- expand : function(){
- if(this.isExpanded() || !this.hasFocus){
- return;
- }
- if(this.bufferSize){
- this.doResize(this.bufferSize);
- delete this.bufferSize;
- }
- this.list.alignTo(this.wrap, this.listAlign);
- this.list.show();
- if(Ext.isGecko2){
- this.innerList.setOverflow('auto');
- }
- this.mon(Ext.getDoc(), {
- scope: this,
- mousewheel: this.collapseIf,
- mousedown: this.collapseIf
- });
- this.fireEvent('expand', this);
- },
- onTriggerClick : function(){
- if(this.readOnly || this.disabled){
- return;
- }
- if(this.isExpanded()){
- this.collapse();
- this.el.focus();
- }else {
- this.onFocus({});
- if(this.triggerAction == 'all') {
- this.doQuery(this.allQuery, true);
- } else {
- this.doQuery(this.getRawValue());
- }
- this.el.focus();
- }
- }
- });
- Ext.reg('combo', Ext.form.ComboBox);
- Ext.form.Checkbox = Ext.extend(Ext.form.Field, {
- focusClass : undefined,
- fieldClass : 'x-form-field',
- checked : false,
- defaultAutoCreate : { tag: 'input', type: 'checkbox', autocomplete: 'off'},
- actionMode : 'wrap',
- initComponent : function(){
- Ext.form.Checkbox.superclass.initComponent.call(this);
- this.addEvents(
- 'check'
- );
- },
- onResize : function(){
- Ext.form.Checkbox.superclass.onResize.apply(this, arguments);
- if(!this.boxLabel && !this.fieldLabel){
- this.el.alignTo(this.wrap, 'c-c');
- }
- },
- initEvents : function(){
- Ext.form.Checkbox.superclass.initEvents.call(this);
- this.mon(this.el, {
- scope: this,
- click: this.onClick,
- change: this.onClick
- });
- },
- markInvalid : Ext.emptyFn,
- clearInvalid : Ext.emptyFn,
- onRender : function(ct, position){
- Ext.form.Checkbox.superclass.onRender.call(this, ct, position);
- if(this.inputValue !== undefined){
- this.el.dom.value = this.inputValue;
- }
- this.wrap = this.el.wrap({cls: 'x-form-check-wrap'});
- if(this.boxLabel){
- this.wrap.createChild({tag: 'label', htmlFor: this.el.id, cls: 'x-form-cb-label', html: this.boxLabel});
- }
- if(this.checked){
- this.setValue(true);
- }else{
- this.checked = this.el.dom.checked;
- }
- if(Ext.isIE){
- this.wrap.repaint();
- }
- this.resizeEl = this.positionEl = this.wrap;
- },
- onDestroy : function(){
- Ext.destroy(this.wrap);
- Ext.form.Checkbox.superclass.onDestroy.call(this);
- },
- initValue : function() {
- this.originalValue = this.getValue();
- },
- getValue : function(){
- if(this.rendered){
- return this.el.dom.checked;
- }
- return this.checked;
- },
- onClick : function(){
- if(this.el.dom.checked != this.checked){
- this.setValue(this.el.dom.checked);
- }
- },
- setValue : function(v){
- var checked = this.checked ;
- this.checked = (v === true || v === 'true' || v == '1' || String(v).toLowerCase() == 'on');
- if(this.rendered){
- this.el.dom.checked = this.checked;
- this.el.dom.defaultChecked = this.checked;
- }
- if(checked != this.checked){
- this.fireEvent('check', this, this.checked);
- if(this.handler){
- this.handler.call(this.scope || this, this, this.checked);
- }
- }
- return this;
- }
- });
- Ext.reg('checkbox', Ext.form.Checkbox);
- Ext.form.CheckboxGroup = Ext.extend(Ext.form.Field, {
- columns : 'auto',
- vertical : false,
- allowBlank : true,
- blankText : "You must select at least one item in this group",
- defaultType : 'checkbox',
- groupCls : 'x-form-check-group',
- initComponent: function(){
- this.addEvents(
- 'change'
- );
- this.on('change', this.validate, this);
- Ext.form.CheckboxGroup.superclass.initComponent.call(this);
- },
- onRender : function(ct, position){
- if(!this.el){
- var panelCfg = {
- autoEl: {
- id: this.id
- },
- cls: this.groupCls,
- layout: 'column',
- renderTo: ct,
- bufferResize: false
- };
- var colCfg = {
- xtype: 'container',
- defaultType: this.defaultType,
- layout: 'form',
- defaults: {
- hideLabel: true,
- anchor: '100%'
- }
- };
- if(this.items[0].items){
- Ext.apply(panelCfg, {
- layoutConfig: {columns: this.items.length},
- defaults: this.defaults,
- items: this.items
- });
- for(var i=0, len=this.items.length; i<len; i++){
- Ext.applyIf(this.items[i], colCfg);
- }
- }else{
- var numCols, cols = [];
- if(typeof this.columns == 'string'){
- this.columns = this.items.length;
- }
- if(!Ext.isArray(this.columns)){
- var cs = [];
- for(var i=0; i<this.columns; i++){
- cs.push((100/this.columns)*.01);
- }
- this.columns = cs;
- }
- numCols = this.columns.length;
- for(var i=0; i<numCols; i++){
- var cc = Ext.apply({items:[]}, colCfg);
- cc[this.columns[i] <= 1 ? 'columnWidth' : 'width'] = this.columns[i];
- if(this.defaults){
- cc.defaults = Ext.apply(cc.defaults || {}, this.defaults)
- }
- cols.push(cc);
- };
- if(this.vertical){
- var rows = Math.ceil(this.items.length / numCols), ri = 0;
- for(var i=0, len=this.items.length; i<len; i++){
- if(i>0 && i%rows==0){
- ri++;
- }
- if(this.items[i].fieldLabel){
- this.items[i].hideLabel = false;
- }
- cols[ri].items.push(this.items[i]);
- };
- }else{
- for(var i=0, len=this.items.length; i<len; i++){
- var ci = i % numCols;
- if(this.items[i].fieldLabel){
- this.items[i].hideLabel = false;
- }
- cols[ci].items.push(this.items[i]);
- };
- }
- Ext.apply(panelCfg, {
- layoutConfig: {columns: numCols},
- items: cols
- });
- }
- this.panel = new Ext.Container(panelCfg);
- this.panel.ownerCt = this;
- this.el = this.panel.getEl();
- if(this.forId && this.itemCls){
- var l = this.el.up(this.itemCls).child('label', true);
- if(l){
- l.setAttribute('htmlFor', this.forId);
- }
- }
- var fields = this.panel.findBy(function(c){
- return c.isFormField;
- }, this);
- this.items = new Ext.util.MixedCollection();
- this.items.addAll(fields);
- }
- Ext.form.CheckboxGroup.superclass.onRender.call(this, ct, position);
- },
- initValue : function(){
- if(this.value){
- this.setValue.apply(this, this.buffered ? this.value : [this.value]);
- delete this.buffered;
- delete this.value;
- }
- },
- afterRender : function(){
- Ext.form.CheckboxGroup.superclass.afterRender.call(this);
- this.eachItem(function(item){
- item.on('check', this.fireChecked, this);
- item.inGroup = true;
- });
- },
- doLayout: function(){
- if(this.rendered){
- this.panel.forceLayout = this.ownerCt.forceLayout;
- this.panel.doLayout();
- }
- },
- fireChecked: function(){
- var arr = [];
- this.eachItem(function(item){
- if(item.checked){
- arr.push(item);
- }
- });
- this.fireEvent('change', this, arr);
- },
- validateValue : function(value){
- if(!this.allowBlank){
- var blank = true;
- this.eachItem(function(f){
- if(f.checked){
- return (blank = false);
- }
- });
- if(blank){
- this.markInvalid(this.blankText);
- return false;
- }
- }
- return true;
- },
- isDirty: function(){
- if (this.disabled || !this.rendered) {
- return false;
- }
- var dirty = false;
- this.eachItem(function(item){
- if(item.isDirty()){
- dirty = true;
- return false;
- }
- });
- return dirty;
- },
- onDisable : function(){
- this.eachItem(function(item){
- item.disable();
- });
- },
- onEnable : function(){
- this.eachItem(function(item){
- item.enable();
- });
- },
- doLayout: function(){
- if(this.rendered){
- this.panel.forceLayout = this.ownerCt.forceLayout;
- this.panel.doLayout();
- }
- },
- onResize : function(w, h){
- this.panel.setSize(w, h);
- this.panel.doLayout();
- },
- reset : function(){
- this.eachItem(function(c){
- if(c.reset){
- c.reset();
- }
- });
- (function() {
- this.clearInvalid();
- }).defer(50, this);
- },
- setValue: function(){
- if(this.rendered){
- this.onSetValue.apply(this, arguments);
- }else{
- this.buffered = true;
- this.value = arguments;
- }
- return this;
- },
- onSetValue: function(id, value){
- if(arguments.length == 1){
- if(Ext.isArray(id)){
- Ext.each(id, function(val, idx){
- var item = this.items.itemAt(idx);
- if(item){
- item.setValue(val);
- }
- }, this);
- }else if(Ext.isObject(id)){
- for(var i in id){
- var f = this.getBox(i);
- if(f){
- f.setValue(id[i]);
- }
- }
- }else{
- this.setValueForItem(id);
- }
- }else{
- var f = this.getBox(id);
- if(f){
- f.setValue(value);
- }
- }
- },
- beforeDestroy: function(){
- Ext.destroy(this.panel);
- Ext.form.CheckboxGroup.superclass.beforeDestroy.call(this);
- },
- setValueForItem : function(val){
- val = String(val).split(',');
- this.eachItem(function(item){
- if(val.indexOf(item.inputValue)> -1){
- item.setValue(true);
- }
- });
- },
- getBox : function(id){
- var box = null;
- this.eachItem(function(f){
- if(id == f || f.dataIndex == id || f.id == id || f.getName() == id){
- box = f;
- return false;
- }
- });
- return box;
- },
- getValue : function(){
- var out = [];
- this.eachItem(function(item){
- if(item.checked){
- out.push(item);
- }
- });
- return out;
- },
- eachItem: function(fn){
- if(this.items && this.items.each){
- this.items.each(fn, this);
- }
- },
- getRawValue : Ext.emptyFn,
- setRawValue : Ext.emptyFn
- });
- Ext.reg('checkboxgroup', Ext.form.CheckboxGroup);
- Ext.form.Radio = Ext.extend(Ext.form.Checkbox, {
- inputType: 'radio',
- markInvalid : Ext.emptyFn,
- clearInvalid : Ext.emptyFn,
- getGroupValue : function(){
- var p = this.el.up('form') || Ext.getBody();
- var c = p.child('input[name='+this.el.dom.name+']:checked', true);
- return c ? c.value : null;
- },
- onClick : function(){
- if(this.el.dom.checked != this.checked){
- var els = this.getCheckEl().select('input[name=' + this.el.dom.name + ']');
- els.each(function(el){
- if(el.dom.id == this.id){
- this.setValue(true);
- }else{
- Ext.getCmp(el.dom.id).setValue(false);
- }
- }, this);
- }
- },
- setValue : function(v){
- if (typeof v == 'boolean') {
- Ext.form.Radio.superclass.setValue.call(this, v);
- } else {
- var r = this.getCheckEl().child('input[name=' + this.el.dom.name + '][value=' + v + ']', true);
- if(r){
- Ext.getCmp(r.id).setValue(true);
- }
- }
- return this;
- },
- getCheckEl: function(){
- if(this.inGroup){
- return this.el.up('.x-form-radio-group')
- }
- return this.el.up('form') || Ext.getBody();
- }
- });
- Ext.reg('radio', Ext.form.Radio);
- Ext.form.RadioGroup = Ext.extend(Ext.form.CheckboxGroup, {
- allowBlank : true,
- blankText : 'You must select one item in this group',
- defaultType : 'radio',
- groupCls : 'x-form-radio-group',
- getValue : function(){
- var out = null;
- this.eachItem(function(item){
- if(item.checked){
- out = item;
- return false;
- }
- });
- return out;
- },
- onSetValue : function(id, value){
- if(arguments.length > 1){
- var f = this.getBox(id);
- if(f){
- f.setValue(value);
- if(f.checked){
- this.eachItem(function(item){
- if (item !== f){
- item.setValue(false);
- }
- });
- }
- }
- }else{
- this.setValueForItem(id);
- }
- },
- setValueForItem : function(val){
- val = String(val).split(',')[0];
- this.eachItem(function(item){
- item.setValue(val == item.inputValue);
- });
- },
- fireChecked : function(){
- if(!this.checkTask){
- this.checkTask = new Ext.util.DelayedTask(this.bufferChecked, this);
- }
- this.checkTask.delay(10);
- },
- bufferChecked : function(){
- var out = null;
- this.eachItem(function(item){
- if(item.checked){
- out = item;
- return false;
- }
- });
- this.fireEvent('change', this, out);
- },
- onDestroy : function(){
- if(this.checkTask){
- this.checkTask.cancel();
- this.checkTask = null;
- }
- Ext.form.RadioGroup.superclass.onDestroy.call(this);
- }
- });
- Ext.reg('radiogroup', Ext.form.RadioGroup);
- Ext.form.Hidden = Ext.extend(Ext.form.Field, {
- inputType : 'hidden',
- onRender : function(){
- Ext.form.Hidden.superclass.onRender.apply(this, arguments);
- },
- initEvents : function(){
- this.originalValue = this.getValue();
- },
- setSize : Ext.emptyFn,
- setWidth : Ext.emptyFn,
- setHeight : Ext.emptyFn,
- setPosition : Ext.emptyFn,
- setPagePosition : Ext.emptyFn,
- markInvalid : Ext.emptyFn,
- clearInvalid : Ext.emptyFn
- });
- Ext.reg('hidden', Ext.form.Hidden);
- Ext.form.BasicForm = function(el, config){
- Ext.apply(this, config);
- if(Ext.isString(this.paramOrder)){
- this.paramOrder = this.paramOrder.split(/[s,|]/);
- }
- this.items = new Ext.util.MixedCollection(false, function(o){
- return o.getItemId();
- });
- this.addEvents(
- 'beforeaction',
- 'actionfailed',
- 'actioncomplete'
- );
- if(el){
- this.initEl(el);
- }
- Ext.form.BasicForm.superclass.constructor.call(this);
- };
- Ext.extend(Ext.form.BasicForm, Ext.util.Observable, {
- timeout: 30,
- paramOrder: undefined,
- paramsAsHash: false,
- waitTitle: 'Please Wait...',
- activeAction : null,
- trackResetOnLoad : false,
- initEl : function(el){
- this.el = Ext.get(el);
- this.id = this.el.id || Ext.id();
- if(!this.standardSubmit){
- this.el.on('submit', this.onSubmit, this);
- }
- this.el.addClass('x-form');
- },
- getEl: function(){
- return this.el;
- },
- onSubmit : function(e){
- e.stopEvent();
- },
- destroy: function() {
- this.items.each(function(f){
- Ext.destroy(f);
- });
- if(this.el){
- this.el.removeAllListeners();
- this.el.remove();
- }
- this.purgeListeners();
- },
- isValid : function(){
- var valid = true;
- this.items.each(function(f){
- if(!f.validate()){
- valid = false;
- }
- });
- return valid;
- },
- isDirty : function(){
- var dirty = false;
- this.items.each(function(f){
- if(f.isDirty()){
- dirty = true;
- return false;
- }
- });
- return dirty;
- },
- doAction : function(action, options){
- if(Ext.isString(action)){
- action = new Ext.form.Action.ACTION_TYPES[action](this, options);
- }
- if(this.fireEvent('beforeaction', this, action) !== false){
- this.beforeAction(action);
- action.run.defer(100, action);
- }
- return this;
- },
- submit : function(options){
- if(this.standardSubmit){
- var v = this.isValid();
- if(v){
- var el = this.el.dom;
- if(this.url && Ext.isEmpty(el.action)){
- el.action = this.url;
- }
- el.submit();
- }
- return v;
- }
- var submitAction = String.format('{0}submit', this.api ? 'direct' : '');
- this.doAction(submitAction, options);
- return this;
- },
- load : function(options){
- var loadAction = String.format('{0}load', this.api ? 'direct' : '');
- this.doAction(loadAction, options);
- return this;
- },
- updateRecord : function(record){
- record.beginEdit();
- var fs = record.fields;
- fs.each(function(f){
- var field = this.findField(f.name);
- if(field){
- record.set(f.name, field.getValue());
- }
- }, this);
- record.endEdit();
- return this;
- },
- loadRecord : function(record){
- this.setValues(record.data);
- return this;
- },
- beforeAction : function(action){
- var o = action.options;
- if(o.waitMsg){
- if(this.waitMsgTarget === true){
- this.el.mask(o.waitMsg, 'x-mask-loading');
- }else if(this.waitMsgTarget){
- this.waitMsgTarget = Ext.get(this.waitMsgTarget);
- this.waitMsgTarget.mask(o.waitMsg, 'x-mask-loading');
- }else{
- Ext.MessageBox.wait(o.waitMsg, o.waitTitle || this.waitTitle);
- }
- }
- },
- afterAction : function(action, success){
- this.activeAction = null;
- var o = action.options;
- if(o.waitMsg){
- if(this.waitMsgTarget === true){
- this.el.unmask();
- }else if(this.waitMsgTarget){
- this.waitMsgTarget.unmask();
- }else{
- Ext.MessageBox.updateProgress(1);
- Ext.MessageBox.hide();
- }
- }
- if(success){
- if(o.reset){
- this.reset();
- }
- Ext.callback(o.success, o.scope, [this, action]);
- this.fireEvent('actioncomplete', this, action);
- }else{
- Ext.callback(o.failure, o.scope, [this, action]);
- this.fireEvent('actionfailed', this, action);
- }
- },
- findField : function(id){
- var field = this.items.get(id);
- if(!Ext.isObject(field)){
- this.items.each(function(f){
- if(f.isFormField && (f.dataIndex == id || f.id == id || f.getName() == id)){
- field = f;
- return false;
- }
- });
- }
- return field || null;
- },
- markInvalid : function(errors){
- if(Ext.isArray(errors)){
- for(var i = 0, len = errors.length; i < len; i++){
- var fieldError = errors[i];
- var f = this.findField(fieldError.id);
- if(f){
- f.markInvalid(fieldError.msg);
- }
- }
- }else{
- var field, id;
- for(id in errors){
- if(!Ext.isFunction(errors[id]) && (field = this.findField(id))){
- field.markInvalid(errors[id]);
- }
- }
- }
- return this;
- },
- setValues : function(values){
- if(Ext.isArray(values)){
- for(var i = 0, len = values.length; i < len; i++){
- var v = values[i];
- var f = this.findField(v.id);
- if(f){
- f.setValue(v.value);
- if(this.trackResetOnLoad){
- f.originalValue = f.getValue();
- }
- }
- }
- }else{
- var field, id;
- for(id in values){
- if(!Ext.isFunction(values[id]) && (field = this.findField(id))){
- field.setValue(values[id]);
- if(this.trackResetOnLoad){
- field.originalValue = field.getValue();
- }
- }
- }
- }
- return this;
- },
- getValues : function(asString){
- var fs = Ext.lib.Ajax.serializeForm(this.el.dom);
- if(asString === true){
- return fs;
- }
- return Ext.urlDecode(fs);
- },
- getFieldValues : function(dirtyOnly){
- var o = {},
- n,
- key,
- val;
- this.items.each(function(f){
- if(dirtyOnly !== true || f.isDirty()){
- n = f.getName();
- key = o[n];
- val = f.getValue();
- if(Ext.isDefined(key)){
- if(Ext.isArray(key)){
- o[n].push(val);
- }else{
- o[n] = [key, val];
- }
- }else{
- o[n] = val;
- }
- }
- });
- return o;
- },
- clearInvalid : function(){
- this.items.each(function(f){
- f.clearInvalid();
- });
- return this;
- },
- reset : function(){
- this.items.each(function(f){
- f.reset();
- });
- return this;
- },
- add : function(){
- this.items.addAll(Array.prototype.slice.call(arguments, 0));
- return this;
- },
- remove : function(field){
- this.items.remove(field);
- return this;
- },
- render : function(){
- this.items.each(function(f){
- if(f.isFormField && !f.rendered && document.getElementById(f.id)){
- f.applyToMarkup(f.id);
- }
- });
- return this;
- },
- applyToFields : function(o){
- this.items.each(function(f){
- Ext.apply(f, o);
- });
- return this;
- },
- applyIfToFields : function(o){
- this.items.each(function(f){
- Ext.applyIf(f, o);
- });
- return this;
- },
- callFieldMethod : function(fnName, args){
- args = args || [];
- this.items.each(function(f){
- if(Ext.isFunction(f[fnName])){
- f[fnName].apply(f, args);
- }
- });
- return this;
- }
- });
- Ext.BasicForm = Ext.form.BasicForm;
- Ext.FormPanel = Ext.extend(Ext.Panel, {
- minButtonWidth : 75,
- labelAlign : 'left',
- monitorValid : false,
- monitorPoll : 200,
- layout : 'form',
- initComponent : function(){
- this.form = this.createForm();
- Ext.FormPanel.superclass.initComponent.call(this);
- this.bodyCfg = {
- tag: 'form',
- cls: this.baseCls + '-body',
- method : this.method || 'POST',
- id : this.formId || Ext.id()
- };
- if(this.fileUpload) {
- this.bodyCfg.enctype = 'multipart/form-data';
- }
- this.initItems();
- this.addEvents(
- 'clientvalidation'
- );
- this.relayEvents(this.form, ['beforeaction', 'actionfailed', 'actioncomplete']);
- },
- createForm : function(){
- var config = Ext.applyIf({listeners: {}}, this.initialConfig);
- return new Ext.form.BasicForm(null, config);
- },
- initFields : function(){
- var f = this.form;
- var formPanel = this;
- var fn = function(c){
- if(formPanel.isField(c)){
- f.add(c);
- }else if(c.findBy && c != formPanel){
- formPanel.applySettings(c);
- if(c.items && c.items.each){
- c.items.each(fn, this);
- }
- }
- };
- this.items.each(fn, this);
- },
- applySettings: function(c){
- var ct = c.ownerCt;
- Ext.applyIf(c, {
- labelAlign: ct.labelAlign,
- labelWidth: ct.labelWidth,
- itemCls: ct.itemCls
- });
- },
- getLayoutTarget : function(){
- return this.form.el;
- },
- getForm : function(){
- return this.form;
- },
- onRender : function(ct, position){
- this.initFields();
- Ext.FormPanel.superclass.onRender.call(this, ct, position);
- this.form.initEl(this.body);
- },
- beforeDestroy : function(){
- this.stopMonitoring();
- Ext.destroy(this.form);
- this.form.items.clear();
- Ext.FormPanel.superclass.beforeDestroy.call(this);
- },
- isField : function(c) {
- return !!c.setValue && !!c.getValue && !!c.markInvalid && !!c.clearInvalid;
- },
- initEvents : function(){
- Ext.FormPanel.superclass.initEvents.call(this);
- this.on({
- scope: this,
- add: this.onAddEvent,
- remove: this.onRemoveEvent
- });
- if(this.monitorValid){
- this.startMonitoring();
- }
- },
- onAdd: function(c){
- Ext.FormPanel.superclass.onAdd.call(this, c);
- this.processAdd(c);
- },
- onAddEvent: function(ct, c){
- if(ct !== this){
- this.processAdd(c);
- }
- },
- processAdd : function(c){
- if(this.isField(c)){
- this.form.add(c);
- }else if(c.findBy){
- this.applySettings(c);
- this.form.add.apply(this.form, c.findBy(this.isField));
- }
- },
- onRemove: function(c){
- Ext.FormPanel.superclass.onRemove.call(this, c);
- this.processRemove(c);
- },
- onRemoveEvent: function(ct, c){
- if(ct !== this){
- this.processRemove(c);
- }
- },
- processRemove : function(c){
- if(this.isField(c)){
- this.form.remove(c);
- }else if(c.findBy){
- var isDestroyed = function(o) {
- return !!o.isDestroyed;
- }
- this.form.items.filterBy(isDestroyed, this.form).each(this.form.remove, this.form);
- }
- },
- startMonitoring : function(){
- if(!this.validTask){
- this.validTask = new Ext.util.TaskRunner();
- this.validTask.start({
- run : this.bindHandler,
- interval : this.monitorPoll || 200,
- scope: this
- });
- }
- },
- stopMonitoring : function(){
- if(this.validTask){
- this.validTask.stopAll();
- this.validTask = null;
- }
- },
- load : function(){
- this.form.load.apply(this.form, arguments);
- },
- onDisable : function(){
- Ext.FormPanel.superclass.onDisable.call(this);
- if(this.form){
- this.form.items.each(function(){
- this.disable();
- });
- }
- },
- onEnable : function(){
- Ext.FormPanel.superclass.onEnable.call(this);
- if(this.form){
- this.form.items.each(function(){
- this.enable();
- });
- }
- },
- bindHandler : function(){
- var valid = true;
- this.form.items.each(function(f){
- if(!f.isValid(true)){
- valid = false;
- return false;
- }
- });
- if(this.fbar){
- var fitems = this.fbar.items.items;
- for(var i = 0, len = fitems.length; i < len; i++){
- var btn = fitems[i];
- if(btn.formBind === true && btn.disabled === valid){
- btn.setDisabled(!valid);
- }
- }
- }
- this.fireEvent('clientvalidation', this, valid);
- }
- });
- Ext.reg('form', Ext.FormPanel);
- Ext.form.FormPanel = Ext.FormPanel;
- Ext.form.FieldSet = Ext.extend(Ext.Panel, {
- baseCls : 'x-fieldset',
- layout : 'form',
- animCollapse : false,
- onRender : function(ct, position){
- if(!this.el){
- this.el = document.createElement('fieldset');
- this.el.id = this.id;
- if (this.title || this.header || this.checkboxToggle) {
- this.el.appendChild(document.createElement('legend')).className = 'x-fieldset-header';
- }
- }
- Ext.form.FieldSet.superclass.onRender.call(this, ct, position);
- if(this.checkboxToggle){
- var o = typeof this.checkboxToggle == 'object' ?
- this.checkboxToggle :
- {tag: 'input', type: 'checkbox', name: this.checkboxName || this.id+'-checkbox'};
- this.checkbox = this.header.insertFirst(o);
- this.checkbox.dom.checked = !this.collapsed;
- this.mon(this.checkbox, 'click', this.onCheckClick, this);
- }
- },
- onCollapse : function(doAnim, animArg){
- if(this.checkbox){
- this.checkbox.dom.checked = false;
- }
- Ext.form.FieldSet.superclass.onCollapse.call(this, doAnim, animArg);
- },
- onExpand : function(doAnim, animArg){
- if(this.checkbox){
- this.checkbox.dom.checked = true;
- }
- Ext.form.FieldSet.superclass.onExpand.call(this, doAnim, animArg);
- },
- onCheckClick : function(){
- this[this.checkbox.dom.checked ? 'expand' : 'collapse']();
- }
- });
- Ext.reg('fieldset', Ext.form.FieldSet);
- Ext.form.HtmlEditor = Ext.extend(Ext.form.Field, {
- enableFormat : true,
- enableFontSize : true,
- enableColors : true,
- enableAlignments : true,
- enableLists : true,
- enableSourceEdit : true,
- enableLinks : true,
- enableFont : true,
- createLinkText : 'Please enter the URL for the link:',
- defaultLinkValue : 'http:/'+'/',
- fontFamilies : [
- 'Arial',
- 'Courier New',
- 'Tahoma',
- 'Times New Roman',
- 'Verdana'
- ],
- defaultFont: 'tahoma',
- defaultValue: (Ext.isOpera || Ext.isIE6) ? ' ' : '​',
- actionMode: 'wrap',
- validationEvent : false,
- deferHeight: true,
- initialized : false,
- activated : false,
- sourceEditMode : false,
- onFocus : Ext.emptyFn,
- iframePad:3,
- hideMode:'offsets',
- defaultAutoCreate : {
- tag: "textarea",
- style:"width:500px;height:300px;",
- autocomplete: "off"
- },
- initComponent : function(){
- this.addEvents(
- 'initialize',
- 'activate',
- 'beforesync',
- 'beforepush',
- 'sync',
- 'push',
- 'editmodechange'
- )
- },
- createFontOptions : function(){
- var buf = [], fs = this.fontFamilies, ff, lc;
- for(var i = 0, len = fs.length; i< len; i++){
- ff = fs[i];
- lc = ff.toLowerCase();
- buf.push(
- '<option value="',lc,'" style="font-family:',ff,';"',
- (this.defaultFont == lc ? ' selected="true">' : '>'),
- ff,
- '</option>'
- );
- }
- return buf.join('');
- },
- createToolbar : function(editor){
- var items = [];
- var tipsEnabled = Ext.QuickTips && Ext.QuickTips.isEnabled();
- function btn(id, toggle, handler){
- return {
- itemId : id,
- cls : 'x-btn-icon',
- iconCls: 'x-edit-'+id,
- enableToggle:toggle !== false,
- scope: editor,
- handler:handler||editor.relayBtnCmd,
- clickEvent:'mousedown',
- tooltip: tipsEnabled ? editor.buttonTips[id] || undefined : undefined,
- overflowText: editor.buttonTips[id].title || undefined,
- tabIndex:-1
- };
- }
- if(this.enableFont && !Ext.isSafari2){
- var fontSelectItem = new Ext.Toolbar.Item({
- autoEl: {
- tag:'select',
- cls:'x-font-select',
- html: this.createFontOptions()
- }
- });
- items.push(
- fontSelectItem,
- '-'
- );
- }
- if(this.enableFormat){
- items.push(
- btn('bold'),
- btn('italic'),
- btn('underline')
- );
- }
- if(this.enableFontSize){
- items.push(
- '-',
- btn('increasefontsize', false, this.adjustFont),
- btn('decreasefontsize', false, this.adjustFont)
- );
- }
- if(this.enableColors){
- items.push(
- '-', {
- itemId:'forecolor',
- cls:'x-btn-icon',
- iconCls: 'x-edit-forecolor',
- clickEvent:'mousedown',
- tooltip: tipsEnabled ? editor.buttonTips.forecolor || undefined : undefined,
- tabIndex:-1,
- menu : new Ext.menu.ColorMenu({
- allowReselect: true,
- focus: Ext.emptyFn,
- value:'000000',
- plain:true,
- listeners: {
- scope: this,
- select: function(cp, color){
- this.execCmd('forecolor', Ext.isWebKit || Ext.isIE ? '#'+color : color);
- this.deferFocus();
- }
- },
- clickEvent:'mousedown'
- })
- }, {
- itemId:'backcolor',
- cls:'x-btn-icon',
- iconCls: 'x-edit-backcolor',
- clickEvent:'mousedown',
- tooltip: tipsEnabled ? editor.buttonTips.backcolor || undefined : undefined,
- tabIndex:-1,
- menu : new Ext.menu.ColorMenu({
- focus: Ext.emptyFn,
- value:'FFFFFF',
- plain:true,
- allowReselect: true,
- listeners: {
- scope: this,
- select: function(cp, color){
- if(Ext.isGecko){
- this.execCmd('useCSS', false);
- this.execCmd('hilitecolor', color);
- this.execCmd('useCSS', true);
- this.deferFocus();
- }else{
- this.execCmd(Ext.isOpera ? 'hilitecolor' : 'backcolor', Ext.isWebKit || Ext.isIE ? '#'+color : color);
- this.deferFocus();
- }
- }
- },
- clickEvent:'mousedown'
- })
- }
- );
- }
- if(this.enableAlignments){
- items.push(
- '-',
- btn('justifyleft'),
- btn('justifycenter'),
- btn('justifyright')
- );
- }
- if(!Ext.isSafari2){
- if(this.enableLinks){
- items.push(
- '-',
- btn('createlink', false, this.createLink)
- );
- }
- if(this.enableLists){
- items.push(
- '-',
- btn('insertorderedlist'),
- btn('insertunorderedlist')
- );
- }
- if(this.enableSourceEdit){
- items.push(
- '-',
- btn('sourceedit', true, function(btn){
- this.toggleSourceEdit(!this.sourceEditMode);
- })
- );
- }
- }
- var tb = new Ext.Toolbar({
- renderTo: this.wrap.dom.firstChild,
- items: items
- });
- if (fontSelectItem) {
- this.fontSelect = fontSelectItem.el;
- this.mon(this.fontSelect, 'change', function(){
- var font = this.fontSelect.dom.value;
- this.relayCmd('fontname', font);
- this.deferFocus();
- }, this);
- }
- this.mon(tb.el, 'click', function(e){
- e.preventDefault();
- });
- this.tb = tb;
- },
- onDisable: function(){
- this.wrap.mask();
- Ext.form.HtmlEditor.superclass.onDisable.call(this);
- },
- onEnable: function(){
- this.wrap.unmask();
- Ext.form.HtmlEditor.superclass.onEnable.call(this);
- },
- setReadOnly: function(readOnly){
- if(this.initialized){
- var newDM = readOnly ? 'off' : 'on',
- doc = this.getDoc();
- if(String(doc.designMode).toLowerCase() != newDM){
- doc.designMode = newDM;
- }
- this.disableItems(!readOnly);
- }
- Ext.form.HtmlEditor.superclass.setReadOnly.call(this, readOnly);
- },
- getDocMarkup : function(){
- return '<html><head><style type="text/css">body{border:0;margin:0;padding:3px;height:98%;cursor:text;}</style></head><body></body></html>';
- },
- getEditorBody : function(){
- var doc = this.getDoc();
- return doc.body || doc.documentElement;
- },
- getDoc : function(){
- return Ext.isIE ? this.getWin().document : (this.iframe.contentDocument || this.getWin().document);
- },
- getWin : function(){
- return Ext.isIE ? this.iframe.contentWindow : window.frames[this.iframe.name];
- },
- onRender : function(ct, position){
- Ext.form.HtmlEditor.superclass.onRender.call(this, ct, position);
- this.el.dom.style.border = '0 none';
- this.el.dom.setAttribute('tabIndex', -1);
- this.el.addClass('x-hidden');
- if(Ext.isIE){
- this.el.applyStyles('margin-top:-1px;margin-bottom:-1px;')
- }
- this.wrap = this.el.wrap({
- cls:'x-html-editor-wrap', cn:{cls:'x-html-editor-tb'}
- });
- this.createToolbar(this);
- this.disableItems(true);
- this.createIFrame();
- if(!this.width){
- var sz = this.el.getSize();
- this.setSize(sz.width, this.height || sz.height);
- }
- this.resizeEl = this.positionEl = this.wrap;
- },
- createIFrame: function(){
- var iframe = document.createElement('iframe');
- iframe.name = Ext.id();
- iframe.frameBorder = '0';
- iframe.src = Ext.SSL_SECURE_URL;
- this.wrap.dom.appendChild(iframe);
- this.iframe = iframe;
- this.monitorTask = Ext.TaskMgr.start({
- run: this.checkDesignMode,
- scope: this,
- interval:100
- });
- },
- initFrame : function(){
- Ext.TaskMgr.stop(this.monitorTask);
- var doc = this.getDoc();
- this.win = this.getWin();
- doc.open();
- doc.write(this.getDocMarkup());
- doc.close();
- var task = {
- run : function(){
- var doc = this.getDoc();
- if(doc.body || doc.readyState == 'complete'){
- Ext.TaskMgr.stop(task);
- doc.designMode="on";
- this.initEditor.defer(10, this);
- }
- },
- interval : 10,
- duration:10000,
- scope: this
- };
- Ext.TaskMgr.start(task);
- },
- checkDesignMode : function(){
- if(this.wrap && this.wrap.dom.offsetWidth){
- var doc = this.getDoc();
- if(!doc){
- return;
- }
- if(!doc.editorInitialized || String(doc.designMode).toLowerCase() != 'on'){
- this.initFrame();
- }
- }
- },
- disableItems: function(disabled){
- if(this.fontSelect){
- this.fontSelect.dom.disabled = disabled;
- }
- this.tb.items.each(function(item){
- if(item.getItemId() != 'sourceedit'){
- item.setDisabled(disabled);
- }
- });
- },
- onResize : function(w, h){
- Ext.form.HtmlEditor.superclass.onResize.apply(this, arguments);
- if(this.el && this.iframe){
- if(Ext.isNumber(w)){
- var aw = w - this.wrap.getFrameWidth('lr');
- this.el.setWidth(aw);
- this.tb.setWidth(aw);
- this.iframe.style.width = Math.max(aw, 0) + 'px';
- }
- if(Ext.isNumber(h)){
- var ah = h - this.wrap.getFrameWidth('tb') - this.tb.el.getHeight();
- this.el.setHeight(ah);
- this.iframe.style.height = Math.max(ah, 0) + 'px';
- var bd = this.getEditorBody();
- if(bd){
- bd.style.height = Math.max((ah - (this.iframePad*2)), 0) + 'px';
- }
- }
- }
- },
- toggleSourceEdit : function(sourceEditMode){
- if(sourceEditMode === undefined){
- sourceEditMode = !this.sourceEditMode;
- }
- this.sourceEditMode = sourceEditMode === true;
- var btn = this.tb.getComponent('sourceedit');
- if(btn.pressed !== this.sourceEditMode){
- btn.toggle(this.sourceEditMode);
- if(!btn.xtbHidden){
- return;
- }
- }
- if(this.sourceEditMode){
- this.disableItems(true);
- this.syncValue();
- this.iframe.className = 'x-hidden';
- this.el.removeClass('x-hidden');
- this.el.dom.removeAttribute('tabIndex');
- this.el.focus();
- }else{
- if(this.initialized && !this.readOnly){
- this.disableItems(false);
- }
- this.pushValue();
- this.iframe.className = '';
- this.el.addClass('x-hidden');
- this.el.dom.setAttribute('tabIndex', -1);
- this.deferFocus();
- }
- var lastSize = this.lastSize;
- if(lastSize){
- delete this.lastSize;
- this.setSize(lastSize);
- }
- this.fireEvent('editmodechange', this, this.sourceEditMode);
- },
- createLink : function(){
- var url = prompt(this.createLinkText, this.defaultLinkValue);
- if(url && url != 'http:/'+'/'){
- this.relayCmd('createlink', url);
- }
- },
- initEvents : function(){
- this.originalValue = this.getValue();
- },
- markInvalid : Ext.emptyFn,
- clearInvalid : Ext.emptyFn,
- setValue : function(v){
- Ext.form.HtmlEditor.superclass.setValue.call(this, v);
- this.pushValue();
- return this;
- },
- cleanHtml: function(html) {
- html = String(html);
- if(Ext.isWebKit){
- html = html.replace(/sclass="(?:Apple-style-span|khtml-block-placeholder)"/gi, '');
- }
- if(html.charCodeAt(0) == this.defaultValue.replace(/D/g, '')){
- html = html.substring(1);
- }
- return html;
- },
- syncValue : function(){
- if(this.initialized){
- var bd = this.getEditorBody();
- var html = bd.innerHTML;
- if(Ext.isWebKit){
- var bs = bd.getAttribute('style');
- var m = bs.match(/text-align:(.*?);/i);
- if(m && m[1]){
- html = '<div style="'+m[0]+'">' + html + '</div>';
- }
- }
- html = this.cleanHtml(html);
- if(this.fireEvent('beforesync', this, html) !== false){
- this.el.dom.value = html;
- this.fireEvent('sync', this, html);
- }
- }
- },
- getValue : function() {
- this[this.sourceEditMode ? 'pushValue' : 'syncValue']();
- return Ext.form.HtmlEditor.superclass.getValue.call(this);
- },
- pushValue : function(){
- if(this.initialized){
- var v = this.el.dom.value;
- if(!this.activated && v.length < 1){
- v = this.defaultValue;
- }
- if(this.fireEvent('beforepush', this, v) !== false){
- this.getEditorBody().innerHTML = v;
- if(Ext.isGecko){
- var d = this.getDoc(),
- mode = d.designMode.toLowerCase();
- d.designMode = mode.toggle('on', 'off');
- d.designMode = mode;
- }
- this.fireEvent('push', this, v);
- }
- }
- },
- deferFocus : function(){
- this.focus.defer(10, this);
- },
- focus : function(){
- if(this.win && !this.sourceEditMode){
- this.win.focus();
- }else{
- this.el.focus();
- }
- },
- initEditor : function(){
- try{
- var dbody = this.getEditorBody(),
- ss = this.el.getStyles('font-size', 'font-family', 'background-image', 'background-repeat'),
- doc,
- fn;
- ss['background-attachment'] = 'fixed';
- dbody.bgProperties = 'fixed';
- Ext.DomHelper.applyStyles(dbody, ss);
- doc = this.getDoc();
- if(doc){
- try{
- Ext.EventManager.removeAll(doc);
- }catch(e){}
- }
- fn = this.onEditorEvent.createDelegate(this);
- Ext.EventManager.on(doc, {
- mousedown: fn,
- dblclick: fn,
- click: fn,
- keyup: fn,
- buffer:100
- });
- if(Ext.isGecko){
- Ext.EventManager.on(doc, 'keypress', this.applyCommand, this);
- }
- if(Ext.isIE || Ext.isWebKit || Ext.isOpera){
- Ext.EventManager.on(doc, 'keydown', this.fixKeys, this);
- }
- doc.editorInitialized = true;
- this.initialized = true;
- this.pushValue();
- this.setReadOnly(this.readOnly);
- this.fireEvent('initialize', this);
- }catch(e){}
- },
- onDestroy : function(){
- if(this.monitorTask){
- Ext.TaskMgr.stop(this.monitorTask);
- }
- if(this.rendered){
- Ext.destroy(this.tb);
- var doc = this.getDoc();
- if(doc){
- try{
- Ext.EventManager.removeAll(doc);
- for (var prop in doc){
- delete doc[prop];
- }
- }catch(e){}
- }
- if(this.wrap){
- this.wrap.dom.innerHTML = '';
- this.wrap.remove();
- }
- }
- if(this.el){
- this.el.removeAllListeners();
- this.el.remove();
- }
- this.purgeListeners();
- },
- onFirstFocus : function(){
- this.activated = true;
- this.disableItems(false);
- if(Ext.isGecko){
- this.win.focus();
- var s = this.win.getSelection();
- if(!s.focusNode || s.focusNode.nodeType != 3){
- var r = s.getRangeAt(0);
- r.selectNodeContents(this.getEditorBody());
- r.collapse(true);
- this.deferFocus();
- }
- try{
- this.execCmd('useCSS', true);
- this.execCmd('styleWithCSS', false);
- }catch(e){}
- }
- this.fireEvent('activate', this);
- },
- adjustFont: function(btn){
- var adjust = btn.getItemId() == 'increasefontsize' ? 1 : -1,
- doc = this.getDoc(),
- v = parseInt(doc.queryCommandValue('FontSize') || 2, 10);
- if((Ext.isSafari && !Ext.isSafari2) || Ext.isChrome || Ext.isAir){
- if(v <= 10){
- v = 1 + adjust;
- }else if(v <= 13){
- v = 2 + adjust;
- }else if(v <= 16){
- v = 3 + adjust;
- }else if(v <= 18){
- v = 4 + adjust;
- }else if(v <= 24){
- v = 5 + adjust;
- }else {
- v = 6 + adjust;
- }
- v = v.constrain(1, 6);
- }else{
- if(Ext.isSafari){
- adjust *= 2;
- }
- v = Math.max(1, v+adjust) + (Ext.isSafari ? 'px' : 0);
- }
- this.execCmd('FontSize', v);
- },
- onEditorEvent : function(e){
- this.updateToolbar();
- },
- updateToolbar: function(){
- if(this.readOnly){
- return;
- }
- if(!this.activated){
- this.onFirstFocus();
- return;
- }
- var btns = this.tb.items.map,
- doc = this.getDoc();
- if(this.enableFont && !Ext.isSafari2){
- var name = (doc.queryCommandValue('FontName')||this.defaultFont).toLowerCase();
- if(name != this.fontSelect.dom.value){
- this.fontSelect.dom.value = name;
- }
- }
- if(this.enableFormat){
- btns.bold.toggle(doc.queryCommandState('bold'));
- btns.italic.toggle(doc.queryCommandState('italic'));
- btns.underline.toggle(doc.queryCommandState('underline'));
- }
- if(this.enableAlignments){
- btns.justifyleft.toggle(doc.queryCommandState('justifyleft'));
- btns.justifycenter.toggle(doc.queryCommandState('justifycenter'));
- btns.justifyright.toggle(doc.queryCommandState('justifyright'));
- }
- if(!Ext.isSafari2 && this.enableLists){
- btns.insertorderedlist.toggle(doc.queryCommandState('insertorderedlist'));
- btns.insertunorderedlist.toggle(doc.queryCommandState('insertunorderedlist'));
- }
- Ext.menu.MenuMgr.hideAll();
- this.syncValue();
- },
- relayBtnCmd : function(btn){
- this.relayCmd(btn.getItemId());
- },
- relayCmd : function(cmd, value){
- (function(){
- this.focus();
- this.execCmd(cmd, value);
- this.updateToolbar();
- }).defer(10, this);
- },
- execCmd : function(cmd, value){
- var doc = this.getDoc();
- doc.execCommand(cmd, false, value === undefined ? null : value);
- this.syncValue();
- },
- applyCommand : function(e){
- if(e.ctrlKey){
- var c = e.getCharCode(), cmd;
- if(c > 0){
- c = String.fromCharCode(c);
- switch(c){
- case 'b':
- cmd = 'bold';
- break;
- case 'i':
- cmd = 'italic';
- break;
- case 'u':
- cmd = 'underline';
- break;
- }
- if(cmd){
- this.win.focus();
- this.execCmd(cmd);
- this.deferFocus();
- e.preventDefault();
- }
- }
- }
- },
- insertAtCursor : function(text){
- if(!this.activated){
- return;
- }
- if(Ext.isIE){
- this.win.focus();
- var doc = this.getDoc(),
- r = doc.selection.createRange();
- if(r){
- r.pasteHTML(text);
- this.syncValue();
- this.deferFocus();
- }
- }else{
- this.win.focus();
- this.execCmd('InsertHTML', text);
- this.deferFocus();
- }
- },
- fixKeys : function(){
- if(Ext.isIE){
- return function(e){
- var k = e.getKey(),
- doc = this.getDoc(),
- r;
- if(k == e.TAB){
- e.stopEvent();
- r = doc.selection.createRange();
- if(r){
- r.collapse(true);
- r.pasteHTML(' ');
- this.deferFocus();
- }
- }else if(k == e.ENTER){
- r = doc.selection.createRange();
- if(r){
- var target = r.parentElement();
- if(!target || target.tagName.toLowerCase() != 'li'){
- e.stopEvent();
- r.pasteHTML('<br />');
- r.collapse(false);
- r.select();
- }
- }
- }
- };
- }else if(Ext.isOpera){
- return function(e){
- var k = e.getKey();
- if(k == e.TAB){
- e.stopEvent();
- this.win.focus();
- this.execCmd('InsertHTML',' ');
- this.deferFocus();
- }
- };
- }else if(Ext.isWebKit){
- return function(e){
- var k = e.getKey();
- if(k == e.TAB){
- e.stopEvent();
- this.execCmd('InsertText','t');
- this.deferFocus();
- }else if(k == e.ENTER){
- e.stopEvent();
- this.execCmd('InsertHtml','<br /><br />');
- this.deferFocus();
- }
- };
- }
- }(),
- getToolbar : function(){
- return this.tb;
- },
- buttonTips : {
- bold : {
- title: 'Bold (Ctrl+B)',
- text: 'Make the selected text bold.',
- cls: 'x-html-editor-tip'
- },
- italic : {
- title: 'Italic (Ctrl+I)',
- text: 'Make the selected text italic.',
- cls: 'x-html-editor-tip'
- },
- underline : {
- title: 'Underline (Ctrl+U)',
- text: 'Underline the selected text.',
- cls: 'x-html-editor-tip'
- },
- increasefontsize : {
- title: 'Grow Text',
- text: 'Increase the font size.',
- cls: 'x-html-editor-tip'
- },
- decreasefontsize : {
- title: 'Shrink Text',
- text: 'Decrease the font size.',
- cls: 'x-html-editor-tip'
- },
- backcolor : {
- title: 'Text Highlight Color',
- text: 'Change the background color of the selected text.',
- cls: 'x-html-editor-tip'
- },
- forecolor : {
- title: 'Font Color',
- text: 'Change the color of the selected text.',
- cls: 'x-html-editor-tip'
- },
- justifyleft : {
- title: 'Align Text Left',
- text: 'Align text to the left.',
- cls: 'x-html-editor-tip'
- },
- justifycenter : {
- title: 'Center Text',
- text: 'Center text in the editor.',
- cls: 'x-html-editor-tip'
- },
- justifyright : {
- title: 'Align Text Right',
- text: 'Align text to the right.',
- cls: 'x-html-editor-tip'
- },
- insertunorderedlist : {
- title: 'Bullet List',
- text: 'Start a bulleted list.',
- cls: 'x-html-editor-tip'
- },
- insertorderedlist : {
- title: 'Numbered List',
- text: 'Start a numbered list.',
- cls: 'x-html-editor-tip'
- },
- createlink : {
- title: 'Hyperlink',
- text: 'Make the selected text a hyperlink.',
- cls: 'x-html-editor-tip'
- },
- sourceedit : {
- title: 'Source Edit',
- text: 'Switch to source editing mode.',
- cls: 'x-html-editor-tip'
- }
- }
- });
- Ext.reg('htmleditor', Ext.form.HtmlEditor);
- Ext.form.TimeField = Ext.extend(Ext.form.ComboBox, {
- minValue : undefined,
- maxValue : undefined,
- minText : "The time in this field must be equal to or after {0}",
- maxText : "The time in this field must be equal to or before {0}",
- invalidText : "{0} is not a valid time",
- format : "g:i A",
- altFormats : "g:ia|g:iA|g:i a|g:i A|h:i|g:i|H:i|ga|ha|gA|h a|g a|g A|gi|hi|gia|hia|g|H",
- increment: 15,
- mode: 'local',
- triggerAction: 'all',
- typeAhead: false,
- initDate: '1/1/2008',
- initComponent : function(){
- if(Ext.isDefined(this.minValue)){
- this.setMinValue(this.minValue, true);
- }
- if(Ext.isDefined(this.maxValue)){
- this.setMaxValue(this.maxValue, true);
- }
- if(!this.store){
- this.generateStore(true);
- }
- Ext.form.TimeField.superclass.initComponent.call(this);
- },
- setMinValue: function(value, initial){
- this.setLimit(value, true, initial);
- return this;
- },
- setMaxValue: function(value, initial){
- this.setLimit(value, false, initial);
- return this;
- },
- generateStore: function(initial){
- var min = this.minValue || new Date(this.initDate).clearTime(),
- max = this.maxValue || new Date(this.initDate).clearTime().add('mi', (24 * 60) - 1),
- times = [];
- while(min <= max){
- times.push(min.dateFormat(this.format));
- min = min.add('mi', this.increment);
- }
- this.bindStore(times, initial);
- },
- setLimit: function(value, isMin, initial){
- var d;
- if(Ext.isString(value)){
- d = this.parseDate(value);
- }else if(Ext.isDate(value)){
- d = value;
- }
- if(d){
- var val = new Date(this.initDate).clearTime();
- val.setHours(d.getHours(), d.getMinutes(), isMin ? 0 : 59, 0);
- this[isMin ? 'minValue' : 'maxValue'] = val;
- if(!initial){
- this.generateStore();
- }
- }
- },
- getValue : function(){
- var v = Ext.form.TimeField.superclass.getValue.call(this);
- return this.formatDate(this.parseDate(v)) || '';
- },
- setValue : function(value){
- return Ext.form.TimeField.superclass.setValue.call(this, this.formatDate(this.parseDate(value)));
- },
- validateValue : Ext.form.DateField.prototype.validateValue,
- parseDate : Ext.form.DateField.prototype.parseDate,
- formatDate : Ext.form.DateField.prototype.formatDate,
- beforeBlur : function(){
- var v = this.parseDate(this.getRawValue());
- if(v){
- this.setValue(v.dateFormat(this.format));
- }
- Ext.form.TimeField.superclass.beforeBlur.call(this);
- }
- });
- Ext.reg('timefield', Ext.form.TimeField);
- Ext.form.Label = Ext.extend(Ext.BoxComponent, {
- onRender : function(ct, position){
- if(!this.el){
- this.el = document.createElement('label');
- this.el.id = this.getId();
- this.el.innerHTML = this.text ? Ext.util.Format.htmlEncode(this.text) : (this.html || '');
- if(this.forId){
- this.el.setAttribute('for', this.forId);
- }
- }
- Ext.form.Label.superclass.onRender.call(this, ct, position);
- },
- setText : function(t, encode){
- var e = encode === false;
- this[!e ? 'text' : 'html'] = t;
- delete this[e ? 'text' : 'html'];
- if(this.rendered){
- this.el.dom.innerHTML = encode !== false ? Ext.util.Format.htmlEncode(t) : t;
- }
- return this;
- }
- });
- Ext.reg('label', Ext.form.Label);
- Ext.form.Action = function(form, options){
- this.form = form;
- this.options = options || {};
- };
- Ext.form.Action.CLIENT_INVALID = 'client';
- Ext.form.Action.SERVER_INVALID = 'server';
- Ext.form.Action.CONNECT_FAILURE = 'connect';
- Ext.form.Action.LOAD_FAILURE = 'load';
- Ext.form.Action.prototype = {
- type : 'default',
- run : function(options){
- },
- success : function(response){
- },
- handleResponse : function(response){
- },
- failure : function(response){
- this.response = response;
- this.failureType = Ext.form.Action.CONNECT_FAILURE;
- this.form.afterAction(this, false);
- },
- processResponse : function(response){
- this.response = response;
- if(!response.responseText && !response.responseXML){
- return true;
- }
- this.result = this.handleResponse(response);
- return this.result;
- },
- getUrl : function(appendParams){
- var url = this.options.url || this.form.url || this.form.el.dom.action;
- if(appendParams){
- var p = this.getParams();
- if(p){
- url = Ext.urlAppend(url, p);
- }
- }
- return url;
- },
- getMethod : function(){
- return (this.options.method || this.form.method || this.form.el.dom.method || 'POST').toUpperCase();
- },
- getParams : function(){
- var bp = this.form.baseParams;
- var p = this.options.params;
- if(p){
- if(typeof p == "object"){
- p = Ext.urlEncode(Ext.applyIf(p, bp));
- }else if(typeof p == 'string' && bp){
- p += '&' + Ext.urlEncode(bp);
- }
- }else if(bp){
- p = Ext.urlEncode(bp);
- }
- return p;
- },
- createCallback : function(opts){
- var opts = opts || {};
- return {
- success: this.success,
- failure: this.failure,
- scope: this,
- timeout: (opts.timeout*1000) || (this.form.timeout*1000),
- upload: this.form.fileUpload ? this.success : undefined
- };
- }
- };
- Ext.form.Action.Submit = function(form, options){
- Ext.form.Action.Submit.superclass.constructor.call(this, form, options);
- };
- Ext.extend(Ext.form.Action.Submit, Ext.form.Action, {
- type : 'submit',
- run : function(){
- var o = this.options;
- var method = this.getMethod();
- var isGet = method == 'GET';
- if(o.clientValidation === false || this.form.isValid()){
- Ext.Ajax.request(Ext.apply(this.createCallback(o), {
- form:this.form.el.dom,
- url:this.getUrl(isGet),
- method: method,
- headers: o.headers,
- params:!isGet ? this.getParams() : null,
- isUpload: this.form.fileUpload
- }));
- }else if (o.clientValidation !== false){
- this.failureType = Ext.form.Action.CLIENT_INVALID;
- this.form.afterAction(this, false);
- }
- },
- success : function(response){
- var result = this.processResponse(response);
- if(result === true || result.success){
- this.form.afterAction(this, true);
- return;
- }
- if(result.errors){
- this.form.markInvalid(result.errors);
- }
- this.failureType = Ext.form.Action.SERVER_INVALID;
- this.form.afterAction(this, false);
- },
- handleResponse : function(response){
- if(this.form.errorReader){
- var rs = this.form.errorReader.read(response);
- var errors = [];
- if(rs.records){
- for(var i = 0, len = rs.records.length; i < len; i++) {
- var r = rs.records[i];
- errors[i] = r.data;
- }
- }
- if(errors.length < 1){
- errors = null;
- }
- return {
- success : rs.success,
- errors : errors
- };
- }
- return Ext.decode(response.responseText);
- }
- });
- Ext.form.Action.Load = function(form, options){
- Ext.form.Action.Load.superclass.constructor.call(this, form, options);
- this.reader = this.form.reader;
- };
- Ext.extend(Ext.form.Action.Load, Ext.form.Action, {
- type : 'load',
- run : function(){
- Ext.Ajax.request(Ext.apply(
- this.createCallback(this.options), {
- method:this.getMethod(),
- url:this.getUrl(false),
- headers: this.options.headers,
- params:this.getParams()
- }));
- },
- success : function(response){
- var result = this.processResponse(response);
- if(result === true || !result.success || !result.data){
- this.failureType = Ext.form.Action.LOAD_FAILURE;
- this.form.afterAction(this, false);
- return;
- }
- this.form.clearInvalid();
- this.form.setValues(result.data);
- this.form.afterAction(this, true);
- },
- handleResponse : function(response){
- if(this.form.reader){
- var rs = this.form.reader.read(response);
- var data = rs.records && rs.records[0] ? rs.records[0].data : null;
- return {
- success : rs.success,
- data : data
- };
- }
- return Ext.decode(response.responseText);
- }
- });
- Ext.form.Action.DirectLoad = Ext.extend(Ext.form.Action.Load, {
- constructor: function(form, opts) {
- Ext.form.Action.DirectLoad.superclass.constructor.call(this, form, opts);
- },
- type : 'directload',
- run : function(){
- var args = this.getParams();
- args.push(this.success, this);
- this.form.api.load.apply(window, args);
- },
- getParams : function() {
- var buf = [], o = {};
- var bp = this.form.baseParams;
- var p = this.options.params;
- Ext.apply(o, p, bp);
- var paramOrder = this.form.paramOrder;
- if(paramOrder){
- for(var i = 0, len = paramOrder.length; i < len; i++){
- buf.push(o[paramOrder[i]]);
- }
- }else if(this.form.paramsAsHash){
- buf.push(o);
- }
- return buf;
- },
- processResponse : function(result) {
- this.result = result;
- return result;
- },
- success : function(response, trans){
- if(trans.type == Ext.Direct.exceptions.SERVER){
- response = {};
- }
- Ext.form.Action.DirectLoad.superclass.success.call(this, response);
- }
- });
- Ext.form.Action.DirectSubmit = Ext.extend(Ext.form.Action.Submit, {
- constructor : function(form, opts) {
- Ext.form.Action.DirectSubmit.superclass.constructor.call(this, form, opts);
- },
- type : 'directsubmit',
- run : function(){
- var o = this.options;
- if(o.clientValidation === false || this.form.isValid()){
- this.success.params = this.getParams();
- this.form.api.submit(this.form.el.dom, this.success, this);
- }else if (o.clientValidation !== false){
- this.failureType = Ext.form.Action.CLIENT_INVALID;
- this.form.afterAction(this, false);
- }
- },
- getParams : function() {
- var o = {};
- var bp = this.form.baseParams;
- var p = this.options.params;
- Ext.apply(o, p, bp);
- return o;
- },
- processResponse : function(result) {
- this.result = result;
- return result;
- },
- success : function(response, trans){
- if(trans.type == Ext.Direct.exceptions.SERVER){
- response = {};
- }
- Ext.form.Action.DirectSubmit.superclass.success.call(this, response);
- }
- });
- Ext.form.Action.ACTION_TYPES = {
- 'load' : Ext.form.Action.Load,
- 'submit' : Ext.form.Action.Submit,
- 'directload' : Ext.form.Action.DirectLoad,
- 'directsubmit' : Ext.form.Action.DirectSubmit
- };
- Ext.form.VTypes = function(){
- var alpha = /^[a-zA-Z_]+$/,
- alphanum = /^[a-zA-Z0-9_]+$/,
- email = /^(w+)([-+.][w]+)*@(w[-w]*.){1,5}([A-Za-z]){2,6}$/,
- url = /(((^https?)|(^ftp))://([-w]+.)+w{2,3}(/[%-w]+(.w{2,})?)*(([w-.?\/+@&#;`~=%!]*)(.w{2,})?)*/?)/i;
- return {
- 'email' : function(v){
- return email.test(v);
- },
- 'emailText' : 'This field should be an e-mail address in the format "user@example.com"',
- 'emailMask' : /[a-z0-9_.-@]/i,
- 'url' : function(v){
- return url.test(v);
- },
- 'urlText' : 'This field should be a URL in the format "http:/'+'/www.example.com"',
- 'alpha' : function(v){
- return alpha.test(v);
- },
- 'alphaText' : 'This field should only contain letters and _',
- 'alphaMask' : /[a-z_]/i,
- 'alphanum' : function(v){
- return alphanum.test(v);
- },
- 'alphanumText' : 'This field should only contain letters, numbers and _',
- 'alphanumMask' : /[a-z0-9_]/i
- };
- }();
- Ext.grid.GridPanel = Ext.extend(Ext.Panel, {
- autoExpandColumn : false,
- autoExpandMax : 1000,
- autoExpandMin : 50,
- columnLines : false,
- ddText : '{0} selected row{1}',
- deferRowRender : true,
- enableColumnHide : true,
- enableColumnMove : true,
- enableDragDrop : false,
- enableHdMenu : true,
- loadMask : false,
- minColumnWidth : 25,