/**--infoview_pub.js--**/ /**--infoview_pub.js--**/ Ext.ns('wcm.LANG'); var ua = navigator.userAgent.toLowerCase(); var isSafari = (/webkit|khtml/).test(ua), isGecko = !isSafari && ua.indexOf("gecko") > -1; var m_readFileUrl, m_fileUploadDowithUrl; var m_sRootPath = '../images/infoview/'; PgC = { initFrmAction : function(){ var frmAction = $('frmAction'); m_sRootPath = frmAction.resourcebase.value; var currDocId = getParameter("documentId") || 0; frmAction.DocumentId.value = currDocId; m_fileUploadDowithUrl = frmAction.fileuploadurl.value; m_readFileUrl = frmAction.readfileurl.value + '?FileName='; if(currDocId > 0){ m_readFileUrl = m_readFileUrl.replace(/file_server_read\.jsp\?/, 'file_server_read_from_wcm.jsp?') } Event.observe('SubmitButton', 'click', function(){ var frm = $('frmAction'); window._databeforeSubmit = {}; if(exCenter._beforeSubmit(window._databeforeSubmit)===false)return; if(frm.OnlyCached != null){ InfoDocHelper.renderSubmit(frm.OnlyCached.value == 'true'); }else{ InfoDocHelper.renderSubmit(); } }); if($('ResetButton')){ Event.observe('ResetButton', 'click', function(){ var arr = document.body.getElementsByTagName('*'), toRemoves = []; for(var i=0, n=arr.length; i{2}', buildMenu : function(items, tg){ var rst = []; for(var i=0, n=items.length; i 0 && frmAction.CachedInfoviewId) { frmAction.CachedInfoviewId.value = nCachedInfoviewId; frmAction.bIsVerifyCode.value = "false"; } frmAction.submit(); } }; function copyAttrs(src, tg){ var attrs = src.attributes; for(var i=0; i 30; nd.setAttribute('infodoc_data', 1); nd.setAttribute("element-type", isTextArea?2:1); var rp = nd; if(isTextArea) { rp = document.createElement("textarea"); rp.style.overflow = "auto"; } else { rp = document.createElement("input"); } copyAttrs(nd, rp); if(isTextArea) { rp.style.whiteSpace="pre-wrap"; } nd.parentNode.insertBefore(rp, nd.nextSibling); nd.parentNode.removeChild(nd); if(nd.innerHTML!=""){ rp.value = nd.innerHTML; } if(only){ disableInput(rp); return rp; } _TransRule_.NotifyMustFill(rp, {marginLeft:'-15px'}); return rp; }); _TransRule_.save("span", "RichText", function(nd, only) { nd.style.overflow = "auto"; nd.setAttribute('infodoc_data', 1); nd.setAttribute("element-type", "7"); if(!isGecko){ nd.contentEditable = !only; }else{ var rp = document.createElement("iframe"); rp.src = ''; copyAttrs(nd, rp); nd.parentNode.insertBefore(rp, nd.nextSibling); nd.parentNode.removeChild(nd); var doc = rp.contentWindow.document; doc.write(''); doc.close(); doc.designMode = only ? 'off' : 'on'; nd = rp; } if(nd.innerHTML!=""){ nd.value = nd.innerHTML; } if(only)return nd; makeTextEditorRule(nd); _TransRule_.NotifyMustFill(nd, {marginLeft:'-15px'}); return nd; }); function makeTextEditorRule(currNode){ var img = document.createElement("img"); img.src = m_sRootPath + "editor.gif"; img.title = '\u70B9\u51FB\u7F16\u8F91\u683C\u5F0F\u6587\u672C'; img.style.width = "16px"; img.style.height = "16px"; img.setAttribute('_action', 'openeditor'); //img.setAttribute('trs_temp_id', nd.getAttribute("trs_temp_id", "2")); img.setAttribute('trs_temp_id', currNode.id); _TransRule_.appendExTool(currNode, img, {marginLeft:'-5px'}); } _TransRule_.save("select", "DropDown", function(nd, only) { nd.setAttribute('infodoc_data', 1); nd.setAttribute("element-type", "8"); nd.disabled = only; _TransRule_.NotifyMustFill(nd); }); _TransRule_.save("select", "ListBox", function(nd, only) { nd.setAttribute('infodoc_data', 1); nd.setAttribute("element-type", "8"); nd.disabled = only; _TransRule_.NotifyMustFill(nd); }); _TransRule_.save("input", "CheckBox", function(nd, only) { nd.setAttribute('infodoc_data', 1); nd.setAttribute("element-type", "9"); nd.disabled = only; }); _TransRule_.save("input", "OptionButton", function(nd, only) { nd.setAttribute('infodoc_data', 1); nd.setAttribute("element-type", "10"); nd.disabled = only; }); _TransRule_.save("div", "Section", function(nd, only) { nd.setAttribute("element-type", "13"); }); _TransRule_.save("div", "RepeatingSection", function(nd, only) { nd.setAttribute("element-type", "3"); nd.setAttribute("fly-button", 1); nd.setAttribute("context-menu", 1); if(only)return; nd.style.border = '1px dotted gray'; }); _TransRule_.save("tbody", "RepeatingTable", function(nd, only) { nd.setAttribute("element-type", "4"); nd.setAttribute("fly-button", 1); nd.setAttribute("context-menu", 1); //\u517C\u5BB9\u591A\u6D4F\u89C8\u5668\uFF0C\u7ED9\u91CD\u590D\u8868\u7684\u7236\u5143\u7D20\u6DFB\u52A0\u6837\u5F0F if(nd.parentNode.tagName.toUpperCase() == 'TABLE'){ var repeatingTableContainer = nd.parentNode.parentNode; if(repeatingTableContainer.tagName.toUpperCase() == 'DIV') repeatingTableContainer.className = 'xdRepeatingTableContainer'; } if(only)return; nd.style.border = '1px dotted gray'; }); _TransRule_.save("span", "ListItem_Plain", function(nd, only) { nd.setAttribute("element-type", "1"); nd.setAttribute('infodoc_data', 1); var rp = document.createElement("input"); copyAttrs(nd, rp); nd.parentNode.insertBefore(rp, nd.nextSibling); nd.parentNode.removeChild(nd); if(only){ disableInput(rp); return rp; } _TransRule_.NotifyMustFill(rp); return rp; }); _TransRule_.save("span", "DTPicker_DTText", function(nd, only) { nd.setAttribute('infodoc_data', 1); nd.setAttribute("element-type", "11"); var rp = document.createElement("input"); copyAttrs(nd, rp); rp.style.border = 0; //\u65E5\u671F\u63A7\u4EF6\u591A\u6D4F\u89C8\u5668\u7684\u517C\u5BB9\uFF0C\u51CF\u6389\u7684\u5BBD\u5EA6\u4E3A\u65E5\u671F\u6309\u94AE\u5360\u7684\u533A\u57DF rp.style.width = (nd.parentNode.offsetWidth - 37) + 'px'; rp.style.height = (nd.parentNode.offsetHeight - 6) + 'px'; //\u65E5\u671F\u63A7\u4EF6\u7684\u7236\u5BB9\u5668\u6307\u5B9A100%\u4F1A\u6EA2\u51FA if(nd.parentNode.style.width == "100%") nd.parentNode.style.width = (nd.parentNode.offsetWidth - 5)+ "px"; nd.parentNode.insertBefore(rp, nd.nextSibling); nd.parentNode.removeChild(nd); var img = rp.parentNode.getElementsByTagName("BUTTON")[0]; if(only){ disableInput(rp); img.disabled = true; img.style.filter = 'gray'; return rp; } makeDateCalendarRule(rp); _TransRule_.NotifyMustFill(rp, {marginLeft:'-13px'}); return rp; }); function makeDateCalendarRule(el){ var img = el.parentNode.getElementsByTagName("BUTTON")[0]; img.setAttribute("type", 'button'); var df = el.getAttribute("xd:datafmt", 2); var time = df != null && df.indexOf("datetime") != -1; var dtfm = null; if(time){ img.unselectable = 'on'; var validation = el.getAttribute("validation", 2); if(!validation)dtfm = 'yyyy-mm-dd HH:MM:ss'; else{ eval("var obj = {" + validation + "}"); dtfm = obj['date_format']; if(dtfm==undefined) dtfm = 'yyyy-mm-dd HH:MM:ss'; } } else{ var validation = el.getAttribute("validation", 2); if(!validation)dtfm = 'yyyy-mm-dd'; else{ eval("var obj = {" + validation + "}"); dtfm = obj['date_format']; if(dtfm==undefined) dtfm = 'yyyy-mm-dd'; } } wcm.TRSCalendar.get({ input : el, handler : img, dtFmt : dtfm, withtime : time }); } _TransRule_.save("span", "FileAttachment", function(nd, only) { nd.setAttribute("element-type", "5"); nd.setAttribute('infodoc_data', 1); if(!only){ nd.setAttribute("fly-button", 1); nd.setAttribute("context-menu", 1); nd.setAttribute('_action', "openFileOrAppend"); nd.style.cursor = "pointer"; } var img = document.createElement("img"); img.src = m_sRootPath + "FileAttachment.gif"; img.style.width = "14px"; img.style.height = "13px"; img.align = 'absmiddle'; nd.appendChild(img); var txt = document.createElement("span"); txt.setAttribute("text_body", "1"); txt.className = 'appendix_txt'; txt.innerHTML = "\u70B9\u51FB\u6B64\u5904\u4EE5\u6DFB\u52A0\u9644\u4EF6"; nd.appendChild(txt); var txtFile = document.createElement("span"); txtFile.setAttribute("text_file", "1"); txtFile.style.display = 'none'; txtFile.innerHTML = ""; var validation = nd.getAttribute("validation", 2); if(validation){ eval("var obj = {" + validation + "}"); var validType = obj['extvalid']; if(validType) nd.setAttribute("allow_ext", validType); } nd.appendChild(txtFile); _TransRule_.NotifyMustFill(nd, {marginLeft:'-15px', marginTop:'7px'}); }); var GetImageAttachmentRule = function(xct){ return function(nd, only) { var sp = document.createElement('SPAN'); sp.setAttribute("element-type", "5"); sp.setAttribute('infodoc_data', 1); sp.setAttribute("is-image", 1); if(!only){ nd.setAttribute("fly-button", 1); nd.setAttribute("context-menu", 1); nd.setAttribute('_action', "openFileOrAppend"); nd.style.cursor = "pointer"; } nd.setAttribute('trs_file_upload_type', "InlineImage"); var validation = nd.getAttribute("validation", 2); if(validation){ eval("var obj = {" + validation + "}"); var validType = obj['extvalid']; if(validType){ nd.setAttribute("allow_ext", validType); }else { nd.setAttribute('allow_ext', "jpg,png,gif,bmp,jpeg"); } } copyAttrs(nd, sp); //sp.style.cursor = "pointer"; nd.parentNode.insertBefore(sp, nd.nextSibling); var w = nd.offsetWidth, h = nd.offsetHeight; nd.parentNode.removeChild(nd); var img = document.createElement('IMG'); img.setAttribute("image_body", "1"); img.src = m_sRootPath + 'spacer.gif'; img.style.width = w + 'px'; img.style.height = h + 'px'; img.style.background = "url(" + m_sRootPath + "ImageAttachment.gif) no-repeat center center"; sp.appendChild(img); var txt = document.createElement("span"); txt.setAttribute("text_body", "1"); txt.innerHTML = ' \u70B9\u51FB\u6B64\u5904\u4EE5\u6DFB\u52A0\u56FE\u7247'; txt.style.marginLeft = (-w) + 'px'; txt.style.marginTop = '-22px'; txt.style.height = '16px'; txt.style.lineHeight = '16px'; sp.appendChild(txt); return sp; }; } var _genId = 0; function genId(){ return ++_genId; } _TransRule_.save("img", "InlineImage", GetImageAttachmentRule('trs_is_inline_image')); _TransRule_.save("img", "LinkedImage", GetImageAttachmentRule('trs_is_linked_image')); _TransRule_.save("span", "ExpressionBox", function(nd, only) { nd.setAttribute("element-type", "101"); nd.setAttribute('infodoc_data', 1); var rp = document.createElement("input"); rp.id = rp.id || 'trs-exp-' + genId(); rp.setAttribute('trs_temp_id', rp.id); copyAttrs(nd, rp); nd.parentNode.insertBefore(rp, nd.nextSibling); nd.parentNode.removeChild(nd); only = only || nd.getAttribute("xd:disableEditing") == "yes"; if(only){ disableInput(rp); return rp; } return rp; }); Event.observe(window, 'resize', function(){ var caches = _TransRule_.getMustDoCaches(); for(var i=0, n=caches.length; i"; document.body.appendChild(flyBtn); var bubblePanel = new wcm.BubblePanel('bubble-panel'); function showContextMenu(ev, tg){ var fb = $('fly-button'); if(!fb.cfg)return true; var items = PgC.flys(fb.cfg.elType, fb.cfg.el); if(!items)return true; $('bubble-panel').innerHTML = PgC.buildMenu(items, fb.cfg.el); bubblePanel.bubble(ev.pointer, function(p){ return [p[0], p[1]+5]; }); ev.stop(); return false; } Ext.get(flyBtn).on('click', showContextMenu); var lastMsm = null; function mouseoverFx(ev, tg){ if(!tg.tagName)return; var temp = findItem(tg, false, '_fxType'); if(temp!=null)return; tg = findItem(tg, false, 'trs_temp_id'); if(lastMsm!=null && lastMsm.el!=tg){ PgC.borderFx(lastMsm.el, true); PgC.flyBtnFx(null, lastMsm.el, true); lastMsm = null; } if(tg==null)return; var nElType = tg.getAttribute('element-type', 2); PgC.borderFx(tg); PgC.flyBtnFx(ev, tg); lastMsm = {ev:ev.browserEvent, el:tg}; return true; } var extBody = Ext.get(document.body); extBody.on('contextmenu', function(ev, tg){ var el = findItem(tg, false, 'context-menu'); if(!el)return true; mouseoverFx(ev, tg); var eid = el.getAttribute('trs_temp_id', 2); var nElType = el.getAttribute('element-type', 2); var items = PgC.flys(nElType, el); if(!items)return true; $('bubble-panel').innerHTML = PgC.buildMenu(items, el); bubblePanel.bubble(ev.pointer, function(p){ return [p[0], p[1]+5]; }); ev.stop(); return false; }); extBody.on('mousemove', function(ev, tg){ if(Element.visible('bubble-panel'))return; mouseoverFx(ev, tg); }); } function regClickEvent(id){ Ext.get(id).on('click', function(exEv, tg){ var actionItem = findItem(tg, false, '_action'); if(!actionItem)return; var action = actionItem.getAttribute('_action', 2); var fn = PgC[action]; if(!fn)return; fn.apply(PgC, [exEv, tg]); }); } function regMenuItemEvent(id){ var lstMenuItem = null; Ext.get(id).on('mousemove', function(exEv, tg){ var menuitem = findItem(tg, 'menuitem'); if(!menuitem)return; if(lstMenuItem){ Element.removeClassName(lstMenuItem, 'menuitem_active'); } Element.addClassName(menuitem, 'menuitem_active'); lstMenuItem = menuitem; }); Ext.get(id).on('mouseout', function(exEv, tg){ if(lstMenuItem){ Element.removeClassName(lstMenuItem, 'menuitem_active'); } lstMenuItem = null; }); } var exCenter = null; function defExCenter(){ var l1 = [], l2 = [], l3 = [], l4 = [], inited; exCenter = { onafterTrans : function(fn){ l1.push(fn); if(window.__loaded)fn(); }, onafterInitData : function(fn){ l2.push(fn); if(window.__loaded)fn(); }, onafterModify : function(fn){ l3.push(fn); }, onbeforeSubmit : function(fn){ l4.push(fn); }, _afterTrans : function(){ for(var i=0,n=l1.length;i0){ alert(infos[0].warning); $(infos[0].id).focus(); } } /**--infoview_elehelper.js--**/ //\u63A7\u4EF6\u52A9\u624B Array.prototype.xJoin = function(c, s, e){ var rst = []; for(var i=s; i<=e; i++)rst.push(this[i]); return rst.join(c); } var EleHelper = { getFile : function(nd, bjson){ var xct = nd.getAttribute("xd:xctname", 2); xct = xct ? xct.toLowerCase() : ''; var arr = nd.childNodes; for(var i=0; i= 0; break; } }, getValueFields : function(){ var arr = document.body.getElementsByTagName('*'); var rst = []; for(var i=0, n=arr.length; i', '' ].join('\n'); return loadXml(xml); }, fetchData : function(){ // window._databeforeSubmit = {}; // if(exCenter._beforeSubmit(window._databeforeSubmit)===false)return; var doc = this.getDoc(), root = doc.documentElement; var json = EleHelper.jsonData(); EleHelper.jsonIntoEle(doc, root, json); return doc.xml; }, initData : function(xml, bFromExtranet) { var doc = loadXml(xml); if(doc == null)return null; var root = doc.documentElement; this._dealData(document.body, root, bFromExtranet); }, _dealData : function(hNode, xNode, bFromExtranet) { if(!hNode || !xNode)return; var hChilds = hNode.childNodes; for(var i=0; i v || v > this.maxValue){ this.warning += this.warn("VALUE_RANGE", "msg_info", this.minValue, this.maxValue); return false; } return true; } if(this.obj['min'] && v < this.minValue){ this.warning += this.warn("MIN", "msg_info", this.minValue); return false; } if(this.obj['max'] && v > this.maxValue){ this.warning += this.warn("MAX", "msg_info", this.maxValue); return false; } return true; }, getMessage:function (){ var msg = ""; if(this.obj['value_range']){ return this._info("VALUE_RANGE", "msg_info", this.minValue, this.maxValue); } if(this.obj['min']){ msg += this._info("MIN", "msg_info", this.minValue); } if(this.obj['max']){ msg += this._info("MAX", "msg_info", this.maxValue); } return msg; }, _check : function(){ if(this.obj['value_range']){ var arr = this.obj['value_range'].split(","); this.minValue = this.parseMethod(arr[0]) || Number.NEGATIVE_INFINITY; this.maxValue = this.parseMethod(arr[1]) || Number.POSITIVE_INFINITY; } if(this.obj['min']){ this.minValue = this.parseMethod(this.obj['min']) || Number.NEGATIVE_INFINITY; } if(this.obj['max']){ this.maxValue = this.parseMethod(this.obj['max']) || Number.POSITIVE_INFINITY; } return true; } }); var StrVdtor = defClass(); Object.extend(StrVdtor.prototype, AbsVdtor.prototype); Object.extend(StrVdtor.prototype, { initialize : function(_field) { AbsVdtor.prototype.initialize.call(this, _field); if(!this._check()) return false; }, method : function(){ var len = ($$F(this.el)||'').byteLength(); if(this.obj['length_range']){ var lengthRange = this.obj['length_range'].split(','); if(lengthRange[0] > len || len > lengthRange[1]){ this.warning += this.warn("LENGTH_RANGE", "msg_info", lengthRange[0], lengthRange[1]); return false; } return true; } if(this.obj['min_len'] && len < this.minLen){ this.warning += this.warn("MIN_LEN", "msg_info", this.minLen); return false; } if(this.obj['max_len'] && len > this.maxLen){ this.warning += this.warn("MAX_LEN", "msg_info", this.maxLen); return false } return true; }, getMessage : function(){ var msg = ""; if(this.obj['len_range']){ return this._info("LENGTH_RANGE", "msg_info", this.minLen, this.maxLen); } if(this.obj['min_len']){ msg += this._info("MIN_LEN", "msg_info", this.minLen); } if(this.obj['max_len']){ msg += this._info("MAX_LEN", "msg_info", this.maxLen); } if(msg == '' && ValidationHelper.isRequired(this.obj, this.el)){ msg = this._info("REQUIRED", "msg_info"); } return msg; }, _check : function(){ if(this.obj['len_range']){ var arr = this.obj['len_range'].split(","); this.minLen = parseInt(arr[0]) || 0; this.maxLen = parseInt(arr[1]) || Number.POSITIVE_INFINITY; } if(this.obj['min_len']){ this.minLen = parseInt(this.obj['min_len']) || 0; } if(this.obj['max_len']){ this.maxLen = parseInt(this.obj['max_len']) || 0; } return true; } }); var DateVdtor = defClass(); Object.extend(DateVdtor.prototype, AbsVdtor.prototype); Object.extend(DateVdtor.prototype, { formatRegExp : /^(yy|yyyy)(-|\/)(m{1,2})(\2)(d{1,2})(\W+(h{1,2})(:)(M{1,2})((\8)(s{0,2}))?)?$/, dateRegExp : /^(\d{2}|\d{4})(-|\/)(\d{1,2})(\2)(\d{1,2})(\W+(\d{1,2})(:)(\d{1,2})((\8)(\d{0,2}))?)?$/, initialize : function(_field) { AbsVdtor.prototype.initialize.call(this, _field); if(!this._check()) return false; }, method : function(){ var sFormat = this.obj['date_format']; if(!sFormat){ var type = this.obj['type']; if(type == 'date'){ sFormat = "yyyy-mm-dd"; }else if(type == 'datetime'){ sFormat = "yyyy-mm-dd HH:MM:ss"; } } var sTemp = sFormat.replace(/yy|mm|dd|hh|ss/gi, "t").replace(/m|d|h|s/ig, '\\d{1,2}').replace(/t/ig, '\\d{2}'); var oRegExp = new RegExp("^"+sTemp+"$"); var sValue = $$F(this.el) || ''; if(!oRegExp.test(sValue)){ this.warning = "\u6CA1\u6709\u5339\u914D\u65E5\u671F\u683C\u5F0F:" + sFormat; return false; } var matchs = sValue.match(this.dateRegExp); if(!matchs){ this.warning = "\u6CA1\u6709\u5339\u914D\u65E5\u671F\u683C\u5F0F:" + sFormat;; return false; } var year = parseInt(matchs[1], 10); var month = parseInt(matchs[3], 10); var day = parseInt(matchs[5], 10); var hour = parseInt(matchs[7], 10); var minute = parseInt(matchs[9], 10); var second = parseInt(matchs[12], 10); if(month < 1 || month > 12){ this.warning = "\u6708\u4EFD\u5E94\u8BE5\u4E3A1\u523012\u7684\u6574\u6570"; return false; } if (day < 1 || day > 31){ this.warning = "\u6BCF\u4E2A\u6708\u7684\u5929\u6570\u5E94\u8BE5\u4E3A1\u523031\u7684\u6574\u6570"; return false; } if ((month==4 || month==6 || month==9 || month==11) && day==31){ this.warning = "\u8BE5\u6708\u4E0D\u5B58\u572831\u53F7"; return false; } if (month==2){ var isleap=(year % 4==0 && (year % 100 !=0 || year % 400==0)); if (day>29){ this.warning = "2\u6708\u6700\u591A\u670929\u5929"; return false; } if ((day==29) && (!isleap)){ this.warning = "\u95F0\u5E742\u6708\u624D\u670929\u5929"; return false; } } if(hour && hour<0 || hour>23){ this.warning = "\u5C0F\u65F6\u5E94\u8BE5\u662F0\u523023\u7684\u6574\u6570"; return false; } if(minute && minute<0 || minute>59){ this.warning = "\u5206\u5E94\u8BE5\u662F0\u523059\u7684\u6574\u6570"; return false; } if(second && second<0 || second>59){ this.warning = "\u79D2\u5E94\u8BE5\u662F0\u523059\u7684\u6574\u6570"; return false; } return true; }, getMessage : function(){ var sFormat = this.obj['date_format']; if(!sFormat){ var type = this.obj['type']; if(type == 'date'){ sFormat = "yyyy-mm-dd"; }else if(type == 'datetime'){ sFormat = "yyyy-mm-dd HH:MM:ss"; } } return String.format("\u65E5\u671F\u683C\u5F0F\u4E3A\uFF1A{0}" ,sFormat); } }); function _valid(ev){ var el = this; var rst = ValidationHelper.valid(el); if(rst==null)return; if(window.bShowTitle) el.title = !rst.isValid ? rst.warning : rst.message; Element[rst.isValid?'removeClassName':'addClassName'](el, 'valid_error'); } function initEvents(){ var doms = [], tags = ["INPUT", "TEXTAREA", "SELECT"]; for (var i = 0; i < tags.length; i++){ var eles = document.body.getElementsByTagName(tags[i]); doms.push.apply(doms, $A(eles)); } for(var i = 0; i < doms.length; i++){ var dom = doms[i], f = (window.onValid||_valid).bind(dom); if(dom.getAttribute("validation", 2)==null)continue; Event.observe(dom, 'change', f); Event.observe(dom, 'blur', f); Event.observe(dom, 'focus', f); } } exCenter.onafterInitData(function(){ var doms = [], tags = ["INPUT", "TEXTAREA", "SELECT"]; for (var i = 0; i < tags.length; i++){ var eles = document.body.getElementsByTagName(tags[i]); doms.push.apply(doms, $A(eles)); } for(var i = 0; i < doms.length; i++){ var dom = doms[i]; var v = dom.getAttribute("validation", 2), pt, tmp, fmt; var pt = dom.getAttribute("pattern", 2); if(pt=='string' && (fmt = dom.getAttribute("xd:datafmt", 2))!=null){ if(fmt.indexOf('"number"')!=-1) pt = fmt.indexOf('numDigits:auto')!=-1? 'float' : 'integer'; } if(v==null || v.trim().length<=0){ if(pt==null || pt=='string')continue; dom.setAttribute("validation", 'type:\'' + pt + '\''); }else if(pt!=null && pt!='string'){ if(v.indexOf('type:')!=-1){ v = v.replace(/(^|,)type:[^,]*(,|$)/, '$1type:\'' + pt + '\'$2'); }else{ v = v + ',type:\'' + pt + '\''; } dom.setAttribute("validation", v); } (window.onValid||_valid).apply(dom, []); } initEvents(); }); function _validError(){ //donothing } document.getElementsByClassName = function(cls, p) { if(p && p.getElementsByClassName) return p.getElementsByClassName(cls); var arr = ($(p) || document.body).getElementsByTagName('*'); var rst = []; var regExp = new RegExp("(^|\\s)" + cls + "(\\s|$)"); for(var i=0,n=arr.length;i