Ext.namespace('Fw.ctrl'); var NUMBER_BASE_CHARS = "0123456789"; var LOWER_CHAR_BASE_CHARS = "abcdefghijklmnopqrstuvwxyz"; var UPPER_CHAR_BASE_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; var OTHER_BASE_CHARS = "`~!@#$%^&*_()\\-+=|\\\\{}:;\"/',.<>\\[\\]"; var BLANK_BASE_CHARS = " "; var PART_ALLOW_BASE_CHARS = NUMBER_BASE_CHARS + LOWER_CHAR_BASE_CHARS + UPPER_CHAR_BASE_CHARS; var ALL_ALLOW_BASE_CHARS = PART_ALLOW_BASE_CHARS + OTHER_BASE_CHARS + BLANK_BASE_CHARS; var ALLOW_BASE_CHARS_NOBLANK = PART_ALLOW_BASE_CHARS + OTHER_BASE_CHARS; var TEXT_MIN_LENGTH_CONST = 0; var TEXT_MAX_LENGTH_CONST = 64; var TEXTAREA_MAX_LENGTH_CONST = 500; var NUMBER_MIN_VALUE_CONST = Number.NEGATIVE_INFINITY; var NUMBER_MAX_VALUE_CONST = Number.MAX_VALUE; var FIELD_WIDTH_CONST = 140; var FIELD_LABEL_WIDTH_CONST = 200; var TEXTAREA_WIDTH_CONST = 180; var TEXT_INVALID_CHARS_CONST = '[ "?*|\:<>]'; Fw.regExpObj = { chinese : new RegExp('[\u0391-\uFFE5]', 'gi'), chineseAndBlank : new RegExp('[\u0391-\uFFE5 ]', 'gi'), ipAndMask : new RegExp('[0-9./-]', 'gi'), noblank : new RegExp('[- ?,]', 'gi'), number : new RegExp('[0-9]', 'gi'), letter : FW_REGEX_TEMPLATE.FW_FWIPTEXTFIELD_ALLOWLETTER } Fw.cutChar = function(e) { var k = e.getKey(); var obj = this, reverseReg = obj.reverseReg; if (k == e.ENTER) { e.stopEvent(); } if (!Ext.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)) { return; } var inputStr = this.getValue(); if (typeof(inputStr) == 'number') { inputStr = new Number(inputStr).toString(); } var result, regObj = this.regObj;resultFlag = false; if (regObj) { var type = e.browserEvent.type; if (type == 'keypress') { var c = e.getCharCode(); result = String.fromCharCode(c).match(regObj); if (reverseReg) { result ? e.stopEvent() : ''; } else { result ? '' : e.stopEvent(); } } else { var flagStr = true,noblankChar=false,valaBlankChar=true; var strLength = inputStr.length - 1; var nochineseFlag=this.nochineseFlag,valueLength=0; if (strLength != -1) { inputStr = inputStr.replace(this.allRegObj, function(a, b, c) { if (!nochineseFlag) { if (a.match(Fw.regExpObj.chinese)) { valueLength += 2; } else { valueLength += 1; } if (valueLength > obj.lengthBak) { resultFlag = true; return ''; } } if (result = a.match(regObj)) { if (reverseReg) { flagStr = ''; resultFlag = true; } else { flagStr = a; } } else { if (reverseReg) { flagStr = a; } else { flagStr = ''; resultFlag = true; } } return flagStr; }); } if (resultFlag) { this.setValue(inputStr); } } } if (this.maxLengthValidata) { inputStr = this.maxLengthValidata(inputStr); } } Fw.ctrl.ipTextField = Ext.extend(Ext.form.TextField, { labelStyle : 'margin-left:0px;width:130px;', allowBlank : false, isDisplay : true, blankText : fw_common.ctrl_field_blankText, fieldLabel : '', minLength : TEXT_MIN_LENGTH_CONST, maxLength : TEXT_MAX_LENGTH_CONST, maxLengthText : fw_common.ctrl_field_maxLengthText, minLengthText : fw_common.ctrl_field_minLengthText, width : FIELD_WIDTH_CONST, labelWidth : FIELD_LABEL_WIDTH_CONST, baseChars : ALL_ALLOW_BASE_CHARS, numberChars : NUMBER_BASE_CHARS, allowFirst : '', allowFirstMsg : fw_common.vfwNamevalidemsg, note : '', regExpObj : Fw.regExpObj, allRegObj : new RegExp('.{1}', 'g'), regExpObjFlag : 'noblank', reverseReg : true, blankFlag : false, labelSeparator : '', msgTarget : 'qtip', enableKeyEvents : true, constructor : function(property) { Fw.ctrl.ipTextField.superclass.constructor.call(this, property); if (this.regExpObjFlag && !(this.regObj = this.regExpObj[this.regExpObjFlag])) { this.regObj = new RegExp('[' + this.regExpObjFlag + ']', 'g') } if (this.allowFirst && !(this.allowFirst = this.regExpObj[this.allowFirst])) { } this.autoCreate = { tag : "input", type : "text", autocomplete : "off", maxLength : this.maxLength } this.lengthBak = this.maxLength; }, cutCHNChar : Fw.cutChar, onKeyUp : function(e){ this.cutCHNChar(e); this.fireEvent('keyup', this, e); }, onKeyPress : function(e){ this.cutCHNChar(e); this.fireEvent('keypress', this, e); }, onClick : function(e) { this.fireEvent('click', this, e); }, onChange : function(e) { this.fireEvent('change', this, e); }, onMouseover : function(e) { this.fireEvent('mouseover', this, e); }, ipOnblur : function(e) { this.cutCHNChar(e); }, allowBlankEvent : function() { if (this.allowBlank === false) { this.allowBlank_fontEl.dom.innerHTML = '  *'; this.allowBlank_fontEl.setStyle('color', this.disabled ? 'Silver' : 'red'); } else { this.allowBlank_fontEl.dom.innerHTML = ''; } if (this.note) { this.noteEl.dom.innerHTML = this.note; } }, initEvents : function() { Fw.ctrl.ipTextField.superclass.initEvents.call(this); this.on({ 'disable' : { fn : function(obj) { if (this.allowBlank_fontEl) { this.allowBlank_fontEl.setStyle('color', 'Silver'); } }, scope : this }, enable : { fn : function(obj) { if (this.allowBlank_fontEl) { this.allowBlank_fontEl.setStyle('color', 'red'); } }, scope : this } }); this.el.on({ 'change' : { fn : this.onChange, scope : this }, 'mouseover' : { fn : this.onMouseover, scope : this }, 'click' : { fn : this.onClick, scope : this }, blur : { fn : this.ipOnblur, scope : this } }); }, onRender : function(op, opt) { Fw.ctrl.ipTextField.superclass.onRender.call(this, op, opt); this.noteEl = this.el.insertHtml('afterEnd', '',true); this.allowBlank_fontEl = this.el.insertHtml('afterEnd','', true); this.allowBlankEvent(); }, validateValue : function(value) { if (Fw.ctrl.ipTextField.superclass.validateValue.call(this, value)) { if (this.allowFirst) { var msg = ''; if (!value.match(this.allowFirst)) { msg = this.allowFirstMsg; } } if (this.blankFlag) { var msg = ''; if (value.match(FW_REGEX_TEMPLATE.FW_FWIPTEXTFIELD_BLANKREG)) { if (!value .match(FW_REGEX_TEMPLATE.FW_FWIPTEXTFIELD_MASKREG)) { msg = fw_firewall_address.desc_Invalid_text; } else if (!value .match(FW_REGEX_TEMPLATE.FW_FWIPTEXTFIELD_MASKREG_TWO)) { msg = fw_firewall_address.desc_Invalid_text_two; } } } if (msg) { this.markInvalid(msg); return false; } return true; } else { return false; } }, setNoteValue : function(noteStr) { this.note = noteStr; var el = document.getElementById(this.noteId); if (el) { el.innerHTML = noteStr; } } }) Ext.reg('fwiptextfield', Fw.ctrl.ipTextField); Fw.ctrl.TextField = Ext.extend(Fw.ctrl.ipTextField, { disableKeyFilter : false, eventKeydown : null, nochineseFlag : true, regExpObjFlag : ALL_ALLOW_BASE_CHARS, reverseReg : false, constructor : function(property) { if (property.baseChars) { this.regExpObjFlag = property.baseChars; } Fw.ctrl.TextField.superclass.constructor.call(this, property); if (property.eventKeydown) { this.eventKeydown = property.eventKeydown; } }, alignErrorIcon : function() { this.errorIcon.alignTo(this.el, 'tl-tr', [65, 0]); }, initEvents : function() { Fw.ctrl.TextField.superclass.initEvents.call(this); if (this.eventKeydown) { this.el.on("keydown", this.eventKeydown, this) } } }) Ext.reg('fwtextfield', Fw.ctrl.TextField); Fw.ctrl.PasswordField = Ext.extend(Fw.ctrl.TextField, { inputType : 'password' }); Ext.reg('fwpasswordfield', Fw.ctrl.PasswordField); Fw.ctrl.NumberField = Ext.extend(Ext.form.NumberField, { labelStyle : 'margin-left:0px;width:130px;', allowBlank : false, fieldLabel : '', note : '', isDisplay : true, isDisplayRange : true, asterisk : true, minValue : NUMBER_MIN_VALUE_CONST, maxValue : NUMBER_MAX_VALUE_CONST, width : FIELD_WIDTH_CONST, labelWidth : FIELD_LABEL_WIDTH_CONST, maxText : fw_common.ctrl_numfield_maxLengthText, minText : fw_common.ctrl_numfield_minLengthText, blankText : fw_common.ctrl_field_blankText, regExpObj : Fw.regExpObj, allRegObj : new RegExp('.{1}', 'g'), regExpObjFlag : 'number', reverseReg : false, blankFlag : false, labelSeparator : '', msgTarget : 'qtip', enableKeyEvents : true, constructor : function(property) { Fw.ctrl.NumberField.superclass.constructor.call(this, property); if (this.regExpObjFlag && !(this.regObj = this.regExpObj[this.regExpObjFlag])) { this.regObj = new RegExp('[' + this.regExpObjFlag + ']', 'g') } this.maxLength = new Number(this.maxValue).toString().length; this.autoCreate = { tag : "input", type : "text", autocomplete : "off", maxLength : this.maxLength } this.lengthBak = this.maxLength; this.oldEmptyText = this.emptyText; }, afterRender : function() { Fw.ctrl.NumberField.superclass.afterRender.call(this); var str = '  '; this.noteId = Ext.id(); var numberFieldElId = this.noteId + '_NumberField'; if (this.allowBlank === false && this.asterisk) { str += '*'; } if (this.isDisplayRange && (this.minValue != NUMBER_MIN_VALUE_CONST) && (this.maxValue != NUMBER_MAX_VALUE_CONST)) { if (!this.noRangeText) { str += '<' + this.minValue + '-' + this.maxValue + '>'; } } str += ''; if (this.note) { str += this.note; } str += ''; if (this.image != undefined && this.imageShow == true) str = str + this.image; this.el.insertHtml('afterEnd', str); this.allowBlank_objEl = Ext.get(numberFieldElId); if (this.allowBlank_objEl) { this.allowBlank_objEl.setStyle('color', this.disabled ? 'Silver' : 'red'); } },initEvents : function() { Fw.ctrl.NumberField.superclass.initEvents.call(this); this.on({ 'disable' : { fn : function(obj) { if (this.allowBlank_objEl) { this.allowBlank_objEl.setStyle('color', 'Silver'); } }, scope : this }, enable : { fn : function(obj) { if (this.allowBlank_objEl) { this.allowBlank_objEl.setStyle('color', 'red'); } }, scope : this }, blur : { fn : function(obj) { var currentlyValue = obj.getRawValue(); var keyValue = currentlyValue.toString().substr(0, this.maxValue.toString().length); if (parseFloat(keyValue) > parseFloat(this.maxValue)) { obj.setValue(keyValue.toString().substr(0, keyValue.toString().length - 1)); } else { this.setValue(keyValue); } }, scope : this } }); this.el.on({ 'change' : { fn : this.onChange, scope : this }, 'mouseover' : { fn : this.onMouseover, scope : this }, 'click' : { fn : this.onClick, scope : this }, 'blur' : { fn : this.ipOnblur, scope : this } }); }, cutCHNChar : Fw.cutChar, onKeyUp : function(e) { this.cutCHNChar(e); this.fireEvent('keyup', this, e); }, onKeyPress : function(e) { this.cutCHNChar(e); this.fireEvent('keypress', this, e); }, onClick : function(e) { this.fireEvent('click', this, e); }, onChange : function(e) { this.fireEvent('change', this, e); }, onMouseover : function(e) { this.fireEvent('mouseover', this, e); }, ipOnblur : function(e) { this.cutCHNChar(e); }, alignErrorIcon : function() { this.errorIcon.alignTo(this.el, 'tl-tr', [65, 0]); }, setNoteValue : function(noteStr) { var el = document.getElementById(this.noteId); if (el) { el.innerHTML = noteStr; } }, preFocus : function() { if (this.emptyText) { if (this.el.dom.value == this.emptyText) { this.el.dom.maxLength=this.maxLength; this.setRawValue(''); this.emptyText = ''; } this.el.removeClass(this.emptyClass); } if (this.selectOnFocus) { this.el.dom.select(); } }, postBlur : function() { this.emptyText = this.oldEmptyText; this.applyEmptyText(); }, applyEmptyText : function() { if (this.rendered && this.emptyText && this.getRawValue().length < 1) { this.el.dom.maxLength=this.emptyText.length; this.setRawValue(this.emptyText); this.el.addClass(this.emptyClass); } } }) Ext.reg('fwnumberfield', Fw.ctrl.NumberField); Fw.ctrl.IntNumberField = Ext.extend(Fw.ctrl.NumberField, { validateOnBlur : true, maxLengthValidata : function(value) { var cop = new Number(value); if (cop > this.maxValue) { this.setValue(value = (value.substr(0, this.maxLength - 1))); } return value; }, validateValue : function(value) { if (!Fw.ctrl.IntNumberField.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.fieldLabel, this.minValue, this.maxValue)); return false; } if (num > this.maxValue) { this.markInvalid(String.format(this.minText, this.fieldLabel, this.minValue, this.maxValue)); return false; } return true; } }) Ext.reg('fwintnumberfield', Fw.ctrl.IntNumberField); Fw.ctrl.ExcepIntNumberField = Ext.extend(Fw.ctrl.IntNumberField, { labelStyle : 'margin-left:0px;width:130px;', fwexcepintnumber : '', constructor : function(property) { Fw.ctrl.ExcepIntNumberField.superclass.constructor.call(this, property); this.minText = fw_common.ctrl_intnumfield_minText; }, 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 && num != this.fwexcepintnumber) { this.markInvalid(String.format(this.minText, this.minValue, this.fwexcepintnumber)); return false; } if (num > this.maxValue && num != this.fwexcepintnumber) { this.markInvalid(String.format(this.maxText, this.maxValue)); return false; } return true; } }); Ext.reg('fwexcepintnumberfield', Fw.ctrl.ExcepIntNumberField); Fw.ctrl.DateField = Ext.extend(Ext.form.DateField, { labelStyle : 'margin-left:0px;width:130px;', fieldLabel : '', allowBlank : false, isDisplay : true, labelWidth : FIELD_LABEL_WIDTH_CONST, triggerClass : 'x-form-date-trigger', maxValue : '2099/12/31', minValue : '2000/01/01', format : 'Y/m/d', altFormats : 'Y/m/d', enableKeyEvents : true, constructor : function(property) { Fw.ctrl.DateField.superclass.constructor.call(this, property); this.msgTarget = 'qtip'; this.labelSeparator = ''; this.invalidText = fw_common.ctrl_datefield_invalidText; this.blankText = fw_common.ctrl_field_blankText; this.maxText = fw_common.ctrl_datefield_maxText; this.minText = fw_common.ctrl_datefield_minText; this.maxLengthText = fw_common.ctrl_datefield_maxLengthText; this.minLengthText = fw_common.ctrl_datefield_minLengthText; }, beforeBlur : function() { } }) Ext.reg('fwdatefield', Fw.ctrl.DateField); Fw.ctrl.TimeField = Ext.extend(Ext.form.TimeField, { labelStyle : 'margin-left:0px;width:130px;', fieldLabel : '', allowBlank : false, isDisplay : true, ctCls : Ext.isIE ? '' : 'x-combobox-list-pos-28', labelWidth : FIELD_LABEL_WIDTH_CONST, note : '', constructor : function(property) { Fw.ctrl.TimeField.superclass.constructor.call(this, property); this.msgTarget = 'qtip'; this.labelSeparator = ''; this.invalidText = fw_common.ctrl_timefield_invalidText; this.blankText = fw_common.ctrl_field_blankText; this.maxText = fw_common.ctrl_timefield_maxText; this.minText = fw_common.ctrl_timefield_minText; this.maxLengthText = fw_common.ctrl_timefield_maxLengthText; this.minLengthText = fw_common.ctrl_timefield_minLengthText; }, afterRender : function() { Fw.ctrl.TimeField.superclass.afterRender.call(this); if (this.allowBlank === false) { var str = '     *'; if (this.hideTrigger) { str = ' *'; } this.xinghao = this.wrap.createChild({ tag : 'font', color : 'red', html : str }); } }, initList : function() { Fw.ctrl.TimeField.superclass.initList.call(this); if (Ext.isIE) { var wid = this.list.getWidth(); var inWid = this.innerList.getWidth(); var isTrig = false; if (this.xinghao) { wid -= this.xinghao.getWidth(); inWid -= this.xinghao.getWidth(); isTrig = true; } if (this.elNote) { wid -= this.elNote.getWidth(); inWid -= this.elNote.getWidth(); isTrig = true; } if (isTrig) { var trig = this.trigger.getWidth(); this.list.setWidth(wid + trig); this.innerList.setWidth(inWid + trig); } } } }) Ext.reg('fwtimefield', Fw.ctrl.TimeField); Fw.ctrl.TimeFieldInput = Ext.extend(Ext.BoxComponent, { labelStyle : 'margin-left:0px;width:130px;', msgTarget : 'qtip', fieldLabel : fw_common.ctrl_timefield_labelText, invalidClass : "x-form-invalid", focusClass : "x-form-focus", validationEvent : "keyup", validateOnBlur : true, defaultAutoCreate : { tag : "input", type : "text", size : "20", autocomplete : "off" }, fieldClass : "x-form-field", isFormField : true, emptyText : null, constructor : function(props) { this.labelSeparator = ''; Fw.ctrl.TimeFieldInput.superclass.constructor.call(this, props); }, initComponent : function() { Fw.ctrl.TimeFieldInput.superclass.initComponent.call(this); this .addEvents('focus', 'blur', 'invalid', 'valid', 'keypress', 'click'); }, disable : function() { var mainId = this.id; Fw.ctrl.TimeFieldInput.superclass.disable.call(this); this.readOnly = true; Ext.get(mainId +"add").removeAllListeners(); Ext.get(mainId +"dec").removeAllListeners(); }, enable : function() { var mainId = this.id; Fw.ctrl.TimeFieldInput.superclass.enable.call(this); this.readOnly = false; Ext.get(mainId + "add").on("click", this.addTime.createDelegate(this)); Ext.get(mainId + "dec").on("click", this.desTime.createDelegate(this)); }, onRender : function(ct, position) { var mainId = this.id; this.template = new Ext.XTemplate( '', '', '', '
', '
', '', '', '', '', '', '
'); this.template.compile(); var timeField; var date = new Date(); this.sTime = parseInt(date.getSeconds()); this.mTime = parseInt(date.getMinutes()); this.hTime = parseInt(date.getHours()); var targs = { hours : this.hTime, minutes : this.mTime, seconds : this.sTime }; if (position) { timeField = this.template.insertBefore(position, targs, true); } else { timeField = this.template.append(ct, targs, true); } this.el = timeField; this.mChanged = true; this.hChanged = true; this.drawTime(); var thisTemp = this; this.secondTask = { run : function() { thisTemp.updateTime(); }, interval : 1000 }; this.secondRunner = new Ext.util.TaskRunner(); this.secondRunner.start(this.secondTask); this.typeTime = ""; var clickRepeaterAdd = new Ext.util.ClickRepeater(Ext.get(mainId + 'add'), { delay : 500, interval : 100 }); clickRepeaterAdd.on('click', this.addTime.createDelegate(this)); var clickRepeaterDec = new Ext.util.ClickRepeater(Ext.get(mainId + 'dec'), { delay : 500, interval : 100 }); clickRepeaterDec.on('click', this.desTime.createDelegate(this)); Ext.get(mainId + "hours").on("dblclick", this.timeOnclick.createDelegate(this, ['hoursInp'])); Ext.get(mainId + "hours").on("click", this.timeOnclick.createDelegate(this, ['hoursInp'])); Ext.get(mainId + "hoursInp").on("focus", this.timeOnclick.createDelegate(this, ['hoursInp'])); Ext.get(mainId + "minutes").on("dblclick", this.timeOnclick.createDelegate(this, ['minutesInp'])); Ext.get(mainId + "minutes").on("click", this.timeOnclick.createDelegate(this, ['minutesInp'])); Ext.get(mainId + "minutesInp").on("focus", this.timeOnclick.createDelegate(this, ['minutesInp'])); Ext.get(mainId + "seconds").on("dblclick", this.stopTask.createDelegate(this)); Ext.get(mainId + "seconds").on("click", this.stopTask.createDelegate(this)); Ext.get(mainId + "secondsInp").on("focus", this.stopTask.createDelegate(this)); Ext.get(mainId + "secondsInp").on("blur", this.blurDeal.createDelegate(this)); Ext.get(mainId + "minutesInp").on("blur", this.blurDeal.createDelegate(this)); Ext.get(mainId + "hoursInp").on("blur", this.blurDeal.createDelegate(this)); function onKeyDown(evt,t,o,valueId,range){ var key = parseInt(evt.getCharCode()); var isStopEvt = true; if((key == Ext.EventObject.TAB)||(key == Ext.EventObject.BACKSPACE)){ isStopEvt = false; }else if(48 <= key && 57 >= key){ isStopEvt = false; } else if(key >= 96 && key <= 105){ isStopEvt = false; } if(isStopEvt){ evt.stopEvent(); } var oldValue = $(mainId+valueId).value; if(oldValue && !isNaN(oldValue)){ Ext.get(mainId+valueId).oldValue = oldValue; } }; function onKeyUp(evt,t,o,valueId,range){ var key = parseInt(evt.getKey()); var isStopEvt = true; if((key == Ext.EventObject.TAB)||(key == Ext.EventObject.BACKSPACE)){ isStopEvt = false; }else if(48 <= key && 57 >= key){ isStopEvt = false; } else if(key >= 96 && key <= 105){ isStopEvt = false; } if(isStopEvt){ evt.stopEvent(); } var value = $(mainId+valueId).value; if(isNaN(value)){ $(mainId+valueId).value = Ext.get(mainId+valueId).oldValue; }else{ var val = parseInt(value); if(val>range){ $(mainId+valueId).value = range; } } }; Ext.get(mainId + 'hours').on('keydown',function(evt,t,o){ onKeyDown(evt,t,o,'hoursInp',23); },this); Ext.get(mainId + 'hours').on('keyup',function(evt,t,o){ onKeyUp(evt,t,o,'hoursInp',23); },this); Ext.get(mainId + "minutes").on('keydown',function(evt,t,o){ onKeyDown(evt,t,o,'minutesInp',59); },this); Ext.get(mainId + "minutes").on('keyup',function(evt,t,o){ onKeyUp(evt,t,o,'minutesInp',59); },this); Ext.get(mainId + "seconds").on('keydown',function(evt,t,o){ onKeyDown(evt,t,o,'secondsInp',59); },this); Ext.get(mainId + "seconds").on('keyup',function(evt,t,o){ onKeyUp(evt,t,o,'secondsInp',59); },this); }, blurDeal : function() { var mainId = this.id; var tempTime = Ext.get(mainId + this.typeTime).getValue(true); if (isNaN(tempTime)) { tempTime = 0; } if (this.typeTime == 'hoursInp') { if (tempTime > 23) { tempTime = 23; } this.hTime = tempTime; this.hChanged = true; } else if (this.typeTime == 'minutesInp') { if (tempTime > 59) { tempTime = 59; } this.mTime = tempTime; this.mChanged = true; } else if (this.typeTime == 'secondsInp') { if (tempTime > 59) { tempTime = 59; } this.sTime = tempTime; } this.drawTime(); }, startTimes : function() { thisTemp = this; this.secondTask = { run : function() { thisTemp.updateTime(); }, interval : 1000 }; this.secondRunner.start(this.secondTask); }, updateTime : function() { if (this.sTime < 59) { this.sTime += 1; this.mChanged = false; this.hChanged = false; } else { this.sTime = 0; this.mChanged = true; this.hChanged = false; if (this.mTime < 59) { this.mTime += 1; } else { this.hChanged = true; this.mTime = 0; if (this.hTime < 23) { this.hTime += 1; } else { this.hTime = 0; this.callBackEvent(); } } } this.drawTime(); }, callBackEvent : function() { }, drawTime : function() { var mainId = this.id; var read = this.readOnly ? 'readonly="readonly" disabled="disabled" ' : ''; Ext .fly(mainId + 'seconds') .update(''); Ext.get(mainId + "secondsInp").on("focus", this.stopTask.createDelegate(this)); Ext.get(mainId + "secondsInp").on("blur", this.blurDeal.createDelegate(this)); if (this.mChanged) { Ext .fly(mainId + 'minutes') .update(''); Ext.get(mainId + "minutesInp").on("focus", this.timeOnclick.createDelegate(this, ['minutesInp'])); Ext.get(mainId + "minutesInp") .on("blur", this.blurDeal.createDelegate(this)); } if (this.hChanged) { Ext .fly(mainId + 'hours') .update(''); Ext.get(mainId + "hoursInp").on("focus", this.timeOnclick.createDelegate(this, ['hoursInp'])); Ext.get(mainId + "hoursInp").on("blur", this.blurDeal.createDelegate(this)); } }, timeToString : function(tm) { return String(tm).length > 1 ? tm : '0' + tm; }, setTime : function(hTime, mTime, sTime) { if (hTime.length == 2 && hTime.substring(0, 1) == '0') { hTime = hTime.substring(1, 2); } if (mTime.length == 2 && mTime.substring(0, 1) == '0') { mTime = mTime.substring(1, 2); } if (sTime.length == 2 && sTime.substring(0, 1) == '0') { sTime = sTime.substring(1, 2); } this.hTime = parseInt(hTime); this.mTime = parseInt(mTime); this.sTime = parseInt(sTime); this.mChanged = true; this.hChanged = true; this.drawTime(); }, getTime : function() { return this.timeToString(this.hTime) + ':' + this.timeToString(this.mTime) + ':' + this.timeToString(this.sTime); }, timeOnclick : function(type) { this.typeTime = type; }, addTime : function() { var mainId = this.id; var intTime = 0; if (this.typeTime != "") { var tempTime = Ext.get(mainId + this.typeTime).getValue(true); if (this.typeTime == "hoursInp" && tempTime == '23') { intTime = 1; } else if ((this.typeTime == "minutesInp" || this.typeTime == "secondsInp") && tempTime == '59') { intTime = 0; } else { intTime = parseInt(tempTime) + 1; } tempTime = intTime; if (this.typeTime == "hoursInp") { this.hTime = intTime; this.hChanged = true; } else if (this.typeTime == "minutesInp") { this.mTime = intTime; this.mChanged = true; } else { this.sTime = intTime; } this.drawTime(); } }, desTime : function() { var mainId = this.id; var intTime = 0; if (this.typeTime != "") { var tempTime = Ext.get(mainId + this.typeTime).getValue(true); if (this.typeTime == "hoursInp" && tempTime == '0') { intTime = 23; } else if ((this.typeTime == "minutesInp" || this.typeTime == "secondsInp") && tempTime == '0') { intTime = 59; } else { intTime = parseInt(tempTime) - 1; } tempTime = intTime; if (this.typeTime == "hoursInp") { this.hTime = intTime; this.hChanged = true; } else if (this.typeTime == "minutesInp") { this.mTime = intTime; this.mChanged = true; } else { this.sTime = intTime; } this.drawTime(); } }, stopTask : function() { this.typeTime = "secondsInp"; if (this.secondRunner) { this.secondRunner.stop(this.secondTask); } }, beforeDestroy : function() { if (this.secondRunner) { this.secondRunner.stop(this.secondTask); } Fw.ctrl.TimeFieldInput.superclass.beforeDestroy.call(this); } }); Ext.reg('fwtimefieldinput', Fw.ctrl.TimeFieldInput); Fw.ctrl.FileUploadField = Ext.extend(Ext.form.TextField, { labelStyle : 'margin-left:0px;width:130px;', buttonText : fw_common.ctrl_fileupload_labelText, buttonOnly : false, buttonOffset : 3, readOnly : true, autoSize : Ext.emptyFn, initComponent : function() { Fw.ctrl.FileUploadField.superclass.initComponent.call(this); this.addEvents('fileselected'); }, onRender : function(ct, position) { Fw.ctrl.FileUploadField.superclass.onRender.call(this, ct, position); this.wrap = this.el.wrap({ cls : 'x-form-field-wrap x-form-file-wrap' }); this.el.addClass('x-form-file-text'); this.el.dom.removeAttribute('name'); this.fileInput = this.wrap.createChild({ id : this.getFileInputId(), name : this.name || this.getId(), cls : 'x-form-file', tag : 'input', type : 'file', size : 1 }); var btnCfg = Ext.applyIf(this.buttonCfg || {}, { text : this.buttonText }); this.button = new Ext.Button(Ext.apply(btnCfg, { renderTo : this.wrap, cls : 'x-form-file-btn' + (btnCfg.iconCls ? ' x-btn-icon' : '') })); if (this.buttonOnly) { this.el.hide(); this.wrap.setWidth(this.button.getEl().getWidth()); } this.fileInput.on('change', function() { var v = this.fileInput.dom.value; this.setValue(v); this.fireEvent('fileselected', this, v); }, this); }, getFileInputId : function() { return this.id + '-file'; }, onResize : function(w, h) { Fw.ctrl.FileUploadField.superclass.onResize.call(this, w, h); this.wrap.setWidth(w); if (!this.buttonOnly) { var w = this.wrap.getWidth() - this.button.getEl().getWidth() - this.buttonOffset; this.el.setWidth(w); } }, preFocus : Ext.emptyFn, getResizeEl : function() { return this.wrap; }, getPositionEl : function() { return this.wrap; }, alignErrorIcon : function() { this.errorIcon.alignTo(this.wrap, 'tl-tr', [2, 0]); } }); Ext.reg('fwfileuploadfield', Fw.ctrl.FileUploadField); Fw.ctrl.ipTextArea = Ext.extend(Ext.form.TextArea, { labelStyle : 'margin-left:0px;width:130px;', fieldLabel : '', allowBlank : true, isDisplay : true, width : TEXTAREA_WIDTH_CONST, labelWidth : FIELD_LABEL_WIDTH_CONST, maxLength : TEXTAREA_MAX_LENGTH_CONST, minLength : TEXT_MIN_LENGTH_CONST, maxLengthText : fw_common.ctrl_field_maxLengthText, minLengthText : fw_common.ctrl_field_minLengthText, blankText : fw_common.ctrl_field_blankText, labelSeparator : '', msgTarget : 'qtip', enableKeyEvents : true, regExpObj : Fw.regExpObj, allRegObj : new RegExp('.{1}', 'g'), regExpObjFlag : '', reverseReg : true, blankFlag : false, constructor : function(property) { Fw.ctrl.ipTextArea.superclass.constructor.call(this, property); if (this.regExpObjFlag && !(this.regObj = this.regExpObj[this.regExpObjFlag])) { this.regObj = new RegExp('[' + this.regExpObjFlag + ']', 'gi') } this.lengthBak = this.maxLength; }, afterRender : function() { Fw.ctrl.ipTextArea.superclass.afterRender.call(this); if (this.allowBlank === false) { this.el.insertHtml('afterEnd', this.disabled ? ' *' : ' *'); } }, onKeyUp : function(e) { this.cutCHNChar(e); this.fireEvent('keyup', this, e); }, maxLengthValidata : function(value) { if (value.length > this.maxLength) { this.setValue(value = value.substr(0, this.maxLength)); } return value; }, onKeyPress : function(e) { this.cutCHNChar(e); this.fireEvent('keypress', this, e); }, ipOnblur : function(e) { this.cutCHNChar(e); this.fireEvent('mouseover', this, e); }, initEvents : function() { Fw.ctrl.ipTextArea.superclass.initEvents.call(this); this.el.on({ blur : { fn : this.ipOnblur, scope : this } }); }, validateValue : function(value) { if (value == '""') { this.markInvalid(fw_common.msg_edit_tip); return false; } if (Fw.ctrl.ipTextArea.superclass.validateValue.call(this, value)) { if (this.blankFlag) { var msg = ''; if (value.match(FW_REGEX_TEMPLATE.FW_FWIPTEXTFIELD_BLANKREG)) { if (!value .match(FW_REGEX_TEMPLATE.FW_FWIPTEXTFIELD_MASKREG)) { msg = fw_firewall_address.desc_Invalid_text; } else if (!value .match(FW_REGEX_TEMPLATE.FW_FWIPTEXTFIELD_MASKREG_TWO)) { msg = fw_firewall_address.desc_Invalid_text_two; } } } if (msg) { this.markInvalid(msg); return false; } return true; } else { return false; } }, cutCHNChar : Fw.cutChar }) Ext.reg('fwiptextarea', Fw.ctrl.ipTextArea); Fw.ctrl.TextArea = Ext.extend(Fw.ctrl.ipTextArea, {}) Ext.reg('fwtextarea', Fw.ctrl.TextArea); Fw.ctrl.TextAreaSpecial = Ext.extend(Fw.ctrl.TextArea, { nochineseFlag : true, baseChars : ALL_ALLOW_BASE_CHARS, reverseReg : false, regExpObjFlag : '', constructor : function(property) { Fw.ctrl.TextAreaSpecial.superclass.constructor.call(this, property); if (!this.regObj) { this.regObj = new RegExp('[' + this.baseChars + ']', 'g'); } }, ipOnblur : function(e) { this.cutCHNChar(e); if (!Ext.isIE) { this.valadataVa(e); } this.fireEvent('blur', this, e); }, onKeyUp : function(e) { var flagV = false; var oldvalue = this.getValue().replace(/\s/g, function() { flagV = true; return ''; }); if (flagV) { this.setValue(oldvalue); } this.cutCHNChar(e); if (!Ext.isIE) { this.valadataVa(e); } this.fireEvent('keyup', this, e); }, valadataVa : function(e) { var k = e.getKey(); var oldValue = ''; if (e.browserEvent.type == "focus" && this.getValue() == "") { return; } oldValue = this.getValue(); var valuesAction = oldValue.match(/\S{34,}/g); if (valuesAction != null) { var newValue = ''; var rawValue = 0; var rawChar = ''; var rawString = new Array(); for (var i = 0, j = 0; i < oldValue.length; i++) { var stringItem = oldValue.charAt(i); if (stringItem.match(/\s/) != null) { continue; } var charValue = 0; if (stringItem >= '0' && stringItem <= '9') { charValue = 7 / 8; } if (stringItem >= 'A' && stringItem <= 'F') { if (stringItem == 'A' || stringItem == 'D') { charValue = 1; } if (stringItem == 'B' || stringItem == 'C' || stringItem == 'E') { charValue = 7 / 8; } if (stringItem == 'F') { charValue = 3 / 4; } } rawChar += stringItem; if (Math.floor(rawValue + charValue) == 33) { rawString[j] = rawChar; rawChar = ''; rawValue = 0; j++; } else { if (i == (oldValue.length - 1) && rawChar != '') { rawString[j] = rawChar; } else { rawValue += charValue; } } } for (var i = 0; i < rawString.length; i++) { newValue += rawString[i]; if (i != rawString.length - 1) { newValue += '\r\n'; } } oldValue = newValue; } this.setValue(oldValue); } }) Ext.reg('fwtextareaspecial', Fw.ctrl.TextAreaSpecial); Fw.ctrl.UTMTimeField = Ext.extend(Ext.BoxComponent, { msgTarget : 'qtip', invalidClass : "x-form-invalid", invalidText : fw_common.ctrl_field_invalidText, focusClass : "x-form-focus", validationEvent : "blur", labelStyle : 'margin-left:0px;width:130px;', validateOnBlur : true, note : '', readOnly : false, allowBlank : true, blankText : fw_common.ctrl_field_blankText, isDisplay : true, sectionCount : 3, sections : null, fieldClass : "x-ip-default", isFormField : true, emptyText : null, vtype : null, constructor : function(props) { Fw.ctrl.UTMTimeField.superclass.constructor.call(this, props); this.fieldLabel = props.fieldLabel; if (props.id) { this.id = props.id; } }, initComponent : function() { Fw.ctrl.UTMTimeField.superclass.initComponent.call(this); this.addEvents('focus', 'blur', 'invalid', 'valid', 'keypress'); }, onRender : function(ct, position) { this.template = new Ext.XTemplate( '
', '', '', '', '
:
'); this.template.compile(); var timeField; var targs = { id : !this.id ? Ext.id() : this.id, cssClass : 'ip-hw-label' }; if (position) { timeField = this.template.insertBefore(position, targs, true); } else { timeField = this.template.append(ct, targs, true); } this.el = timeField; this.initTimeSection({ readOnly : this.readOnly }); if (Ext.isIE) { var cmps1 = this.el.select('.x-form-text'); for (i = 0; i < cmps1.getCount(); i++) { cmps1.item(i).setStyle('background', 'none'); } var cmps2 = this.el.select('.x-form-ie'); for (i = 0; i < cmps2.getCount(); i++) { cmps2.item(i).setStyle('background', 'none'); } } }, initTimeSection : function(props) { this.sections = new Array(); var fields = this; for (var i = 0; i < this.sectionCount; i++) { if (i % 2 == 0) { var field = new Ext.form.NumberField({ renderTo : this.id + i, width : Ext.isIE ? 24 : 21, style : 'border:0px solid #666666;', maxLength : 2, maxText : '', height : Ext.isIE ? 20 : 20, maxValue : i == 0 ? 23 : 59, validateOnBlur : true, readOnly : props.readOnly, enableKeyEvents : true, seqId : i / 2, seqNextField : null, previousField : null, beforeBlur : function() { }, setValue : function(v) { Ext.form.NumberField.superclass.setValue.call(this, v); }, listeners : { 'keypress' : fields.preventInputPress, 'keyup' : function(field, event) { var key = event.getKey(); var nextfield, previous; if (event.getKey() != Ext.EventObject.BACKSPACE) { if (event.getKey() > 57 || event.getKey() < 48) { event.stopEvent(); } var txt = field.getRawValue(); if (field.getValue() > field.maxValue) { event.stopEvent(); field.setValue(''); txt = ''; } if (i == 2 && field.getRawValue().length > 2) { event.stopEvent(); field.setValue(''); txt = ''; } if (txt.length >= 2 && ((key >= 96 && key <= 105) || (key >= 48 && key <= 57))) { nextfield = field.seqNextField; if (nextfield != null) { nextfield.focus(); nextfield.selectText(); } } if (key == Ext.EventObject.LEFT) { previous = field.previousField; if (previous) { previous.focus(); previous.selectText(); } } if (key == Ext.EventObject.RIGHT) { nextfield = field.seqNextField; if (nextfield) { nextfield.focus(); nextfield.selectText(); } } } else { previous = field.previousField; if (previous && field.getRawValue() == '') { if (field.lyby) { previous.focus(); previous.selectText(); } field.lyby = 1; } else { field.lyby = 0; } } fields.validateValue(); } } }); field.addListener('focus', this.onFocus, this); field.addListener('blur', this.onBlur, this); this.sections.push(field); } } for (var i = 0; i < this.sections.length; i++) { t = i + 1; this.sections[i].seqNextField = this.sections[t]; this.sections[i].previousField = this.sections[i - 1]; } this.el.child('.ip-input-area').addClass(this.fieldClass); var cmps = this.el.select('.x-form-text'); for (i = 0; i < cmps.getCount(); i++) { cmps.item(i).setStyle('border', '0px solid #666666'); } }, preventInputPress : function(field, event) { var key = event.getKey(); if (event.getKey() != Ext.EventObject.BACKSPACE) { if (event.getKey() > 57 || event.getKey() < 48 && event.getKey() != 9) { event.stopEvent(); } var txt = field.getRawValue(); if (field.getValue() > field.maxValue) { event.stopEvent(); field.setValue(''); } } }, setTime : function(value) { if (typeof value == 'string') { var ipSubs = value.split(':'); if (ipSubs.length != 0) { for (var i = 0, count = this.sections.length; i < count; i++) { this.sections[i].setValue(ipSubs[i]); } } } }, setValue : function(value) { this.setTime(value); }, onDisable : function() { Fw.ctrl.UTMTimeField.superclass.onDisable.call(this); for (var i = 0, count = this.sections.length; i < count; i++) { this.sections[i].el.dom.disabled = true; } }, onEnable : function() { Fw.ctrl.UTMTimeField.superclass.onEnable.call(this); for (var i = 0, count = this.sections.length; i < count; i++) { this.sections[i].el.dom.disabled = false; } }, reset : function() { if (this.sections) { for (var i = 0, count = this.sections.length; i < count; i++) { this.sections[i].reset(); } this.clearInvalid(); } }, getTime : function() { var value = ''; for (var i = 0, count = this.sections.length; i < count; i++) { if (i != count - 1) { value += this.sections[i].getValue() + ':' } else { value += this.sections[i].getValue(); } } return value; }, getValue : function() { return this.getTime(); }, addNote : function(allowBlank) { this.elNotes = this.el.findParent('.x-ip-comp', 5, true).createChild({ tag : 'span', cls : 'x-ip-note' }); if (allowBlank === false) { this.elNotes.insertHtml('beforeEnd', ' ' + this.note + '*'); } else { this.elNotes.insertHtml('beforeEnd', ' ' + this.note); } if (this.image) { this.elImage = this.elNotes.createChild({ tag : 'span', cls : 'x-ip-note' }); this.elImage.insertHtml('beforeEnd', ' ' + this.image); this.elImage.alignTo(this.elNotes, 'tl-tr', [2, 4]); } this.elNotes.alignTo(this.el.child('.ip-input-area'), 'tl-tr', [2, 4]); if (Ext.isIE) { this.el.setWidth(this.el.getWidth() + this.elNotes.getWidth() + 2); } else { this.el.setWidth(this.el.getWidth() + this.elNotes.getWidth() + 14); } this.elNotes.show; this.on('resize', this.elNotes.alignTo(this.el.child('.ip-input-area'), 'tl-tr', [2, 4]), this); }, afterRender : function() { Fw.ctrl.UTMTimeField.superclass.afterRender.call(this); this.addNote(this.allowBlank); this.initEvents(); }, initEvents : function() { }, onFocus : function() { if (!Ext.isOpera && this.focusClass) { this.el.child('.ip-input-area').removeClass(this.fieldClass); this.el.child('.ip-input-area').addClass(this.focusClass); } }, focus : function() { if (this.sections) { this.sections[0].focus(); } }, setFocus : function() { if (!Ext.isOpera && this.focusClass) { this.el.child('.ip-input-area').removeClass(this.fieldClass); this.el.child('.ip-input-area').addClass(this.focusClass); } this.sections[0].focus(); }, thefield : null, onBlur : function(field) { var currentlyFieldValue = field.getRawValue(); if (currentlyFieldValue > field.maxValue) { field.setValue(''); } thefield = this; setTimeout("thefield.validate()", 250); this.el.child('.ip-input-area').removeClass(this.focusClass); this.el.child('.ip-input-area').addClass(this.fieldClass); }, alignErrorIcon : function() { this.errorIcon .alignTo(this.el.child('.ip-input-area'), 'tl-tr', [2, 0]); }, markInvalid : function(msg) { if (!this.rendered || this.preventMark) { return; } this.el.child('.ip-input-area').addClass(this.invalidClass); this.el.child('.ip-input-area').removeClass(this.fieldClass); msg = msg || this.invalidText; switch (this.msgTarget) { case 'qtip' : this.el.child('.ip-input-area').dom.qtip = msg; this.el.child('.ip-input-area').dom.qclass = 'x-form-invalid-tip'; if (Ext.QuickTips) { Ext.QuickTips.enable(); } break; case 'title' : this.el.dom.title = msg; break; case 'under' : if (!this.errorEl) { var elp = this.getErrorCt(); if (!elp) { this.el.dom.title = msg; break; } this.errorEl = elp.createChild({ cls : 'x-form-invalid-msg' }); this.errorEl.setWidth(elp.getWidth(true) - 20); } this.errorEl.update(msg); Ext.form.Field.msgFx[this.msgFx].show(this.errorEl, this); break; case 'side' : if (!this.errorIcon) { var elp = this.getErrorCt(); if (!elp) { this.el.dom.title = msg; break; } this.errorIcon = elp.createChild({ cls : 'x-form-invalid-icon' }); } this.alignErrorIcon(); this.errorIcon.dom.qtip = msg; this.errorIcon.dom.qclass = 'x-form-invalid-tip'; this.errorIcon.show(); this.on('resize', this.alignErrorIcon, this); break; default : var t = Ext.getDom(this.msgTarget); t.innerHTML = msg; t.style.display = this.msgDisplay; break; } this.fireEvent('invalid', this, msg); if (this.unpassCallBack) { this.unpassCallBack(); } }, passCallBack : function() { }, unpassCallBack : function() { }, clearInvalid : function() { try{ if (!this.rendered || this.preventMark) { return; } this.el.child('.ip-input-area').removeClass(this.invalidClass); this.el.child('.ip-input-area').addClass(this.fieldClass); switch (this.msgTarget) { case 'qtip' : this.el.child('.ip-input-area').dom.qtip = ''; break; case 'title' : this.el.child('.ip-input-area').dom.title = ''; break; case 'under' : if (this.errorEl) { Ext.form.Field.msgFx[this.msgFx].hide(this.errorEl, this); } break; case 'side' : if (this.errorIcon) { this.errorIcon.dom.qtip = ''; this.errorIcon.hide(); this.un('resize', this.alignErrorIcon, this); } break; default : var t = Ext.getDom(this.msgTarget); t.innerHTML = ''; t.style.display = 'none'; break; } this.fireEvent('valid', this); if (this.passCallBack) { this.passCallBack(); } }catch(e){} }, validateValue : function() { if (!this.disabled) { var hourReg = UTM_REGEX_VIEW.UTMTIMEFIELD_HOUR; var minReg = UTM_REGEX_VIEW.UTMTIMEFIELD_MINUTE; var hourValue = ''; if (this.sections[0].getRawValue()) { hourValue = this.sections[0].getRawValue(); } var minValue = ''; if (this.sections[1].getRawValue()) { minValue = this.sections[1].getRawValue(); } if (!hourReg.test(hourValue) || !minReg.test(minValue)) { this.markInvalid(this.invalidText); return false; } else { this.clearInvalid(); } if (this.vtype) { var vt = Ext.form.VTypes; if (!vt[this.vtype](this.getValue(), this)) { this.markInvalid(this.vtypeText || vt[this.vtype + 'Text']); return false; } } if (typeof this.validator == "function") { var msg = this.validator(this.getValue()); if (msg !== true) { this.markInvalid(msg); return false; } } } return true; }, validate : function() { if (!this.disabled) { var isBlank = ''; var isabsNaN = false; var currentlyFieldValue; for (var i = 0; i < 2; i++) { if (this.sections[i].getRawValue() != '') { currentlyFieldValue = this.sections[i].getRawValue(); isBlank = currentlyFieldValue; } } if (isBlank == '') { if (!this.allowBlank) { this.markInvalid(this.blankText); return false; } else { this.clearInvalid(); return true; } } if (this.validateOnBlur) { if (!this.validateValue()) return false; } } return true; } }); Ext.reg('fwutmtimefield', Fw.ctrl.UTMTimeField);