-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathDer.min.js
27 lines (27 loc) · 4.63 KB
/
Der.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
window.Der=window.Der||{};Der.getById=Der.g=function(a){if(typeof a==="string"&&!!a){return document.getElementById(a);}};Der.getByAttribute=function(f,g,a){a=(a)?a:document;
var b=[],d=a.getElementsByTagName("*");for(var c=d.length-1;c>=0;c--){var e=d[c];if(f==="className"||f==="class"){if(e.className===g){b.push(e);}}else{if(e.getAttribute(f)===g){b.push(e);
}}}return b;};Der.getByClass=function(b,a){if(typeof document.getElementsByClassName==="function"){a=(a)?a:document;return Array.prototype.slice.call(a.getElementsByClassName(b));
}else{return Der.getByAttribute("className",b,a);}};Der.createElement=function(d,a){var c=document.createElement(d);if(a){for(var b in a){if(a.hasOwnProperty(b)){if(b==="class"||b==="className"){c.className=a[b];
}else{if(b==="style"){c.style.cssText=a[b];}else{c.setAttribute(b,a[b]);}}}}}return c;};Der.addEvent=function(a,b,c){if(a.addEventListener){a.addEventListener(b,c,false);
}else{if(a.attachEvent){a.attachEvent("on"+b,function(){c.call(a);});}else{a["on"+b]=c;}}};Der.removeEvent=function(a,b,c){if(a.removeEventListener){a.removeEventListener(b,c,false);
}else{if(a.detachEvent){a.detachEvent("on"+b,function(){c.call(a);});}else{a["on"+b]=null;}}};Der.getEvent=function(a){return a||event;};Der.getEventTarget=function(a){return a.target||a.srcElement;
};Der.getRelatedTarget=function(a){if(a.relatedTarget){return a.relatedTarget;}else{if(a.toElement){return a.toElement;}else{if(a.fromElement){return a.fromElement;
}else{return null;}}}};Der.stopPropagation=function(a){if(a.stopPropagation){a.stopPropagation();}else{a.cancelBubble=true;}};Der.preventDefault=function(a){if(a.preventDefault){a.preventDefault();
}else{a.returnValue=false;}};Der.windowLoad=function(a){var b=window;Der.addEvent(b,"load",function(){Der.removeEvent(b,"load",arguments.callee);a();});
};Der.DOMReady=function(a){var b=document;if(b.addEventListener){b.addEventListener("DOMContentLoaded",function(){b.removeEventListener("DOMContentLoaded",arguments.callee,false);
a();},false);}else{if(b.attachEvent){b.attachEvent("onreadystatechange",function(){if(b.readyState==="interactive"||b.readyState==="complete"){b.detachEvent("onreadystatechange",arguments.callee);
a();}});}}};Der.setCookie=function(a,d,h,f,c,e){var b=encodeURIComponent(a)+"="+encodeURIComponent(d);if(h){var g=new Date();g.setTime(g.getTime()+h*24*60*60*1000);
b+="; expires="+g.toGMTString();}if(f){b+="; path="+f;}if(c){b+="; domain="+c;}if(e){b+="; secure";}document.cookie=b;};Der.getCookie=function(b){var e=encodeURIComponent(b)+"=",a=document.cookie.indexOf(e),d="";
if(a>-1){var c=document.cookie.indexOf(";",a);if(c===-1){c=document.cookie.length;}d=decodeURIComponent(document.cookie.slice(a+e.length,c));}return d;
};Der.deleteCookie=function(a){Der.setCookie(a,"",-1);};Der.ajax=function(settings){settings=Der.extend({url:"",type:"get",data:"",isJson:false},settings);
var url=Der.trim(settings.url),type=settings.type.toLowerCase(),data=settings.data,isJson=settings.isJson,success=settings.success,response;if(typeof url!=="string"||url===""){return;
}function createXHR(){if(typeof XMLHttpRequest==="function"){return new XMLHttpRequest();}else{if(typeof ActiveXObject==="function"){return new ActiveXObject("Microsoft.XMLHTTP");
}}}var xhr=createXHR();xhr.onreadystatechange=function(){if(xhr.readyState===4){if((xhr.status>=200&&xhr.status<300)||xhr.status===304||xhr.status===1223){var response=decodeURIComponent(xhr.responseText);
if(isJson){response=eval("("+response+")");}if(success){success(response);}}}};xhr.open(type,url,true);if(type==="get"){xhr.send(null);}else{if(type==="post"){xhr.send(data);
}}};Der.loadScript=function(a,b){setTimeout(function(){var c=Der.createElement("script",{src:a,type:"text/javascript"});if(c.readyState){Der.addEvent(c,"readystatechange",function(){if(c.readyState==="loaded"||c.readyState==="complete"){if(b){b();
}Der.removeEvent(c,"readystatechange",arguments.callee);}});}else{Der.addEvent(c,"load",function(){if(b){b();}Der.removeEvent(c,"load",arguments.callee);
});}document.getElementsByTagName("head")[0].appendChild(c);},0);};Der.loadCss=function(a){var b=Der.createElement("link",{href:a,rel:"stylesheet",type:"text/css"});
document.getElementsByTagName("head")[0].appendChild(b);};Der.trim=function(c,d){var b=/^[\s\xA0]+/,a=/[\s\xA0]+$/;if(!d||(d!=="left"&&d!=="right")){return c.replace(b,"").replace(a,"");
}else{if(d==="left"){return c.replace(b,"");}else{if(d==="right"){return c.replace(a,"");}}}};Der.extend=function(c,b){if(b){for(var a in c){if((typeof b[a])==="undefined"){b[a]=c[a];
}}return b;}else{return c;}};Der.type=function(b){if(b==null){return String(b);}var a=Object.prototype.toString.call(b);return a.slice(8,a.length-1).toLowerCase();
};