30 lines
12 KiB
JavaScript
30 lines
12 KiB
JavaScript
var needRegisterH5Exts=!0,isAlreadyInitialized=!1;needRegisterH5Exts&&($(document).ready(function(){needPlaceHoldersShim()&&!isAlreadyInitialized&&(isAlreadyInitialized=!0,registerPlaceHoldersShim($("input[cp5ph]")),registerPlaceHoldersShim($("textarea[cp5ph]")))}),needRegisterH5Exts=!1);function registerPlaceHoldersShimOnContainer(d){registerPlaceHoldersShim($("input[cp5ph]",d));registerPlaceHoldersShim($("textarea[cp5ph]",d))}
|
|
function unregisterPlaceHoldersShimOnContainer(d){unregisterPlaceHolderShim($("input[cp5ph]",d));unregisterPlaceHolderShim($("textarea[cp5ph]",d))}function needPlaceHoldersShim(){return!("placeholder"in document.createElement("input"))}function getPlaceholder(d){var b=d.getAttribute("placeholder");return null==b?(b=d.attributes.placeholder,null==b?"":b.value):b}
|
|
function unregisterPlaceHolderShim(d){var b=d.data("cp5ph_hooks");if(b){for(var l=null==b.ie?[]:b.ie,f=null==b.std?[]:b.std,g=null==b.jqr?[]:b.jqr,b=null==b.spawns?[]:b.spawns,a=0,k=l.length;a<k;a++)l[a].element&&l[a].element.detachEvent(l[a].event,l[a].method);a=0;for(k=f.length;a<k;a++)f[a].element&&f[a].element.removeEventListener(f[a].event,f[a].method,!1);a=0;for(k=g.length;a<k;a++)g[a].instance&&g[a].instance.unbind(g[a].event,g[a].method);a=0;for(k=b.length;a<k;a++)b[a]&&(b[a].innerHTML="",
|
|
b[a].style.display="none",b[a].parentNode&&b[a].parentNode.removeChild(b[a]));d.removeData("cp5ph_hooks")}}
|
|
function registerPlaceHoldersShim(d){var b=[],l=[],f=[],g=[],a=function(c,s){if(c.__defineSetter__){var a=c.__lookupSetter__("value");a&&c.__defineSetter__("value",function(e){a.call(c,e);s()})}c.attachEvent&&(b.push({element:c,event:"onpropertychange",method:s}),c.attachEvent("onpropertychange",s))},k=/^(class|value|className|placeholder|id|style|style\..*)$/,t=function(c,s){if(c.addEventListener){var a=function(c){c.stopPropagation();"_ph_shim"!=c.target.className&&k.test(c.attrName)&&s(c.attrName)};
|
|
l.push({element:c,event:"DOMAttrModified",method:a});c.addEventListener("DOMAttrModified",a,!1)}else c.attachEvent&&(a=function(c){k.test(c.propertyName)&&s(c.propertyName)},b.push({element:c,event:"onpropertychange",method:a}),c.attachEvent("onpropertychange",a))},q=function(c,a){for(var e=c;e&&e!=document.body;)t(e,a),e=e.parentNode},n=[],u=function(c){var a=function(a){for(a=0;a<n.length;a++)if(n[a].object===c)return a;return-1}(c);if(-1===a){var e={object:c,recentlyOccured:!0};n.push(e);setTimeout(function(){e.recentlyOccured=
|
|
!1},30);return!1}if(n[a].recentlyOccured)return!0;n[a].recentlyOccured=!0;setTimeout(function(){n[a].recentlyOccured=!1},30);return!1},p=function(c,a){var e=$(a);if(!u(a))if(null!=a.parentNode&&!a._focus&&e.is(":visible")){c.style.display=""==a.value||null==a.value?"block":"none";var b=e.offsetParent().get(0);if("TR"==b.tagName)for(b=a;"TD"!=b.tagName;)b=b.parentNode;var h=c.getAttribute("_ph_val")!=getPlaceholder(a);if(b!=c.parentNode||h)c.parentNode.removeChild(c),h&&(c.innerHTML=getPlaceholder(a)),
|
|
b.appendChild(c);c.style.width=a.clientWidth+"px";c.style.height=a.clientHeight+"px";c.style.verticalAlign=a.style.verticalAlign;c.style.lineHeight=a.style.lineHeight;c.style.textAlign=a.style.textAlign;c.style.fontSize=a.style.fontSize;c.style.fontFamily=a.style.fontFamily;h=window.getComputedStyle?window.getComputedStyle(a,null):a.currentStyle;b=parseInt(h.paddingLeft.replace(/px$/g,""),10);h=parseInt(h.paddingTop.replace(/px$/g,""),10);e=e.position();c.style.top=e.top+a.clientTop+h-2+"px";c.style.left=
|
|
e.left+a.clientLeft+b+"px"}else c.style.display="none"},e=function(a){var e=document.createElement("div");a._ph_shim=e;var b=getPlaceholder(a);e.innerHTML=null==b?"":b;e.setAttribute("_ph_val","phValue");e.setAttribute("id","ph_"+a.id);e.setAttribute("name","ph_"+a.id);$(a).offsetParent().get(0).appendChild(e);e.className="_ph_shim";e.style.position="absolute";e.style.color="#aaa";e.style.backgroundColor="transparent";e.style.cssFloat="none";p(e,a);var b=$(e),h=function(b){e.style.display="none";
|
|
$(a).trigger("mousedown",b);setTimeout(function(){try{a.focus()}catch(e){-1<location.href.toLowerCase().indexOf("/admin/formcenter")&&alert("You have selected the field input. Please select the field label or instructions.")}},15)};b.mousedown(h);f.push({instance:b,event:"mousedown",method:h});return e},h=function(c){var b=$(c),h=e(c);g.push(h);var d=function(){c._focus=!0;h.style.display="none"},n=function(){c._focus=!1;""!=c.value&&null!=c.value||!$(c).is(":visible")||(h.style.display="block")};
|
|
b.focus(d);b.blur(n);f.push({instance:b,event:"focus",method:d});f.push({instance:b,event:"blur",method:n});a(c,function(){c._focus?h.style.display="none":""!=c.value&&null!=c.value||!$(c).is(":visible")?h.style.display="none":h.style.display="block"});q(c,function(){p(h,c)})};d.each(function(){h(this)});d.data("cp5ph_hooks",{ie:b,std:l,jqr:f,spawns:g})}
|
|
function unregisterPlaceHoldersShimForEach(d){d.each(function(){var b=$(this).data("cp5ph_hooks");if(b){for(var d=null==b.ie?[]:b.ie,f=null==b.std?[]:b.std,g=null==b.jqr?[]:b.jqr,b=null==b.spawns?[]:b.spawns,a=0,k=d.length;a<k;a++)d[a].element&&d[a].element.detachEvent(d[a].event,d[a].method);a=0;for(k=f.length;a<k;a++)f[a].element&&f[a].element.removeEventListener(f[a].event,f[a].method,!1);a=0;for(k=g.length;a<k;a++)g[a].instance&&g[a].instance.unbind(g[a].event,g[a].method);a=0;for(k=b.length;a<
|
|
k;a++)b[a]&&(b[a].innerHTML="",b[a].style.display="none",b[a].parentNode&&b[a].parentNode.removeChild(b[a]));$(this).removeData("cp5ph_hooks")}})}
|
|
function registerPlaceHoldersShimForEach(d){var b=[],l=[],f=[],g=[],a=function(a,h){if(a.__defineSetter__){var c=a.__lookupSetter__("value");c&&a.__defineSetter__("value",function(b){c.call(a,b);h()})}a.attachEvent&&(b.push({element:a,event:"onpropertychange",method:h}),a.attachEvent("onpropertychange",h))},k=/^(class|value|className|placeholder|id|style|style\..*)$/,t=function(a,h){if(a.addEventListener){var c=function(a){a.stopPropagation();"_ph_shim"!=a.target.className&&k.test(a.attrName)&&h(a.attrName)};
|
|
l.push({element:a,event:"DOMAttrModified",method:c});a.addEventListener("DOMAttrModified",c,!1)}else a.attachEvent&&(c=function(a){k.test(a.propertyName)&&h(a.propertyName)},b.push({element:a,event:"onpropertychange",method:c}),a.attachEvent("onpropertychange",c))},q=function(a,b){for(var c=a;c&&c!=document.body;)t(c,b),c=c.parentNode},n=function(a,b){var c=$(b);if(null!=b.parentNode&&!b._focus&&c.is(":visible")){a.style.display=""==b.value||null==b.value?"block":"none";var d=c.offsetParent().get(0);
|
|
if("TR"==d.tagName)for(d=b;"TD"!=d.tagName;)d=d.parentNode;var n=a.getAttribute("_ph_val")!=getPlaceholder(b);if(d!=a.parentNode||n)a.parentNode.removeChild(a),n&&(a.innerHTML=getPlaceholder(b)),d.appendChild(a);a.style.width=b.clientWidth+"px";a.style.height=b.clientHeight+"px";a.style.verticalAlign=b.style.verticalAlign;a.style.lineHeight=b.style.lineHeight;a.style.textAlign=b.style.textAlign;a.style.fontSize=b.style.fontSize;a.style.fontFamily=b.style.fontFamily;n=window.getComputedStyle?window.getComputedStyle(b,
|
|
null):b.currentStyle;d=parseInt(n.paddingLeft.replace(/px$/g,""),10);n=parseInt(n.paddingTop.replace(/px$/g,""),10);c=c.position();a.style.top=c.top+b.clientTop+n-2+"px";a.style.left=c.left+b.clientLeft+d+"px"}else a.style.display="none"},u=function(a){var b=document.createElement("div");a._ph_shim=b;var c=getPlaceholder(a);b.innerHTML=null==c?"":c;b.setAttribute("_ph_val","phValue");b.setAttribute("id","ph_"+a.id);b.setAttribute("name","ph_"+a.id);$(a).offsetParent().get(0).appendChild(b);b.className=
|
|
"_ph_shim";b.style.position="absolute";b.style.color="#aaa";b.style.backgroundColor="transparent";b.style.cssFloat="none";n(b,a);var c=$(b),d=function(c){b.style.display="none";$(a).trigger("mousedown",c);setTimeout(function(){try{a.focus()}catch(b){-1<location.href.toLowerCase().indexOf("/admin/formcenter")&&alert("You have selected the field input. Please select the field label or instructions.")}},15)};c.mousedown(d);f.push({instance:c,event:"mousedown",method:d});return b},p=function(b){var d=
|
|
$(b),c=u(b);g.push(c);var k=function(){b._focus=!0;c.style.display="none"},p=function(){b._focus=!1;""!=b.value&&null!=b.value||!$(b).is(":visible")||(c.style.display="block")};d.focus(k);d.blur(p);f.push({instance:d,event:"focus",method:k});f.push({instance:d,event:"blur",method:p});a(b,function(){b._focus?c.style.display="none":""!=b.value&&null!=b.value||!$(b).is(":visible")?c.style.display="none":c.style.display="block"});q(b,function(){n(c,b)})};d.each(function(){p(this)});d.each(function(){$(this).data("cp5ph_hooks",
|
|
{ie:b,std:l,jqr:f,spawns:g})})}
|
|
null!=this.QueryStringBuilder&&$.isFunction(this.QueryStringBuilder)||(QueryStringBuilder=function(d){this.dict={};null!=d&&this.merge(d)},QueryStringBuilder.prototype.merge=function(d){return $.extend(this.dict,null==d?{}:d,!1)},QueryStringBuilder.prototype.toDictionary=function(){return $.extend({},this.dict,!1)},QueryStringBuilder.prototype.toString=function(d){d=null!=d||!!d;var b=[],l;for(l in this.dict)b.push(encodeURIComponent(l)+"\x3d"+encodeURIComponent(this.dict[l]));return 0<b.length?(d?
|
|
"":"?")+b.join("\x26"):""});
|
|
null!=this.QueryStringExtractor&&$.isFunction(this.QueryStringExtractor)||(QueryStringExtractor=function(){},QueryStringExtractor.prototype._fromCommon=function(d,b){var l={},f=null;if(0<=b)for(var g=b,a=0;0<=g;)if(startAmpPos=g,g=d.indexOf("\x26",startAmpPos+1),f=0<=g?d.substring(startAmpPos+1,g):d.substring(startAmpPos+1),a=f.indexOf("\x3d"),0<=a){var k=decodeURIComponent(f.substr(0,a)),f=decodeURIComponent(f.substr(a+1));l[k]=f}return l},QueryStringExtractor.prototype.fromURL=function(d){var b=
|
|
null==d?-1:d.indexOf("?");return this._fromCommon(d,b)},QueryStringExtractor.prototype.fromQueryString=function(d){var b=0;null==d||1>d.length?b=-1:"?"!=d.charAt(0)&&(d="?"+d);return this._fromCommon(d,b)});var JSON;JSON||(JSON={});
|
|
(function(){function d(a){return 10>a?"0"+a:a}function b(a){g.lastIndex=0;return g.test(a)?'"'+a.replace(g,function(a){var b=t[a];return"string"===typeof b?b:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+a+'"'}function l(d,f){var p,e,h,c,g=a,r,m=f[d];m&&("object"===typeof m&&"function"===typeof m.toJSON)&&(m=m.toJSON(d));"function"===typeof q&&(m=q.call(f,d,m));switch(typeof m){case "string":return b(m);case "number":return isFinite(m)?String(m):"null";case "boolean":case "null":return String(m);
|
|
case "object":if(!m)return"null";a+=k;r=[];if("[object Array]"===Object.prototype.toString.apply(m)){c=m.length;for(p=0;p<c;p+=1)r[p]=l(p,m)||"null";h=0===r.length?"[]":a?"[\n"+a+r.join(",\n"+a)+"\n"+g+"]":"["+r.join(",")+"]";a=g;return h}if(q&&"object"===typeof q)for(c=q.length,p=0;p<c;p+=1)"string"===typeof q[p]&&(e=q[p],(h=l(e,m))&&r.push(b(e)+(a?": ":":")+h));else for(e in m)Object.prototype.hasOwnProperty.call(m,e)&&(h=l(e,m))&&r.push(b(e)+(a?": ":":")+h);h=0===r.length?"{}":a?"{\n"+a+r.join(",\n"+
|
|
a)+"\n"+g+"}":"{"+r.join(",")+"}";a=g;return h}}"function"!==typeof Date.prototype.toJSON&&(Date.prototype.toJSON=function(a){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+d(this.getUTCMonth()+1)+"-"+d(this.getUTCDate())+"T"+d(this.getUTCHours())+":"+d(this.getUTCMinutes())+":"+d(this.getUTCSeconds())+"Z":null},String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(a){return this.valueOf()});var f=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
|
|
g=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,a,k,t={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},q;"function"!==typeof JSON.stringify&&(JSON.stringify=function(b,d,f){var e;k=a="";if("number"===typeof f)for(e=0;e<f;e+=1)k+=" ";else"string"===typeof f&&(k=f);if((q=d)&&"function"!==typeof d&&("object"!==typeof d||"number"!==typeof d.length))throw Error("JSON.stringify");return l("",{"":b})});
|
|
"function"!==typeof JSON.parse&&(JSON.parse=function(a,b){function d(a,c){var e,f,g=a[c];if(g&&"object"===typeof g)for(e in g)Object.prototype.hasOwnProperty.call(g,e)&&(f=d(g,e),void 0!==f?g[e]=f:delete g[e]);return b.call(a,c,g)}var e;a=String(a);f.lastIndex=0;f.test(a)&&(a=a.replace(f,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)}));if(/^[\],:{}\s]*$/.test(a.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
|
|
"]").replace(/(?:^|:|,)(?:\s*\[)+/g,"")))return e=eval("("+a+")"),"function"===typeof b?d({"":e},""):e;throw new SyntaxError("JSON.parse");})})(); |