EventUtils = function() { }; EventUtils.clickElement = function(element) { if(document.all) { element.click(); return; } if(element.onclick) { element.onclick(); return; } var win = (element.ownerDocument.parentWindow ? element.ownerDocument.parentWindow : element.ownerDocument.defaultView); var evt = win.document.createEvent("MouseEvents"); evt.initMouseEvent('click', false, true, win, 0, 0, 0, 0, 0, false, false, false, false, 0, null); element.dispatchEvent(evt); }; EventUtils.createTouchEevent = function(element, eventType, pageX, pageY, screenX, screenY, clientX, clientY) { var event = element.ownerDocument.createEvent('TouchEvent'); var touch = element.ownerDocument.createTouch(window, element, 1, pageX, pageY, screenX, screenY, clientX, clientY, 0, 0, 0, true); var touches = element.ownerDocument.createTouchList(touch); var targetTouches = element.ownerDocument.createTouchList(touch); var changedTouches = element.ownerDocument.createTouchList(touch); event.initTouchEvent(eventType, true, true, window, null, screenX, screenY, clientX, clientY, false, false, false, false, touches, targetTouches, changedTouches, 1, 0); element.dispatchEvent(event); }; EventUtils.addEvent = function(element, eventName, func) { if(element.attachEvent) { try { element.attachEvent(eventName, func); } catch(e) { } try { element.attachEvent("on" + eventName, func); } catch(e) { } } else if(element.addEventListener) { element.addEventListener(eventName, func, true); } else { element["on" + eventName] = func; } }; EventUtils.removeEvent = function(element, eventName, func) { if(element.detachEvent) { element.detachEvent("on" + eventName, func); } else if(element.removeEventListener) { element.removeEventListener(eventName, func, true); } else { //element["on" + eventName] = func; } }; EventUtils.stopPropagation = function(event) { if(event.stopPropagation) { event.stopPropagation(); } else { event.cancelBubble = true; } }; FormField = function(inputElementHTML, fieldType, style, styleClass, isTextArea) { this.inputElementHTML = inputElementHTML; this.id = "field_" + ("" + Math.random()).substring(2); this.fieldType = fieldType; this.style = !style || style=='null' || style=='' ? '' : style + (style.substring(style.length-1)==';' ? '' : ';'); this.styleClass = !styleClass || styleClass=='null' ? '' : styleClass; this.isTextArea = isTextArea; }; FormField.prototype.writeFieldElement = function(fieldBodyHTML, parentElement) { this.document = parentElement ? parentElement.ownerDocument : document; var height = this._getHeight(); var html = (this.fieldType=='hidden' ? this.resetInputElementHTML() : '') + '\n' + ' ' + ' ' + ' ' + fieldBodyHTML + ' ' + ' ' + '
'; var div = this.document.createElement('div'); div.id = this.id; div.style.cssText = "display:block; " + this.style + "text-indent: 0px !important; background-color:transparent !important; padding:0px 0px 0px 0px !important; border: #ffffff 0px none !important; outline:none !important; overflow:visible !important;"; if(this.styleClass!='') { div.className = this.styleClass; } div.innerHTML = html; if(parentElement) { parentElement.appendChild(div); } else { var id = Math.random(); document.write(' '); var span = document.getElementById(id); span.parentNode.replaceChild(div, span); } this.getInputElement().formField = this; }; FormField.prototype.resetInputElementHTML = function() { this._resetAttribute("id", 'input_' + this.id); if(this.fieldType) { this._resetAttribute("type", this.fieldType); } if(this.fieldType!='hidden') { this._resetAttribute("style", this.getInputElementCssText()); this._resetAttribute("class", this.styleClass); } return this.inputElementHTML; }; FormField.prototype._resetAttribute = function(attributeName, attributeValue) { var index = this.inputElementHTML.indexOf(attributeName + '="'); if(index==-1) { index = this.inputElementHTML.indexOf(' '); this.inputElementHTML = this.inputElementHTML.substring(0, index) + ' ' + attributeName + '="' + attributeValue + '"' + this.inputElementHTML.substring(index); } else { index += (attributeName + '="').length; var indexEnd = this.inputElementHTML.indexOf('"', index); this.inputElementHTML = this.inputElementHTML.substring(0, index) + attributeValue + this.inputElementHTML.substring(indexEnd); } }; FormField.prototype._getHeight = function() { var height = this.styleClass=='' ? null : CssUtils.getStyleByName(document, '.' + this.styleClass, 'height'); if(!height || height=='') { height = CssUtils.getStyle(this.style, 'height'); } return height; }; FormField.prototype.getAttribute = function(attributeName) { var index = this.inputElementHTML.indexOf(attributeName + '="'); if(index==-1) { return ""; } index += (attributeName + '="').length; var indexEnd = this.inputElementHTML.indexOf('"', index); return this.inputElementHTML.substring(index, indexEnd); }; FormField.prototype.getFieldElement = function() { return this.document.getElementById(this.id); }; FormField.prototype.getInputElement = function() { return this.document.getElementById('input_' + this.id); }; FormField.prototype.getInputElementCssText = function() { var height = this._getHeight(); return (this.isTextArea ? "" : ";line-height:normal !important") + ';' + this.style + (!height || height=='' ? '' : 'height:100% !important;') + 'display:inline-block; float:none; width:100% !important; background-color:transparent !important; padding:1px 0px 1px 1px !important; margin:0px !important; margin-left:-1px !important; border: 0px #fff none !important; outline:none !important;'; }; FormField.getFormField = function(fieldName) { var field = document.getElementById(fieldName); field = field ? field : document.getElementsByName(fieldName)[0]; if(field && field.formField) { return field.formField; } field = document.getElementsByName(fieldName + '_title')[0]; return field ? field.formField : null; }; FormField.Picker = function(pickerTitle, pickerHtml, displayArea, pickerWidth, pickerHeight, alignRight, autoSize, transparentDisabled, coverDisabled, terminalType) { if(!pickerHtml || pickerHtml=='') { return; } this.pickerTitle = pickerTitle; this.displayArea = displayArea; this.pickerWidth = (pickerWidth && pickerWidth>0 ? pickerWidth : (!this.displayArea ? 200 : this.displayArea.offsetWidth)); this.pickerHeight = (pickerHeight && pickerHeight>0 ? pickerHeight : 165); this.autoSize = autoSize; this.alignRight = alignRight; this.transparentDisabled = transparentDisabled; this.coverDisabled = coverDisabled; this.isTouchMode = terminalType && terminalType!='' && terminalType!='computer'; this.pickerHTML = typeof pickerHtml == 'function' ? pickerHtml.call(this) : pickerHtml; if(this.pickerHTML!='') { this.create(); this._created = true; } }; FormField.Picker.prototype.isCreated = function() { return this._created; }; FormField.Picker.prototype.create = function() { if(!this.isTouchMode) { this._createComputerPicker(); } else { this._createTouchPicker(); } }; FormField.Picker.prototype.show = function(pickerLeft, pickerTop) { if(!this.isCreated()) { var picker = this; window.setTimeout(function() { picker.show(pickerLeft, pickerTop); }, 100); } else if(!this.isTouchMode) { this._showComputerPicker(pickerLeft, pickerTop); } else { this._showTouchPicker(pickerLeft, pickerTop); } }; FormField.Picker.prototype.hide = function() { this.pickerContainer.style.display = 'none'; if(this.cover) { this.cover.style.display = 'none'; } }; FormField.Picker.prototype.destory = function() { if(!this.isTouchMode) { this._destoryComputerPicker(); } else { this._destoryTouchPicker(); } }; FormField.Picker.prototype.getRelationFields = function() { }; FormField.Picker.prototype._createComputerPicker = function() { this.topWindow = PageUtils.getTopWindow(); if(!this.coverDisabled) { var picker = this; this.cover = PageUtils.createCover(this.topWindow, 0, true); this.cover.onclick = function() { picker.destory(); }; } this.pickerContainer = this.topWindow.document.createElement("div"); this.pickerContainer.style.zIndex = this.cover ? Number(this.cover.style.zIndex) + 1 : DomUtils.getMaxZIndex(this.topWindow.document.body) + 1; this.pickerContainer.style.position = "absolute"; this.pickerContainer.style.width = this.pickerWidth + "px"; this.pickerContainer.style.height = "1px"; this.pickerContainer.style.visibility = 'hidden'; this.topWindow.document.body.insertBefore(this.pickerContainer, this.topWindow.document.body.childNodes[0]); this.pickerContainer.innerHTML = ''; this.pickerFrame = this.pickerContainer.getElementsByTagName("iframe")[0].contentWindow; var doc = this.pickerFrame.document; doc.open(); doc.write(this.pickerHTML); doc.close(); this.pickerBody = doc.body; this.pickerBody.style.margin = "0px"; CssUtils.cloneStyle(document, doc); }; FormField.Picker.prototype._showComputerPicker = function(pickerLeft, pickerTop) { this.pickerContainer.style.visibility = 'hidden'; this.pickerContainer.style.display = ''; if(this.cover) { this.cover.style.display = ''; } if(this.displayArea) { var pos = DomUtils.getAbsolutePosition(this.displayArea, null, true); pickerLeft = pos.left; pickerTop = pos.top; } var body = this.topWindow.document.body; var bottomSpacing = DomUtils.getClientHeight(this.topWindow.document) - (pickerTop + (this.displayArea ? this.displayArea.offsetHeight : 0) - DomUtils.getScrollTop(this.topWindow.document)) - 3; var topSpacing = pickerTop - DomUtils.getScrollTop(this.topWindow.document) - 3; var width = this.pickerWidth; if(this.autoSize) { this.pickerContainer.getElementsByTagName("iframe")[0].style.width = "1px"; width = Math.max(this.pickerWidth, this.pickerFrame.document.body.scrollWidth); } this.pickerContainer.style.width = width + "px"; this.pickerContainer.getElementsByTagName("iframe")[0].style.width = width + "px"; var height = this.pickerHeight; if(this.autoSize) { this.pickerContainer.getElementsByTagName("iframe")[0].style.height = "1px"; height = Math.min(this.pickerFrame.document.body.scrollHeight, Math.max(bottomSpacing, topSpacing)); } this.pickerContainer.style.height = height + "px"; this.pickerContainer.getElementsByTagName("iframe")[0].style.height = height + "px"; if(!this.displayArea && this.autoSize) { this.pickerContainer.style.top = Math.max(DomUtils.getScrollTop(this.topWindow.document), Math.min(pickerTop, DomUtils.getScrollTop(this.topWindow.document) + DomUtils.getClientHeight(this.topWindow.document) - height)) + "px"; } else if(bottomSpacing>=height || topSpacing' + '
' + this.pickerHTML + '
' + '
' + ' ' + ' ' + ' ' + ' ' + ' ' + '
\u53D6\u6D88\u786E\u5B9A
' + '
'; this.pickerContainer.innerHTML = html; this.pickerBody = this.topWindow.document.getElementById('pickerBody'); var picker = this; this.topWindow.document.getElementById('touchPickerOkButton').onclick = function() { if(picker.doOK) { picker.doOK(); } picker.destory(); }; this.topWindow.document.getElementById('touchPickerCancelButton').onclick = function() { picker.destory(); }; }; FormField.Picker.prototype._showTouchPicker = function(pickerLeft, pickerTop) { if(this.cover) { this.cover.style.display = ''; } this.pickerContainer.style.left = Math.round((this.cover.offsetWidth - this.pickerContainer.offsetWidth)/2) + 'px'; this.pickerBody.style.overflowY = "hidden" var diff = this.pickerContainer.offsetHeight + 20 - this.cover.offsetHeight; if(diff > 0) { this.pickerBody.style.height = (this.pickerBody.offsetHeight - diff) + "px"; this.pickerBody.style.overflowY = "auto" } this.pickerContainer.style.top = Math.round((this.cover.offsetHeight - this.pickerContainer.offsetHeight)/2) + 'px'; this.pickerContainer.style.visibility = 'visible'; }; FormField.Picker.prototype._destoryTouchPicker = function() { PageUtils.destoryCover(this.topWindow, this.cover); }; Ajax = function() { this.xmlHttp = null; this.errorCount = 0; try { this.xmlHttp = new XMLHttpRequest(); } catch(e) { try { this.xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch(ex) { this.xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } } } Ajax.prototype.openRequest = function(method, url, data, async, onDataArriveCallback, onErrorCallback, contentType) { try { this.abort(); } catch(e) { } try { this.xmlHttp.timeout = async ? 30000 : 0; } catch(e) { } this.xmlHttp.open(method, url, async); var ajax = this; this.xmlHttp.onreadystatechange = function() { if(ajax.xmlHttp.readyState!=4) { return; } if(ajax.xmlHttp.status<300 && ajax.xmlHttp.status>=200) { ajax.errorCount = 0; if(onDataArriveCallback) { onDataArriveCallback.call(); } } else if(ajax.xmlHttp.status!=0) { ajax.errorCount++; if(onErrorCallback) { onErrorCallback.call(); ajax.errorCount = 0; } } }; try { this.xmlHttp.onerror = function() { if(onErrorCallback) { onErrorCallback.call(); } }; } catch(e) { } if(contentType) { this.xmlHttp.setRequestHeader("Content-Type", contentType); } this.xmlHttp.send(data); }; Ajax.prototype.abort = function() { this.xmlHttp.abort(); }; Ajax.prototype.getStatus = function() { return this.xmlHttp.status; }; Ajax.prototype.getErrorCount = function() { return this.errorCount; }; Ajax.prototype.getResponseText = function() { return this.xmlHttp.responseText; }; Ajax.prototype.getResponseXML = function() { return this.xmlHttp.responseXML; }; Ajax.getText = function(xmlElement) { return document.all ? xmlElement.text : xmlElement.textContent; }; function linkJumpCheck(){ var host=window.location.host; if(host.indexOf('.gov.cn')==-1){ return; } var links=document.getElementsByTagName('a'); for(i=0;links && i 0 && (plugin = navigator.plugins["Shockwave Flash"])) { var values = plugin.description.split(" "); for(var i = 0; i < values.length; ++i) { if(!isNaN(values[i]=parseInt(values[i]))) { return values[i]; } } } return null; } CookieUtils = function() { }; CookieUtils.getCookie = function(cookieName) { var cookies = document.cookie.split("; "); for (var i=0; i < cookies.length; i++) { var values = cookies[i].split("="); if (cookieName == values[0]) { return unescape(values[1]); } } return null; }; CookieUtils.setCookie = function(cookieName, cookieValue, age) { var expires = new Date(new Date().valueOf() + age * 1000); document.cookie = cookieName + "=" + cookieValue + ";" + (age >= 0 ? " expires=" + expires.toGMTString() + ";" : "") + " path=/"; }; CookieUtils.removeCookie = function(cookieName) { CookieUtils.setCookie(cookieName, '', 0); }; CssUtils = function() { }; CssUtils.appendCssFile = function(doc, cssId, cssUrl) { var head = DomUtils.getHead(doc); var links = head.getElementsByTagName("link"); if(links && links.length>0) { for(var i=0; i currentDegree ? 1 : -1) * Math.abs(step); } CssUtils.stopRotate(element); element.rotateTimer = window.setInterval(function() { currentDegree += step; if(targetDegree!=-1 && ((step<0 && currentDegree<=targetDegree) || (step>0 && currentDegree>=targetDegree))) { CssUtils.stopRotate(element); CssUtils.setDegree(element, targetDegree); return; } CssUtils.setDegree(element, currentDegree); }, interval); }; CssUtils.stopRotate = function(element) { if(element.rotateTimer && element.rotateTimer!=0) { window.clearInterval(element.rotateTimer); element.rotateTimer = 0; CssUtils.setDegree(element, 0); } }; CssUtils.setOpacity = function(element, opacity) { opacity = Math.max(0, opacity); element.style.cssText += 'filter: alpha(opacity=' + (opacity*100) + '); opacity: ' + opacity + ';' }; DateView = function(date, terminalType, selectDisabled) { this.year = date.getFullYear(); this.month = date.getMonth() + 1; this.day = date.getDate(); this.isTouchMode = terminalType && terminalType!='' && terminalType!='computer'; this.selectDisabled = selectDisabled; }; DateView.prototype.create = function(parentElement) { if(parentElement.innerHTML=='') { parentElement.innerHTML = this.getHTML(); } if(!this.isTouchMode) { this._writeDate(parentElement); this.created = true; if(this.onload) { this.onload(); } } else { var dateView = this; ScriptUtils.appendJsFile(document, RequestUtils.getContextPath() + '/jeaf/common/js/scroller.js', 'scrollerScript', function() { dateView._initTouchView(parentElement); dateView.created = true; if(dateView.onload) { dateView.onload(); } }); } }; DateView.prototype.getHTML = function() { var weekDays = ["\u65E5", "\u4E00", "\u4E8C", "\u4E09", "\u56DB", "\u4E94", "\u516D"]; var html = '' html += '
' + '
' + ' ' + ' ' + ' ' + ' ' + ' ' + '
' + '
' + '
' + ' ' + ' '; for(var i = 0; i < weekDays.length; i++) { html += ' '; } html += ' '; for(var i = 0; i < 6; i++) { html+= ''; for(var j = 0; j < 7; j++) { html += ''; } html += ''; } html += '
\u661F\u671F' + weekDays[i] + '
' + '
' + '
'; return html; }; DateView.prototype._initTouchView = function(parentElement) { var dateView = this; var dayPicker = DomUtils.getElement(parentElement, 'div', 'dayPicker'); dayPicker.scroller = new Scroller(dayPicker, false, false, false, false, false); dayPicker.scroller.onAfterScroll = function(x, y, isLeft, isRight, isTop, isBottom, touchEnd) { if(Math.abs(y) < Math.abs(x)) { y = 0; } else { x = 0; } if(x>0 || y>0) { dateView.month++; if(dateView.month>12) { dateView.month = 1; dateView.year++; } } else if(x<0 || y<0) { dateView.month--; if(dateView.month<1) { dateView.month = 12; dateView.year--; } } dateView.day = -1; dateView._writeDate(parentElement); if(dateView.onmonthchanged) { dateView.onmonthchanged(); } }; this._writeDate(parentElement); }; DateView.prototype._writeDate = function(parentElement) { var dateView = this; FormField.NumberPicker.generateNumberPicker(DomUtils.getElement(parentElement, 'div', 'yearPicker'), this.year - 10, this.year + 10, this.year, "\u5E74", function(numberValue) { dateView.year = numberValue; dateView.day = -1; dateView._writeDate(parentElement); if(dateView.onmonthchanged) { dateView.onmonthchanged(); } }, false, this.isTouchMode); FormField.NumberPicker.generateNumberPicker(DomUtils.getElement(parentElement, 'div', 'monthPicker'), 1, 12, this.month, "\u6708", function(numberValue) { dateView.month = numberValue; dateView.day = -1; dateView._writeDate(parentElement); if(dateView.onmonthchanged) { dateView.onmonthchanged(); } }, false, this.isTouchMode); this.dayCell = null; this.dayTable = DomUtils.getElement(parentElement, 'table', 'dayTable'); var today = new Date(); var date = new Date(this.year, this.month - 1, 1); var week = date.getDay(); var maxDay = 100; for(var i = 0; i < 42; i++) { var cell = this.dayTable.rows[Math.floor(i/7)+1].cells[i%7]; var value = " "; var className = "day"; if(i >= week && i < maxDay) { value = date.getDate(); date.setDate(value + 1); if(date.getMonth() + 1 != this.month) { maxDay = value; } if(i%7==0 || i%7==6) { className += " weekend"; } if(this.year==today.getFullYear() && this.month==today.getMonth() + 1 && value==today.getDate()) { className += " today"; } if(value==this.day && !this.selectDisabled) { this.dayCell = cell; className += " selectedDay"; } } cell.innerHTML = value; cell.className = className; if(cell.onclick) { continue; } cell.onclick = function() { var day = Number(this.innerHTML); if(isNaN(day)) { return; } dateView.day = day; if(dateView.dayCell) { dateView.setSelected(dateView.dayCell, false); } if(!dateView.selectDisabled) { dateView.dayCell = this; dateView.setSelected(this, true); } if(dateView.onclick) { dateView.onclick(this); } }; cell.onmouseover = function() { if(dateView.onmouseover) { dateView.onmouseover(this); } }; cell.onmouseout = function() { if(dateView.onmouseout) { dateView.onmouseout(this); } }; } }; DateView.prototype.setSelected = function(dayCell, selected) { if(!selected) { dayCell.className = dayCell.className.replace(" selectedDay", ''); } else if(dayCell.className.indexOf(" selectedDay")==-1) { dayCell.className = dayCell.className + " selectedDay"; } }; DialogUtils = function() { }; DialogUtils.openDialog = function(dialogUrl, width, height, dialogTitle, dialogArguments, onDialogLoad, onDialogBodyLoad, onDialogClose) { if(RequestUtils.isMobileRequest) { window.dialogUrl = dialogUrl; return; } var topWindow = PageUtils.getTopWindow(); var clientWidth = DomUtils.getClientWidth(topWindow.document); var clientHeight = DomUtils.getClientHeight(topWindow.document); if(("" + width).lastIndexOf('%')!=-1) { width = clientWidth * Number(width.substring(0, width.length - 1)) / 100; } if(("" + height).lastIndexOf('%')!=-1) { height = clientHeight * Number(height.substring(0, height.length - 1)) / 100; } var cover = PageUtils.createCover(topWindow, 6); var top = Math.max((cover.offsetHeight - height - 20) / 2, 0); var left = Math.max((cover.offsetWidth - width - 20) / 2, 0); var dialog = topWindow.document.createElement('iframe'); dialog.dialogUrl = dialogUrl; if(onDialogLoad) { dialog.onDialogLoad = onDialogLoad; } if(onDialogBodyLoad) { dialog.onDialogBodyLoad = onDialogBodyLoad; } if(onDialogClose) { dialog.onDialogClose = onDialogClose; } dialog.frameBorder = 0 ; dialog.allowTransparency = true; var siteId = StringUtils.getPropertyValue(location.href, "siteId"); if(!siteId || siteId=='') { siteId = DomUtils.getMetaContent(document, "siteIdMeta"); } if((!siteId || siteId=='') && document.getElementsByName("siteId")[0]) { siteId = document.getElementsByName("siteId")[0].value; } var url = RequestUtils.getContextPath() + "/jeaf/dialog/dialog.shtml"; url += siteId && siteId!="" && siteId!="0" ? '?siteId=' + siteId : ''; url += (dialogTitle ? (url.indexOf('?')==-1 ? '?' : '&') + "dialogTitle=" + StringUtils.utf8Encode(dialogTitle) : ""); dialog.src = url; dialog.style.cssText = 'position: absolute; z-index:' + (Number(cover.style.zIndex) + 1) + '; left:' + left + 'px; top:' + top + 'px; width:' + width + 'px; height:' + height + 'px; visibility: hidden; box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.3)'; dialog.opener = window; dialog.id = "dialog"; dialog.dialogArguments = dialogArguments; cover.appendChild(dialog); }; DialogUtils.closeDialog = function() { if(!window.frameElement) { window.close(); return; } var win = PageUtils.getTopWindow(); var dialogFrame = DialogUtils.getDialogFrame(); if(dialogFrame.onDialogClose) { dialogFrame.onDialogClose.call(null, dialogFrame.contentWindow.document.getElementById("dialogBody")); } PageUtils.destoryCover(win, dialogFrame.parentNode); try { var range = DomSelection.createRange(win.document, win.document.body); range.collapse(true); DomSelection.selectRange(win, range); } catch(e) { } }; DialogUtils.adjustPriority = function(applicationName, viewName, title, width, height, parameter) { var left =(screen.width - width)/2; var top =(screen.height - height - 16)/2; var url = RequestUtils.getContextPath() + "/jeaf/dialog/adjustPriority.shtml"; url += "?applicationName=" + applicationName; url += "&viewName=" + viewName; url += "&title=" + StringUtils.utf8Encode(title); if(parameter && parameter!="") { url += "&" + parameter; } DialogUtils.openDialog(url, width, height); }; DialogUtils.selectAttachment = function(selectorUrl, recordId, attachmentType, width, height, scriptRunAfterSelect) { var url = RequestUtils.getContextPath() + selectorUrl; url += (selectorUrl.lastIndexOf('?')==-1 ? '?' : '&') + 'id=' + recordId; url += '&attachmentSelector.scriptRunAfterSelect=' + StringUtils.utf8Encode(scriptRunAfterSelect); url += '&attachmentSelector.type=' + attachmentType; DialogUtils.openDialog(url, width, height); }; DialogUtils.openListDialog = function(dialogTitle, source, width, height, multiSelect, param, scriptEndSelect, key, itemsText, separator) { if(itemsText && itemsText!="") { if(RequestUtils.isMobileRequest) { window.itemsText = itemsText; } else { itemsText = itemsText.replace(/\0/g, ','); source = "listDialogItemsText"; var hidden = document.getElementsByName(source)[0]; if(!hidden) { try { hidden = document.createElement(''); } catch(e) { hidden = document.createElement('input'); hidden.type = 'hidden'; hidden.name = source; } document.body.appendChild(hidden); } hidden.value = itemsText; } } var url = RequestUtils.getContextPath() + "/jeaf/dialog/listDialog.shtml" + "?title=" + StringUtils.utf8Encode(dialogTitle) + "&source=" + StringUtils.utf8Encode(source) + "&multiSelect=" + multiSelect + "¶m=" + StringUtils.utf8Encode(param) + (scriptEndSelect ? "&script=" + StringUtils.utf8Encode(scriptEndSelect) : "") + (key ? "&key=" + StringUtils.utf8Encode(key) : "") + (separator && separator!="" ? "&separator=" + StringUtils.utf8Encode(separator) : ""); DialogUtils.openDialog(url, width, height); }; DialogUtils.openInputDialog = function(dialogTitle, inputs, width, height, script, callback, onDialogLoad, onDialogBodyLoad, onDialogClose) { var url = RequestUtils.getContextPath() + "/jeaf/dialog/inputDialog.shtml" + "?formTitle=" + StringUtils.utf8Encode(dialogTitle) + (script && script!="" ? "&script=" + StringUtils.utf8Encode(script) : ""); for(var i=0; i0) { range = selection.getRangeAt(0); } var element = DomSelection.getSelectedElement(range); return element && element.ownerDocument!=window.document ? null : range; }; DomSelection.getSelectedElement = function(range) { if(!range) { return null; } if(range.getBookmark) { return range.parentElement(); } else if(range.select) { return range.item(0); } else if(range.startContainer) { if(range.startContainer.nodeType==3) { if(!range.collapsed && range.startOffset==range.startContainer.length && range.startContainer.nextSibling) { return range.startContainer.nextSibling; } return range.startContainer.parentNode; } var element = range.startContainer.childNodes[range.startOffset]; if(element && element.nodeType==1) { return element; } return range.startContainer; } }; DomSelection.getSelectText = function(window) { var range = DomSelection.getRange(window); if(!range) { return ""; } if(range.getBookmark) { return range.text; } else if(range.toString) { return range.toString(); } }; DomSelection.getSelectHtmlText = function(window) { var range = DomSelection.getRange(window); if(!range) { return ""; } if(range.getBookmark) { return range.htmlText; } var htmlText = ""; if(range.startContainer.nodeType==3) { htmlText = range.startContainer.nodeValue.substring(range.startOffset, range.startContainer==range.endContainer ? range.endOffset : range.startContainer.nodeValue.length); } else { htmlText = range.startContainer.outerHTML; } if(range.startContainer==range.endContainer) { return htmlText; } var startSibiling = range.startContainer; while(true) { if(DomUtils.containsNode(startSibiling.parentNode, range.endContainer)) { break; } startSibiling = startSibiling.parentNode; } startSibiling = startSibiling.nextSibling; while(!DomUtils.containsNode(startSibiling, range.endContainer)) { htmlText += startSibiling.nodeType==3 ? startSibiling.textContent : startSibiling.outerHTML; startSibiling = startSibiling.nextSibling; } if(range.endContainer.nodeType==3) { htmlText += range.endContainer.nodeValue.substring(0, range.endOffset); } else { htmlText += range.endContainer.outerHTML; } return htmlText; }; DomSelection.selectRange = function(window, range) { if(!range) { return; } if(range.select) { try { range.select();} catch(e) {} } else if(range.startContainer) { var selection = DomSelection.getSelection(window); window.focus(); selection.removeAllRanges(); selection.addRange(range); } }; DomSelection.createRange = function(document, element) { var range = document.createRange ? document.createRange() : document.body.createTextRange(); if(element==document.body) { return range; } if(range.moveToElementText) { range.moveToElementText(element); } else if(element.childNodes.length==0) { range.setStart(element, 0); range.setEnd(element, 0); } else { range.setStart(element.childNodes[0], 0); var endNode = element.childNodes[element.childNodes.length - 1]; range.setEnd(endNode, endNode.length ? endNode.length : 0); } return range; }; DomSelection.getRangeBookmark = function(range) { if(range.getBookmark) { return {bookmark: range.getBookmark()}; } else if(range.select) { return {control: DomSelection._getRangeAddress(range.item(0), 0)}; } else if(range.startContainer) { return {start: DomSelection._getRangeAddress(range.startContainer, range.startOffset), end: DomSelection._getRangeAddress(range.endContainer, range.endOffset)}; } }; DomSelection.createRangeByBookmark = function(document, rangeBookmark) { try { var range; if(rangeBookmark.bookmark) { range = document.body.createTextRange(); range.moveToBookmark(rangeBookmark.bookmark); } else if(rangeBookmark.control) { range = document.body.createControlRange(); range.add(DomSelection._getNodeByAddress(document, rangeBookmark.control.address)); } else if(rangeBookmark.start) { range = document.createRange(); range.setStart(DomSelection._getNodeByAddress(document, rangeBookmark.start.address), rangeBookmark.start.offset); range.setEnd(DomSelection._getNodeByAddress(document, rangeBookmark.end.address), rangeBookmark.end.offset); } return range; } catch(e) { return null; } }; DomSelection._getRangeAddress = function(node, offset) { while(node.nodeType==3) { if(!node.previousSibling || node.previousSibling.nodeType!=3) { break; } node = node.previousSibling; offset += node.length; } var address = []; while(node.tagName!="BODY") { var childNodes = node.parentNode.childNodes; for(var i=0; i=0; i--) { node = node.childNodes[address[i]]; } return node; }; DomSelection.pasteHTML = function(window, range, html) { DomSelection.selectRange(window, range); if(range && range.pasteHTML) { range.pasteHTML(html); } else if("" + window.document.queryCommandSupported('insertHTML')=="true") { window.document.execCommand('insertHTML', false, html); } else if(range && range.surroundContents) { var element = window.document.createElement("b"); range.surroundContents(element); element.outerHTML = html; } }; DomSelection.inRange = function(range, element) { if(DomSelection.getSelectedElement(range)==element) { return true; } else if(range.selectNode) { var elementRange = element.ownerDocument.createRange(); elementRange.selectNode(element); var elementRect = elementRange.getBoundingClientRect(); var rangeRect = range.getBoundingClientRect(); return elementRect.right >= rangeRect.left && elementRect.left <= rangeRect.left + rangeRect.width && elementRect.bottom >= rangeRect.top && elementRect.top <= rangeRect.top + rangeRect.height; } else { var rect = element.getBoundingClientRect(); return rect.right >= range.boundingLeft && rect.left <= range.boundingLeft + range.boundingWidth && rect.bottom >= range.boundingTop && rect.top <= range.boundingTop + range.boundingHeight; } }; DomSelection.getRangePosition = function(range, element) { if(!range.startContainer || range.startContainer!=range.endContainer || range.startOffset!=range.endOffset) { return 'in'; } if(range.startContainer.nodeType==1) { return 'before'; } if(range.startContainer.nodeType!=3 || (range.startOffset!=0 && range.startOffset!=range.startContainer.length)) { return 'in'; } var position = range.startOffset==0 ? 'before' : 'after'; for(var obj = range.startContainer; position!='in' && obj!=element && obj.tagName!='BODY'; obj = obj.parentNode) { if((position=='before' && obj.previousSibling) || (position=='after' && obj.nextSibling && (obj.nextSibling.tagName!='BR' || obj.nextSibling.nextSibling))) { position = 'in'; } } return position; }; DomUtils = function() { }; DomUtils.createActiveXObject = function(classid, id) { var obj = document.getElementById(id); if(obj) { return obj; } obj = document.createElement("object"); obj.classid = classid; obj.id = id; document.body.appendChild(obj); return obj; }; DomUtils.getElement = function(parentElement, tagName, id) { if(tagName && tagName!="") { var elements = parentElement.getElementsByTagName(tagName); for(var i = 0; elements && i < elements.length; i++) { if(elements[i].id == id || elements[i].name == id) { return elements[i]; } } return null; } var found = null; DomUtils.traversalChildElements(parentElement, function(element) { if(element.id==id || element.name==id) { found = element; return true; } }); return found; }; DomUtils.getElements = function(parentElement, tagName, id) { var found = []; if(tagName && tagName!="") { var elements = parentElement.getElementsByTagName(tagName); for(var i = 0; elements && i < elements.length; i++) { if(elements[i].id == id || elements[i].name == id) { found.push(elements[i]); } } return found; } DomUtils.traversalChildElements(parentElement, function(element) { if(element.id==id || element.name==id) { founds.push(element); return true; } }); return found; }; DomUtils.nextElement = function(element) { var next = element.nextSibling; while(next) { if(next.tagName) { return next; } next = next.nextSibling; } return null; }; DomUtils.getOffsetParent = function(element) { var parent = element.parentNode; for(; ",BODY,TD,TABLE,DIV,SPAN,A,UL,LI,PRE,".indexOf("," + parent.tagName + ",")==-1; parent = parent.parentNode); return parent; }; DomUtils.insertAfter = function(newNode, refNode) { var nextSibling = refNode.nextSibling; if(nextSibling) { refNode.parentNode.insertBefore(newNode, nextSibling); } else { refNode.parentNode.appendChild(newNode); } return newNode; }; DomUtils.containsNode = function(parentNode, childNode) { if(parentNode==childNode) { return true; } var childNodes = parentNode.childNodes; for(var i=0; imaxZIndex) { maxZIndex = zIndex; } }); return maxZIndex; }; DomUtils.getMetaContent = function(doc, name) { var metas = doc.getElementsByTagName("meta"); if(!metas) { return null; } for(var i=metas.length-1; i>=0; i--) { if(metas[i].name==name) { return metas[i].content; } } return null; }; DomUtils.getMeta = function(doc, name, autoCreate) { var metas = doc.getElementsByTagName('meta'); for(var i=0; i < metas.length; i++) { if(metas[i].name==name) { return metas[i]; break; } } if(!autoCreate) { return null; } var meta; try { meta = doc.createElement(''); } catch(e) { meta = doc.createElement('meta'); meta.setAttribute('name', name); } doc.getElementsByTagName('head')[0].appendChild(meta); return meta; }; DomUtils.setElementHTML = function(element, html, inner) { html = html.replace(/]+))/gi,'$& _savedurl=$1'); html = html.replace(/]+))/gi,'$& _savedurl=$1'); html = html.replace(/]+))/gi,'$& _savedurl=$1'); var parentElement; if(inner) { parentElement = element; element.innerHTML = html; } else { parentElement = element.parentElement; element.outerHTML = html; } var tags = [["img", "src"], ["a", "href"], ["area", "href"]]; for(var i=0; i"; return str+">"+this.innerHTML+""; }); HTMLElement.prototype.__defineSetter__("outerHTML",function(s) { var r = this.ownerDocument.createRange(); r.setStartBefore(this); var df = r.createContextualFragment(s); this.parentNode.replaceChild(df, this); return s; }); HTMLElement.prototype.__defineGetter__("canHaveChildren",function() { return !/^(area|base|basefont|col|frame|hr|img|br|input|isindex|link|meta|param)$/.test(this.tagName.toLowerCase()); }); } } catch(e) { } DomUtils.getHead = function(doc) { var head = doc.getElementsByTagName("head")[0]; if(!head) { head = doc.createElement("head"); if(doc.getFirstChild()) { doc.insertBefore(head, doc.getFirstChild()); } else { doc.appendChild(head); } } return head; }; DomUtils.getClientWidth = function(doc) { if(doc.documentElement.clientWidth > 0 && doc.body.clientWidth > 0 && doc.body.clientWidth < doc.body.scrollWidth) { return doc.documentElement.clientWidth < doc.body.scrollWidth ? doc.documentElement.clientWidth : doc.body.clientWidth; } return doc.documentElement.clientWidth==0 ? doc.body.clientWidth : doc.documentElement.clientWidth; }; DomUtils.getClientHeight = function(doc) { if(doc.documentElement.clientHeight > 0 && doc.body.clientHeight > 0 && doc.body.clientHeight < doc.body.scrollHeight) { return doc.documentElement.clientHeight < doc.body.scrollHeight ? doc.documentElement.clientHeight : doc.body.clientHeight; } return doc.documentElement.clientHeight==0 ? doc.body.clientHeight : doc.documentElement.clientHeight; }; DomUtils.getScrollTop = function(doc) { var scrollTop = doc.documentElement.scrollTop; if(scrollTop==0) { scrollTop = doc.body.scrollTop; } if(scrollTop==0 && doc.defaultView && doc.defaultView.scrollY) { scrollTop = doc.defaultView.scrollY; } return scrollTop; }; DomUtils.getScrollLeft = function(doc) { var scrollLeft = doc.documentElement.scrollLeft; if(scrollLeft==0) { scrollLeft = doc.body.scrollLeft; } if(scrollLeft==0 && doc.defaultView && doc.defaultView.scrollX) { scrollLeft = doc.defaultView.scrollX; } return scrollLeft; }; DomUtils.getSpacing = function(obj, place) { //\u83B7\u53D6\u5BF9\u8C61\u95F4\u9699,place=['left', 'top', 'right', 'bottom'] var margin = CssUtils.getElementComputedStyle(obj, 'margin-' + place); var padding = CssUtils.getElementComputedStyle(obj, 'padding-' + place); margin = !margin ? 0 : Number(margin.replace("px", "")); padding = !padding ? 0 : Number(padding.replace("px", "")); return (isNaN(margin) ? 0 : margin) + (isNaN(padding) ? 0 : padding); }; DomUtils.getBorderWidth = function(obj, place) { //\u83B7\u53D6\u8FB9\u6846\u5BBD\u5EA6,place=['left', 'top', 'right', 'bottom'] var width = CssUtils.getElementComputedStyle(obj, 'border-' + place + "-width"); width = !width ? 0 : Number(width.replace("px", "")); return (isNaN(width) ? 0 : width) }; DomUtils.createLink = function(window, range) { var random = ("" + Math.random()).substring(2); var href = 'javascript:alert(' + random + ')'; if(range && range.execCommand) { range.execCommand("createLink", false, href); } else { DomSelection.selectRange(window, range); if(!window.document.execCommand("createLink", false, href)) { var a = window.document.createElement("a"); range.surroundContents(a); a.href = href; } } var i=0; var links = window.document.getElementsByTagName("a"); for(; i < links.length && links[i].href.indexOf(random)==-1; i++); var images = links[i].getElementsByTagName("img"); for(var j=0; j<(images ? images.length : 0); j++) { images[j].border = 0; } links[i].removeAttribute("href"); if(links[i].innerHTML && links[i].innerHTML.indexOf(random)!=-1) { links[i].innerHTML = ''; } return links[i]; }; DomUtils.createElement = function(window, range, elementType) { var id = ("" + Math.random()).substring(2); DomSelection.pasteHTML(window, range, '<' + elementType + ' id="' + id + '">'); var element = window.document.getElementById(id); if(element) { element.removeAttribute("id"); return element; } }; DomUtils.getWindowBookmark = function(window, noFocusPrompt) { var selection = DomSelection.getSelection(window); var range = DomSelection.getRange(window); var selectedElement = DomSelection.getSelectedElement(range); if(!selectedElement) { alert(noFocusPrompt); return null; } return {window:window, document:window.document, range:range, selection:selection, selectedElement:selectedElement}; }; DomUtils.setAttribute = function(element, propertyName, propertyValue) { var document = element.ownerDocument; if(!document.all) { element.setAttribute(propertyName, propertyValue); return element; } var id = element.id; var newId = Math.random(); element.id = newId; element.removeAttribute(propertyName); element.setAttribute("temp_property", propertyValue); element.outerHTML = element.outerHTML.replace("temp_property", propertyName); element = document.getElementById(newId); element.id = id; return element }; DomUtils.moveTableRow = function(table, fromRowIndex, toRowIndex) { if(fromRowIndex==toRowIndex || toRowIndex>=table.rows.length) { return; } if(table.moveRow) { table.moveRow(fromRowIndex, toRowIndex); return; } var parentNode = table.rows[fromRowIndex].parentNode; if(toRowIndex=table.rows.length-1) { parentNode.appendChild(table.rows[fromRowIndex]); } else { parentNode.insertBefore(table.rows[fromRowIndex], table.rows[toRowIndex + 1]); } }; FieldValidator = function() { }; FieldValidator.validateFieldRequired = function(src, required, fieldName) { if(!src) { return ""; } if(src.value=="" && required) { alert((fieldName ? fieldName : "\u5185\u5BB9") + "\u4E0D\u80FD\u4E3A\u7A7A\uFF01"); src.focus(); return "NaN"; } return src.value; }; FieldValidator.validateStringField = function(src, mask, required, fieldName) { var value = FieldValidator.validateFieldRequired(src, required, fieldName); if(value == "" || value == "NaN") { return value; } if(mask && mask != "") { var newMask = mask.replace(new RegExp("\\x27", "g"), "\\x27").replace(new RegExp(",", "g"), ""); if(value.search(new RegExp("[" + newMask + "]")) != - 1) { alert((fieldName ? fieldName : "\u8F93\u5165\u5185\u5BB9") + "\u4E0D\u80FD\u5305\u542B" + mask + "\u7B49\u5B57\u7B26\uFF01"); src.focus(); src.select(); return "NaN"; } } return value; }; FieldValidator.validateNumberField = function(src, required, fieldName) { var value = FieldValidator.validateFieldRequired(src, required, fieldName); if(value == "" || value == "NaN") { return value; } if(isNaN(Number(value))) { alert((fieldName ? fieldName : "\u60A8") + "\u8F93\u5165\u7684\u6570\u5B57\u4E0D\u6B63\u786E\uFF01"); src.focus(); src.select(); return "NaN"; } return value.trim(); }; FieldValidator.validateDateField = function(src, required, fieldName) { var value = FieldValidator.validateFieldRequired(src, required, fieldName); if(value == "" || value == "NaN") { return value; } var dateValue = new Date(value.replace(new RegExp("-", "g"), "/")); if(isNaN(dateValue)) { alert((fieldName ? fieldName : "\u60A8") + "\u8F93\u5165\u7684\u65E5\u671F\u683C\u5F0F\u4E0D\u6B63\u786E\uFF01"); src.focus(); src.select(); return "NaN"; } return value; }; DateField = function(inputElementHTML, styleClass, style, selectButtonStyleClass, selectButtonStyle, alignLeft, parentElement, terminalType) { FormField.call(this, inputElementHTML, 'text', style, styleClass); this.terminalType = terminalType; this.alignLeft = alignLeft; if(!selectButtonStyleClass || selectButtonStyleClass=='' || selectButtonStyleClass=='null') { selectButtonStyleClass = 'dropDownButton'; } var html = '' + ' ' + ' ' + ' ' + ' ' + '
' + this.resetInputElementHTML() + ' 
'; this.writeFieldElement(html, parentElement); var datePickerButton = this.document.getElementById((this.getInputElement().readOnly ? "dateTable_" : "picker_") + this.id); var dateField = this; datePickerButton.onclick = function() { dateField.onSelectDate(); } }; DateField.prototype = new FormField(); DateField.prototype.onSelectDate = function() { new FormField.DatePicker(this.getInputElement(), this.getFieldElement(), this.alignLeft, this.terminalType).show(); }; DateTimeField = function(inputElementHTML, styleClass, style, selectButtonStyleClass, selectButtonStyle, parentElement, selectOnly, terminalType) { FormField.call(this, inputElementHTML, 'hidden', style, styleClass); this.terminalType = terminalType; this.timeFocus = "Hour"; var dateValue = ''; var hourValue = ''; var minuteValue = ''; var secondValue = ''; var fieldValue = this.getAttribute("value"); if(fieldValue!='') { var values = fieldValue.split(' '); dateValue = values[0]; if(values[1]) { values = values[1].split(":"); hourValue = Number(values[0]); minuteValue = Number(values[1]); secondValue = Number(values[2]); } } if(!selectButtonStyleClass || selectButtonStyleClass=='' || selectButtonStyleClass=='null') { selectButtonStyleClass = 'dropDownButton'; } var alt = this.getAttribute('alt'); var title = this.getAttribute('title'); var html = '' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + '
 :: 
'; this.writeFieldElement(html, parentElement); var dateTimeField = this; var datePickerButton = this.document.getElementById("datePicker_" + this.id); datePickerButton.onclick = function() { dateTimeField.onSelectDate(datePickerButton); } if(selectOnly) { var dateField = this.document.getElementById(this.id + "Date").parentNode; dateField.onclick = function() { dateTimeField.onSelectDate(dateField); } } var timePickerButton = this.document.getElementById('timePicker_' + this.id); timePickerButton.onclick = function() { dateTimeField.onSelectTime(timePickerButton); }; var fieldNames = ["Date", "Hour", "Minute", "Second"]; for(var i=0; i 12 && i < fieldNames.length; i++) { this.document.getElementById(this.id + fieldNames[i]).style.width = Math.floor(22 * fontSize / 12) + 'px'; } }; DateTimeField.prototype = new FormField(); DateTimeField.prototype.onSelectDate = function(datePickerButton) { new FormField.DatePicker(this.document.getElementById(this.id + "Date"), datePickerButton, false, this.terminalType).show(); }; DateTimeField.prototype.onSelectTime = function(timePickerButton) { var numberFields = [{field:this.document.getElementById(this.id + 'Hour'), minNumber:0, maxNumber:23, focus:this.timeFocus=='Hour'}, {field:this.document.getElementById(this.id + 'Minute'), minNumber:0, maxNumber:59, focus:this.timeFocus=='Minute'}, {field:this.document.getElementById(this.id + 'Second'), minNumber:0, maxNumber:59, focus:this.timeFocus=='Second'}]; new FormField.NumberPicker(this.getAttribute('title'), numberFields, ':', timePickerButton, this.terminalType).show(); }; DateTimeField.prototype._update = function() { var value = this.document.getElementById(this.id + "Date").value; if(value!='') { value += ' ' + new Number(this.document.getElementById(this.id + "Hour").value); value += ':' + new Number(this.document.getElementById(this.id + "Minute").value); value += ':' + new Number(this.document.getElementById(this.id + "Second").value); } this.getInputElement().value = value; try { this.getInputElement().onchange(); } catch(e) { } }; DateTimeField.setValue = function(fieldName, timeField, timeValue) { var field = FormField.getFormField(fieldName); var input = field.document.getElementById(field.id + timeField.substring(0, 1).toUpperCase() + timeField.substring(1)); input.value = timeValue; input.onchange(); }; DayField = function(inputElementHTML, styleClass, style, selectButtonStyleClass, selectButtonStyle, parentElement, terminalType) { style = (!style || style=='null' ? '' : style + ";") + 'width:68px !important'; FormField.call(this, inputElementHTML, 'hidden', style, styleClass); this.terminalType = terminalType; this.dayFocus = "Month"; var monthValue = ''; var dayValue = ''; var fieldValue = this.getAttribute("value"); if(fieldValue!='') { var values = fieldValue.split("\-"); monthValue = Number(values[0]); dayValue = Number(values[1]); } if(!selectButtonStyleClass || selectButtonStyleClass=='' || selectButtonStyleClass=='null') { selectButtonStyleClass = 'dropDownButton'; } var title = this.getAttribute('title'); var html = '' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + '
- 
'; this.writeFieldElement(html, parentElement); var dayField = this; var dayPickerButton = this.document.getElementById('dayPicker_' + this.id); dayPickerButton.onclick = function() { dayField.onSelectDay(dayPickerButton); }; var fieldNames = ["Month", "Day"]; for(var i=0; i 12) { this.getFieldElement().style.width = Math.floor(68 * fontSize / 12) + "px"; } }; DayField.prototype = new FormField(); DayField.prototype.onSelectDay = function(dayPickerButton) { var numberFields = [{field:this.document.getElementById(this.id + 'Month'), minNumber:1, maxNumber:12, focus:this.dayFocus=='Month'}, {field:this.document.getElementById(this.id + 'Day'), minNumber:1, maxNumber:function(allFieldValues) { return allFieldValues[0]==2 ? 29 : (',1,3,5,7,8,10,12,'.indexOf(',' + allFieldValues[0] + ',')!=-1 ? 31 : 30); }, focus:this.dayFocus=='Day'}]; new FormField.NumberPicker(this.getAttribute('title'), numberFields, '-', dayPickerButton, this.terminalType).show(); }; DayField.prototype._update = function() { var value = ''; var month = new Number(this.document.getElementById(this.id + "Month").value); if(!isNaN(month) && month>=1 && month<=12) { var day = new Number(this.document.getElementById(this.id + "Day").value); if(!isNaN(month) && day>=1) { var limit = 30; if(month==2) { limit = 29; } else if(',1,3,5,7,8,10,12,'.indexOf(',' + month + ',')!=-1) { limit = 31; } day = (day>=limit ? limit : day); value = (month<10 ? "0" : "") + month + "-" + (day<10 ? "0" : "") + day; } } this.getInputElement().value = value; try { this.getInputElement().onchange(); } catch(e) { } }; DayField.setValue = function(fieldName, dayField, dayValue) { var field = FormField.getFormField(fieldName); var input = field.document.getElementById(field.id + dayField.substring(0, 1).toUpperCase() + dayField.substring(1)); input.value = dayValue; input.onchange(); }; DropdownField = function(inputElementHTML, listValues, valueField, titleField, styleClass, style, selectButtonStyleClass, selectButtonStyle, parentElement, listPickerWidth, terminalType) { FormField.call(this, inputElementHTML, 'text', style, styleClass); this.listValues = listValues; this.valueField = valueField; this.titleField = titleField; this.listPickerWidth = listPickerWidth; this.terminalType = terminalType; this.parentElement = parentElement; if(!selectButtonStyleClass || selectButtonStyleClass=='' || selectButtonStyleClass=='null') { selectButtonStyleClass = 'dropDownButton'; } var html = '' + ' ' + ' ' + ' ' + ' ' + '
' + this.resetInputElementHTML() + ' 
'; this.writeFieldElement(html, parentElement); var dropdownField = this; var fieldElement = this.getFieldElement(); var form = DomUtils.getParentNode(fieldElement, "form"); this.form = form ? form : this.document.body; var field = this.getField(false); if(field) { field.formField = this; } var dropdownPickerButton = inputElementHTML.toLowerCase().indexOf(" readonly")==-1 ? this.document.getElementById('picker_' + this.id) : fieldElement; dropdownPickerButton.onclick = function() { dropdownField.onDropdown(); }; EventUtils.addEvent(window, "load", function() { try { dropdownField.getField(true).onchange(); } catch(e) {} try { dropdownField.getField(false).onchange(); } catch(e) {} }); }; DropdownField.prototype = new FormField(); DropdownField.prototype.onDropdown = function() { new FormField.ListPicker(this._getListValues(), this.getField(false), this.getField(true), this.getFieldElement(), this.listPickerWidth, false, null, this.terminalType).show(); }; DropdownField.prototype._getListValues = function() { if(typeof this.listValues == 'function') { return this.listValues.call(this); } else { return this.listValues; } }; DropdownField.prototype.getField = function(isTitleInput) { var fieldName = isTitleInput ? this.titleField : this.valueField; if(!fieldName || fieldName=="") { return null; } var input = this.inputElementHTML.indexOf('name="' + fieldName + '"')==-1 ? DomUtils.getElement(this.form, "input", fieldName) : this.getInputElement(); if(input) { return input; } input = this.document.getElementsByName(fieldName)[0]; if(input) { return input; } return this.getInputElement(); }; DropdownField.prototype.setValue = function(value) { if(!value) { this.getField(false).value = this.getField(true).value = ''; return false; } this.getField(false).value = value; var items = this._getListValues().split('\0'); for(var i=0; iitems.length-1) { return false; } var index = items[valueIndex].indexOf("|"); dropdownField.getField(false).value = items[valueIndex].substring(index + 1).trim(); dropdownField.getField(true).value = (index==-1 ? items[valueIndex] : items[valueIndex].substring(0, index)).trim(); return true; }; DropdownField.getSelectedIndex = function(fieldName) { var dropdownField = DropdownField.getDropdownField(fieldName); if(!dropdownField || !dropdownField.listValues || dropdownField.listValues=="") { return -1; } var title = dropdownField.getField(true).value.trim(); var value = dropdownField.getField(false).value.trim(); var items = dropdownField._getListValues().split('\0'); for(var i=0; i' + ' ' + ''; } else { html = '' + '' + ' ' + ' ' + ' ' + ' ' + '
' + ' ' + '
' + '
' + ' ' + ''; } return html; }; FormField.ListPicker.prototype._initComputerPicker = function() { var picker = this; this.listTable = this.pickerFrame.document.getElementById("listPicker.listTable"); for(var i = 0; i < this.listItems.length; i++) { var td = this.listTable.insertRow(-1).insertCell(-1); td.noWrap = true; td.className = "listnormal"; td.id = this.listItems[i].value; td.innerHTML = this.listItems[i].title; td.onmouseover = function() { for(var i = 0; i < picker.listTable.rows.length; i++) { var cell = picker.listTable.rows[i].cells[0]; cell.className = cell==this ? "listover" : "listnormal"; } } td.onmousedown = function() { picker.destory(); picker._onOK(this.id, this.innerHTML); } } this.pickerHeight = Math.min(Math.max(this.listTable.offsetHeight + DomUtils.getBorderWidth(this.listTable.parentNode, 'top') + DomUtils.getBorderWidth(this.listTable.parentNode, 'bottom'), 10), 180); }; FormField.ListPicker.prototype._initTouchPicker = function() { var picker = this; this.doOK = function() { var values = "", titles = ""; var inputs = picker.pickerBody.getElementsByTagName('input'); for(var i=0; i'; } } html += ' '; html += ''; return html; }; FormField.NumberPicker.prototype._initTouchPicker = function() { var picker = this; this.doOK = function() { for(var i = 0; i < picker.numberFields.length; i++) { picker.numberFields[i].field.value = picker.numberFields[i]._value; try { picker.numberFields[i].field.onchange(); } catch(e) { } } }; ScriptUtils.appendJsFile(document, RequestUtils.getContextPath() + '/jeaf/common/js/scroller.js', 'scrollerScript', function() { picker._resetPicker(); }); }; FormField.NumberPicker.prototype._resetPicker = function(pickerBody) { var picker = this; this._retrieveFieldValues(); var numberPickerTable = DomUtils.getElement(this.pickerBody, 'table', 'numberPickerTable'); for(var i = 0; i < this.numberFields.length; i++) { FormField.NumberPicker.generateNumberPicker(numberPickerTable.rows[0].cells[i * 2].childNodes[0], this.numberFields[i]._minNumber, this.numberFields[i]._maxNumber, this.numberFields[i]._value, this.numberFields[i].suffix, function(numberValue, parentElement) { picker.numberFields[parentElement.parentNode.cellIndex / 2]._value = numberValue; picker._resetPicker(); }, true, this.isTouchMode); } }; FormField.NumberPicker.prototype.show = function(pickerLeft, pickerTop, displayOnly) { if(this.isTouchMode) { this.constructor.prototype.show.call(this, pickerLeft, pickerTop, displayOnly); return; } var focus = 0; for(; focus < this.numberFields.length && !this.numberFields[focus].focus; focus++); this._retrieveFieldValues(); var itemsText = ''; for(var i= this.numberFields[focus]._minNumber; i <= this.numberFields[focus]._maxNumber; i++) { itemsText += (itemsText=='' ? '' : '\0 ') + i; } var picker = this; new FormField.ListPicker(itemsText, this.numberFields[focus].field, null, this.displayArea, 50, true, function() { if(focus < picker.numberFields.length - 1) { window.setTimeout(function() { picker.numberFields[focus + 1].field.focus(); }, 100); } }).show(); }; FormField.NumberPicker.prototype._retrieveFieldValues = function() { var values = []; for(var i = 0; i < this.numberFields.length; i++) { if(!this.numberFields[i]._value && this.numberFields[i]._value!=0) { var suffix = this.numberFields[i].suffix; this.numberFields[i]._value = Number(suffix ? this.numberFields[i].field.value.replace(suffix, '') : this.numberFields[i].field.value); if(isNaN(this.numberFields[i]._value)) { this.numberFields[i]._value = 0; } } values.push(this.numberFields[i]._value); } for(var i = 0; i < this.numberFields.length; i++) { this.numberFields[i]._minNumber = typeof this.numberFields[i].minNumber == 'function' ? this.numberFields[i].minNumber.call(this, values) : this.numberFields[i].minNumber; this.numberFields[i]._maxNumber = typeof this.numberFields[i].maxNumber == 'function' ? this.numberFields[i].maxNumber.call(this, values) : this.numberFields[i].maxNumber; this.numberFields[i]._value = Math.min(Math.max(this.numberFields[i]._value, this.numberFields[i]._minNumber), this.numberFields[i]._maxNumber); } }; FormField.NumberPicker.generateNumberPicker = function(parentElement, minValue, maxValue, currentValue, suffix, onNumberPicked, verticalScroll, isTouchMode) { if(!suffix) { suffix = ''; } parentElement.innerHTML = ""; var document = parentElement.ownerDocument; var divNumbers = document.createElement("div"); parentElement.appendChild(divNumbers); var selectedIndex; for(var i = minValue-1; i <= maxValue+1; i++) { var span = document.createElement("span"); span.className = "pickerItem" + (currentValue==i ? " selectedPickerItem" : ""); if(!verticalScroll) { span.style.display = 'inline-block'; } span.innerHTML = i==minValue-1 || i==maxValue+1 ? ' ' : i + suffix; if(currentValue==i) { selectedIndex = divNumbers.childNodes.length; } else if(i!=minValue-1 && i!=maxValue+1) { span.onclick = function() { onNumberPicked.call(null, Number(suffix=='' ? this.innerHTML : this.innerHTML.replace(suffix, '')), parentElement); }; } divNumbers.appendChild(span); if(isTouchMode || currentValue!=i) { continue; } var dropDownButton = document.createElement("span"); dropDownButton.className = "dropDownButton"; dropDownButton.innerHTML = " "; divNumbers.appendChild(dropDownButton); span.onclick = dropDownButton.onclick = function() { var itemsText = ''; for(var j = minValue; j <= maxValue; j++) { itemsText += (itemsText=='' ? '' : '\0 ') + j + suffix; } var listPicker = new FormField.ListPicker(itemsText, null, null, dropDownButton, span.offsetWidth + 8, true, function(selectedItemValue, selectedItemTitle) { onNumberPicked.call(null, Number(suffix=='' ? selectedItemValue : selectedItemValue.replace(suffix, '')), parentElement); }); listPicker.selectedIndex = currentValue - minValue; listPicker.show(); }; } if(verticalScroll) { parentElement.scrollTop = (selectedIndex - (parentElement.offsetHeight > 2 * divNumbers.childNodes[0].offsetHeight ? 1 : 0)) * divNumbers.childNodes[0].offsetHeight; } else { divNumbers.style.width = (divNumbers.childNodes[0].offsetWidth * (maxValue - minValue + 3)) + "px"; parentElement.scrollLeft = (selectedIndex - (parentElement.offsetWidth > 2 * divNumbers.childNodes[0].offsetWidth ? 1 : 0)) * divNumbers.childNodes[0].offsetWidth; } if(!isTouchMode) { return; } parentElement.scroller = new Scroller(parentElement, !verticalScroll, verticalScroll, false, false, false); parentElement.scroller.onAfterScroll = function(x, y, isLeft, isRight, isTop, isBottom, touchEnd) { var index; if(verticalScroll) { index = Math.round(parentElement.scrollTop / divNumbers.childNodes[0].offsetHeight) + 1; } else { index = Math.round(parentElement.scrollLeft / divNumbers.childNodes[0].offsetWidth) + 1; } onNumberPicked.call(null, Number(suffix=='' ? divNumbers.childNodes[index].innerHTML : divNumbers.childNodes[index].innerHTML.replace(suffix, '')), parentElement); }; }; SelectField = function(inputElementHTML, onSelect, styleClass, style, selectButtonStyleClass, selectButtonStyle, parentElement) { FormField.call(this, inputElementHTML, 'text', style, styleClass); if(!selectButtonStyleClass || selectButtonStyleClass=='' || selectButtonStyleClass=='null') { selectButtonStyleClass = 'selectButton'; } var colorField = typeof onSelect != 'function' && onSelect.indexOf(' DialogUtils.openColorDialog')==0; var html = '' + ' ' + (colorField ? '' : '') + ' ' + ' ' + ' ' + '
' + this.resetInputElementHTML() + ' 
'; this.writeFieldElement(html, parentElement); var selectButton = inputElementHTML.toLowerCase().indexOf(" readonly")==-1 ? this.document.getElementById('picker_' + this.id ) : this.getFieldElement(); var field = this; selectButton.onclick = function() { FormUtils.setCurrentForm(DomUtils.getParentNode(this, 'form')); if(typeof onSelect == 'function') { onSelect.call(null); } else { eval(onSelect.replace(/{INPUTELEMENTID}/g, 'input_' + field.id)); } }; if(colorField) { var inputElement = this.getInputElement(); inputElement.onchange = function() { field._applyColorValue(); } this._applyColorValue(); } }; SelectField.prototype = new FormField(); SelectField.prototype._applyColorValue = function() { try { document.getElementById('color_' + this.id).style.backgroundColor = this.getInputElement().value; } catch(e) { } }; TextAreaField = function(inputElementHTML, styleClass, style, parentElement) { FormField.call(this, inputElementHTML, 'text', style, styleClass, true); this.writeFieldElement(this.resetInputElementHTML(), parentElement); }; TextAreaField.prototype = new FormField(); TextField = function(inputElementHTML, styleClass, style, parentElement) { FormField.call(this, inputElementHTML, null, style, styleClass); this.writeFieldElement(this.resetInputElementHTML(), parentElement); }; TextField.prototype = new FormField(); TimeField = function(inputElementHTML, secondEnabled, styleClass, style, selectButtonStyleClass, selectButtonStyle, parentElement, terminalType) { style = (!style || style=='null' ? '' : style + ";") + 'width:' + (secondEnabled ? 106 : 68) + 'px !important'; FormField.call(this, inputElementHTML, 'hidden', style, styleClass); this.terminalType = terminalType; this.timeFocus = "Hour"; this.secondEnabled = secondEnabled; var hourValue = ''; var minuteValue = ''; var secondValue = ''; var fieldValue = this.getAttribute("value"); if(fieldValue!='') { var values = fieldValue.split(":"); hourValue = Number(values[0]); minuteValue = Number(values[1]); if(secondEnabled) { secondValue = Number(values[2]); } } if(!selectButtonStyleClass || selectButtonStyleClass=='' || selectButtonStyleClass=='null') { selectButtonStyleClass = 'dropDownButton'; } var title = this.getAttribute('title'); var html = '' + ' ' + ' ' + ' ' + ' ' + (secondEnabled ? ' ' : '') + (secondEnabled ? ' ' : '') + ' ' + ' ' + '
:: 
'; this.writeFieldElement(html, parentElement); var timeField = this; var timePickerButton = this.document.getElementById('timePicker_' + this.id); timePickerButton.onclick = function() { timeField.onSelectTime(timePickerButton); }; var fieldNames = ["Hour", "Minute"]; if(secondEnabled) { fieldNames.append("Second"); } for(var i=0; i 12) { this.getFieldElement().style.width = Math.floor((secondEnabled ? 106 : 68) * fontSize / 12) + "px"; } }; TimeField.prototype = new FormField(); TimeField.prototype.onSelectTime = function(timePickerButton) { var numberFields = [{field:this.document.getElementById(this.id + 'Hour'), minNumber:0, maxNumber:23, focus:this.timeFocus=='Hour'}, {field:this.document.getElementById(this.id + 'Minute'), minNumber:0, maxNumber:59, focus:this.timeFocus=='Minute'}]; if(this.secondEnabled) { numberFields.push({field:this.document.getElementById(this.id + 'Second'), minNumber:0, maxNumber:59, focus:this.timeFocus=='Second'}); } new FormField.NumberPicker(this.getAttribute('title'), numberFields, ':', timePickerButton, this.terminalType).show(); }; TimeField.prototype._update = function() { var hour = new Number(this.document.getElementById(this.id + "Hour").value); var value = (hour<10 ? "0" : "") + hour; var minute = new Number(this.document.getElementById(this.id + "Minute").value); value += ":" + (minute<10 ? "0" : "") + minute; if(this.secondEnabled) { var second = new Number(this.document.getElementById(this.id + "Second").value); value += ":" + (second<10 ? "0" : "") + second; } this.getInputElement().value = value; try { this.getInputElement().onchange(); } catch(e) { } }; TimeField.setValue = function(fieldName, timeField, timeValue) { var field = FormField.getFormField(fieldName); var input = field.document.getElementById(field.id + timeField.substring(0, 1).toUpperCase() + timeField.substring(1)); input.value = timeValue; input.onchange(); }; FormUtils = function() { }; FormUtils.doAction = function(actionName, param, notLockForm, formName, target) { if(window.submitting) { return false; } var form = FormUtils._getForm(formName); form.oldAction = form.action; form.oldTarget = form.target; if(target) { form.target = target; } if(actionName.substring(0, 1)=="/") { form.action = actionName; } else { var action = form.action; var index = action.lastIndexOf(".shtml"); if(index==-1) { return false; } index = action.lastIndexOf("/", index); if(index==-1) { return false; } form.action = action.substring(0, index + 1) + actionName + ".shtml"; } FormUtils.submitForm(notLockForm, formName, param); return true; }; FormUtils.submitForm = function(notLockForm, formName, param) { if(window.submitting) { return false; } if(window.lastSubmitted && new Date().valueOf() - window.lastSubmitted < 500) { return false; } try { HtmlEditor.saveHtmlContent(); } catch(e) { } if(!formOnSubmit()) { return false; } var form = FormUtils._getForm(formName); if(param && param!='') { form.action += (form.action.indexOf('?')==-1 ? '?' : '&') + param; } FormUtils.resetBoxElements(form); try { form.ownerDocument.body.focus(); } catch(e) { } window.submitting = !notLockForm && (!form.target || form.target=='' || form.target=='_self'); if(!window.submitting) { window.lastSubmitted = new Date().valueOf(); } if(window.submitting) { PageUtils.showToast('\u6B63\u5728\u5904\u7406\u4E2D, \u8BF7\u7A0D\u5019...'); // } var displayMode = DomUtils.getElement(form, 'input', 'displayMode'); var internalForm = DomUtils.getElement(form, 'input', 'internalForm'); if(form.target=='_self' || !window.submitting || (displayMode && displayMode.value!='window') || !internalForm || internalForm.value!='true') { FormUtils.preSubmit(form); return true; } var win = window; DialogUtils.openDialog(null, 480, 200, null, null, function(dialogBodyFrame) { form.target = dialogBodyFrame.name; if(!form.oldAction) { form.oldAction = form.action; } form.action += (form.action.indexOf('?')==-1 ? '?' : '&') + 'displayMode=dialog&internalForm=true' + (window.tabLists ? '&tabSelected=' + window.tabLists[0].getSelectedTabId() : ''); FormUtils.preSubmit(form); }, function(dialogBodyFrame) { win.submitting = false; PageUtils.removeToast(); }, function(dialogBodyFrame) { var reloadPageURL = dialogBodyFrame.contentWindow.document.getElementsByName("reloadPageURL")[0]; if(reloadPageURL && reloadPageURL.value!='') { PageUtils.showToast('\u91CD\u65B0\u52A0\u8F7D\u4E2D, \u8BF7\u7A0D\u5019...'); window.location.href = reloadPageURL.value; } } ); }; FormUtils._getForm = function(formName) { return !formName || formName=='' ? document.forms[0] : (document.forms[formName] ? document.forms[formName] : document.getElementById(formName)); }; FormUtils._restoreForm = function(form) { if(!form.oldAction) { return; } form.action = form.oldAction; if(form.oldTarget && form.oldTarget!='') { form.target = form.oldTarget; } else { form.removeAttribute("target"); } form.oldAction = null; form.oldTarget = null; }; FormUtils.preSubmit = function(form) { window.preSubmitForm = form; ScriptUtils.appendJsFile(document, RequestUtils.getContextPath() + '/jeaf/requestmanage/presubmit.shtml?seq=' + new Date().valueOf()); }; FormUtils.resetBoxElements = function(form) { var inputs = form.getElementsByTagName("input"); for(var i=(inputs ? inputs.length-1: -1); i>=0; i--) { if(inputs[i].id && inputs[i].parentNode==form && inputs[i].id.indexOf("hidden_")==0) { form.removeChild(inputs[i]); } else if(inputs[i].type=="text" && inputs[i].value==inputs[i].alt) { inputs[i].value = ""; } } inputs = form.getElementsByTagName("textarea"); for(var i=(inputs ? inputs.length-1: -1); i>=0; i--) { if(inputs[i].value==inputs[i].getAttribute("alt")) { inputs[i].value = ""; } } inputs = form.getElementsByTagName("input"); var checkedFields = new Array(); var uncheckedFields = new Array(); var processedFields = ""; for(var i=0; i<(inputs ? inputs.length : 0); i++) { if(!inputs[i].type || !inputs[i].name) { continue; } var type = inputs[i].type.toLowerCase(); if(type!="checkbox" && type!="radio" || processedFields.indexOf("[" + inputs[i].name + "]")!=-1) { continue; } processedFields += "[" + inputs[i].name + "]"; var checked = false; for(j=i; j