forked from intel/appframework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjq.mobi.min.js
24 lines (24 loc) · 11.9 KB
/
jq.mobi.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
if(!window.jq||typeof jq!=="function"){var jq=function(j){function p(a){return a in o?o[a]:o[a]=RegExp("(^|\\s)"+a+"(\\s|$)")}function m(a){for(var c=0;c<a.length;c++)a.indexOf(a[c])!=c&&a.splice(c,1);return a}function q(a,c){var b=[];if(a==f)return b;for(;a;a=a.nextSibling)a.nodeType==1&&a!==c&&b.push(a);return b}function l(){}function r(a,c){a.os={};a.os.webkit=c.match(/WebKit\/([\d.]+)/)?!0:!1;a.os.android=c.match(/(Android)\s+([\d.]+)/)||c.match(/Silk-Accelerated/)?!0:!1;a.os.ipad=c.match(/(iPad).*OS\s([\d_]+)/)?
!0:!1;a.os.iphone=!a.os.ipad&&c.match(/(iPhone\sOS)\s([\d_]+)/)?!0:!1;a.os.webos=c.match(/(webOS|hpwOS)[\s\/]([\d.]+)/)?!0:!1;a.os.touchpad=a.os.webos&&c.match(/TouchPad/)?!0:!1;a.os.ios=a.os.ipad||a.os.iphone;a.os.blackberry=c.match(/BlackBerry/)||c.match(/PlayBook/)?!0:!1;a.os.opera=c.match(/Opera Mobi/)?!0:!1;a.os.fennec=c.match(/fennec/i)?!0:!1}var f,g=j.document,i=[],t=i.slice,o=[],n=[],u=1,v=1,k=function(a,c){this.length=0;if(a)if(a instanceof k&&c==f)return a;else if(d.isFunction(a))return d(g).ready(a);
else if(d.isArray(a)&&a.length!=f){for(var b=0;b<a.length;b++)this[this.length++]=a[b];return this}else if(d.isObject(a)&&d.isObject(c)){if(a.length==f)a.parentNode==c&&(this[this.length++]=a);else for(b=0;b<a.length;b++)a[b].parentNode==c&&(this[this.length++]=a[b]);return this}else if(d.isObject(a)&&c==f)return this[this.length++]=a,this;else if(c!==f){if(c instanceof k)return c.find(a)}else c=g;else return this;if(b=this.selector(a,c))if(d.isArray(b))for(var e=0;e<b.length;e++)this[this.length++]=
b[e];else this[this.length++]=b;return this},d=function(a,c){return new k(a,c)};d.map=function(a,c){var b,e=[],h;if(d.isArray(a))for(h=0;h<a.length;h++)b=c(a[h],h),b!==f&&e.push(b);else if(d.isObject(a))for(h in a)a.hasOwnProperty(h)&&(b=c(a[h],h),b!==f&&e.push(b));return d([e])};d.each=function(a,c){var b;if(d.isArray(a))for(b=0;b<a.length;b++){if(c(b,a[b])===!1)break}else if(d.isObject(a))for(b in a)if(a.hasOwnProperty(b)&&c(b,a[b])===!1)break;return a};d.extend=function(a){a==f&&(a=this);if(arguments.length===
1){for(var c in a)this[c]=a[c];return this}else t.call(arguments,1).forEach(function(b){for(var c in b)a[c]=b[c]});return a};d.isArray=function(a){return a!=f&&Array.isArray(a)};d.isFunction=function(a){return a!=f&&typeof a==="function"};d.isObject=function(a){return a!=f&&typeof a==="object"};d.fn=k.prototype={constructor:k,forEach:i.forEach,reduce:i.reduce,push:i.push,indexOf:i.indexOf,concat:i.concat,selector:function(a,c){var b;try{if(a[0]==="#"&&a.indexOf(" ")===-1&&a.indexOf(">")===-1)b=c==
g?c.getElementById(a.replace("#","")):[].slice.call(c.querySelectorAll(a));else if(a[0]==="<"&&a[a.length-1]===">"){var e=g.createElement("div");e.innerHTML=a.trim();b=[].slice.call(e.childNodes)}else b=[].slice.call(c.querySelectorAll(a))}catch(d){}return b},oldElement:f,slice:i.slice,setupOld:function(a){if(a==f)return d();a.oldElement=this;return a},map:function(a){return d.map(this,function(c,b){return a.call(c,b,c)})},each:function(a){this.forEach(function(c,b){a.call(c,b,c)});return this},ready:function(a){(g.readyState===
"complete"||g.readyState==="loaded")&&a();g.addEventListener("DOMContentLoaded",a,!1);return this},find:function(a){if(this.length===0)return f;for(var c=[],b,e=0;e<this.length;e++){b=d(a,this[e]);for(var h=0;h<b.length;h++)c.push(b[h])}return d(m(c))},html:function(a){if(this.length===0)return f;if(a===f)return this[0].innerHTML;for(var c=0;c<this.length;c++)this[c].innerHTML=a;return this},text:function(a){if(this.length===0)return f;if(a===f)return this[0].textContent;for(var c=0;c<this.length;c++)this[c].textContent=
a;return this},css:function(a,c){if(this.length===0)return f;if(c===f&&typeof a==="string"){var b=j.getComputedStyle(this[0]);return b[a]?b[a]:this[0].style[a]}for(b=0;b<this.length;b++)if(d.isObject(a))for(var e in a)this[b].style[e]=a[e];else this[b].style[a]=c;return this},empty:function(){for(var a=0;a<this.length;a++)this[a].innerHTML="";return this},hide:function(){if(this.length===0)return f;for(var a=0;a<this.length;a++)if(this[a].style.display!="none")this[a].setAttribute("jqmOldStyle",this[a].style.display),
this[a].style.display="none";return this},show:function(){if(this.length===0)return f;for(var a=0;a<this.length;a++)if(this[a].style.display=="none")this[a].style.display=this[a].getAttribute("jqmOldStyle")?this[a].getAttribute("jqmOldStyle"):"block",this[a].removeAttribute("jqmOldStyle");return this},toggle:function(a){for(var c=a===!0?!0:!1,b=0;b<this.length;b++)this[b].style.display!=="none"||a!==f&&c===!1?(this[b].setAttribute("jqmOldStyle",this[b].style.display),this[b].style.display="none"):
(this[b].style.display=this[b].getAttribute("jqmOldStyle")!==""?this[b].getAttribute("jqmOldStyle"):"block",this[b].removeAttribute("jqmOldStyle"));return this},val:function(a){if(this.length===0)return f;if(a==f)return this[0].value;for(var c=0;c<this.length;c++)this[c].value=a;return this},attr:function(a,c){if(this.length===0)return f;if(c===f&&!d.isObject(a)){var b=this[0].getAttribute(a);try{b=JSON.parse(b)}catch(e){}return b}c=d.isArray(c)||d.isObject(c)?JSON.stringify(c):c;for(b=0;b<this.length;b++)if(d.isObject(a))for(var h in a)c==
null&&c!==f?this[b].removeAttribute(h):this[b].setAttribute(h,a[h]);else c==null&&c!==f?this[b].removeAttribute(a):this[b].setAttribute(a,c);return this},removeAttr:function(a){for(var c=this,b=0;b<this.length;b++)a.split(/\s+/g).forEach(function(a){c[b].removeAttribute(a)});return this},remove:function(a){for(var a=d(this).filter(a),c=0;c<a.length;c++)a[c].parentNode.removeChild(a[c]);return a},addClass:function(a){for(var c=0;c<this.length;c++){var b=this[c].className,e=[],d=this;a.split(/\s+/g).forEach(function(a){d.hasClass(a,
d[c])||e.push(a)});this[c].className+=(b?" ":"")+e.join(" ");this[c].className=this[c].className.trim()}return this},removeClass:function(a){for(var c=0;c<this.length;c++){if(a==f){this[c].className="";break}var b=this[c].className;a.split(/\s+/g).forEach(function(a){b=b.replace(p(a),"")});this[c].className=b.length>0?b.trim():""}return this},hasClass:function(a,c){if(this.length===0)return!1;c||(c=this[0]);return p(a).test(c.className)},bind:function(a,c){if(!(a===""||a==f)){for(var b=0;b<this.length;b++)(function(b){var d=
b._eventID?b._eventID:u++;b._eventID=d;a.split(/\s+/g).forEach(function(a){var f=function(a){a.originalEvent=a;var d=c.call(b,a);d===!1&&a.preventDefault();return d};n[d+"_"+a]=f;b.addEventListener(a,f,!1)})})(this[b]);return this}},unbind:function(a){if(!(a===""||a==f)){for(var c=0;c<this.length;c++)(function(b){var c=b._eventID;a.split(/\s+/g).forEach(function(a){if(n[c+"_"+a]){var d=n[c+"_"+a];delete n[c+"_"+a];b.removeEventListener(a,d,!1)}})})(this[c]);return this}},trigger:function(a,c){if(this.length===
0)return this;if(typeof a==="string"){var b=g.createEvent("Event");b.type=a;b.target=this[0];b.initEvent(a,!1,!0)}else b=a;b.data=c;this[0].dispatchEvent(b);return this},append:function(a,c){if(a&&a.length!=f&&a.length===0)return this;if(d.isArray(a)||d.isObject(a))a=d(a);var b;for(b=0;b<this.length;b++)if(a.length&&typeof a!="string")for(var a=d(a),e=0;e<a.length;e++)c!=f?this[b].insertBefore(a[e],this[b].firstChild):this[b].appendChild(a[e]);else{e=d(a).get();if(e==f||e.length==0)e=g.createTextNode(a);
e.nodeName!=f&&e.nodeName.toLowerCase()=="script"&&(!e.type||e.type.toLowerCase()==="text/javascript")?j.eval(e.innerHTML):c!=f?this[b].insertBefore(e,this[b].firstChild):this[b].appendChild(e)}return this},prepend:function(a){return this.append(a,1)},get:function(a){a=a==f?0:a;a<0&&(a+=this.length);return this[a]?this[a]:f},offset:function(){if(this.length===0)return f;var a=this[0].getBoundingClientRect();return{left:a.left+j.pageXOffset,top:a.top+j.pageYOffset,width:parseInt(this[0].style.width),
height:parseInt(this[0].style.height)}},parent:function(a){if(this.length==0)return f;for(var c=[],b=0;b<this.length;b++)this[b].parentNode&&c.push(this[b].parentNode);return this.setupOld(d(m(c)).filter(a))},children:function(a){if(this.length==0)return f;for(var c=[],b=0;b<this.length;b++)c=c.concat(q(this[b].firstChild));return this.setupOld(d(c).filter(a))},siblings:function(a){if(this.length==0)return f;for(var c=[],b=0;b<this.length;b++)this[b].parentNode&&(c=c.concat(q(this[b].parentNode.firstChild,
this[b])));return this.setupOld(d(c).filter(a))},closest:function(a,c){if(this.length==0)return f;var b=this[0],e=d(a,c);if(e.length==0)return d();for(;b&&e.indexOf(b)==-1;)b=b!==c&&b!==g&&b.parentNode;return d(b)},filter:function(a){if(this.length==0)return f;if(a==f)return this;for(var c=[],b=0;b<this.length;b++){var e=this[b];e.parentNode&&d(a,e.parentNode).indexOf(e)>=0&&c.push(e)}return this.setupOld(d(m(c)))},not:function(a){if(this.length==0)return f;for(var c=[],b=0;b<this.length;b++){var e=
this[b];e.parentNode&&d(a,e.parentNode).indexOf(e)==-1&&c.push(e)}return this.setupOld(d(m(c)))},data:function(a,c){return this.attr("data-"+a,c)},end:function(){return this.oldElement!=f?this.oldElement:d()},clone:function(a){a=a===!1?!1:!0;if(this.length==0)return f;for(var c=[],b=0;b<this.length;b++)c.push(this[b].cloneNode(a));return d(c)},size:function(){return this.length}};var s={type:"GET",beforeSend:l,success:l,error:l,complete:l,context:f,timeout:0};d.jsonP=function(a){var c="jsonp_callback"+
++v,b="",e=g.createElement("script");j[c]=function(f){clearTimeout(b);d(e).remove();delete j[c];a.success.call(void 0,f)};e.src=a.url.replace(/=\?/,"="+c);d("head").append(e);a.timeout>0&&(b=setTimeout(function(){a.error.call(void 0,"","timeout")},a.timeout));return{}};d.ajax=function(a){var c;try{c=new j.XMLHttpRequest;var b=a||{},e;for(e in s)b[e]||(b[e]=s[e]);if(!b.url)b.url=j.location;if(!b.contentType)b.contentType="application/x-www-form-urlencoded";if(!b.headers)b.headers={};b.headers=d.extend({"X-Requested-With":"XMLHttpRequest"},
b.headers);if(b.dataType)switch(b.dataType){case "script":b.dataType="text/javascript, application/javascript";break;case "json":b.dataType="application/json";break;case "xml":b.dataType="application/xml, text/xml";break;case "html":b.dataType="text/html";break;case "text":b.dataType="text/plain";break;default:b.dataType="text/html";break;case "jsonp":return d.jsonP(a)}else b.dataType="text/html";if(d.isObject(b.data))b.data=d.param(b.data);b.type.toLowerCase()==="get"&&b.data&&(b.url+=b.url.indexOf("?")===
-1?"?"+b.data:"&"+b.data);if(/=\?/.test(b.url))return d.jsonP(b);var f,g=b.context;c.onreadystatechange=function(){var a=b.dataType;if(c.readyState===4){clearTimeout(f);var d,e=!1;if(c.status>=200&&c.status<300||c.status===0){if(a==="application/json"&&!/^\s*$/.test(c.responseText))try{d=JSON.parse(c.responseText)}catch(i){e=i}else d=c.responseText;e?b.error.call(g,c,"parsererror",e):b.success.call(g,d,"success",c)}else e=!0,b.error.call(g,c,"error");b.complete.call(g,c,e?"error":"success")}};c.open(b.type,
b.url,!0);if(b.contentType)b.headers["Content-Type"]=b.contentType;for(var i in b.headers)c.setRequestHeader(i,b.headers[i]);if(b.beforeSend.call(g,c,b)===!1)return c.abort(),!1;b.timeout>0&&(f=setTimeout(function(){c.onreadystatechange=l;c.abort();b.error.call(g,c,"timeout")},b.timeout));c.send(b.data)}catch(k){console.log(k)}return c};d.get=function(a,c){return this.ajax({url:a,success:c})};d.post=function(a,c,b,d){typeof c==="function"&&(b=c,c={});d===f&&(d="html");return this.ajax({url:a,type:"POST",
data:c,dataType:d,success:b})};d.getJSON=function(a,c,b){typeof c==="function"&&(b=c,c={});return this.ajax({url:a,data:c,success:b,dataType:"json"})};d.param=function(a,c){var b=[];if(a instanceof k)a.each(function(){b.push((c?c+"[]":this.id)+"="+encodeURIComponent(this.value))});else for(var e in a){var f=c?c+"["+e+"]":e,g=a[e];b.push(d.isObject(g)?d.param(g,f):f+"="+encodeURIComponent(g))}return b.join("&")};d.parseJSON=function(a){return JSON.parse(a)};d.parseXML=function(a){return(new DOMParser).parseFromString(a,
"text/xml")};r(d,navigator.userAgent);d.__detectUA=r;if(typeof String.prototype.trim!=="function")String.prototype.trim=function(){return this.replace(/^\s+|\s+$/,"")};return d}(window);"$"in window||(window.$=jq)};