function PioWeb() { function DoctypeVersionInfo() { this.xhtml = ""; this.version = ""; this.importance = ""; } function detectDoctype() { var oReg = /\s+(X?HTML)\s+([\d\.]+)\s*([^\/]+)*\//gi; var oVersionInfo = new DoctypeVersionInfo(); var bDoctypeFound = false; if (document.doctype != null) { oReg.exec(document.doctype.publicId); bDoctypeFound = true; } else if (typeof document.namespaces != "undefined" && document.all[0].nodeType == 8) { oReg.exec(document.all[0].nodeValue); bDoctypeFound = true; } //else // return null; if (bDoctypeFound) { oVersionInfo.xhtml = RegExp.$1; oVersionInfo.version = RegExp.$2; oVersionInfo.importance = RegExp.$3.toUpperCase(); } else { oVersionInfo.xhtml = "HTML"; oVersionInfo.version = "undefined"; oVersionInfo.importance = "TRANSITIONAL"; } return oVersionInfo; } var _oDoctypeInfo = detectDoctype(); this.getDocTypeInfo = function() { return _oDoctypeInfo; } this.trim = function(str) { if (typeof (str) != "string") return str; return str.replace(/^\s+|\s+$/g, ""); } this.getElementById = function(id) { if (document.getElementById) return document.getElementById(id); else if (document.all) return document.all(id); else return null; } this.getAncestorById = function(obj, id) { for (var oAncestor = obj; oAncestor != null && oAncestor.id != id; oAncestor = oAncestor.parentNode) ; return oAncestor; } this.getDescendantsById = function(obj, id) { var oDescendants = null; if (obj == null) oDescendants = this.getElementById(id); else if (obj.all) oDescendants = obj.all[id]; else if (obj.item) oDescendants = obj.item(id); else if (obj.getElementById) oDescendants = obj.getElementById(id); else if (obj.getElementsByTagName) oDescendants = Array.filter(obj.getElementsByTagName("*"), function(elem) { return elem.id == id; }); if (oDescendants != null && oDescendants.length == undefined) oDescendants = [oDescendants]; return oDescendants; } this.getSingleDescendantById = function(obj, id) { var oDescendants = this.getDescendantsById(obj, id); if (oDescendants != null) return oDescendants[0]; return null; } //~~~ getElementsByClassName //~~~ Developed by Robert Nyman, http://www.robertnyman.com //~~~ Code/licensing: http://code.google.com/p/getelementsbyclassname/ this.getElementsByClassName = function(className, tag, elm) { if (document.getElementsByClassName) { getElementsByClassName = function(className, tag, elm) { elm = elm || document; var elements = elm.getElementsByClassName(className), nodeName = (tag) ? new RegExp("\\b" + tag + "\\b", "i") : null, returnElements = [], current; for (var i = 0, il = elements.length; i < il; i += 1) { current = elements[i]; if (!nodeName || nodeName.test(current.nodeName)) { returnElements.push(current); } } return returnElements; }; } else if (document.evaluate) { getElementsByClassName = function(className, tag, elm) { tag = tag || "*"; elm = elm || document; var classes = className.split(" "), classesToCheck = "", xhtmlNamespace = "http://www.w3.org/1999/xhtml", namespaceResolver = (document.documentElement.namespaceURI === xhtmlNamespace) ? xhtmlNamespace : null, returnElements = [], elements, node; for (var j = 0, jl = classes.length; j < jl; j += 1) { classesToCheck += "[contains(concat(' ', @class, ' '), ' " + classes[j] + " ')]"; } try { elements = document.evaluate(".//" + tag + classesToCheck, elm, namespaceResolver, 0, null); } catch (e) { elements = document.evaluate(".//" + tag + classesToCheck, elm, null, 0, null); } while ((node = elements.iterateNext())) { returnElements.push(node); } return returnElements; }; } else { getElementsByClassName = function(className, tag, elm) { tag = tag || "*"; elm = elm || document; var classes = className.split(" "), classesToCheck = [], elements = (tag === "*" && elm.all) ? elm.all : elm.getElementsByTagName(tag), current, returnElements = [], match; for (var k = 0, kl = classes.length; k < kl; k += 1) { classesToCheck.push(new RegExp("(^|\\s)" + classes[k] + "(\\s|$)")); } for (var l = 0, ll = elements.length; l < ll; l += 1) { current = elements[l]; match = false; for (var m = 0, ml = classesToCheck.length; m < ml; m += 1) { match = classesToCheck[m].test(current.className); if (!match) { break; } } if (match) { returnElements.push(current); } } return returnElements; }; } return getElementsByClassName(className, tag, elm); }; this.getInnerText = function(elm) { if (elm == null || typeof (elm.innerHTML) == "undefined") return null; if (typeof (elm.innerText) != "undefined") return elm.innerText; else if (typeof (elm.textContent) != "undefined") return elm.textContent; else { switch (elm.nodeType) { case 1: // ELEMENT_NODE var sText = ''; if (elm.childNodes.length == 0 && this.getInnerText.oLeafElems[elm.nodeName]) return sText; else { for (var i = 0; i < elm.childNodes.length; i++) sText += getInnerText(elm.childNodes.item(i)); return sText; } case 3: // TEXT_NODE case 4: // CDATA_SECTION_NODE return elm.nodeValue; default: return ''; } } } var _oLeafTags = ["IMG", "HR", "BR", "INPUT"]; this.getInnerText.oLeafElems = {} for (var i = 0; i < _oLeafTags.length; i++) this.getInnerText.oLeafElems[_oLeafTags[i]] = true; this.getEventTargetElement = function(e) { var oRv; try { oRv = e.srcElement; if (typeof (oRv) == "undefined") { oRv = e.target; } } catch (ex) { oRv = e.target; } return oRv; } this.htmlEncode = function(s) { return s.replace(//gi, ">").replace(/"/g, """).replace(/'/g, "'"); } this.getStyleValue = function(obj, styleName) { var sRv = null; if (PioWeb.BrName != "IE") { var oHz = window.getComputedStyle(obj, null); sRv = oHz[styleName]; /*sRv = oHz.getPropertyValue(styleName);*/ } else { sRv = obj.currentStyle.getAttribute(styleName); } return sRv; } this.attachEvent = function(elObj, eventName, handler, optionalUseCapture) { if (elObj != null) { if (elObj.attachEvent /*PioWeb.BrName == "IE"*/) { elObj.attachEvent("on" + eventName, handler);} else {elObj.addEventListener(eventName, handler, (optionalUseCapture == null) ? true : optionalUseCapture); } } } this.detachEvent = function(elObj, eventName, handler) { if (elObj != null) { if (elObj.detachEvent /*PioWeb.BrName == "IE"*/) { elObj.detachEvent("on" + eventName, handler); } else { elObj.removeEventListener(eventName, handler, true); } } } this.randomInt = function(min, max) { return Math.floor((max - min + 1) * Math.random() + min); } this.documentWrite = function(html) { document.write(html); } //============================================================= // function: addFavorite() // // description: add page to favorites // // input parameters: // url - string. optional favorite URL. if not specified then location.href will be used // title - string. optional favorite title. if not specified then window.title will be used //============================================================= this.addFavorite = function(url, title) { var sUrl = url || location.href; var sTitle = title || window.title; if (window.sidebar) // Mozilla Firefox Bookmark window.sidebar.addPanel(sTitle, sUrl, ""); else if (window.external) // IE Favorite window.external.AddFavorite(sUrl, sTitle); else if (window.opera && window.print) // opera { var oElem = document.createElement("a"); oElem.setAttribute("href", sUrl); oElem.setAttribute("title", sTitle); oElem.setAttribute("rel", "sidebar"); oElem.click(); } } //============================================================= // function: setHomePage() // // description: set page as default browser's home page IE only!! //============================================================= this.setHomePage = function() { if (document.body && document.body.style && document.body.style.behavior) { document.body.style.behavior = 'url(#default#homepage)'; document.body.setHomePage(window.location.href); } } //============================================================= // function: stringIsNullOrEmpty() // // description: returns true if input string is null or empty //============================================================= this.stringIsNullOrEmpty = function(str) { return (str == null || str.toString().length == 0); } //============================================================= // function: stringReverse() // // description: returns a reversed string //============================================================= this.stringReverse = function(str) { if (typeof (str) != "string") return str; var sReversed = ""; for (var i = str.length - 1; i > -1; i--) sReversed += str.charAt(i); return sReversed; } //https://code.google.com/p/javascript-number-formatter/ //============================================================= // @preserve IntegraXor Web SCADA - JavaScript Number Formatter // http://www.integraxor.com/ // author: KPL, KHL // (c)2011 ecava // Dual licensed under the MIT or GPL Version 2 licenses. //============================================================= //////////////////////////////////////////////////////////////////////////////// // param: Mask & Value //////////////////////////////////////////////////////////////////////////////// //Features // Accept standard number formatting like #,##0.00 or with negation -000.####. // Accept any country format like # ##0,00, #,###.##, #'###.## or any type of non-numbering symbol. // Accept any numbers of digit grouping. #,##,#0.000 or #,###0.## are all valid. // Accept any redundant/fool-proof formatting. ##,###,##.# or 0#,#00#.###0# are all OK. // Auto number rounding. // Simple interface, just supply mask & value like this: format( "0.0000", 3.141592) //Limitation // No prefix or suffix is allowed except leading negation symbol. So $#,##0.00 or #,###.##USD will not yield expected outcome. Use '$'+format('#,##0.00', 123.45) or format('#,##0.00', 456.789) + 'USD' // No scientific/engineering formatting. //this.numberFormat = function( m, v){ this.numberFormat = function(value, format){ var m = format; var v = value; if (!m || isNaN(+v)) { return v; //return as it is. } //convert any string to number according to formation sign. var v = m.charAt(0) == '-'? -v: +v; var isNegative = v<0? v= -v: 0; //process only abs(), and turn on flag. //search for separator for grp & decimal, anything not digit, not +/- sign, not #. var result = m.match(/[^\d\-\+#]/g); var Decimal = (result && result[result.length-1]) || '.'; //treat the right most symbol as decimal var Group = (result && result[1] && result[0]) || ','; //treat the left most symbol as group separator //split the decimal for the format string if any. var m = m.split( Decimal); //Fix the decimal first, toFixed will auto fill trailing zero. v = v.toFixed( m[1] && m[1].length); v = +(v) + ''; //convert number to string to trim off *all* trailing decimal zero(es) //fill back any trailing zero according to format var pos_trail_zero = m[1] && m[1].lastIndexOf('0'); //look for last zero in format var part = v.split('.'); //integer will get !part[1] if (!part[1] || part[1] && part[1].length <= pos_trail_zero) { v = (+v).toFixed( pos_trail_zero+1); } var szSep = m[0].split( Group); //look for separator m[0] = szSep.join(''); //join back without separator for counting the pos of any leading 0. var pos_lead_zero = m[0] && m[0].indexOf('0'); if (pos_lead_zero > -1 ) { while (part[0].length < (m[0].length - pos_lead_zero)) { part[0] = '0' + part[0]; } } else if (+part[0] == 0){ part[0] = ''; } v = v.split('.'); v[0] = part[0]; //process the first group separator from decimal (.) only, the rest ignore. //get the length of the last slice of split result. var pos_separator = ( szSep[1] && szSep[ szSep.length-1].length); if (pos_separator) { var integer = v[0]; var str = ''; var offset = integer.length % pos_separator; for (var i=0, l=integer.length; i 12) return 0; else return arr[month]; } //============================================================= // function: stringFormat() // // description: replaces placeholders in input string with specified values // // parameters: // i_sInput - string. input string containing placeholders in the format {0}, {1}, ..., {N} // i_sReplaceWith0 - string. replacement value corresponding with {0} placeholders // i_sReplaceWith1 - string. replacement value corresponding with {1} placeholders // ... // i_sReplaceWithN - string. replacement value corresponding with {N} placeholders // // examples: // stringFormat("My name is {0}, {1} {0}", "Bond", "James") // returns "My name is Bond, James Bond" // // remarks: // literal {} must be escaped as {{}}, for example // stringFormat("Literal {{curlies}} and with placeholder {{{0}}}", "it works") // returns "Literal {curlies} and with placeholder {it works}" //============================================================= this.stringFormat = function() { if (arguments.length < 1) return ""; else if (arguments.length == 1 || typeof (arguments[0]) != "string") return sInput; var sInput = arguments[0]; //~~~ escape literal curlies i.e. "{{" and "}}" //sInput = sInput.replace(/({{)([^{}]*){(.*?)(}}})/g, "_DCURL1_$2{$3}_DCURL2_"); //~~~ handles {{{0}}} and {{ {0}}} but not {{{{0}}}} etc. //sInput = sInput.replace(/({{)(.*?)(}})/g, "_DCURL1_$2_DCURL2_"); //~~~ handle all other escaped curlies sInput = sInput.replace(/{{/g, "_DCURL1_"); sInput = this.stringReverse(this.stringReverse(sInput).replace(/}}/g, this.stringReverse("_DCURL2_"))); //~~~ replace {n} with argument number n + 1 for (var i = 1; i < arguments.length; i++) { var oReplacementReg = new RegExp("\\{" + (i - 1) + "\\}", "g"); sInput = sInput.replace(oReplacementReg, arguments[i]); } //~~~ unescape literal curlies //sInput = sInput.replace(/(_DCURL1_)(.*?)(_DCURL2_)/g, "{$2}"); sInput = sInput.replace(/_DCURL1_/g, "{").replace(/_DCURL2_/g, "}"); return sInput; } //============================================================= // function: randomString() // // description: // create a random string // // input parameters: // i_iStrLength - int. string length // // return value: // string. randomized string //============================================================= this.randomString = function(i_iStrLength) { var sChars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz"; var sRandom = ""; for (var i = 0; i < i_iStrLength; i++) { var iRandomNum = Math.floor(Math.random() * sChars.length); sRandom += sChars.charAt(iRandomNum); } return sRandom; } this.urlEncode = function(input) { if (PioWeb.BrName == "IE" && PioWeb.BrVers <= 7) { //return escape(input); return encodeURIComponent(input); } else { //return encodeURIComponent(input); var sRv = ''; for (var i = 0; i < input.length; i++) { var sChar = input.charAt(i); switch (sChar) { case '&': case ' ': case ',': case '=': case '?': case '%': case '#': case '\'': case '"': case '<': case '>': sChar = escape(sChar); break; case '+': //~~~ escape('+') == '+' and '+' converted to ' ' in url sChar = '%2b'; break; } sRv += sChar; } return sRv; } } //============================================================= // function: resetFormByContainerId() // // description: // reset form fields within a container // // input parameters: // i_sContainerId - string. container id //============================================================= this.resetFormByContainerId = function(i_sContainerId) { var oContainer = this.getElementById(i_sContainerId); if (oContainer == null) return; if (oContainer.tagName == "FORM") { oContainer.reset(); return; } if (oContainer.getElementsByTagName) { var oElementsCollection = null; //~~~ reset INPUT elements oElementsCollection = oContainer.getElementsByTagName("INPUT"); for (var i = 0; i < oElementsCollection.length; i++) { switch (oElementsCollection[i].type) { case "text": case "password": oElementsCollection[i].value = oElementsCollection[i].defaultValue; break; case "checkbox": case "radio": oElementsCollection[i].value = oElementsCollection[i].defaultValue; oElementsCollection[i].checked = oElementsCollection[i].defaultChecked; break; default: oElementsCollection[i].value = ""; break; } } //~~~ reset SELECT elements oElementsCollection = oContainer.getElementsByTagName("SELECT"); for (var i = 0; i < oElementsCollection.length; i++) { if (oElementsCollection[i].defaultSelectedIndex == undefined) { var iDefaultSelectedIndex = 0; for (var j = 0; j < oElementsCollection[i].options.length; j++) { if (oElementsCollection[i].options[j].defaultSelected) { iDefaultSelectedIndex = j; break; } } oElementsCollection[i].defaultSelectedIndex = iDefaultSelectedIndex; } oElementsCollection[i].selectedIndex = oElementsCollection[i].defaultSelectedIndex; } //~~~ reset TEXTAREA elements oElementsCollection = oContainer.getElementsByTagName("TEXTAREA"); for (var i = 0; i < oElementsCollection.length; i++) { oElementsCollection[i].value = ""; } } } //~~~ for Netscape 6/Mozilla by Thor Larholm me@jscript.dk //~~~ if(typeof HTMLElement!="undefined" && ! HTMLElement.prototype.insertAdjacentElement) this.insertAdjacentElement = function(where, parsedNode, refNode) { if (PioWeb.BrName == "IE") { refNode.insertAdjacentElement(where, parsedNode); } else { switch (where) { case 'beforeBegin': refNode.parentNode.insertBefore(parsedNode, refNode); break; case 'afterBegin': refNode.insertBefore(parsedNode, refNode.firstChild); break; case 'beforeEnd': refNode.appendChild(parsedNode); break; case 'afterEnd': if (refNode.nextSibling) refNode.parentNode.insertBefore(parsedNode, refNode.nextSibling); else refNode.parentNode.appendChild(parsedNode); break; } } } //~~~ this.insertAdjacentElement = function this.insertAdjacentHTML = function(where, htmlStr, refNode) { if (PioWeb.BrName == "IE") { refNode.insertAdjacentHTML(where, htmlStr); } else { var oHz = refNode.ownerDocument.createRange(); oHz.setStartBefore(refNode); var oParsedNode = oHz.createContextualFragment(htmlStr); this.insertAdjacentElement(where, oParsedNode, refNode); } } //~~~ this.insertAdjacentHTML = function this.insertAdjacentText = function(where, txtStr, refNode) { if (PioWeb.BrName == "IE") { refNode.insertAdjacentText(where, htmlStr); } else { var oParsedNode = document.createTextNode(txtStr) this.insertAdjacentElement(where, oParsedNode, refNode); } } //~~~ this.insertAdjacentText = function this.setClassName = function(ev, obj, validateFunctionCallback, className, isSet, isReplaceClassName) { var el = null; if (ev != null) { el = this.getEventTargetElement(ev); } else { el = obj; } if (validateFunctionCallback != null && typeof (validateFunctionCallback) == "function") { el = validateFunctionCallback(obj, el); } if (el == null || typeof (el) == "undefined") return; if (className == null) return; if (isSet == null) isSet = true; if (isReplaceClassName == null) isReplaceClassName = true; var oRe = null; if (!isReplaceClassName && el.className != "") { oRe = new RegExp("((^)|([ ]+))" + className + "(([ ]+)|($))"); } var sCurrent = el.className; var sNew = null; if (isSet) { if (sCurrent != className) { if (isReplaceClassName || sCurrent == "") { sNew = className; } else { if (!oRe.test(sCurrent)) { sNew = sCurrent + " " + className + " "; } } } } else { if (sCurrent != "") { if (isReplaceClassName || sCurrent == className) { sNew = ""; } else { sNew = this.trim(sCurrent.replace(oRe, " ")); } } } if (sNew != null) { //alert(el.className + "\n" + sNew); el.className = sNew; } } this.setClassNameAndInThisCaseReturnTrue = function(element, className) { if (className == null || className == "") return false; if (element == null) return false; if (typeof (element) == "string") element = this.getElementById(element); if (element == null) return false; var bRv = true; if (element.className.indexOf(className) >= 0) bRv = false; else this.setClassName(null, element, null, className, true, false); return bRv; } this.buttonSingleClick = function(button) { var bRv = true; if (button.className.indexOf('button-disabled') >= 0) { bRv = false; } else { this.setClassName(null, button, null, "button-disabled", true, false); } return bRv; } this.buttonSingleClickReset = function(button) { if (button != null) this.setClassName(null, button, null, "button-disabled", false, false); } this.getTransparentPngProcessor = function() { if (PioWeb.BrName == "IE" && PioWeb.BrVers <= 6) { return new function() { this.mustProcess = true; this.processTransparentPngImage = function(img) { if (img == null || img.tagName != "IMG" || img.nodeName != "IMG") return; var sID = (img.id) ? "id=\"" + img.id + "\" " : ""; var sClassName = (img.className) ? "class=\"" + img.className + "\" " : ""; var sTitle = (img.title) ? "title=\"" + PioWeb.htmlEncode(img.title) + "\" " : "title=\"" + PioWeb.htmlEncode(img.alt) + "\" "; var sStyle = "display:inline-block;" + img.style.cssText; if (img.align == "left") sStyle = "float:left;" + sStyle; if (img.align == "right") sStyle = "float:right;" + sStyle; if (img.parentElement.href) sStyle = "cursor:hand;" + sStyle; sStyle = "width:" + img.width + "px; height:" + img.height + "px;" + sStyle; sStyle = "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'" + img.src + "\', sizingMethod='scale');" + sStyle; var sHtml = ""; img.outerHTML = sHtml; }; this.processTransparentPngBackground = function(elm) { if (elm == null) return; var sBgImageStyle = elm.style.backgroundImage; var oReg = /^url\((.*\.png)\)$/i; if (oReg.test(sBgImageStyle)) { var sImage = sBgImageStyle.replace(oReg, "$1"); elm.style.cssText += "; background: none !important; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'" + sImage + "\', sizingMethod='scale');"; }; }; }; } else { return new function() { this.mustProcess = false; this.processTransparentPngImage = function(img) { }; this.processTransparentPngBackground = function(elm) { }; }; } } this.hideSelectBoxes = function(objLayer) { if (PioWeb.BrName != "IE") return new Array(); //~~~ empty array : evething is ok if (PioWeb.BrVers >= 7) return new Array(); //~~~ empty array : evething is ok var sCol = document.all.tags("SELECT"); if (sCol.length == 0) return new Array(); //~~~ hides all "select" tags var objSC; var objLayerC = new PioWebElementCoordinates(objLayer); var el; var i; var rvArray = new Array(); for (i = 0; i < sCol.length; i++) { el = sCol[i]; if (this.getStyleValue(el, "display") != "none" && this.getStyleValue(el, "visibility") != "hidden") { objSC = new PioWebElementCoordinates(el); if (!(objSC.x1 <= objLayerC.x || objSC.x >= objLayerC.x1) && !(objSC.y1 <= objLayerC.y || objSC.y >= objLayerC.y1)) { el.style.visibility = "hidden"; rvArray.push(el); } } } return rvArray; } //~~~ this.hideSelectBoxes = function this.setChildCoordinates = function(parentObj, childObj, parentAlign, childAlign, parentValign, childValign, offsetX, offsetY) { if (parentObj != null && childObj != null && parentAlign != null && childValign != null && parentValign != null && childValign != null) { var parentC = new PioWebElementCoordinates(parentObj); var childC = new PioWebElementCoordinates(childObj, true); var x, y; //~~~ calculate align by page direction if (parentAlign == "align" || parentAlign == "opposite-align" || childAlign == "align" || childAlign == "opposite-align") { var sDir = PioWeb.pageDir_get(); if (parentAlign == "align") { parentAlign = (sDir == "rtl") ? "right" : "left"; } else if (parentAlign == "opposite-align") { parentAlign = (sDir == "rtl") ? "left" : "right"; } if (childAlign == "align") { childAlign = (sDir == "rtl") ? "right" : "left"; } else if (childAlign == "opposite-align") { childAlign = (sDir == "rtl") ? "left" : "right"; } if (offsetX != null && offsetX != 0) { if (sDir == "rtl") offsetX = -1 * offsetX; } } if (parentValign == "middle") parentValign = "center"; if (childValign == "middle") childValign = "center"; //~~~ calculate coordinates if (parentAlign == "left" && childAlign == "left") { x = parentC.x; } else if (parentAlign == "right" && childAlign == "right") { x = parentC.x1 - childC.width; } else if (parentAlign == "right" && childAlign == "left") { x = parentC.x1; } else if (parentAlign == "left" && childAlign == "right") { x = parentC.x - childC.width; } else if (parentAlign == "center" && childAlign == "center") { var dC = (childC.width / 2); var dP = (parentC.width / 2); x = parentC.x + dP - dC; } if (parentValign == "bottom" && childValign == "bottom") { y = parentC.y1 - childC.height; } else if (parentValign == "bottom" && childValign == "top") { y = parentC.y1; } else if (parentValign == "top" && childValign == "bottom") { y = parentC.y - childC.height; } else if (parentValign == "top" && childValign == "top") { y = parentC.y; } else if (parentValign == "center" && childValign == "center") { var dC = (childC.height / 2); var dP = (parentC.height / 2); y = parentC.y + dP - dC; } if (offsetX != null) x = x + offsetX * 1; if (offsetY != null) y = y + offsetY * 1; //~~~ end calculate coordinates //alert(x+"\n"+y); //~~~ set coordinates if (PioWeb.BrName == "IE") { childObj.style.pixelLeft = x; childObj.style.pixelTop = y; } else { /*if(navigator.userAgent.indexOf("Opera") < 0){ if(PioWeb.getStyleValue(childObj,"position")=="absolute"){ var oFirstChild = childObj.firstChild; if(oFirstChild != null){ if(oFirstChild.offsetHeight == childObj.clientHeight){ var iTmp1 = (oFirstChild.offsetHeight - oFirstChild.clientHeight) / 2; if(iTmp1 != 0){ y += Math.ceil(iTmp1 / 2); //y += iTmp1; } } if(oFirstChild.offsetWidth == childObj.clientWidth){ var iTmp1 = (oFirstChild.offsetWidth - oFirstChild.clientWidth) / 2; if(iTmp1 != 0){ var iTmpDir = (PioWeb.pageDir_get()=="rtl")? -1 : 1; x += (Math.ceil(iTmp1 / 2) * iTmpDir); //x -= iTmp1; } } } } }*/ childObj.style.left = x + "px"; childObj.style.top = y + "px"; } } } //~~~ this.setChildCoordinates = function var sPageDir = ""; this.pageDir_get = function() { if (sPageDir == "rtl" || sPageDir == "ltr") { return sPageDir; } else { var sRv = "ltr"; if (document.body.style.direction == "rtl") sRv = "rtl"; else if ((PioWeb.BrName != "IE" && window.getComputedStyle(document.body, null).getPropertyValue('direction') == "rtl") || (PioWeb.BrName == "IE" && document.body.currentStyle.direction == "rtl")) sRv = "rtl"; else if (document.body.dir == "rtl") sRv = "rtl"; else if (document.dir == "rtl") sRv = "rtl"; else { try { if (document.body.parentNode.dir == "rtl") sRv = "rtl"; } catch (e) { } } sPageDir = sRv; return sRv; } } var _oConvertAbsolutePathToReative1 = null; this.convertAbsolutePathToReative = function(path) { var sRv = ""; if (_sAppPath != "/") { if (_oConvertAbsolutePathToReative1 == null) { _oConvertAbsolutePathToReative = new RegExp("^" + _sAppPath + "/", "i"); } sRv = path.replace(_oConvertAbsolutePathToReative, ""); } else sRv = path.replace("/", ""); sRv = _sPageRelPath + sRv; //window.open(sRv); return sRv; } this.FixUrlPath = function(path) { if (path == null || path == "" || path == "/") return _sAppPath; else { if (path.indexOf("/") == 0) { if (_sAppPath == "/") return path; else return _sAppPath + path; } else { if (_sAppPath == "/") return "/" + path; else return _sAppPath + "/" + path; } } } //~~~ private var _sAppPath; var _sPageRelPath; this.setPagePathProps = function(appPath, pageRelPath) { _sAppPath = appPath; _sPageRelPath = pageRelPath; } this.registerBestOnPageExecutionHandler = function(handler, doNotExecuteImmediatelyButOnDocumentReady) { if (handler == null || typeof (handler) != "function") return; function internalClass() { var iExecState = 2; var hdlExec = function() { iExecState--; if (iExecState == 0) return; handler(); } this.execHandler = function() { hdlExec(); } } var oHz = new internalClass(); var hdlHz = function() { oHz.execHandler(); try { Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(function(sender, args) { oHz.execHandler(); }); } catch (e) { } } if (!doNotExecuteImmediatelyButOnDocumentReady) { hdlHz(); } else { try { $(document).ready(hdlHz); } catch (e) { PioWeb.attachEvent(window, "load", hdlHz); } } } } //~~~ class PioWeb var PioWeb = new PioWeb(); //PioWeb.BrName //PioWeb.BrVers //PioWeb.NullGifSrc function PioWebElementCoordinates(o, onlyDimensions) { this.x = 0; this.y = 0; this.x1 = 0; this.y1 = 0; this.width = 0; this.height = 0; this.obj = o; this.width = o.offsetWidth; if (this.width == 0 && PioWeb.getStyleValue(o, "display") == "none") { o.style.display = ""; this.width = o.offsetWidth; this.height = o.offsetHeight; o.style.display = "none"; } else { this.height = o.offsetHeight; } if (onlyDimensions) return; var elCurr = o; var iX = 0; var iY = 0; if (PioWeb.BrName == "IE") { var iDiffX1 = 0; if (true || PioWeb.pageDir_get() != "rtl") { while (elCurr != null) { iX += elCurr.offsetLeft; iY += elCurr.offsetTop; iDiffX1 = elCurr.offsetLeft - elCurr.clientLeft; if (iDiffX1 < 0) iX -= iDiffX1; if (elCurr.offsetParent != null) { if (elCurr.offsetParent == document.body || elCurr.offsetParent == document.documentElement) { break; } } elCurr = elCurr.offsetParent; } } else { var sDebug = ""; var elTopNotAbsolute = null; var bIsIE7 = (PioWeb.BrVers >= 7); while (elCurr != null) { iX += elCurr.offsetLeft; iY += elCurr.offsetTop; //iX += elCurr.clientLeft; //iY += elCurr.clientTop; //iX += elCurr.scrollLeft; //iY += elCurr.scrollTop; if (!bIsIE7) { iDiffX1 = elCurr.offsetLeft - elCurr.clientLeft; if (iDiffX1 < 0) iX -= iDiffX1; } /* sDebug += debugProp(elCurr,"elCurr","id"); sDebug += debugProp(elCurr,"elCurr","offsetLeft"); sDebug += debugProp(elCurr,"elCurr","clientLeft"); sDebug += debugProp(elCurr,"elCurr","scrollLeft"); sDebug += debugProp(elCurr,"elCurr","offsetWidth"); sDebug += debugProp(elCurr,"elCurr","clientWidth"); sDebug += "\n"; */ if (elCurr.offsetParent != null) { if (elCurr.offsetParent == document.body || elCurr.offsetParent == document.documentElement) { if (PioWeb.getStyleValue(elCurr, "position") == "absolute") { break; } else { if (!bIsIE7) { if (iDiffX1 < 0) iX += iDiffX1; } elTopNotAbsolute = elCurr; break; } } } elCurr = elCurr.offsetParent; } //~~~ while //~~~ patch rtl with horizontal scroll if (elTopNotAbsolute) { elCurr = elTopNotAbsolute; var elHtml = document.documentElement; var elBody = document.body; /* sDebug += "it's top element
\n"; sDebug += debugProp(elCurr,"elCurr","id"); sDebug += "\n"; sDebug += debugProp(elBody,"elBody","offsetLeft"); sDebug += debugProp(elBody,"elBody","clientLeft"); sDebug += debugProp(elBody,"elBody","scrollLeft"); sDebug += debugProp(elBody,"elBody","offsetWidth"); sDebug += debugProp(elBody,"elBody","clientWidth"); sDebug += debugProp(elBody,"elBody","scrollWidth"); sDebug += debugProp(elBody,"elBody","offsetHeight"); sDebug += debugProp(elBody,"elBody","clientHeight"); sDebug += debugProp(elBody,"elBody","scrollHeight"); sDebug += "\n"; sDebug += debugProp(elHtml,"elHtml","offsetLeft"); sDebug += debugProp(elHtml,"elHtml","clientLeft"); sDebug += debugProp(elHtml,"elHtml","scrollLeft"); sDebug += debugProp(elHtml,"elHtml","offsetWidth"); sDebug += debugProp(elHtml,"elHtml","clientWidth"); sDebug += debugProp(elHtml,"elHtml","scrollWidth"); sDebug += debugProp(elHtml,"elHtml","offsetHeight"); sDebug += debugProp(elHtml,"elHtml","clientHeight"); sDebug += debugProp(elHtml,"elHtml","scrollHeight"); sDebug += "\n"; */ if (elCurr.offsetLeft != elBody.offsetLeft) { iX += elBody.offsetLeft; /*if(elCurr.offsetLeft < 0){ iDiffX1 = elHtml.scrollWidth - elHtml.clientWidth; iX += iDiffX1; }*/ } else { //iX -= elBody.offsetLeft; //iDiffX1 = 0; if (elHtml.clientWidth != 0) { iDiffX1 = Math.abs(elHtml.clientWidth - elHtml.scrollWidth); } else { iDiffX1 = Math.abs(elBody.scrollLeft); } /*if(iDiffX1 <= 1){ if(elHtml.offsetHeight != 0 && elHtml.clientHeight != 0 && Math.abs(elHtml.offsetHeight - elHtml.clientHeight) > 10){ iDiffX1 = 2; } }*/ if (iDiffX1 > 1) { //~~~ have horiz scroll iDiffX1 = elHtml.offsetWidth - elHtml.clientWidth; //~~~ vertical scroll bar width iX += iDiffX1; } } iY += elBody.offsetTop; if (elCurr.offsetWidth < elBody.offsetWidth) { //iX += (elBody.offsetWidth - elCurr.offsetWidth); if (elCurr.offsetLeft != elBody.offsetLeft) { iX += (elHtml.scrollWidth - elHtml.clientWidth); } } /* if(elHtml.clientWidth != elHtml.scrollWidth){ //~~~ have horizontal scroll //~~~ elHtml.scrollWidth = elHtml.clientWidth + elHtml.scrollLeft + a; //~~~ so a = elHtml.scrollWidth - elHtml.clientWidth - elHtml.scrollLeft; //~~~ or elHtml.scrollLeft + a = elHtml.scrollWidth - elHtml.clientWidth; } */ try { var iXNew = PioWebElementCoordinates_Fix_X_IE_RTL(o, iX, elTopNotAbsolute); iX = iXNew; } catch (e) { } //if(sDebug!=""){sDebug=iX+"\n\n"+sDebug;alert(sDebug);} } //~~~ patch rtl with horizontal scroll } //~~~ rtl } else { //~~~ MZ while (elCurr != null) { iX += elCurr.offsetLeft; iY += elCurr.offsetTop; if (elCurr.offsetParent != null) { if (elCurr.offsetParent == document.body || elCurr.offsetParent == document.documentElement) { break; } } elCurr = elCurr.offsetParent; } } this.x = iX; this.y = iY; this.x1 = this.x + this.width; this.y1 = this.y + this.height; function debugProp(el, elName, propName) { var sRv = ""; eval("sRv = el." + propName); sRv = el.tagName + "." + propName + ": " + sRv + "\n"; //sRv = elName + "." + propName + ": " + sRv + " \n
\n"; return sRv; } this.isInnerXYbyEvent = function(e) { return this.isInnerXYbyXY(e.clientX, e.clientY); } this.isInnerXYbyJQueryEvent = function(jqE) { //return this.isInnerXYbyXY(jqE.pageX, jqE.pageY); return this.isInnerXYbyEvent(jqE.originalEvent); } this.isInnerXYbyXY = function(x, y) { var iEx = x + document.documentElement.scrollLeft; if (this.x < iEx && this.x1 > iEx) { var bIsFixed = false; var ctlTmp = this.obj; while (ctlTmp != null) { var sPosition; try { sPosition = PioWeb.getStyleValue(ctlTmp, "position"); } catch (e) { sPosition = null; } if (sPosition == "fixed") { bIsFixed = true; break; } ctlTmp = ctlTmp.parentNode; if (ctlTmp && null && (ctlTmp == document.body || ctlTmp == document.documentElement)) { break; } } var iEySc = bIsFixed ? 0 : (window.pageXOffset ? window.pageXOffset : document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop); var iEy = y + iEySc; if (this.y < iEy && this.y1 > iEy) { //~~~ inner click return true; } } return false; } } //~~~ class PioWebElementCoordinates function PioWebElementCoordinates_Fix_X_IE_RTL(obj, calculatedX, objTop) { //var elHtml = document.documentElement; //var elBody = document.body; //var elCurr = objTop; return calculatedX; } function PioWebAbsoluteElement(parentObj, childObj, parentAlign, childAlign, parentValign, childValign, offsetX, offsetY) { this.parentObj = (typeof (parentObj) == "string") ? PioWeb.getElementById(parentObj) : parentObj; this.childObj = (typeof (childObj) == "string") ? PioWeb.getElementById(childObj) : childObj; this.parentAlign = parentAlign; this.childAlign = childAlign; this.parentValign = parentValign; this.childValign = childValign; this.offsetX = offsetX; this.offsetY = offsetY; var arHiddenSelectBoxes = null; this.setPosition = function(parentObj) { var oParent; if (parentObj == null) { oParent = this.parentObj; } else { oParent = (typeof (parentObj) == "string") ? PioWeb.getElementById(parentObj) : parentObj; this.parentObj = oParent; } PioWeb.setChildCoordinates(oParent, this.childObj, this.parentAlign, this.childAlign, this.parentValign, this.childValign, this.offsetX, this.offsetY); } this.show = function() { if (PioWeb.getStyleValue(this.childObj, "display") == "none") { this.childObj.style.display = ""; } unHideSelectBoxes(); arHiddenSelectBoxes = PioWeb.hideSelectBoxes(this.childObj); this.childObj.style.visibility = "visible"; } this.hide = function() { this.childObj.style.visibility = "hidden"; if (this.hide_fixChildObjectPosition != null && typeof (this.hide_fixChildObjectPosition) == "function") { this.hide_fixChildObjectPosition(); } this.childObj.style.display = "none"; unHideSelectBoxes(); } this.hide_fixChildObjectPosition = function() { this.childObj.style.left = 0 + "px"; //~~~ maby to prevent horizontal scroll } function unHideSelectBoxes() { var oAr = arHiddenSelectBoxes; if (oAr != null) { for (var i = 0; i < oAr.length; i++) { oAr[i].style.visibility = "visible"; } this.arHiddenSelectBoxes = null; } } } //~~~ class PioWebAbsoluteElement function PioWebAbsoluteElementEx(selfVarName, parentObj, childObj, parentAlign, childAlign, parentValign, childValign, offsetX, offsetY) { this.flyObj = new PioWebAbsoluteElement(parentObj, childObj, parentAlign, childAlign, parentValign, childValign, offsetX, offsetY); var flyObj = this.flyObj; this.selfVarName = selfVarName; this.mouseOutAutoClose = null; //~~~ may be null or true or function callback (function gets PioWebAbsoluteElementEx object returns true if must be closed) this.innerClickAutoClose = null; //~~~ may be null or true or function callback (function gets PioWebAbsoluteElementEx object and srcElement and returns true if must be closed) this.outerClickAutoClose = null; //~~~ may be null or true or function callback (function gets PioWebAbsoluteElementEx object, event and returns true if must be closed) this.outerClickAutoCloseDisableOnParent = false; this.timeoutAutoClose = null; //~~~ may be integer greater then 0 (milleseconds) or null this.timeoutAutoCloseCancelCallBack = null; this.freeStateObject = null; this.closeOnResize = true; this.afterHideHandler = null; //~~~ may be null or function callback (function gets PioWebAbsoluteElementEx object) or "focusOnParent" var hTimer = null; var iTimer = null; var bIsOpened = (PioWeb.getStyleValue(flyObj.childObj, "visibility") != "hidden"); var bIsMouseOver = false; var bMsOvHandlers = false; var bMsLvHandlers = false; var bOuterClickHandlers = false; var bRszHandlers = false; var bInnerClickAutoClose = false; var sWindowSize = ""; this.isOpened_get = function() { return bIsOpened; } this.setPosition = function(parentObj) { flyObj.setPosition(parentObj); } this.show = function() { if (bIsOpened) return false; clearTimeout(); ensureFlyObjectMark(); ensureMsOvLvHandlers(this.timeoutAutoClose, this.mouseOutAutoClose); ensureInnerClickHandlers(this.innerClickAutoClose) ensureOuterClickHandlers(this.outerClickAutoClose); ensureRszHandlers(this.closeOnResize); if (this.closeOnResize) { sWindowSize = document.documentElement.offsetWidth + "X" + document.documentElement.offsetHeight; } bIsOpened = true; this.flyObj.show(); if (this.timeoutAutoClose != null && this.timeoutAutoClose > 0) { increaseTimeOut(true); } return true; } this.hide = function() { if (!bIsOpened) return false; clearTimeout(); ensureOuterClickHandlers(false); bIsOpened = false; flyObj.hide(); if (this.afterHideHandler != null && typeof (this.afterHideHandler) == "function") { this.afterHideHandler(this); }else if(this.afterHideHandler == "focusOnParent"){ if(flyObj.parentObj != null){ try{flyObj.parentObj.focus();}catch(e){} } } return true; } //~~~ private functions this.hideByResize = function(e) {//~~~ only IE function var sWindowSize1 = document.documentElement.offsetWidth + "X" + document.documentElement.offsetHeight; if (sWindowSize != sWindowSize1) { this.hide(); } } this.clkHandlerOuter = function(e) { if (this.outerClickAutoClose != null && (typeof (this.outerClickAutoClose) == "function" || this.outerClickAutoClose)) { var oC = new PioWebElementCoordinates(flyObj.childObj); if (oC.isInnerXYbyEvent(e)) { //~~~ inner click } else { if (this.outerClickAutoCloseDisableOnParent) { var oC = new PioWebElementCoordinates(flyObj.parentObj); if (oC.isInnerXYbyEvent(e)) { //~~~ inner click on parent return; } } if (typeof (this.outerClickAutoClose) == "function") { if (this.outerClickAutoClose(this, e)) this.hide(); } else { this.hide(); } } } } this.clkHandlerInner = function(e) { if (this.innerClickAutoClose != null && (typeof (this.innerClickAutoClose) == "function" || this.innerClickAutoClose)) { var bClose = false; if (typeof (this.innerClickAutoClose) == "function") { bClose = this.innerClickAutoClose(this, PioWeb.getEventTargetElement(e)); } else if (this.innerClickAutoClose) { bClose = true; } if (bClose) { this.hide(); } } } this.hideByTimeout = function() { if (hTimer != null) { if (iTimer != null) { var dTmp = new Date(); iTimer1 = dTmp.valueOf(); if ((iTimer1 - iTimer) > this.timeoutAutoClose) { if (bIsOpened && this.timeoutAutoCloseCancelCallBack != null && typeof (this.timeoutAutoCloseCancelCallBack) == "function") { if (this.timeoutAutoCloseCancelCallBack(this)) { return; } } this.hide(); } } else { clearTimeout(); } } } this.msovHandler = function(e) { increaseTimeOut(); } this.mslvHandler = function(e) { increaseTimeOut(); if ((this.mouseOutAutoClose != null && (typeof (this.mouseOutAutoClose) == "function" || this.mouseOutAutoClose))) { if (bIsOpened) { var oC = new PioWebElementCoordinates(flyObj.childObj); if (oC.x < e.clientX && oC.x1 > e.clientX && oC.y < e.clientY && oC.y1 > e.clientY) { //~~~ inner element return; } if (typeof (this.mouseOutAutoClose) == "function") { if (this.mouseOutAutoClose(this)) { return; } } this.hide(); } } } function increaseTimeOut(onShow) { if (hTimer != null || onShow) { var dTmp = new Date(); iTimer = dTmp.valueOf(); if (onShow) hTimer = window.setInterval(selfVarName + ".hideByTimeout();", 250); } } function clearTimeout() { if (hTimer != null) window.clearInterval(hTimer); hTimer = null; iTimer = null; } function ensureFlyObjectMark(){ if (flyObj.childObj != null) if (flyObj.childObj.getAttribute("PWFlyEX") != selfVarName) flyObj.childObj.setAttribute("PWFlyEX", selfVarName); } function ensureMsOvLvHandlers(timeoutAutoClose, mouseOutAutoClose) { var bMsOv = (timeoutAutoClose != null && timeoutAutoClose > 0); var bMsLv = (bMsOv || (mouseOutAutoClose != null && (typeof (mouseOutAutoClose) == "function" || mouseOutAutoClose))); if (bMsOv) { if (!bMsOvHandlers) { bMsOvHandlers = true; PioWeb.attachEvent(flyObj.childObj, "mouseover", PioWebAbsoluteElementEx_msovHandler); } } else { if (bMsOvHandlers) { bMsOvHandlers = false; PioWeb.detachEvent(flyObj.childObj, "mouseover", PioWebAbsoluteElementEx_msovHandler); } } if (bMsLv) { if (!bMsLvHandlers) { bMsLvHandlers = true; PioWeb.attachEvent(flyObj.childObj, "mouseout", PioWebAbsoluteElementEx_mslvHandler); } } else { if (!bMsLvHandlers) { bMsLvHandlers = false; PioWeb.detachEvent(flyObj.childObj, "mouseout", PioWebAbsoluteElementEx_mslvHandler); } } } function ensureInnerClickHandlers(innerClickAutoClose) { if (innerClickAutoClose != null && (typeof (innerClickAutoClose) == "function" || innerClickAutoClose)) { if (!bInnerClickAutoClose) { if (flyObj.childObj != null) { bInnerClickAutoClose = true; PioWeb.attachEvent(flyObj.childObj, "click", PioWebAbsoluteElementEx_clkHandler); } } } else { if (bInnerClickAutoClose) { if (this.flyObj.childObj != null) { bInnerClickAutoClose = false; PioWeb.detachEvent(flyObj.childObj, "click", PioWebAbsoluteElementEx_clkHandler); } } } } function ensureOuterClickHandlers(outerClickAutoClose) { if (flyObj.childObj != null) { if (outerClickAutoClose != null && (typeof (outerClickAutoClose) == "function" || outerClickAutoClose)) { if (!bOuterClickHandlers) { bOuterClickHandlers = true; var sHandlerName = selfVarName + "_outerClickAutoCloseHandler"; var oHandler = window[sHandlerName]; if (oHandler == null) { var sCommand = "oHandler = function(e){if(" + selfVarName + "!=null)" + selfVarName + ".clkHandlerOuter(e);}"; eval(sCommand); window[sHandlerName] = oHandler; } PioWeb.attachEvent(document, "click", oHandler); } } else { if (bOuterClickHandlers) { bOuterClickHandlers = false; var sHandlerName = selfVarName + "_outerClickAutoCloseHandler"; var oHandler = window[sHandlerName]; if (oHandler != null) { PioWeb.detachEvent(document, "click", oHandler); //window[sHandlerName] = null; } } } } } function ensureRszHandlers(closeOnResize) { if (flyObj.childObj != null) { if (closeOnResize) { if (!bRszHandlers) { bRszHandlers = true; var sHandlerName = selfVarName + "_windowResizeHandler"; var oHandler = window[sHandlerName]; if (oHandler == null) { if (PioWeb.BrName == "IE") { var sCommand = "oHandler = function(e){if(" + selfVarName + "!=null)" + selfVarName + ".hideByResize(e);}"; eval(sCommand); } else { var sCommand = "oHandler = function(e){if(" + selfVarName + "!=null)" + selfVarName + ".hide();}"; eval(sCommand); } window[sHandlerName] = oHandler; } PioWeb.attachEvent(window, "resize", oHandler); } } else { if (bRszHandlers) { bRszHandlers = false; var sHandlerName = selfVarName + "_windowResizeHandler"; var oHandler = window[sHandlerName]; if (oHandler != null) { PioWeb.detachEvent(window, "resize", oHandler); //window[sHandlerName] = null; } } } } } } function PioWebAbsoluteElementEx_getFlyObjectByMask(e, el) { var elObj = el; if (PioWeb.BrName == "IE") { elObj = e.srcElement; while (elObj != null) { if (elObj.getAttribute("PWFlyEX") != null) break; elObj = elObj.offsetParent; } } eval("var rRv = " + elObj.getAttribute("PWFlyEX") + ";"); return rRv; } function PioWebAbsoluteElementEx_msovHandler(e) { var elObj = PioWebAbsoluteElementEx_getFlyObjectByMask(e, this); if (elObj != null) elObj.msovHandler(e); } function PioWebAbsoluteElementEx_mslvHandler(e) { var elObj = PioWebAbsoluteElementEx_getFlyObjectByMask(e, this); if (elObj != null) elObj.mslvHandler(e); } function PioWebAbsoluteElementEx_clkHandler(e) { var elObj = PioWebAbsoluteElementEx_getFlyObjectByMask(e, this); if (elObj != null) elObj.clkHandlerInner(e); } //~~~ class PioWebAbsoluteElementEx //~~~ global functions for DatePickerControl (simple control, without DatePicker.js, without monthview) function PioDateControl_RenderComboBoxOptions__(minValue, maxValue, selectedValue, nullableText, addZerosToText, isYear) { var sHtml = ""; var sSelectedValue = selectedValue + ""; if (nullableText != null && nullableText != "") { sHtml += ""; } if (isYear && selectedValue != -1 && selectedValue < minValue) { sHtml += ""; } for (var i = minValue; i <= maxValue; i++) { sHtml += ""; } if (isYear && selectedValue != -1 && selectedValue > maxValue) { sHtml += ""; } document.write(sHtml); } function PioDateControl_RenderComboBoxOptions_Day(nullableText, selectedDay, addZerosToText) { PioDateControl_RenderComboBoxOptions__(1, 31, selectedDay, nullableText, addZerosToText, false); } function PioDateControl_RenderComboBoxOptions_Month(nullableText, selectedMonth, addZerosToText) { PioDateControl_RenderComboBoxOptions__(1, 12, selectedMonth, nullableText, addZerosToText, false); } function PioDateControl_FixComboBoxes(daySelectBox, monthSelectBox, yearSelectBox) { if (typeof (daySelectBox) == 'string') daySelectBox = document.getElementById(daySelectBox); if (typeof (monthSelectBox) == 'string') monthSelectBox = document.getElementById(monthSelectBox); if (typeof (yearSelectBox) == 'string') yearSelectBox = document.getElementById(yearSelectBox); return PioDateControl_FixComboBoxes1(daySelectBox, monthSelectBox, yearSelectBox); } function PioDateControl_FixComboBoxes0(datePickerControlClientId) { return PioDateControl_FixComboBoxes(datePickerControlClientId + "__day", datePickerControlClientId + "__month", datePickerControlClientId + "__year"); } function PioDateControl_FixComboBoxes1(daySelectBox, monthSelectBox, yearSelectBox) { var iDay = daySelectBox.value * 1; var iMonth = monthSelectBox.value * 1; var iYear = yearSelectBox.value * 1; var ar__1 = new Array(); if (iYear == -1) ar__1.push(-1); if (iMonth == -1) ar__1.push(-1); if (iDay == -1) ar__1.push(-1); switch (ar__1.length) { case 1: daySelectBox.selectedIndex = 0; monthSelectBox.selectedIndex = 0; yearSelectBox.selectedIndex = 0; return true; //~~~ changed case 2: var dToday = PioDateMonthView_today; if (iDay == -1) daySelectBox.value = dToday.getDate(); if (iMonth == -1) monthSelectBox.value = dToday.getMonth() + 1; if (iYear == -1) PioDateControl_FixComboBoxes1_SetYearComboBoxValue(yearSelectBox, dToday.getFullYear(), true); return true; //~~~ changed case 3: return false; //~~~ not changed } if (iDay < 29) return false; //~~~ not changed var iDayMax = PioWeb.dateDaysInMonth(iMonth, iYear); if (iDay > iDayMax) { daySelectBox.value = iDayMax; return true; //~~~ changed } return false; //~~~ not changed } function PioDateControl_FixComboBoxes1_SetYearComboBoxValue(yearSelectBox, year, isFromNullable) { var bProcessAdditional = false; try { yearSelectBox.value = year; if (yearSelectBox.value != year) bProcessAdditional = true; } catch (e) {bProcessAdditional = true;} if (bProcessAdditional) { var bIsNullable = yearSelectBox.options[0].value == "-1"; //getIsNullable_(); if (isFromNullable) { yearSelectBox.selectedIndex = bIsNullable ? 1 : 0; } else { var iInsertIndex = 0; var iFirstValue = yearSelectBox.options[(bIsNullable) ? 1 : 0].value * 1; if (year < iFirstValue) { if (bIsNullable) iInsertIndex = 1; } else if (year > yearSelectBox.options[yearSelectBox.options.length - 1].value * 1) { iInsertIndex = -1; } else { for (var i = (bIsNullable) ? 2 : 1; i < yearSelectBox.options.length; i++) { if (year < yearSelectBox.options[i].value * 1) { iInsertIndex = i; break; } } } var o = new Option(); o.value = year; o.text = year; yearSelectBox.options.add(o, iInsertIndex); yearSelectBox.selectedIndex = (iInsertIndex >= 0) ? iInsertIndex : yearSelectBox.options.length - 1; } } } //~~~ global functions for DatePickerControl (simple control, without DatePicker.js, without monthview) //~~~ default hint on textbox function PioWebForm_FieldOtherOption_0(control) { var sAnchor = control.getAttribute("PioWebForm_FieldOtherOption_0"); if (sAnchor != "YOC") { control.setAttribute("PioWebForm_FieldOtherOption_0", "YOC"); if (sAnchor != null && sAnchor != "") { control.setAttribute("PioWebForm_FieldOtherOption_01", sAnchor); var sTitle = control.title; if(sTitle == null || sTitle == "") control.title = sAnchor; var hdlOnChange = function() { var sDefaultHint = control.getAttribute("PioWebForm_FieldOtherOption_01"); var sValue = PioWeb.trim(control.value); PioWeb.setClassName(null, control, null, "default-hint", (sValue == sDefaultHint), false); } var hdlOnBlur = function() { var sValue = PioWeb.trim(control.value); if (sValue == "") { var sDefaultHint = control.getAttribute("PioWebForm_FieldOtherOption_01"); control.value = sDefaultHint; } hdlOnChange(); } PioWeb.attachEvent(control, "change", hdlOnChange); PioWeb.attachEvent(control, "keydown", hdlOnChange); PioWeb.attachEvent(control, "blur", hdlOnBlur); } } var sDefaultHint = control.getAttribute("PioWebForm_FieldOtherOption_01"); if (sAnchor != null && sAnchor != "") { var sValue = PioWeb.trim(control.value); if (sValue == sDefaultHint) control.value = ""; PioWeb.setClassName(null, control, null, "default-hint", false, false); } } //~~~ other option on list controls function PioWebForm_FieldOtherOption_1(control) { var hdlTmp = function() { var oHz = PioWebForm_FieldOtherOption_1_private(control); if (oHz == null) { alert("Can't find control with nd-list-field-other-option"); } else { PioWeb.setClassName(null, oHz.ctl, null, "nd-list-field-other-option-selected", oHz.show, false); } } window.setTimeout(hdlTmp, 100); } function PioWebForm_FieldOtherOption_1_private(control) { var sAnchorValue = "**[other]**"; var bShow = false; if (control.tagName == "SELECT") { for (var i = 0; i < control.options.length; i++) { if (control.options[i].value == sAnchorValue) { if (control.options[i].selected) { bShow = true; break; } } } } else { var colInputs = control.getElementsByTagName("INPUT"); var bOtherIsFound = false; //~~~ in checkbox list it's impossible to find by value so we will take the last one var ctlLastCheckBox = null; for (var i = 0; i < colInputs.length; i++) { var ctlTmp = colInputs[i]; ctlLastCheckBox = ctlTmp; if (ctlTmp.type == "radio" || ctlTmp.type == "checkbox") { if (ctlTmp.value == sAnchorValue) { bOtherIsFound = true; if (ctlTmp.checked) { bShow = true; break; } } } } if (!bOtherIsFound) { if (ctlLastCheckBox != null && ctlLastCheckBox.checked) { bShow = true; } } } var ctlControl = control.nextSibling; if (ctlControl == null || ctlControl.className.indexOf("nd-list-field-other-option") < 0) { return null; } else { return {ctl:ctlControl, show:bShow}; } } function PioWebForm() { var bJqIsEnabled; try { var jqTmp = $(document); bJqIsEnabled = true; } catch (e) { bJqIsEnabled = false; } var sJqAnchor = ".pio-form-cell.pio-form-field, .pio-form-field-part-container.pio-form-field-part-field"; this.validateForm = function (obj, globalErrorHandler) { if (!bJqIsEnabled) return true; //~~~ transfer to server side var jqContainer = $(obj).first(); var jqFieldsToValidate = jqContainer.find("*[__piowebform_validation]"); if (jqFieldsToValidate.length <= 0) return true; var oFirstError = null; var ar_ctlHz = []; for (var i = 0; i < jqFieldsToValidate.length; i++) { if (!this.validateField(jqFieldsToValidate[i])) { if (oFirstError == null) oFirstError = jqFieldsToValidate[i]; } if (jqFieldsToValidate[i].getAttribute("__piowebform_validation_mode") == "3") { ar_ctlHz.push(jqFieldsToValidate[i]); } } PioWebForm.improveHtml(jqContainer, 1); var bIsValid = oFirstError == null; if (!bIsValid && ar_ctlHz.length > 0) { for (var i = 0; i < ar_ctlHz.length; i++) { ar_ctlHz[i].setAttribute("__piowebform_validation_mode", "2"); } } if (globalErrorHandler != null && typeof (globalErrorHandler) == "function") { globalErrorHandler(bIsValid); } return bIsValid; } this.validateField = function (obj) { if (!bJqIsEnabled) return true; //validateField_setError(null); //~~~ transfer to server side var jqContainer = $(obj).closest(sJqAnchor); var jqJson = jqContainer.is("*[__piowebform_validation]") ? jqContainer : jqContainer.find("*[__piowebform_validation]").first(); if (jqJson.length <= 0) return validateField_setError(null, jqContainer); //~~~ transfer to server side var sJson = jqJson.attr("__piowebform_validation"); var oJson; eval("oJson = " + sJson); var ar_oValidationRules = oJson.v; if (ar_oValidationRules == null || ar_oValidationRules.length <= 0) return validateField_setError(null, jqContainer); //~~~ transfer to server side var hdlIsEmpty = oJson.ise; var hdlGetValue = oJson.gev; if (hdlIsEmpty != null && typeof (hdlIsEmpty) == "function") { var bIsEmpty; try { bIsEmpty = hdlIsEmpty(jqContainer); } catch (e) { bIsEmpty = null; } if (bIsEmpty == null) return validateField_setError(null, jqContainer); //~~~ transfer to server side var oValue; if (!bIsEmpty) { try { oValue = (hdlGetValue != null && typeof (hdlGetValue) == "function") ? hdlGetValue(jqContainer) : null; } catch (e) { oValue = null; } if (oValue == null) return validateField_setError(null, jqContainer); //~~~ transfer to server side } else oValue = null; var sErrorMessage = null; for (var i = 0; i < ar_oValidationRules.length; i++) { var bIsValid1; try { bIsValid1 = ar_oValidationRules[i].h(bIsEmpty, oValue, ar_oValidationRules[i].p); } catch (e) { return validateField_setError(null, jqContainer); /*~~~ transfer to server side*/ } if (bIsValid1 == null) return validateField_setError(null, jqContainer); //~~~ transfer to server side if (!bIsValid1) { var sErrorMessage1; try { sErrorMessage1 = $.trim(ar_oValidationRules[i].e); } catch (e) { sErrorMessage1 = null; } if (sErrorMessage1 == null) return validateField_setError(null, jqContainer); //~~~ transfer to server side sErrorMessage1 = $.trim(sErrorMessage1); if (sErrorMessage1 == "") return validateField_setError(null, jqContainer); //~~~ transfer to server side sErrorMessage = sErrorMessage1; break; } } return validateField_setError(sErrorMessage, jqContainer); } } function validateField_setError(errorMessage, container) { var bIsError = errorMessage != null; var oFieldParts = PioWebForm.getFieldParts(container); var jqErrorContainer = oFieldParts.errContainer; var jqError = oFieldParts.err; if (!bIsError) { if (jqErrorContainer != null) { var sHtml = jqErrorContainer.html(); if (sHtml != null && sHtml != "") { jqErrorContainer.html(""); } } } else { if (jqError == null || jqError.length <= 0) { if (jqErrorContainer != null && jqErrorContainer.length > 0) { jqError = $("
").appendTo(jqErrorContainer); } else { return true; //~~~ transfer to server side } } var sHtml = jqError.html(); if (sHtml != errorMessage) { jqError.html(errorMessage); } } //if (bIsError) alert(errorMessage); return !bIsError; } this.validationRule_IsRequired = function (isEmpty, value, params) { return !isEmpty; } this.validationRule_Email = function (isEmpty, value, params) { if (isEmpty) return true; var oRe = /^[\w\.-]+@[\w-]+\.[\w\.-]+$/gi var bRv; try { bRv = oRe.test(value); } catch (e) { bRv = null; } return bRv; } this.validationRule_IsraeliIdNumber = function (isEmpty, value, params) { if (isEmpty) return true; var oRe = /^[\d]{6,9}$/gi var bRv; try { bRv = oRe.test(PioWeb.trim(value)); } catch (e) { bRv = null; } return bRv; } this.validationRule_RegEx = function (isEmpty, value, params) { if (isEmpty) return true; var oRe = new RegExp(params.re, "gm" + params.ic ? "i" : ""); var bRv; try { bRv = oRe.test(value); } catch (e) { bRv = null; } if (bRv != null) { if (!params.rv) return bRv; return !bRv; } return bRv; } this.validationRule_MinLength = function (isEmpty, value, params) { if (isEmpty) return true; if (PioWeb.trim(value).length > params.min) return false; return true; } this.validationRule_CCExpiration = function (isEmpty, value, params) { if (isEmpty) return true; var iTmp = value.getFullYear(); //~~~ maby exception but it's ok var dToday = new Date(); return value >= dToday; } this.getValueIsEmpty_TextBox = function (obj) { var sValue = PioWebForm.getValue_TextBox(obj); if (sValue == null) return null; //~~~ transfer to server side return sValue == ""; } this.getValue_TextBox = function (obj) { var sValue = PioWebForm.getValue_TextBox_NoAutoTrim(obj); if (sValue == null || sValue == "") return sValue; return $.trim(sValue) } this.getValue_TextBox_NoAutoTrim = function (obj) { if (!bJqIsEnabled) return null; var jqContainer = $(obj).closest(sJqAnchor); var jqInput = jqContainer.find("INPUT.inputtext[type=text], TEXTAREA").first(); if (jqInput.length <= 0) return null; var ctlInput = jqInput[0]; PioWebForm_FieldOtherOption_0(ctlInput); if (jqInput.hasClass("default-hint")) return ""; //var sValue = $.trim(ctlInput.value); var sValue = ctlInput.value; return sValue; } this.getValueIsEmpty_SelectBox = function (obj) { var sValue = PioWebForm.getValue_SelectBox(obj); if (sValue == null) return null; //~~~ transfer to server side return sValue == ""; } this.getValue_SelectBox = function (obj) { if (!bJqIsEnabled) return null; var jqContainer = $(obj).closest(sJqAnchor); var jqInput = jqContainer.find("SELECT").first(); if (jqInput.length <= 0) return null; var sValue; var oHz = PioWebForm_FieldOtherOption_1_private(jqInput[0]); if (oHz == null || !oHz.show) { sValue = $.trim(jqInput[0].value); } else { sValue = $.trim(oHz.ctl.value); } return sValue; } this.getValueIsEmpty_DatePicker = function (obj) { var oRv = getValue_DatePicker_(obj); if (oRv == -1) return null; //~~~ transfer to server side return oRv == null; } this.getValue_DatePicker = function (obj) { var oRv = getValue_DatePicker_(obj); if (oRv == -1) return null; //~~~ transfer to server side return oRv; } function getValue_DatePicker_(obj) { if (!bJqIsEnabled) return -1; var jqContainer = $(obj).closest(sJqAnchor); var jqYear = jqContainer.find("SELECT.combo.combo-year").first(); var jqMonth = jqContainer.find("SELECT.combo.combo-month").first(); var jqDay = jqContainer.find("SELECT.combo.combo-day").first(); if (jqYear.length <= 0 || jqMonth.length <= 0 || jqDay.length <= 0) return -1; var iDay = jqDay[0].value * 1; var iMonth = jqMonth[0].value * 1; var iYear = jqYear[0].value * 1; if (iDay == -1 || iMonth == -1 || iYear == -1) return null; var dDate = new Date(iYear, iMonth - 1, iDay); return dDate; } this.getValueIsEmpty_CCExp = function (obj) { var oRv = getValue_DatePicker_(obj); if (oRv == -1) return null; //~~~ transfer to server side return oRv == null; } this.getValue_CCExp = function (obj) { var oRv = getValue_DatePicker_(obj); if (oRv == -1 || oRV == null) return null; //~~~ transfer to server side oRv.setMonth(oRv.getMonth() + 1, 1); oRv.setDate(0); return oRv; } this.getFieldParts = function (obj) { if (!bJqIsEnabled) return null; var jqTr = $(obj).closest(".pio-form-row, .pio-form-field-container"); var sLayout = null; var jqLabel = null; var jqRemarks = null; var jqErrorContainer = null; var jqError = null; var jqErrorHighlight = null; if (jqTr.hasClass("pio-form-field-container")) { //~~~ div layout sLayout = "div"; jqLabel = jqTr.find(".pio-form-field-part-container.pio-form-field-part-title .pio-form-field-title"); jqError = jqTr.find(".pio-form-field-part-container.pio-form-field-part-error .pio-form-error"); jqRemarks = jqTr.find(".pio-form-field-part-container.pio-form-field-part-remarks .pio-form-field-remarks"); if (jqError.length > 0) jqErrorContainer = jqError.parent(); else jqErrorContainer = jqTr.find(".pio-form-field-part-container.pio-form-field-part-error"); } else if (jqTr.hasClass("pio-form-row-narrow")) { sLayout = "narrow"; jqErrorHighlight = jqTr; var jqTrTmp = jqTr; for (var i = 0; i <= 1; i++) { var jqPrev = jqTrTmp.prev(); if (jqPrev.length > 0) { if (jqPrev.hasClass("pio-form-row") && jqPrev.hasClass("pio-form-row-narrow") && jqPrev.hasClass("pio-form-row-title")) { jqErrorHighlight = jqErrorHighlight.add(jqPrev.first()); jqLabel = jqPrev.first().find(".pio-form-cell.pio-form-field-title .pio-form-field-title"); break; } else if (jqPrev.hasClass("pio-form-row") && jqPrev.hasClass("pio-form-row-remarks")) { jqErrorHighlight = jqErrorHighlight.add(jqPrev.first()); jqRemarks = jqPrev.first().find(".pio-form-cell.pio-form-field-remarks .pio-form-field-remarks"); } jqTrTmp = jqPrev; } } var jqNext = jqTr.next(); if (jqNext.length > 0) { if (jqNext.hasClass("pio-form-row") && jqNext.hasClass("pio-form-error")) { jqErrorHighlight = jqErrorHighlight.add(jqNext.first()); jqError = jqNext.first().find(".pio-form-cell.pio-form-error .pio-form-error"); if (jqError.length > 0) jqErrorContainer = jqError.parent(); else jqErrorContainer = jqNext.first().find(".pio-form-cell.pio-form-error"); } } } else { sLayout = "std"; jqLabel = jqTr.find(".pio-form-cell.pio-form-field-title .pio-form-field-title"); jqError = jqTr.find(".pio-form-cell.pio-form-error .pio-form-error"); if (jqError.length > 0) jqErrorContainer = jqError.parent(); else jqErrorContainer = jqTr.find(".pio-form-cell.pio-form-error"); jqErrorHighlight = jqTr; var jqNext = jqTr.next(); if (jqNext.length > 0) { if (jqNext.hasClass("pio-form-row") && jqNext.hasClass("pio-form-row-remarks")) { jqRemarks = jqNext.first().find(".pio-form-cell.pio-form-field-remarks .pio-form-field-remarks"); jqErrorHighlight = jqErrorHighlight.add(jqNext.first()); } } } return { layout: sLayout, lbl: jqLabel, remarks: jqRemarks, errContainer: jqErrorContainer, err: jqError, errCls: "pio-form-error", errHighlight: jqErrorHighlight }; } //~~~ executing context: null, 0 from PioWeb.registerBestOnPageExecutionHandler //~~~ 1 from validation this.improveHtml = function (container, executingContext) { if (executingContext != 1) executingContext = 0; if (!bJqIsEnabled){ try { var jqTmp = $(document); bJqIsEnabled = true; } catch (e) { bJqIsEnabled = false; } if(!bJqIsEnabled) return; } var ar_ctlError = []; var jqFields; if(container == null) jqFields = $(sJqAnchor); else{ var jqTmp = $(container); if(jqTmp.is(sJqAnchor)) jqFields = jqTmp; else jqFields = jqTmp.find(sJqAnchor); }; jqFields.each(function () { var jqFieldContainer = $(this); jqFieldContainer.find("INPUT, SELECT, TEXTAREA").each(function () { var ctlInput = this; if (ctlInput.tagName == "INPUT") { switch (ctlInput.type) { case "checkbox": case "radio": case "button": case "submit": case "image": return; //~~~ exit function } } var jqInput = $(this); if (executingContext == 0) { if (ctlInput.getAttribute("__piowebform_validation_blur_inited") != "yoc") { var jqJson = jqFieldContainer.is("*[__piowebform_validation]") ? jqFieldContainer : jqFieldContainer.find("*[__piowebform_validation]").first(); if (jqJson.length > 0 && (jqJson.attr("__piowebform_validation_mode") * 1) >= 2) { jqInput.blur(function () { if (jqJson.attr("__piowebform_validation_mode") == "2") { window.setTimeout(function () { PioWebForm.validateField(jqJson); PioWebForm.improveHtml(jqFieldContainer, 1); }, 300); } }); } ctlInput.setAttribute("__piowebform_validation_blur_inited", "yoc"); } } var oFieldParts = PioWebForm.getFieldParts(this); var sLayout = oFieldParts == null ? null : oFieldParts.layout; var jqLabel = oFieldParts == null ? null : oFieldParts.lbl; var jqRemarks = oFieldParts == null ? null : oFieldParts.remarks; var jqErrorContainer = oFieldParts == null ? null : oFieldParts.errContainer; var jqError = oFieldParts == null ? null : oFieldParts.err; var jqErrorHighlight = oFieldParts == null ? null : oFieldParts.errHighlight; if (executingContext != 1 && jqLabel != null && jqLabel.length > 0) { var sLableAriaLabel = null; if(ctlInput.tagName == "SELECT" && jqInput.hasClass("combo")){ if(jqInput.hasClass("combo-year")){ sLableAriaLabel = (PioWeb.Lang == "he") ? "בחר שנה" : "choose year"; } else if(jqInput.hasClass("combo-month")){ sLableAriaLabel = (PioWeb.Lang == "he") ? "בחר חודש" : "choose month"; } else if(jqInput.hasClass("combo-day")){ sLableAriaLabel = (PioWeb.Lang == "he") ? "בחר יום" : "choose day"; } } if(sLableAriaLabel != null){ sLableAriaLabel = jqLabel.text() + ": " + sLableAriaLabel; ctlInput.setAttribute("aria-label", sLableAriaLabel); }else{ var ctlLabel = jqLabel[0]; var sLabelId = ctlLabel.id; if (sLabelId == null || sLabelId == "") { sLabelId = ctlInput.id; if (sLabelId == null || sLabelId == "") { sLabelId = ctlInput.name; } if (sLabelId != null && sLabelId != "") { sLabelId = sLabelId + "____lbl____"; ctlLabel.id = sLabelId; } } if (sLabelId != null && sLabelId != "") { ctlInput.setAttribute("aria-labelledby", sLabelId); } } } var sRemarksId = null; var sErrorId = null; if (jqRemarks != null && jqRemarks.length > 0) { var ctlRemarks = jqRemarks[0]; sRemarksId = ctlRemarks.id; if (sRemarksId == null || sRemarksId == "") { sRemarksId = ctlInput.id; if (sRemarksId == null || sRemarksId == "") { sRemarksId = ctlInput.name; } if (sRemarksId != null && sRemarksId != "") { sRemarksId = sRemarksId + "____remrks____"; ctlRemarks.id = sRemarksId; } } if (sRemarksId == "") sRemarksId = null; } if (jqError != null && jqError.length > 0) { ctlInput.setAttribute("aria-invalid", "true"); var ctlError = jqError[0]; sErrorId = ctlError.id; if (sErrorId == null || sErrorId == "") { sErrorId = ctlInput.id; if (sErrorId == null || sErrorId == "") { sErrorId = ctlInput.name; } if (sErrorId != null && sErrorId != "") { sErrorId = sErrorId + "____error____"; ctlError.id = sErrorId; } } if (sErrorId == "") sErrorId = null; if (executingContext == 1) { if (jqErrorContainer != null) { if (sLayout != "div") jqErrorContainer.removeClass("pio-form-no-error"); if (sLayout == "narrow") jqErrorContainer.parent().removeClass("pio-form-no-error"); } if (jqErrorHighlight != null) { jqErrorHighlight.addClass("pio-form-error-highlight"); } if (sLayout != "div") jqFieldContainer.addClass("pio-form-field-error"); if (sLayout == "div") jqFieldContainer.closest(".pio-form-field-container").addClass("pio-form-error").removeClass("pio-form-no-error"); } } else if (executingContext == 1) { ctlInput.setAttribute("aria-invalid", "false"); //ctlInput.removeAttribute("aria-invalid"); if (jqErrorContainer != null) { if (sLayout != "div") jqErrorContainer.addClass("pio-form-no-error"); if (sLayout == "narrow") jqErrorContainer.parent().addClass("pio-form-no-error"); } if (jqErrorHighlight != null) { jqErrorHighlight.removeClass("pio-form-error-highlight"); } if (sLayout != "div") jqFieldContainer.removeClass("pio-form-field-error"); if (sLayout == "div") jqFieldContainer.closest(".pio-form-field-container").removeClass("pio-form-error").addClass("pio-form-no-error"); } if (sErrorId != null && sRemarksId != null) { ctlInput.setAttribute("aria-describedby", sErrorId + " " + sRemarksId); if (jqInput.is(":visible")) ar_ctlError.push(ctlInput); } else if (sErrorId != null) { ctlInput.setAttribute("aria-describedby", sErrorId); if (jqInput.is(":visible")) ar_ctlError.push(ctlInput); } else if (sRemarksId != null) { ctlInput.setAttribute("aria-describedby", sRemarksId); } else if (executingContext == 1) { ctlInput.removeAttribute("aria-describedby"); } }); }); if(executingContext == 0){ if (ar_ctlError != null && ar_ctlError.length > 0) { var jqFocus = null; for (var i = 0; i < ar_ctlError.length; i++) { var jqFocusCondidate = $(ar_ctlError[i]); if (jqFocusCondidate.closest(".pio-form-active").length > 0) { jqFocus = jqFocusCondidate; break; } } if (jqFocus == null) jqFocus = $(ar_ctlError[0]); jqFocus.focus(); } } } } var PioWebForm = new PioWebForm(); //~~~ Chrome compatibility if (!Array.prototype.filter) { Array.prototype.filter = function(fun /*, thisp */) { if (this === void 0 || this === null) throw new TypeError(); var t = Object(this); var len = t.length >>> 0; if (typeof fun !== "function") throw new TypeError(); var res = []; var thisp = arguments[1]; for (var i = 0; i < len; i++) { if (i in t) { var val = t[i]; // in case fun mutates this if (fun.call(thisp, val, i, t)) res.push(val); } } return res; }; } if (!Array.filter) { Array.filter = function filter(array, test) { return Array.prototype.filter.call(array, test); } } //~~~ Chrome compatibility PioWeb.registerBestOnPageExecutionHandler(function() { try { var jqTmp = $(document); } catch (e) { return; } PioWebForm.improveHtml(); //~~~ .nd-container-onclick function applyClick(jqApplyTo, ctlApplyBy, findInners, onlyFind) { var bFound = false; switch (ctlApplyBy.tagName) { case "A": bFound = true; break; case "INPUT": switch (ctlApplyBy.type) { case "button": case "image": case "submit": bFound = true; break; } case "BUTTON": bFound = true; break; default: if (findInners) { var jqInners = $(ctlApplyBy).find("A, INPUT, BUTTON"); for (var i = 0; i < jqInners.length; i++) { bFound = applyClick(jqApplyTo, jqInners[i], false, false); if (bFound) return true; //~~~ exit function } } else if (onlyFind) { if ($(ctlApplyBy).closest("A, .nd-container-onclick-cancel").length == 1) { bFound = true; } } break; } if (bFound && !onlyFind) { //$(ctlApplyBy).click(function () { // alert("sssss"); //}); //alert(ctlApplyBy.onclick); jqApplyTo.attr({ tabindex: 0, onkeydown: "if(event.keyCode==13)$(this).click();" }).css("cursor","pointer").addClass("container-onclick-applied").click(function (e) { //e.stopPropagation(); //e.preventDefault(); var ctlActive = e.target; if (ctlActive != ctlApplyBy) { if (!applyClick(null, ctlActive, false, true)) { if (ctlApplyBy.tagName == "A") { //todo emulate the real click event on A element. It's not so easy, becourse we must to know if it's contains "onclick" handlers and it's returns false we must to prevent applying href attribute var sLink = $.trim(ctlApplyBy.href); if (sLink != "") { if (sLink.toLowerCase().indexOf("javascript:") == 0) { var sScript = sLink.replace("javascript:", ""); eval(sScript); } else { location.href = sLink; } } } else { $(ctlApplyBy).click(); //ctlApplyBy.onclick(); } } } }); } return bFound; } $(".nd-container-onclick").each(function () { var jqThis = $(this); if (jqThis.attr("nd-container-onclick-ininted") == "yoc") return; var jqAnchors = jqThis.find(".nd-container-onclick-anchor"); var bFound = false; for (var i = 0; i < jqAnchors.length; i++) { bFound = applyClick(jqThis, jqAnchors[i], true, false); if (bFound) break; } /*if (bFound)*/ jqThis.attr("nd-container-onclick-ininted", "yoc"); }); //~~~~ /.nd-container-onclick }, true);