UNPKG

iuap-design

Version:
1 lines 7.36 kB
function isDomElement(e){return window.HTMLElement?e instanceof HTMLElement:e&&e.tagName&&1===e.nodeType}if(String.prototype.trim||(String.prototype.trim=function(){return this.replace(/^\s*(\b.*\b|)\s*$/,"$1")}),Array.prototype.indexOf||(Array.prototype.indexOf=function(e){for(var t=0;t<this.length;t++)if(this[t]==e)return t;return-1}),Array.prototype.remove||(Array.prototype.remove=function(e){return e<0||e>this.length?void alert("index out of bound"):void this.splice(e,1)}),Array.prototype.forEach||(Array.prototype.forEach=function(e){for(var t=0,r=this.length;t<r;t++)e(this[t],t,this)}),NodeList.prototype.forEach||(NodeList.prototype.forEach=Array.prototype.forEach),!window.HTMLElement){var _querySelectorAll=Element.prototype.querySelectorAll;Element.prototype.querySelectorAll=function(e){var t=_querySelectorAll.call(this,e);if(!isDomElement(this))return t;for(var r=[],n=0;n<t.length;n++)r.push(t[n]);return r};var _docquerySelectorAll=document.querySelectorAll;document.querySelectorAll=function(e){try{var t=_docquerySelectorAll.call(this,e),r=[];if(t.length>0){for(var n=0;n<t.length;n++)r.push(t[n]);return r}return t}catch(a){}}}Element.prototype.addEventListener||(Element.prototype.addEventListener=function(e,t){var r=this;this.attachEvent("on"+e,function(){t.apply(r,arguments)})}),"function"!=typeof Function.prototype.bind&&(Function.prototype.bind=function(e){for(var t=this,r=[],n=1,a=arguments.length;n<a;n++)r.push(arguments[n]);return function(){return t.apply(e,r.concat(Array.prototype.slice.call(arguments)))}}),window.getCurrentJsPath=function(){var e=document,t={},r=+new Date,n=/((?:http|https|file):\/\/.*?\/[^:]+)(?::\d+)?:\d+/,a=(""+e.querySelector).indexOf("[native code]")===-1;if(e.currentScript)return e.currentScript.src;var o;try{t.b()}catch(i){o=i.fileName||i.sourceURL||i.stack||i.stacktrace}if(o){var s=n.exec(o)[1];if(s)return s}for(var l,c=e.scripts,u=c.length-1;l=c[u--];)if(l.className!==r&&"interactive"===l.readyState)return l.className=r,a?l.getAttribute("src",4):l.src},window.encodeBase64=function(e){for(var t,r,n,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,i=e.length,s="";o<i;){if(t=255&e[o++],o==i){s+=a.charAt(t>>2),s+=a.charAt((3&t)<<4),s+="==";break}if(r=e[o++],o==i){s+=a.charAt(t>>2),s+=a.charAt((3&t)<<4|(240&r)>>4),s+=a.charAt((15&r)<<2),s+="=";break}n=e[o++],s+=a.charAt(t>>2),s+=a.charAt((3&t)<<4|(240&r)>>4),s+=a.charAt((15&r)<<2|(192&n)>>6),s+=a.charAt(63&n)}return s},window.u=window.u||{};var u=window.u;u.polyfill=!0,u._addClass=function(e,t){var r,n,a,o,i,s=/[\t\r\n\f]/g,l="string"==typeof t&&t,c=/\S+/g;if(l&&(r=(t||"").match(c)||[],n=1===e.nodeType&&(e.className?(" "+e.className+" ").replace(s," "):" "))){for(o=0;a=r[o++];)n.indexOf(" "+a+" ")<0&&(n+=a+" ");i=(n+"").trim(),e.className!==i&&(e.className=i)}return this},u._removeClass=function(e,t){var r,n,a,o,i,s=/\S+/g,l=/[\t\r\n\f]/g,c=0===arguments.length||"string"==typeof t&&t;if(c&&(r=(t||"").match(s)||[],n=1===e.nodeType&&(e.className?(" "+e.className+" ").replace(l," "):""))){for(o=0;a=r[o++];)for(;n.indexOf(" "+a+" ")>=0;)n=n.replace(" "+a+" "," ");i=t?(n+"").trim():"",e.className!==i&&(e.className=i)}return this},u._hasClass=function(e,t){var r=/[\t\r\n\f]/g;return 1===e.nodeType&&(" "+e.className+" ").replace(r," ").indexOf(t)>=0},u._toggleClass=function(e,t){u._hasClass(e,t)?u._removeClass(e,t):u._addClass(e,t)}(function(e){"use strict";function t(){E(!0)}var r={};e.respond=r,r.update=function(){};var n=[],a=function(){var t=!1;try{t=new e.XMLHttpRequest}catch(r){t=new e.ActiveXObject("Microsoft.XMLHTTP")}return function(){return t}}(),o=function(e,t){var r=a();r&&(r.open("GET",e,!0),r.onreadystatechange=function(){4!==r.readyState||200!==r.status&&304!==r.status||t(r.responseText)},4!==r.readyState&&r.send(null))},i=function(e){return e.replace(r.regex.minmaxwh,"").match(r.regex.other)};if(r.ajax=o,r.queue=n,r.unsupportedmq=i,r.regex={media:/@media[^\{]+\{([^\{\}]*\{[^\}\{]*\})+/gi,keyframes:/@(?:\-(?:o|moz|webkit)\-)?keyframes[^\{]+\{(?:[^\{\}]*\{[^\}\{]*\})+[^\}]*\}/gi,comments:/\/\*[^*]*\*+([^\/][^*]*\*+)*\//gi,urls:/(url\()['"]?([^\/\)'"][^:\)'"]+)['"]?(\))/g,findStyles:/@media *([^\{]+)\{([\S\s]+?)$/,only:/(only\s+)?([a-zA-Z]+)\s?/,minw:/\(\s*min\-width\s*:\s*(\s*[0-9\.]+)(px|em)\s*\)/,maxw:/\(\s*max\-width\s*:\s*(\s*[0-9\.]+)(px|em)\s*\)/,minmaxwh:/\(\s*m(in|ax)\-(height|width)\s*:\s*(\s*[0-9\.]+)(px|em)\s*\)/gi,other:/\([^\)]*\)/g},r.mediaQueriesSupported=e.matchMedia&&null!==e.matchMedia("only all")&&e.matchMedia("only all").matches,!r.mediaQueriesSupported){var s,l,c,u=e.document,h=u.documentElement,p=[],f=[],m=[],d={},y=30,g=u.getElementsByTagName("head")[0]||h,v=u.getElementsByTagName("base")[0],x=g.getElementsByTagName("link"),w=function(){var e,t=u.createElement("div"),r=u.body,n=h.style.fontSize,a=r&&r.style.fontSize,o=!1;return t.style.cssText="position:absolute;font-size:1em;width:1em",r||(r=o=u.createElement("body"),r.style.background="none"),h.style.fontSize="100%",r.style.fontSize="100%",r.appendChild(t),o&&h.insertBefore(r,h.firstChild),e=t.offsetWidth,o?h.removeChild(r):r.removeChild(t),h.style.fontSize=n,a&&(r.style.fontSize=a),e=c=parseFloat(e)},E=function(t){var r="clientWidth",n=h[r],a="CSS1Compat"===u.compatMode&&n||u.body[r]||n,o={},i=x[x.length-1],d=(new Date).getTime();if(t&&s&&d-s<y)return e.clearTimeout(l),void(l=e.setTimeout(E,y));s=d;for(var v in p)if(p.hasOwnProperty(v)){var S=p[v],A=S.minw,T=S.maxw,b=null===A,N=null===T,C="em";A&&(A=parseFloat(A)*(A.indexOf(C)>-1?c||w():1)),T&&(T=parseFloat(T)*(T.indexOf(C)>-1?c||w():1)),S.hasquery&&(b&&N||!(b||a>=A)||!(N||a<=T))||(o[S.media]||(o[S.media]=[]),o[S.media].push(f[S.rules]))}for(var q in m)m.hasOwnProperty(q)&&m[q]&&m[q].parentNode===g&&g.removeChild(m[q]);m.length=0;for(var O in o)if(o.hasOwnProperty(O)){var $=u.createElement("style"),L=o[O].join("\n");$.type="text/css",$.media=O,g.insertBefore($,i.nextSibling),$.styleSheet?$.styleSheet.cssText=L:$.appendChild(u.createTextNode(L)),m.push($)}},S=function(e,t,n){var a=e.replace(r.regex.comments,"").replace(r.regex.keyframes,"").match(r.regex.media),o=a&&a.length||0;t=t.substring(0,t.lastIndexOf("/"));var s=function(e){return e.replace(r.regex.urls,"$1"+t+"$2$3")},l=!o&&n;t.length&&(t+="/"),l&&(o=1);for(var c=0;c<o;c++){var u,h,m,d;l?(u=n,f.push(s(e))):(u=a[c].match(r.regex.findStyles)&&RegExp.$1,f.push(RegExp.$2&&s(RegExp.$2))),m=u.split(","),d=m.length;for(var y=0;y<d;y++)h=m[y],i(h)||p.push({media:h.split("(")[0].match(r.regex.only)&&RegExp.$2||"all",rules:f.length-1,hasquery:h.indexOf("(")>-1,minw:h.match(r.regex.minw)&&parseFloat(RegExp.$1)+(RegExp.$2||""),maxw:h.match(r.regex.maxw)&&parseFloat(RegExp.$1)+(RegExp.$2||"")})}E()},A=function(){if(n.length){var t=n.shift();o(t.href,function(r){S(r,t.href,t.media),d[t.href]=!0,e.setTimeout(function(){A()},0)})}},T=function(){for(var t=0;t<x.length;t++){var r=x[t],a=r.href,o=r.media,i=r.rel&&"stylesheet"===r.rel.toLowerCase();a&&i&&!d[a]&&(r.styleSheet&&r.styleSheet.rawCssText?(S(r.styleSheet.rawCssText,a,o),d[a]=!0):(/^([a-zA-Z:]*\/\/)/.test(a)||v)&&a.replace(RegExp.$1,"").split("/")[0]!==e.location.host||("//"===a.substring(0,2)&&(a=e.location.protocol+a),n.push({href:a,media:o})))}A()};T(),r.update=T,r.getEmValue=w,e.addEventListener?e.addEventListener("resize",t,!1):e.attachEvent&&e.attachEvent("onresize",t)}})(this);