/* Product Name: dhtmlxSuite Version: 4.0.3 Edition: Professional License: content of this file is covered by DHTMLX Commercial or Enterprise license. Usage without proper license is prohibited. To obtain it contact sales@dhtmlx.com Copyright UAB Dinamenta http://www.dhtmlx.com */ function dhtmlXForm(parentObj, data, skin) { this.idef = { position: "label-left", labelWidth: "auto", labelHeight: "auto", inputWidth: "auto", inputHeight: "auto", labelAlign: "left", noteWidth: "auto", offsetTop: 0, offsetLeft: 0, blockOffset: 20 // block only }; this.idef_const = { offsetNested: 20 // sub_level }; this.apos_css = { "label-left": "dhxform_item_label_left", "label-right": "dhxform_item_label_right", "label-top": "dhxform_item_label_top", "label-bottom": "dhxform_item_label_bottom", // new "absolute": "dhxform_item_absolute" }; this.align_css = { left: "dhxform_label_align_left", center: "dhxform_label_align_center", right: "dhxform_label_align_right" }; var that = this; // define skin // 1) skin 3rd arg [new] // 2) dhtmlx.skin // 3) autodetect skin // 4) default skyblue this.setSkin = function(skin) { this.skin = skin; this.cont.className = "dhxform_obj_"+this.skin; this.cont.style.fontSize = (skin=="dhx_terrace"?"13px":"12px"); this._updateBlocks(); // update calendar skin this.forEachItem(function(id){ var t = that.getItemType(id); if (typeof(that.items[t]) != "undefined" && typeof(that.items[t].setSkin) == "function") { that.doWithItem(id, "setSkin", skin); } }); } this.skin = (skin||window.dhx4.skin||(typeof(dhtmlx)!="undefined"?dhtmlx.skin:null)||window.dhx4.skinDetect("dhx_form")||"dhx_skyblue"); this.separator = ","; this.live_validate = false; this._type = "checkbox"; this._rGroup = "default"; this._idIndex = {}; this._indexId = []; this.cont = (typeof(parentObj)=="object"?parentObj:document.getElementById(parentObj)); if (!parentObj._isNestedForm) { this._parentForm = true; this.cont.style.fontSize = (this.skin=="dhx_terrace"?"13px":"12px"); this.cont.className = "dhxform_obj_"+this.skin; this.setFontSize = function(fs) { this.cont.style.fontSize = fs; this._updateBlocks(); } this.getForm = function() { return this; } this.cont.onkeypress = function(e) { e = (e||event); if (e.keyCode == 13) { var t = (e.target||e.srcElement); if (typeof(t.tagName) != "undefined" && String(t.tagName).toLowerCase() == "textarea" && !e.ctrlKey) return; that.callEvent("onEnter",[]); } } } this.b_index = null; this.base = []; this._prepare = function(ofsLeft, pos) { if (this.b_index == null) this.b_index = 0; else this.b_index++; // if pos specified, check all items inside all bases, var insBeforeBase = null; // base var insBeforeItem = null; // items from start to move next-items within single base if (pos != null) { if (pos < 0) pos = 0; var i = 0; for (var w=0; w=0?u:data.length] = i; return data; } this._genStr = function(w) { var s = ""; var z = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; for (var q=0; q 0) { insBeforeItem = this.itemPull[a]._listBase[this.itemPull[a]._listBase.length-1]; } } } } var tr = document.createElement("DIV"); if (insertAfter == true && insBeforeItem != null) insBeforeItem = insBeforeItem.nextSibling; if (insBeforeItem != null) { insBeforeBase.insertBefore(tr, insBeforeItem); } else { insBeforeBase.appendChild(tr); } } } tr._idd = id; tr._rId = this._rId; if (typeof(tr.style) != "undefined") { // read from settings if not set if (typeof(data.offsetLeft) == "undefined" && this.idef.offsetLeft > 0) data.offsetLeft = this.idef.offsetLeft; if (typeof(data.offsetTop) == "undefined" && this.idef.offsetTop > 0) data.offsetTop = this.idef.offsetTop; // var k = ""; if (typeof(data.offsetLeft) != "undefined") k += " padding-left:"+data.offsetLeft+"px!important;"; if (typeof(data.offsetTop) != "undefined") k += " padding-top:"+data.offsetTop+"px!important;"; tr.style.cssText += k; } if (type == "block") { if (isNaN(data.blockOffset)) data.blockOffset = this.idef.blockOffset; } if (type == "list") { if (typeof(tr._ofsNested) == "undefined") tr._ofsNested = this.idef_const.offsetNested; if (sId != null) tr._sId = sId; var listData = this.items[type].render(tr, this.skin); if (!this.itemPull[this.idPrefix+id]._listObj) this.itemPull[this.idPrefix+id]._listObj = []; if (!this.itemPull[this.idPrefix+id]._list) this.itemPull[this.idPrefix+id]._list = []; if (!this.itemPull[this.idPrefix+id]._listBase) this.itemPull[this.idPrefix+id]._listBase = []; (this.itemPull[this.idPrefix+id]._listObj).push(listData[0]); (this.itemPull[this.idPrefix+id]._list).push(listData[1]); (this.itemPull[this.idPrefix+id]._listBase).push(tr); listData[1].checkEvent = function(evName) { return that.checkEvent(evName); } listData[1].callEvent = function(evName, evData) { return that.callEvent(evName, evData); } listData[1].getForm = function() { return that.getForm(); } listData[1]._initObj(this._mergeSettings(data)); if (tr._inBlcok) tr.className += " in_block"; return listData[1]; } if (type == "newcolumn") { this._prepare(data.offset, pos); return; } if (type == "label" && this._ic++ == 0) data._isTopmost = true; //if (type == "select" && this.skin == "dhx_terrace") tr._inpWidthFix=-6; data.position = this.apos_css[(!data.position||!this.apos_css[data.position]?this.idef.position:data.position)]; tr.className = data.position+(typeof(data.className)=="string"?" "+data.className:""); if (!data.labelWidth) data.labelWidth = this.idef.labelWidth; if (!data.labelHeight) data.labelHeight = this.idef.labelHeight; if (typeof(data.wrap) != "undefined") data.wrap = window.dhx4.s2b(data.wrap); data.labelAlign = (this.align_css[data.labelAlign]?this.align_css[data.labelAlign]:this.align_css[this.idef.labelAlign]); data.inputWidth = (data.width?data.width:(data.inputWidth?data.inputWidth:this.idef.inputWidth)); if (!data.inputHeight) data.inputHeight = this.idef.inputHeight; if (typeof(data.note) != "undefined") { if (data.note.length != null && data.note[0] != null) data.note = data.note[0]; // probably array from xml conversion if (typeof(data.note.width) == "undefined") data.note.width = this.idef.noteWidth; if (data.note.width == "auto") data.note.width = data.inputWidth; } tr.checkEvent = function(evName) { return that.checkEvent(evName); } tr.callEvent = function(evName, evData) { return that.callEvent(evName, evData); } tr.getForm = function() { return that.getForm(); } tr._autoCheck = function(t) { that._autoCheck(t); } // convert r/o if (typeof(data.readonly) == "string") data.readonly = window.dhx4.s2b(data.readonly); if (typeof(data.autoStart) == "string") data.autoStart = window.dhx4.s2b(data.autoStart); if (typeof(data.autoRemove) == "string") data.autoRemove = window.dhx4.s2b(data.autoRemove); if (typeof(data.titleScreen) == "string") data.titleScreen = window.dhx4.s2b(data.titleScreen); if (typeof(data.info) == "string") data.info = window.dhx4.s2b(data.info); if (typeof(data.hidden) == "string") data.hidden = window.dhx4.s2b(data.hidden); if (typeof(data.checked) == "string") data.checked = window.dhx4.s2b(data.checked); // userdata if (typeof(data.userdata) != "undefined") { for (var a in data.userdata) this.getForm().setUserData(id,a,data.userdata[a]); } // validate if (data.validate) { if (typeof(data.validate != "undefined") && (typeof(data.validate) == "function" || typeof(window[data.validate]) == "function")) { tr._validate = [data.validate]; } else { tr._validate = String(data.validate).split(this.separator); } } if (typeof(data.required) != "undefined") { if (typeof(data.required) == "string") data.required = window.dhx4.s2b(data.required); tr._required = (data.required==true); } if (tr._required) { if (!tr._validate) tr._validate = []; var p = false; for (q=0; q 0) opts[0].selected = true; } // radiobutton if (this.itemPull[a]._type == "ra") { var g = this.itemPull[a]._group; if (!usedRAs[g]) { this.checkItem(g, this.doWithItem(t, "_getFirstValue")); usedRAs[g] = true; } } // nested lists if (this.itemPull[a]._list) for (var q=0; q 0) this.base[q].removeChild(this.base[q].childNodes[0]); if (this.base[q].parentNode) this.base[q].parentNode.removeChild(this.base[q]); this.base[q] = null; } this.base = null; this.cont.onkeypress = null; this.cont.className = ""; this.cont = null; for (var a in this) this[a] = null; that = null; } for (var a in this.items) { this.items[a].t = a; if (typeof(this.items[a]._index) == "undefined") { this.items[a]._index = true; } if (!this.items[a].show) { this.items[a].show = function(item) { item.style.display = ""; if (item._listObj) for (var q=0; q"+data.label+(data.info?"[?]":"")+(item._required?"*":"")+''; if (!isNaN(data.labelWidth)) t.firstChild.style.width = parseInt(data.labelWidth)+"px"; if (!isNaN(data.labelHeight)) t.firstChild.style.height = parseInt(data.labelHeight)+"px"; if (!isNaN(data.labelLeft)) t.style.left = parseInt(data.labelLeft)+"px"; if (!isNaN(data.labelTop)) t.style.top = parseInt(data.labelTop)+"px"; }, doAddInput: function(item, data, el, type, pos, dim, css) { var p = document.createElement("DIV"); p.className = "dhxform_control"; if (item._ll) { item.appendChild(p); } else { item.insertBefore(p,item.firstChild); } var t = document.createElement(el); t.className = css; t.name = item._idd; t._idd = item._idd; t.id = data.uid; if (typeof(type) == "string") t.type = type; if (el == "INPUT" || el == "TEXTAREA") { t.onkeyup = function(e) { e = e||event; item.callEvent("onKeyUp",[this,e,this._idd]); }; t.onkeydown = function(e) { e = e||event; item.callEvent("onKeyDown",[this,e,this._idd]); }; } p.appendChild(t); if (data.readonly) this.setReadonly(item, true); if (data.hidden == true) this.hide(item); if (data.disabled == true) this.userDisable(item); if (pos) { if (!isNaN(data.inputLeft)) p.style.left = parseInt(data.inputLeft)+"px"; if (!isNaN(data.inputTop)) p.style.top = parseInt(data.inputTop)+"px"; } var u = ""; var dimFix = false; if (dim) { if (!isNaN(data.inputWidth)) { u += "width:"+parseInt(data.inputWidth)+"px;"; dimFix=true; } if (!isNaN(data.inputHeight)) u += "height:"+parseInt(data.inputHeight)+"px;"; } if (typeof(data.style) == "string") u += data.style; t.style.cssText = u; if (data.maxLength) t.setAttribute("maxLength", data.maxLength); if (data.connector) t.setAttribute("connector",data.connector); if (dimFix && {input:1, password:1, select:1, calendar:1, colorpicker:1}[this.t]) { if (dhtmlXForm.prototype.items[this.t]._dim == null) { var w = parseInt(t.style.width); var w2 = (dhx4.isFF || dhx4.isIE ? t.offsetWidth : t.clientWidth); dhtmlXForm.prototype.items[this.t]._dim = w2-w; } t.style.width = parseInt(t.style.width)-dhtmlXForm.prototype.items[this.t]._dim+"px"; } if (typeof(data.note) == "object") { var note = document.createElement("DIV"); note.className = "dhxform_note"; note.style.width = (isNaN(data.note.width)?t.offsetWidth:parseInt(data.note.width))+"px"; note._w = data.note.width; note.innerHTML = data.note.text; p.appendChild(note); note = null; } }, doUnloadNestedLists: function(item) { if (!item._list) return; for (var q=0; q 0) item.removeChild(item.childNodes[0]); item.parentNode.removeChild(item); item = null; }, doAttachEvents: function(item) { var that = this; // image click item.childNodes[item._ll?1:0][window.dhx4.isIPad?"ontouchstart":"onmousedown"] = function(e) { e = e||event; if (e.preventDefault) e.preventDefault(); var t = (e.target||e.srcElement); // need to skip "note" if exists if (!this.parentNode._enabled || this.parentNode._ro || (typeof(t.className) != "undefined" && t.className == "dhxform_note")) { e.cancelBubble = true; if (e.preventDefault) e.preventDefault(); else e.returnValue = false; return false; } that.doClick(this.parentNode); } // label click item.childNodes[item._ll?0:1].childNodes[0][window.dhx4.isIPad?"ontouchstart":"onmousedown"] = function(e) { e = e||event; if (e.preventDefault) e.preventDefault(); // do not check if r/o here, allow item's be highlighted, check for r/o added into doClick if (!this.parentNode.parentNode._enabled) { e.cancelBubble = true; if (e.preventDefault) e.preventDefault(); else e.returnValue = false; return false; } // check if "info" clicked (checkbox/radio only) var t = e.target||e.srcElement; if (typeof(t.className) != "undefined" && t.className == "dhxform_info") { this.parentNode.parentNode.callEvent("onInfo",[this.parentNode.parentNode._idd]); e.cancelBubble = true; if (e.preventDefault) e.preventDefault(); else e.returnValue = false; return false; } that.doClick(this.parentNode.parentNode); } }, doClick: function(item) { item.childNodes[item._ll?0:1].childNodes[0].focus(); if (!item._enabled || item._ro) return; if (item.checkEvent("onBeforeChange")) if (item.callEvent("onBeforeChange", [item._idd, item._value, item._checked]) !== true) return; this.setChecked(item, !item._checked); item._autoCheck(); item.callEvent("onChange", [item._idd, item._value, item._checked]); }, doCheckValue: function(item) { if (item._checked && item._enabled) { item.childNodes[item._ll?1:0].firstChild.name = String(item._idd); item.childNodes[item._ll?1:0].firstChild.value = this.getValue(item); } else { item.childNodes[item._ll?1:0].firstChild.name = ""; item.childNodes[item._ll?1:0].firstChild.value = ""; } }, setChecked: function(item, state) { item._checked = (state===true?true:false); //item.childNodes[item._ll?1:0].lastChild.className = "dhxform_img "+(item._checked?"chbx1":"chbx0"); item.childNodes[item._ll?1:0].lastChild.className = item.childNodes[item._ll?1:0].lastChild.className.replace(/chbx[0-1]{1}/gi,"")+(item._checked?" chbx1":" chbx0"); this.doCheckValue(item); }, check: function(item) { this.setChecked(item, true); }, unCheck: function(item) { this.setChecked(item, false); }, isChecked: function(item) { return item._checked; }, enable: function(item) { if (String(item.className).search("disabled") >= 0) item.className = String(item.className).replace(/disabled/gi,""); item._enabled = true; item.childNodes[item._ll?0:1].childNodes[0].tabIndex = 0; item.childNodes[item._ll?0:1].childNodes[0].removeAttribute("disabled"); this.doCheckValue(item); }, disable: function(item) { if (String(item.className).search("disabled") < 0) item.className += " disabled"; item._enabled = false; item.childNodes[item._ll?0:1].childNodes[0].tabIndex = -1; item.childNodes[item._ll?0:1].childNodes[0].setAttribute("disabled", "true"); this.doCheckValue(item); }, isEnabled: function(item) { return item._enabled; }, setText: function(item, text) { item.childNodes[item._ll?0:1].childNodes[0].innerHTML = text+(item._required?"*":""); }, getText: function(item) { return item.childNodes[item._ll?0:1].childNodes[0].innerHTML.replace(/[^<]*<\/span>/g,""); }, setValue: function(item, value) { this.setChecked(item,(value===true||parseInt(value)==1||value=="true"||item._value===value)); }, getValue: function(item, mode) { if (mode == "realvalue") return item._value; return ((typeof(item._value)=="undefined"||item._value==null)?(item._checked?1:0):item._value); }, setReadonly: function(item, state) { item._ro = (state===true); }, isReadonly: function(item) { return item._ro; }, setFocus: function(item) { item.childNodes[item._ll?0:1].childNodes[0].focus(); } }; /* radio */ dhtmlXForm.prototype.items.radio = { input: {}, r: {}, firstValue: {}, render: function(item, data, uid) { item._type = "ra"; item._enabled = true; item._checked = false; item._group = data.name; item._value = data.value; item._uid = uid; item._ro = (data.readonly==true); item._rName = item._rId+item._group; this.r[item._idd] = item; data.inputWidth = 14; this.doAddLabel(item, data); this.doAddInput(item, data, "INPUT", "TEXT", true, true, "dhxform_textarea"); item.childNodes[item._ll?1:0].className += " dhxform_img_node"; // radio img var p = document.createElement("DIV"); p.className = "dhxform_img rdbt0"; item.appendChild(p); if (!isNaN(data.inputLeft)) item.childNodes[item._ll?1:0].style.left = parseInt(data.inputLeft)+"px"; if (!isNaN(data.inputTop)) item.childNodes[item._ll?1:0].style.top = parseInt(data.inputTop)+"px"; item.childNodes[item._ll?1:0].appendChild(p); // hidden input needed just to keep common logic, name-value should be empty to prevent sending to server from real form item.childNodes[item._ll?1:0].firstChild.name = ""; item.childNodes[item._ll?1:0].firstChild.value = ""; item._updateImgNode = function(item, state) { var t = item.childNodes[item._ll?1:0].lastChild; t.className = (state?"dhxform_actv_r":"dhxform_img")+" "+(item._checked?"rdbt1":"rdbt0"); item = t = null; } item._doOnFocus = function(item) { item.getForm().callEvent("onFocus",[item._group, item._value]); } item._doOnBlur = function(item) { item.getForm().callEvent("onBlur",[item._group, item._value]); } item._doOnKeyUpDown = function(evName, evObj) { this.callEvent(evName, [this.childNodes[this._ll?0:1].childNodes[0], evObj, this._group, this._value]); } // input if (this.input[item._rName] == null) { var k = document.createElement("INPUT"); k.type = "HIDDEN"; k.name = data.name; k.firstValue = item._value; item.appendChild(k); this.input[item._rName] = k; } if (!this.firstValue[item._rName]) this.firstValue[item._rName] = data.value; if (data.checked == true) this.check(item); if (data.hidden == true) this.hide(item); if (data.disabled == true) this.userDisable(item); this.doAttachEvents(item); return this; }, destruct: function(item, value) { // check if any items will left to keep hidden input on page if (item.lastChild == this.input[item._rName]) { var done = false; for (var a in this.r) { if (!done && this.r[a]._group == item._group && this.r[a]._idd != item._idd) { this.r[a].appendChild(this.input[item._rName]); done = true; } } if (!done) { // remove hidden input this.input[item._rName].parentNode.removeChild(this.input[item._rName]); this.input[item._rName] = null; this.firstValue[item._rName] = null; } } var id = item._idd; item._doOnFocus = item._doOnBlur = item._updateImgNode = null; this.doUnloadNestedLists(item); this.doDestruct(item); return id; }, doClick: function(item) { item.childNodes[item._ll?0:1].childNodes[0].focus(); if (!(item._enabled && !item._checked)) return; if (item._ro) return; var args = [item._group, item._value, true]; if (item.checkEvent("onBeforeChange")) if (item.callEvent("onBeforeChange", args) !== true) return; this.setChecked(item, true); item.getForm()._autoCheck(); item.callEvent("onChange", args); }, doCheckValue: function(item) { var value = null; for (var a in this.r) { if (this.r[a]._checked && this.r[a]._group == item._group && this.r[a]._rId == item._rId) value = this.r[a]._value; // allow getChecked for disabled, v3.6.2 } if (value != null && this.r[a]._enabled) { this.input[item._rName].name = String(item._group); this.input[item._rName].value = value; } else { this.input[item._rName].name = ""; this.input[item._rName].value = ""; } this.input[item._rName]._value = value; }, setChecked: function(item, state) { state = (state===true); for (var a in this.r) { if (this.r[a]._group == item._group && this.r[a]._rId == item._rId) { var needCheck = false; if (this.r[a]._idd == item._idd) { if (this.r[a]._checked != state) { this.r[a]._checked = state; needCheck = true; } } else { if (this.r[a]._checked) { this.r[a]._checked = false; needCheck = true; } } if (needCheck) { var t = this.r[a].childNodes[this.r[a]._ll?1:0].childNodes[1]; t.className = t.className.replace(/rdbt[0-1]{1}/gi,"")+(this.r[a]._checked?" rdbt1":" rdbt0"); t = null; } } } this.doCheckValue(item); }, getChecked: function(item) { return this.input[item._rName]._value; }, _getFirstValue: function(item) { return this.firstValue[item._rName]; }, _getId: function(item) { return item._idd; // return inner id by name/value }, setValue: function(item, value) { // this method will never called at all } }; (function(){ for (var a in {doAddLabel:1,doAddInput:1,doDestruct:1,doUnloadNestedLists:1,doAttachEvents:1,check:1,unCheck:1,isChecked:1,enable:1,disable:1,isEnabled:1,setText:1,getText:1,getValue:1,setReadonly:1,isReadonly:1,setFocus:1}) dhtmlXForm.prototype.items.radio[a] = dhtmlXForm.prototype.items.checkbox[a]; })(); /* select */ dhtmlXForm.prototype.items.select = { render: function(item, data) { item._type = "se"; item._enabled = true; item._value = null; item._newValue = null; // in ff borders included into width if (window.dhx4.isFF||window.dhx4.isIE && typeof(data.inputWidth) == "number") { data.inputWidth = Number(data.inputWidth);//+(item._inpWidthFix||2); } this.doAddLabel(item, data); this.doAddInput(item, data, "SELECT", null, true, true, "dhxform_select"); this.doAttachEvents(item); this.doLoadOpts(item, data); if (data.connector != null) this.doLoadOptsConnector(item, data.connector); if (typeof(data.value) != "undefined" && data.value != null) { this.setValue(item, data.value); } return this; }, destruct: function(item) { this.doUnloadNestedLists(item); item.callEvent = null; item.checkEvent = null; item.getForm = null; item._autoCheck = null; item._enabled = null; item._idd = null; item._type = null; item._value = null; item._newValue = null; item.onselectstart = null; item.childNodes[item._ll?1:0].childNodes[0].onclick = null; item.childNodes[item._ll?1:0].childNodes[0].onkeydown = null; item.childNodes[item._ll?1:0].childNodes[0].onchange = null; item.childNodes[item._ll?1:0].childNodes[0].onfocus = null; item.childNodes[item._ll?1:0].childNodes[0].onblur = null; item.childNodes[item._ll?1:0].childNodes[0].onkeyup = null; item.childNodes[item._ll?1:0].removeChild(item.childNodes[item._ll?1:0].childNodes[0]); while (item.childNodes.length > 0) item.removeChild(item.childNodes[0]); item.parentNode.removeChild(item); item = null; }, doAddLabel: function(item, data) { var j = document.createElement("DIV"); j.className = "dhxform_label "+data.labelAlign; j.innerHTML = ""; // if (data.wrap == true) j.style.whiteSpace = "normal"; if (typeof(data.tooltip) != "undefined") j.title = data.tooltip; item.appendChild(j); if (typeof(data.label) == "undefined" || data.label == null || data.label.length == 0) j.style.display = "none"; if (!isNaN(data.labelWidth)) j.style.width = parseInt(data.labelWidth)+"px"; if (!isNaN(data.labelHeight)) j.style.height = parseInt(data.labelHeight)+"px"; if (!isNaN(data.labelLeft)) j.style.left = parseInt(data.labelLeft)+"px"; if (!isNaN(data.labelTop)) j.style.top = parseInt(data.labelTop)+"px"; if (data.info) { j.onclick = function(e) { e = e||event; var t = e.target||e.srcElement; if (typeof(t.className) != "undefined" && t.className == "dhxform_info") { this.parentNode.callEvent("onInfo",[this.parentNode._idd]); e.cancelBubble = true; if (e.preventDefault) e.preventDefault(); else e.returnValue = false; return false; } } } }, doAttachEvents: function(item) { var t = item.childNodes[item._ll?1:0].childNodes[0]; var that = this; t.onclick = function() { that.doOnChange(this); } t.onkeydown = function(e) { e = e||event; that.doOnChange(this); this.parentNode.parentNode.callEvent("onKeyDown",[this,e,this.parentNode.parentNode._idd]); } t.onchange = function() { that.doOnChange(this); } t.onkeyup = function(e) { e = e||event; this.parentNode.parentNode.callEvent("onKeyUp",[this,e,this.parentNode.parentNode._idd]); } t = null; this.doAttachChangeLS(item); }, doAttachChangeLS: function(item) { var t = item.childNodes[item._ll?1:0].childNodes[0]; t.onfocus = function() { var i = this.parentNode.parentNode; i.getForm()._ccActivate(i._idd, this, i.getForm().getItemValue(i._idd,true)); i.getForm().callEvent("onFocus",[i._idd]); i = null; } t.onblur = function() { var i = this.parentNode.parentNode; i.getForm()._ccDeactivate(i._idd); i.getForm().callEvent("onBlur",[i._idd]); i = null; } t = null; }, doValidate: function(item) { if (item.getForm().live_validate) this._validate(item); }, doLoadOpts: function(item, data, callEvent) { var t = item.childNodes[item._ll?1:0].childNodes[0]; var opts = data.options; var k = false; for (var q=0; q= 0) item._value = t.options[t.selectedIndex].value; if (callEvent === true) item.callEvent("onOptionsLoaded", [item._idd]); // fix note if width set to auto this._checkNoteWidth(item); }, doLoadOptsConnector: function(item, url) { var that = this; item._connector_working = true; window.dhx4.ajax.get(url, function(r) { r = r.xmlDoc.responseXML; if (r == null) return; var root = r.getElementsByTagName("data"); if (root == null || root[0] == null) return; root = root[0]; var opts = []; for (var q=0; q=0?sel.options[sel.selectedIndex].value:null); if (item._newValue != item._value) { if (item.checkEvent("onBeforeChange")) { if (item.callEvent("onBeforeChange", [item._idd, item._value, item._newValue]) !== true) { // restore last value for (var q=0; q*":""); item.childNodes[item._ll?0:1].style.display = (text.length==0||text==null?"none":""); }, getText: function(item) { return item.childNodes[item._ll?0:1].childNodes[0].innerHTML.replace(/[^<]*<\/span>/g,""); }, enable: function(item) { if (String(item.className).search("disabled") >= 0) item.className = String(item.className).replace(/disabled/gi,""); item._enabled = true; item.childNodes[item._ll?1:0].childNodes[0].removeAttribute("disabled"); }, disable: function(item) { if (String(item.className).search("disabled") < 0) item.className += " disabled"; item._enabled = false; item.childNodes[item._ll?1:0].childNodes[0].setAttribute("disabled", true); }, getOptions: function(item) { return item.childNodes[item._ll?1:0].childNodes[0].options; }, setValue: function(item, val) { if (item._connector_working) { // attemp to set value while optins not yet loaded (connector used) item._connector_value = val; return; } var opts = this.getOptions(item); for (var q=0; q 0) { item.getForm()._autoCheck(); } item.getForm()._ccReload(item._idd, item._value); // selected option id }, getValue: function(item) { var k = -1; var opts = this.getOptions(item); for (var q=0; q= 0 && t._w == "auto") t.style.width = item.childNodes[item._ll?1:0].childNodes[0].offsetWidth+"px"; } t = null; } }; (function(){ for (var a in {doAddInput:1,doUnloadNestedLists:1,isEnabled:1}) dhtmlXForm.prototype.items.select[a] = dhtmlXForm.prototype.items.checkbox[a]; })(); /* multiselect */ dhtmlXForm.prototype.items.multiselect = { doLoadOpts: function(item, data, callEvent) { var t = item.childNodes[item._ll?1:0].childNodes[0]; t.multiple = true; if (!isNaN(data.size)) t.size = Number(data.size); item._value = []; item._newValue = []; var opts = data.options; for (var q=0; q 1) item._df.i_len = r[r.length-1].length; if (refresh) this.setValue(item, item._value); return true; }, _getFmtValue: function(item, v) { var r = v.match(/^(-)?([0-9]{1,})(\.([0-9]{1,}))?$/); // r = [coplete value, minus sign, integer, full decimal, decimal] if (r != null && r.length == 5) { var v0 = ""; // minus sign if (r[1] != null) v0 += r[1]; // chars before v0 += item._df.s_bef; // int part if (item._df.i_len !== false) { var i = 0; var v1 = ""; for (var q=r[2].length-1; q>=0; q--) { v1 = ""+r[2].charAt(q)+v1; if (++i == item._df.i_len && q > 0) { v1=item._df.i_sep+v1; i=0; } } v0 += v1; } else { v0 += r[2]; } // dec part if (item._df.d_len !== false) { if (r[4] == null) r[4] = ""; while (r[4].length < item._df.d_len) r[4] += "0"; eval("dhx4.temp = new RegExp(/\\d{"+item._df.d_len+"}/);"); var t1 = (r[4]).match(dhx4.temp); if (t1 != null) v0 += item._df.d_sep+t1; dhx4.temp = t1 = null; } // chars after v0 += item._df.s_aft; return v0; } return v; } }; (function(){ for (var a in {doAddLabel:1,doAddInput:1,destruct:1,doUnloadNestedLists:1,setText:1,getText:1,enable:1,disable:1,isEnabled:1,setWidth:1,setFocus:1}) dhtmlXForm.prototype.items.input[a] = dhtmlXForm.prototype.items.select[a]; })(); /* password */ dhtmlXForm.prototype.items.password = { render: function(item, data) { item._type = "pw"; item._enabled = true; this.doAddLabel(item, data); this.doAddInput(item, data, "INPUT", "PASSWORD", true, true, "dhxform_textarea"); this.doAttachEvents(item); this.setValue(item, data.value); return this; } }; (function(){ for (var a in {doAddLabel:1,doAddInput:1,doAttachEvents:1,destruct:1,doUnloadNestedLists:1,setText:1,getText:1,setValue:1,getValue:1,updateValue:1,enable:1,disable:1,isEnabled:1,setWidth:1,setReadonly:1,isReadonly:1,setFocus:1,getInput:1}) dhtmlXForm.prototype.items.password[a] = dhtmlXForm.prototype.items.input[a]; })(); /* file */ dhtmlXForm.prototype.items.file = { render: function(item, data) { item._type = "fl"; item._enabled = true; this.doAddLabel(item, data); this.doAddInput(item, data, "INPUT", "FILE", true, false, "dhxform_textarea"); var t = item.childNodes[item._ll ? 1 : 0].childNodes[0]; var that = this; t.onfocus = function() { var i = this.parentNode.parentNode; i.getForm().callEvent("onFocus",[i._idd]); i = null; }; t.onblur = function () { var i = this.parentNode.parentNode; if (i.getForm().live_validate) that._validate(i); i.getForm().callEvent("onBlur", [i._idd]); i = null; }; t = null; item.childNodes[item._ll?1:0].childNodes[0].onchange = function() { item.callEvent("onChange", [item._idd, this.value]); } return this; }, setValue: function(){}, getValue: function(item) { return item.childNodes[item._ll?1:0].childNodes[0].value; } }; (function(){ for (var a in {doAddLabel:1,doAddInput:1,destruct:1,doUnloadNestedLists:1,setText:1,getText:1,enable:1,disable:1,isEnabled:1,setWidth:1}) dhtmlXForm.prototype.items.file[a] = dhtmlXForm.prototype.items.input[a]; })(); /* label */ dhtmlXForm.prototype.items.label = { _index: false, render: function(item, data) { item._type = "lb"; item._enabled = true; item._checked = true; var t = document.createElement("DIV"); t.className = "dhxform_txt_label2"+(data._isTopmost?" topmost":""); t.innerHTML = data.label; item.appendChild(t); if (data.hidden == true) this.hide(item); if (data.disabled == true) this.userDisable(item); if (!isNaN(data.labelWidth)) t.style.width = parseInt(data.labelWidth)+"px"; if (!isNaN(data.labelHeight)) t.style.height = parseInt(data.labelHeight)+"px"; if (!isNaN(data.labelLeft)) t.style.left = parseInt(data.labelLeft)+"px"; if (!isNaN(data.labelTop)) t.style.top = parseInt(data.labelTop)+"px"; return this; }, destruct: function(item) { this.doUnloadNestedLists(item); item._autoCheck = null; item._enabled = null; item._type = null; item.callEvent = null; item.checkEvent = null; item.getForm = null; item.onselectstart = null; item.parentNode.removeChild(item); item = null; }, enable: function(item) { if (String(item.className).search("disabled") >= 0) item.className = String(item.className).replace(/disabled/gi,""); item._enabled = true; }, disable: function(item) { if (String(item.className).search("disabled") < 0) item.className += " disabled"; item._enabled = false; }, setText: function(item, text) { item.firstChild.innerHTML = text; }, getText: function(item) { return item.firstChild.innerHTML; } }; (function(){ for (var a in {doUnloadNestedLists:1,isEnabled:1}) dhtmlXForm.prototype.items.label[a] = dhtmlXForm.prototype.items.checkbox[a]; })(); /* button */ dhtmlXForm.prototype.items.button = { render: function(item, data) { item._type = "bt"; item._enabled = true; item._name = data.name; item.className = String(item.className).replace("item_label_top","item_label_left").replace("item_label_right","item_label_left"); if (!isNaN(data.width)) var w = Math.max(data.width,10); var k = (typeof(w) != "undefined"); item._doOnKeyUpDown = function(evName, evObj) { this.callEvent(evName, [this.childNodes[0].childNodes[0], evObj, this._idd]); } item.innerHTML = '
'+ '
'+data.value+'
'+ '
'; if (!isNaN(data.inputLeft)) item.childNodes[0].style.left = parseInt(data.inputLeft)+"px"; if (!isNaN(data.inputTop)) item.childNodes[0].style.top = parseInt(data.inputTop)+"px"; if (data.hidden == true) this.hide(item); if (data.disabled == true) this.userDisable(item); if (typeof(data.tooltip) != "undefined") item.firstChild.title = data.tooltip; // item onselectstart also needed once // will reconstructed! item.onselectstart = function(e){ e = e||event; e.cancelBubble = true; if (e.preventDefault) e.preventDefault(); else e.returnValue = false; return false; } item.firstChild.onselectstart = function(e){ e = e||event; e.cancelBubble = true; if (e.preventDefault) e.preventDefault(); else e.returnValue = false; return false; } item.firstChild.onkeypress = function(e) { e = e||event if ((e.keyCode == 32 || e.charCode == 32 || e.keyCode == 13 || e.charCode == 13) && !this.parentNode._busy) { this.parentNode._busy = true; e.cancelBubble = true; if (e.preventDefault) e.preventDefault(); else e.returnValue = false; _dhxForm_doClick(this.childNodes[0], ["mousedown", "mouseup"]); return false; } } item.firstChild.ontouchstart = function(){ e = e||event; e.preventDefault(); if (!this.parentNode._busy) { this.parentNode._busy = true; _dhxForm_doClick(this.childNodes[0],["mousedown", "mouseup"]); } } item.firstChild.onfocus = function() { this.parentNode._doOnFocus(this.parentNode); } item.firstChild.onblur = function() { _dhxForm_doClick(this.childNodes[0], "mouseout"); this.parentNode._doOnBlur(this.parentNode); } item.firstChild.onkeyup = function(e) { this.parentNode._doOnKeyUpDown("onKeyUp", e||event); } item.firstChild.onkeydown = function(e) { this.parentNode._doOnKeyUpDown("onKeyDown", e||event); } item.firstChild.onmouseover = function(){ var t = this.parentNode; if (!t._enabled) return; this._isOver = true; this.className = "dhxform_btn dhxform_btn_over"; t = null; } item.firstChild.onmouseout = function(){ var t = this.parentNode; if (!t._enabled) return; this.className = "dhxform_btn"; this._allowClick = false; this._pressed = false; this._isOver = false; t = null; } item.firstChild.onmousedown = function(e){ e = e||event; if (e.button >= 2) return; // ie=0/other=1 if (this._pressed) return; var t = this.parentNode; if (!t._enabled) return; this.className = "dhxform_btn dhxform_btn_pressed"; this._allowClick = true; this._pressed = true; t = null; } item.firstChild.onmouseup = function(e){ e = e||event; if (e.button >= 2) return; if (!this._pressed) return; var t = this.parentNode; if (!t._enabled) return; t._busy = false; this.className = "dhxform_btn"+(this._isOver?" dhxform_btn_over":""); if (this._pressed && this._allowClick) t.callEvent("_onButtonClick", [t._name, t._cmd]); this._allowClick = false; this._pressed = false; t = null; } item._doOnFocus = function(item) { item.getForm().callEvent("onFocus",[item._idd]); } item._doOnBlur = function(item) { item.getForm().callEvent("onBlur",[item._idd]); } return this; }, destruct: function(item) { this.doUnloadNestedLists(item); item.callEvent = null; item.checkEvent = null; item.getForm = null; item._autoCheck = null; item._type = null; item._enabled = null; item._cmd = null; item._name = null; item._doOnFocus = null; item._doOnBlur = null; item._doOnKeyUpDown = null; item.onselectstart = null; item.firstChild.onselectstart = null; item.firstChild.onkeypress = null; item.firstChild.ontouchstart = null; item.firstChild.onfocus = null; item.firstChild.onblur = null; item.firstChild.onkeyup = null; item.firstChild.onkeydown = null; item.firstChild.onmouseover = null; item.firstChild.onmouseout = null; item.firstChild.onmousedown = null; item.firstChild.onmouseup = null; while (item.childNodes.length > 0) item.removeChild(item.childNodes[0]); item.parentNode.removeChild(item); item = null; }, enable: function(item) { if (String(item.className).search("disabled") >= 0) item.className = String(item.className).replace(/disabled/gi,""); item._enabled = true; item.childNodes[0].removeAttribute("disabled"); item.childNodes[0].setAttribute("role", "link"); item.childNodes[0].setAttribute("tabIndex", "0"); }, disable: function(item) { if (String(item.className).search("disabled") < 0) item.className += " disabled"; item._enabled = false; item.childNodes[0].setAttribute("disabled", "true"); item.childNodes[0].removeAttribute("role"); item.childNodes[0].removeAttribute("tabIndex"); }, setText: function(item, text) { item.childNodes[0].childNodes[0].innerHTML = text; }, getText: function(item) { return item.childNodes[0].childNodes[0].innerHTML; }, setFocus: function(item) { item.childNodes[0].focus(); } }; (function(){ for (var a in {doUnloadNestedLists:1,isEnabled:1}) dhtmlXForm.prototype.items.button[a] = dhtmlXForm.prototype.items.checkbox[a]; })(); /* hidden item */ dhtmlXForm.prototype.items.hidden = { _index: false, render: function(item, data) { item.style.display = "none"; item._name = data.name; item._type = "hd"; item._enabled = true; var t = document.createElement("INPUT"); t.type = "HIDDEN"; t.name = data.name; t.value = (data.value||"") item.appendChild(t); return this; }, destruct: function(item) { this.doUnloadNestedLists(item); while (item.childNodes.length > 0) item.removeChild(item.childNodes[0]); item._autoCheck = null; item._name = null; item._type = null; item._enabled = null; item.onselectstart = null; item.callEvent = null; item.checkEvent = null; item.getForm = null; item.parentNode.removeChild(item); item = null; }, enable: function(item) { item._enabled = true; item.childNodes[0].setAttribute("name", item._name); }, disable: function(item) { item._enabled = false; item.childNodes[0].removeAttribute("name"); }, show: function() { }, hide: function() { }, isHidden: function() { return true; }, setValue: function(item, val) { item.childNodes[0].value = val; }, getValue: function(item) { return item.childNodes[0].value; }, getInput: function(item) { return item.childNodes[0]; } }; (function(){ for (var a in {doUnloadNestedLists:1,isEnabled:1}) dhtmlXForm.prototype.items.hidden[a] = dhtmlXForm.prototype.items.checkbox[a]; })(); /* sub list */ dhtmlXForm.prototype.items.list = { _index: false, render: function(item, skin) { item._type = "list"; item._enabled = true; item._isNestedForm = true; item.style.paddingLeft = item._ofsNested+"px"; item.className = "dhxform_base_nested"+(item._custom_css||""); return [this, new dhtmlXForm(item, null, skin)]; }, destruct: function(item) { // linked to _listBase // automaticaly cleared when parent item unloaded } }; /* fieldset */ dhtmlXForm.prototype.items.fieldset = { _index: false, render: function(item, data) { item._type = "fs"; if (typeof(parseInt(data.inputWidth)) == "number") { // if (window.dhx4.isFF||window.dhx4.isOpera) data.inputWidth -= 12; // chrome-11/ie9 - ok } item._width = data.width; item._enabled = true; item._checked = true; // required for authoCheck item.className = "fs_"+data.position+(typeof(data.className)=="string"?" "+data.className:""); var f = document.createElement("FIELDSET"); f.className = "dhxform_fs"; var align = String(data.labelAlign).replace("align_",""); f.innerHTML = ""+data.label+""; item.appendChild(f); if (!isNaN(data.inputLeft)) f.style.left = parseInt(data.inputLeft)+"px"; if (!isNaN(data.inputTop)) f.style.top = parseInt(data.inputTop)+"px"; if (data.inputWidth != "auto") { if (!isNaN(data.inputWidth)) { f.style.width = parseInt(data.inputWidth)+"px"; var w = parseInt(f.style.width); if (f.offsetWidth > w) f.style.width = w+(w-f.offsetWidth)+"px"; } } item._addSubListNode = function() { var t = document.createElement("DIV"); t._custom_css = " dhxform_fs_nested"; this.childNodes[0].appendChild(t); return t; } if (data.hidden == true) this.hide(item); if (data.disabled == true) this.userDisable(item); return this; }, destruct: function(item) { this.doUnloadNestedLists(item); item._checked = null; item._enabled = null; item._idd = null; item._type = null; item._width = null; item.onselectstart = null; item._addSubListNode = null; item._autoCheck = null; item.callEvent = null; item.checkEvent = null; item.getForm = null; while (item.childNodes.length > 0) item.removeChild(item.childNodes[0]); item.parentNode.removeChild(item); item = null; }, setText: function(item, text) { item.childNodes[0].childNodes[0].innerHTML = text; }, getText: function(item) { return item.childNodes[0].childNodes[0].innerHTML; }, enable: function(item) { item._enabled = true; if (String(item.className).search("disabled") >= 0) item.className = String(item.className).replace(/disabled/gi,""); }, disable: function(item) { item._enabled = false; if (String(item.className).search("disabled") < 0) item.className += " disabled"; }, setWidth: function(item, width) { item.childNodes[0].style.width = width+"px"; item._width = width; }, getWidth: function(item) { return item._width; } }; (function(){ for (var a in {doUnloadNestedLists:1,isEnabled:1}) dhtmlXForm.prototype.items.fieldset[a] = dhtmlXForm.prototype.items.checkbox[a]; })(); /* block */ dhtmlXForm.prototype.items.block = { _index: false, render: function(item, data) { item._type = "bl"; item._width = data.width; item._enabled = true; item._checked = true; // required for authoCheck item.className = "block_"+data.position+(typeof(data.className)=="string"?" "+data.className:""); var b = document.createElement("DIV"); b.className = "dhxform_obj_"+item.getForm().skin+" dhxform_block"; b.style.fontSize = item.getForm().cont.style.fontSize; if (data.style) b.style.cssText = data.style; if (typeof(data.id) != "undefined") b.id = data.id; item.appendChild(b); if (!isNaN(data.inputLeft)) b.style.left = parseInt(data.inputLeft)+"px"; if (!isNaN(data.inputTop)) b.style.top = parseInt(data.inputTop)+"px"; if (data.inputWidth != "auto") if (!isNaN(data.inputWidth)) b.style.width = parseInt(data.inputWidth)+"px"; if (!isNaN(data.blockOffset)) { item._ofsNested = data.blockOffset; } item._addSubListNode = function() { var t = document.createElement("DIV"); t._inBlcok = true; if (typeof(this._ofsNested) != "undefined") t._ofsNested = this._ofsNested; this.childNodes[0].appendChild(t); return t; } if (data.hidden == true) this.hide(item); if (data.disabled == true) this.userDisable(item); return this; }, _setCss: function(item, skin, fontSize) { item.firstChild.className = "dhxform_obj_"+skin+" dhxform_block"; item.firstChild.style.fontSize = fontSize; } }; (function(){ for (var a in {enable:1,disable:1,isEnabled:1,setWidth:1,getWidth:1,doUnloadNestedLists:1,destruct:1}) dhtmlXForm.prototype.items.block[a] = dhtmlXForm.prototype.items.fieldset[a]; })(); /* new column */ dhtmlXForm.prototype.items.newcolumn = { _index: false }; /* template */ dhtmlXForm.prototype.items.template = { render: function(item, data) { var ta = (!isNaN(data.rows)); item._type = "tp"; item._enabled = true; if (data.format) { if (typeof(data.format) == "function") item.format = data.format; if (typeof(window[data.format]) == "function") item.format = window[data.format]; } if (!item.format) item.format = function(name, value) { return value; } this.doAddLabel(item, data); this.doAddInput(item, data, "DIV", null, true, true, "dhxform_item_template"); item._value = (data.value||""); item.childNodes[1].childNodes[0].innerHTML = item.format(item._idd, item._value); return this; }, // destruct should be added, // item.format also should be cleared setValue: function(item, value) { item._value = value; item.childNodes[1].childNodes[0].innerHTML = item.format(item._idd, item._value); }, getValue: function(item) { return item._value; }, enable: function(item) { if (String(item.className).search("disabled") >= 0) item.className = String(item.className).replace(/disabled/gi,""); item._enabled = true; }, disable: function(item) { if (String(item.className).search("disabled") < 0) item.className += " disabled"; item._enabled = false; } }; (function(){ for (var a in {doAddLabel:1,doAddInput:1,destruct:1,doUnloadNestedLists:1,setText:1,getText:1,/*enable:1,disable:1,*/isEnabled:1,setWidth:1}) dhtmlXForm.prototype.items.template[a] = dhtmlXForm.prototype.items.select[a]; })(); //loading from UL list dhtmlXForm.prototype._ulToObject = function(ulData, a) { var obj = []; for (var q=0; q= 0) this.cont.className = String(this.cont.className).replace(/dhxform_rtl/gi,""); } }; _dhxForm_doClick = function(obj, evType) { if (typeof(evType) == "object") { var t = evType[1]; evType = evType[0]; } if (document.createEvent) { var e = document.createEvent("MouseEvents"); e.initEvent(evType, true, false); obj.dispatchEvent(e); } else if (document.createEventObject) { var e = document.createEventObject(); e.button = 1; obj.fireEvent("on"+evType, e); } if (t) window.setTimeout(function(){_dhxForm_doClick(obj,t);},100); } dhtmlXForm.prototype.setFormData = function(t) { for (var a in t) { var r = this.getItemType(a); switch (r) { case "checkbox": this[t[a]==true||parseInt(t[a])==1||t[a]=="true"||t[a]==this.getItemValue(a, "realvalue")?"checkItem":"uncheckItem"](a); break; case "radio": this.checkItem(a,t[a]); break; case "input": case "textarea": case "password": case "select": case "multiselect": case "hidden": case "template": case "combo": case "calendar": case "colorpicker": case "editor": this.setItemValue(a,t[a]); break; default: if (this["setFormData_"+r]) { // check for custom cell this["setFormData_"+r](a,t[a]); } else { // if item with specified name not found, keep value in userdata if (!this.hId) this.hId = this._genStr(12); this.setUserData(this.hId, a, t[a]); } break; } } }; dhtmlXForm.prototype.getFormData = function(p0, only_fields) { var r = {}; var that = this; for (var a in this.itemPull) { var i = this.itemPull[a]._idd; var t = this.itemPull[a]._type; if (t == "ch") r[i] = (this.isItemChecked(i)?this.getItemValue(i):0); if (t == "ra" && !r[this.itemPull[a]._group]) r[this.itemPull[a]._group] = this.getCheckedValue(this.itemPull[a]._group); if (t in {se:1,ta:1,pw:1,hd:1,tp:1,fl:1,calendar:1,combo:1,editor:1,colorpicker:1}) r[i] = this.getItemValue(i,p0); // check for custom cell if (this["getFormData_"+t]) r[i] = this["getFormData_"+t](i); // merge with files/uploader if (t == "up") { var r0 = this.getItemValue(i); for (var a0 in r0) r[a0] = r0[a0]; } // if (this.itemPull[a]._list) { for (var q=0; q ky) ky = this.base[q].offsetHeight; } // check if layout var isLayout = false; try { isLayout = (this.cont.parentNode.parentNode.parentNode.parentNode._isCell==true); if (isLayout) var layoutCell = this.cont.parentNode.parentNode.parentNode.parentNode; } catch(e){}; if (isLayout && typeof(layoutCell) != "undefined") { if (kx > 0) layoutCell.setWidth(kx+10); if (ky > 0) layoutCell.setHeight(ky+layoutCell.firstChild.firstChild.offsetHeight+5); isLayout = layoutCell = null; return; } // check if window var isWindow = false; try { isWindow = (this.cont.parentNode.parentNode.parentNode._isWindow == true); if (isWindow) { var winCell = this.cont.parentNode.parentNode; if (typeof(winCell.callEvent) == "function") { this.cont.style.display = "none"; winCell.callEvent("_setCellSize", [kx+15,ky+15]); this.cont.style.display = ""; } } } catch(e){}; }; // dataproc dhtmlXForm.prototype.reset = function() { if (this.callEvent("onBeforeReset", [this.formId, this.getFormData()])) { if (this._last_load_data) this.setFormData(this._last_load_data); this.callEvent("onAfterReset", [this.formId]); } }; dhtmlXForm.prototype.send = function(url, mode, callback, skipValidation) { if (typeof mode == "function") { callback = mode; mode = "post"; } else { mode = (mode=="get"?"get":"post"); } if (skipValidation !== true && !this.validate()) return; var formData = this.getFormData(true); var data = []; for (var key in formData) data.push(key+"="+encodeURIComponent(formData[key])); var afterload = function(loader) { if (callback) callback.call(this, loader, loader.xmlDoc.responseText); }; if (mode == "get") { window.dhx4.ajax.get(url+(url.indexOf("?")==-1?"?":"&")+data.join("&"), afterload); } else { window.dhx4.ajax.post(url, data.join("&"), afterload); } }; dhtmlXForm.prototype.save = function(url, type){}; dhtmlXForm.prototype.dummy = function(){}; dhtmlXForm.prototype._changeFormId = function(oldid, newid) { this.formId = newid; }; dhtmlXForm.prototype._dp_init = function(dp) { dp._methods = ["dummy", "dummy", "_changeFormId", "dummy"]; dp._getRowData = function(id, pref) { var data = this.obj.getFormData(true); data[this.action_param] = this.obj.getUserData(id, this.action_param); return data; }; dp._clearUpdateFlag = function(){}; dp.attachEvent("onAfterUpdate", function(sid, action, tid, tag){ if (action == "inserted" || action == "updated"){ this.obj.resetDataProcessor("updated"); this.obj._last_load_data = this.obj.getFormData(true); } this.obj.callEvent("onAfterSave",[this.obj.formId, tag]); return true; }); dp.autoUpdate = false; dp.setTransactionMode("POST", true); this.dp = dp; this.formId = (new Date()).valueOf(); this.resetDataProcessor("inserted"); this.save = function(){ if (!this.callEvent("onBeforeSave", [this.formId, this.getFormData()])) return; if (!this.validate()) return; dp.sendData(); }; }; dhtmlXForm.prototype.resetDataProcessor = function(mode){ if (!this.dp) return; this.dp.updatedRows = []; this.dp._in_progress = []; this.dp.setUpdated(this.formId, true, mode); }; // cc listener dhtmlXForm.prototype._ccActivate = function(id, inp, val) { if (!this._formLS) this._formLS = {}; if (!this._formLS[id]) this._formLS[id] = {input: inp, value: val}; if (!this._ccActive) { this._ccActive = true; this._ccDo(); } inp = null; }; dhtmlXForm.prototype._ccDeactivate = function(id) { if (this._ccTm) window.clearTimeout(this._ccTm); this._ccActive = false; if (this._formLS != null && this._formLS[id] != null) { this._formLS[id].input = null; this._formLS[id] = null; delete this._formLS[id]; } }; dhtmlXForm.prototype._ccDo = function() { if (this._ccTm) window.clearTimeout(this._ccTm); for (var a in this._formLS) { var inp = this._formLS[a].input; if (String(inp.tagName).toLowerCase() == "select") { var v = ""; if (inp.selectedIndex >= 0 && inp.selectedIndex < inp.options.length) v = inp.options[inp.selectedIndex].value; } else { var v = inp.value; } if (v != this._formLS[a].value) { this._formLS[a].value = v; this.callEvent("onInputChange",[inp._idd,v,this]); } inp = null; } if (this._ccActive) { var t = this; this._ccTm = window.setTimeout(function(){t._ccDo();t=null;},100); } }; dhtmlXForm.prototype._ccReload = function(id, value) { // update item's value while item have focus if (this._formLS && this._formLS[id]) { this._formLS[id].value = value; } }; dhtmlXForm.prototype._autoload = function() { var a = [ "ftype", "name", "value", "label", "check", "checked", "disabled", "text", "rows", "select", "selected", "width", "style", "className", "labelWidth", "labelHeight", "labelLeft", "labelTop", "inputWidth", "inputHeight", "inputLeft", "inputTop", "position", "size" ]; var k = document.getElementsByTagName("UL"); var u = []; for (var q=0; q0:!value == ''); // array in case of multiselect }, isValidBoolean: function(value) { return !!value.toString().match(/^(0|1|true|false)$/); }, isValidEmail: function(value) { return !!value.toString().match(/(^[a-z0-9]([0-9a-z\-_\.]*)@([0-9a-z_\-\.]*)([.][a-z]{3})$)|(^[a-z]([0-9a-z_\.\-]*)@([0-9a-z_\-\.]*)(\.[a-z]{2,4})$)/i); }, isValidInteger: function(value) { return !!value.toString().match(/(^-?\d+$)/); }, isValidNumeric: function(value) { return !!value.toString().match(/(^-?\d\d*[\.|,]\d*$)|(^-?\d\d*$)|(^-?[\.|,]\d\d*$)/); }, isValidAplhaNumeric: function(value) { return !!value.toString().match(/^[_\-a-z0-9]+$/gi); }, // 0000-00-00 00:00:00 to 9999:12:31 59:59:59 (no it is not a "valid DATE" function) isValidDatetime: function(value) { var dt = value.toString().match(/^(\d{4})-(\d{2})-(\d{2})\s(\d{2}):(\d{2}):(\d{2})$/); return dt && !!(dt[1]<=9999 && dt[2]<=12 && dt[3]<=31 && dt[4]<=59 && dt[5]<=59 && dt[6]<=59) || false; }, // 0000-00-00 to 9999-12-31 isValidDate: function(value) { var d = value.toString().match(/^(\d{4})-(\d{2})-(\d{2})$/); return d && !!(d[1]<=9999 && d[2]<=12 && d[3]<=31) || false; }, // 00:00:00 to 59:59:59 isValidTime: function(value) { var t = value.toString().match(/^(\d{1,2}):(\d{1,2}):(\d{1,2})$/); return t && !!(t[1]<=24 && t[2]<=59 && t[3]<=59) || false; }, // 0.0.0.0 to 255.255.255.255 isValidIPv4: function(value) { var ip = value.toString().match(/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/); return ip && !!(ip[1]<=255 && ip[2]<=255 && ip[3]<=255 && ip[4]<=255) || false; }, isValidCurrency: function(value) { // Q: Should I consider those signs valid too ? : ¢|€|₤|₦|¥ return value.toString().match(/^\$?\s?\d+?([\.,\,]?\d+)?\s?\$?$/) && true || false; }, // Social Security Number (999-99-9999 or 999999999) isValidSSN: function(value) { return value.toString().match(/^\d{3}\-?\d{2}\-?\d{4}$/) && true || false; }, // Social Insurance Number (999999999) isValidSIN: function(value) { return value.toString().match(/^\d{9}$/) && true || false; } }; dhtmlxValidation = new dhtmlxValidation(); };