This repository was archived by the owner on Jan 15, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathnwt.min.js
More file actions
1 lines (1 loc) · 12.5 KB
/
nwt.min.js
File metadata and controls
1 lines (1 loc) · 12.5 KB
1
!function(a,b){function c(){}function e(a){this.request=a;try{this.obj=JSON.parse(a.responseText)}catch(b){}}function f(a){this.req=new XMLHttpRequest,this.config={},this.url=a[0],this.ioData="";var b=["success","failure","serialize"],c,d,e=this,f=function(a){return function(b){return e.config[a]=b,this}};for(c=0,d;d=b[c];c++)this[d]=f(d)}function h(a){d.implement("DelayableQueue",this),this._node=a}function j(){}function k(a){function i(a){return function(){for(var b=0,c;c=g.nodes[b];b++)c[a].apply(c,arguments);return g}}d.implement("DelayableQueue",this);var b=[];for(var c=0,e;e=a[c];c++)b.push(new h(e));this.nodes=b;var f=["anim","remove","addClass","removeClass","setStyle","setStyles","removeStyle","removeStyles","swapClass","plug"],g=this;for(var c=0,j;j=f[c];c++)this[j]=i(j)}function m(){this.animClass="nwt-anim-on"}function p(a,b){this._e=a,this.target=new h(a.target);for(var c in b)this[c]=b[c]}function q(){this._cached={},this._eventData=[]}c.prototype={implement:function(a,b){var c={DelayableQueue:["wait",function(){function a(a){this.queue=[],this.context=a,this.inWork=!1}return a.prototype={_add:function(a,b){var c=this;c.queue.push({type:"chain",func:a,args:b});if(!c.inWork)return c._process()},_process:function(){var a=this,b;a.inWork=!0;if(!a.queue.length)return;return b=a.queue.shift(),b.type=="wait"?setTimeout(function(){a._process()},b.duration*1e3):(a.context=b.func.apply(a.context,b.args),a._process()),a},wait:function(a){return this.queue.push({type:"wait",duration:a}),this}},function(b){var c=this,d=new a(c);getQueuedFunction=function(a){return function(){return d._add(a,arguments),d}};for(var e in c){if(typeof c[e]!="function"||e=="wait")continue;d[e]=getQueuedFunction(c[e])}return d.wait(b),d}}]};b[c[a][0]]=c[a][1]()},declare:function(a,b){d._lib=d._lib||{},d._lib[a]=b},augment:function(a,b,c){d._lib[a].prototype[b]=c},uuid:function(){var a=0;return function(){return a++,a.toString(16)}}()};var d=new c;a.nwt=a.n=d,e.prototype={toString:function(){return this.request.responseText}},f.prototype={_run:function(){var a=this;return this.req.onload=function(){if(a.config.success){var b=new e(a.req);a.config.success(b)}},this.req.onerror=function(){if(a.config.failure){var b=new e(a.req);a.config.failure(b)}},this.req.send(this.ioData?this.ioData:null),this},post:function(a,b){var c=!0;typeof a=="string"?this.ioData=a:typeof a=="object"&&a._node&&(a.getAttribute("enctype")&&(c=!1),this.ioData=new FormData(a._node));var d=this.req,b=b||"POST";return d.open(b,this.url),c&&d.setRequestHeader("Content-type","application/x-www-form-urlencoded"),this._run()},get:function(a){return a&&(this.url=this.url.split("?",1)[0]+"?"+a),this.req.open("GET",this.url),this._run()},put:function(a){return this.post("?"+a,"PUT")},"delete":function(a){return this.post("?"+a,"DELETE")},abort:function(){return this.req.abort(),this}},d.io=function(){return new f(arguments)};var g={};n.declare("Node",h),h.prototype={region:function(){var c={width:this.get("offsetWidth"),height:this.get("offsetHeight")},d=this._node.getBoundingClientRect(),e=b,f=e.documentElement,g=e.body,h=a,i=f.clientTop||g.clientTop||0,j=f.clientLeft||g.clientLeft||0,k=h.pageYOffset||f.scrollTop||g.scrollTop,l=h.pageXOffset||f.scrollLeft||g.scrollLeft;return c.top=d.top+k-i,c.left=d.left+l-j,c.bottom=c.top+c.height,c.right=c.left+c.width,c},intersects:function(a){var b=this.region(),c=a.region();return!(b.left>c.right||b.right<c.left||b.top>c.bottom||b.bottom<c.top||c.left>b.right||c.right<b.left||c.top>b.bottom||c.bottom<b.top)},ancestor:function(a){var b=d.all(a),c=this._node,e=null,f=0;if(b.size()==0)return null;for(;;){b.each(function(a){a._node==c&&(e=a)});var g=c.parentNode;if(e||!g)break;c=g}return e?e:null},parent:function(){var a=new h(this._node.parentNode);return a},hasClass:function(a){return this._node.classList.contains(a)},addClass:function(a){return this._node.classList.add(a),this},removeClass:function(a){return this.swapClass(a,"")},swapClass:function(a,b){return this._node.className=this._node.className.replace(a,b),this},data:function(a){return this._node.getAttribute("data-"+a)},setData:function(a,b){return this._node.setAttribute("data-"+a,b)},get:function(a){if(a==="parentNode"){var b=this._node[a];return b?new h(b):null}return this._node[a]},set:function(a,b){return this._node[a]=b,this},getAttribute:function(a){return this._node.getAttribute(a)},hasAttribute:function(a){return this._node.hasAttribute(a)},setAttribute:function(a,b){return this._node.setAttribute(a,b),this},_jsStyle:function(a){var b={"float":"cssFloat"};return b[a]&&(a=b[a]),a},getStyle:function(a){if(!this.getAttribute("style"))return"";a=this._jsStyle(a);var b=this._node.style[a];return b?b:null},removeStyle:function(a){return this.removeStyles(a)},removeStyles:function(a){typeof a=="string"&&(a=[a]);var b,c=a.length;for(b=0;b<c;b+=1)this._node.style[a[b]]="";return this},setStyle:function(a,b){var c={};return c[a]=b,this.setStyles(c)},setStyles:function(a){this.getAttribute("style")||this.setAttribute("style","");var b="",c={top:"px",left:"px",width:"px",height:"px"},d,e,f=[];for(d in a){var g=this._jsStyle(d),h=a[d];c[g]&&!isNaN(h)&&(h+=c[g]),this._node.style[g]=h}return this},serialize:function(){var a="",b=this._node.getElementsByTagName("*");for(var c=0,d;d=b[c];c++)if(!d.disabled&&d.name&&d.name.length>0)switch(d.tagName.toLowerCase()){case"input":switch(d.type){case"checkbox":case"radio":d.checked&&(a.length>0&&(a+="&"),a+=d.name+"="+encodeURIComponent(d.value));break;case"hidden":case"password":case"text":a.length>0&&(a+="&"),a+=d.name+"="+encodeURIComponent(d.value)}break;case"select":case"textarea":a.length>0&&(a+="&"),a+=d.name+"="+encodeURIComponent(d.value)}return a},getHtml:function(){return this._node.innerHTML},setHtml:function(a){var c=this,d,e;c._node.innerHTML=a,e=c.all("script"),d=function(){var a=e.nodes.shift();if(!a||!a._node)return;var f=a.getAttribute("src");if(f){var g=b.createElement("script"),h;g.type="text/javascript",g.src=f,g.onload=g.onreadystatechange=function(){!h&&(!this.readyState||this.readyState==="loaded"||this.readyState==="complete")&&(h=!0,d())},c._node.appendChild(g)}else if(a.get("text")){var i=eval;i(a.get("text")),d()}};try{d()}catch(f){}return this},val:function(){return this.get("value")},_find:function(a,b){var c=this._node,d=a+"Sibling",e,f;typeof b=="string"?(f=n.all(b),e=function(a){var b=!1;return f.each(function(c){a==c._node&&(b=!0)}),b}):b?e=function(a){return b(new h(a))}:e=function(){return!0};while(c){c=c[d];if(c&&c.nodeType==1&&e(c))break}return c?new h(c):null},next:function(a){return this._find("next",a)},previous:function(a){return this._find("previous",a)},one:function(a){var b=this._node.querySelector(a);return new h(b)},all:function(a){var b=this._node.querySelectorAll(a);return new k(b)},append:function(a){return a instanceof h&&(a=a._node),this._node.appendChild(a),this},appendTo:function(a){var b=a instanceof h?a:d.one(a);return b.append(this),this},prepend:function(a){a instanceof h&&(a=a._node);var b=this.one("*");return this._node.insertBefore(a,b._node?b._node:null),this},insertTo:function(a,b){var c=a instanceof h?a:d.one(a);return c.insert(this,b),this},remove:function(){this._node.parentNode.removeChild(this._node)},insert:function(a,b){b=b||"before",b=="before"?this._node.parentNode.insertBefore(a._node,this._node):b=="after"&&this._node.parentNode.insertBefore(a._node,this.next()?this.next()._node:null)},click:function(){var c=b.createEvent("MouseEvents");return c.initMouseEvent("click",!0,!0,a,0,0,0,0,0,!1,!1,!1,!1,0,null),!this._node.dispatchEvent(c)},addEventListener:function(a,b){return this._node.addEventListener(a,b,!1)},removeEventListener:function(a,b){return this._node.removeEventListener(a,b,!1)},on:function(a,b,c,e){return d.event.on(this,a,b,c,e)},once:function(a,b,c,e){return d.event.on(this,a,b,c,e,!0)},off:function(a,b){return d.event.off(this,a,b)},purge:function(a,b,c){var e=d.event;for(var f in e._cached)for(var g=0,h=e._cached[f].length;g<h;g++){var i=e._cached[f][g];this._node==i.obj._node&&(!a||a==i.type)&&e.off(i.obj,i.type,i.raw)}c&&this.all("*").each(function(d){d.purge(a,b,c)})},fire:function(a,c){var e=Array.prototype.slice.call(arguments,1);d.event._eventData=e;var f=b.createEvent("UIEvents");f.initEvent(a,!0,!1),this._node.dispatchEvent(f)},uuid:function(){return this._node.id||(this._node.id="n"+d.uuid()),this._node.id},computeCss:function(a){var c=b.defaultView.getComputedStyle(this._node),d,e,f={};if(typeof a=="string")return c[a];for(d=0;e=a[d];d++)f[e]=c[e];return f},anim:function(a,b,c,e){if(!e){var f=[],h,i,j;for(j in a)f.push(j);h=this.computeCss(f),i={from:[h,b,c,!0],to:[a,b,c]},g[this.uuid()]=i,this.fire("anim:push",i)}return d.anim(this,a,b,c)},popAnim:function(){var a=this.uuid(),b=g[a];return b?(delete g[a],this.fire("anim:pop",b),this.anim.apply(this,b.from)):!1},plug:function(a,b){return b=b||{},b.node=this,d.plugin(a,b)}},n.declare("NodeMgr",j),j.prototype={create:function(a){var c=b.createElement("div");return c.innerHTML=a,new h(c.childNodes[0])},one:function(a){if(typeof a=="string"){var c=b.querySelectorAll(a);return c.length==0?null:new h(c[0])}return new h(a)},all:function(a){var c=b.querySelectorAll(a);return new k(c)}},d.node=new j,d.one=d.node.one,n.declare("NodeList",k),k.prototype={each:function(a){for(var b=0,c;c=this.nodes[b];b++)a(c)},item:function(a){return this.nodes[a]},size:function(){return this.nodes.length}},d.all=d.node.all;var l={};d.register=function(a){l[a.name]=a},d.plugin=function(a){var b=Array.prototype.slice.call(arguments),c,e=b.shift(),f=l[a],g=function(){},h;wrapPluginCall=function(a){var b;return f.extend&&(b=function(){l[f.extend].methods[a].apply(this,arguments)}),function(){return this._super=b,f.methods[a].apply(this,arguments)}};if(f.methods)for(c in f.methods)g.prototype[c]=wrapPluginCall(c);d.ready(function(){h=new g,h.init.apply(h,b)})},m.prototype={init:function(a,b){var c=d.node.create('<style type="text/css"></style>');b=b||"ease-in",a=a||1;var e=" "+a+"s "+b,f={"-webkit-transition":"all"+e,"-moz-transition":" all"+e,"-o-ransition":" all"+e,"ms-transition":" all"+e,transition:" all"+e},g="";for(i in f)g+=i+": "+f[i]+";";c.setHtml("."+this.animClass+"{"+g+"}"),d.one("head").append(c),setTimeout(function(){c.remove()},a*1001)},anim:function(a,b,c,d){return o.init(c,d),a.fire("anim:start",[b,c,d]),setTimeout(function(){a.fire("anim:done",[b,c,d])},c*1e3),a.addClass(o.animClass),a.setStyles(b),a}};var o=new m;d.anim=o.anim,n.declare("Event",p),p.prototype={pageX:function(){return this._e.pageX},pageY:function(){return this._e.pageY},code:function(){return this._e.keyCode},stop:function(){return this.noBubble().noDefault()},noDefault:function(){return this._e.preventDefault(),this},noBubble:function(){return this._e.stopPropagation(),this}},q.prototype={live:function(a,c,e,f,g){var h=new RegExp(c),f=f||"click",i,j,k=d.one("body");f=="click"?i=100:i=g||1,j=function(b){var f=b.target,g=f,h=!0,j=0;while(g._node&&g._node.parentNode){if(g._node==d.one("body")._node||j>=i)break;if(g.hasAttribute(a)){var k=g.getAttribute(a).match(c);if(k){e(f,g,k),g.get("nodeName").toUpperCase()!=="INPUT"&&b.stop();break}}j++,g=g.parent()}return};var l=function(){k.on(f,j)};l();if(f!=="click"){var m=!1;d.one(b).on("scroll",function(){k.off(f,j),m&&(clearTimeout(m),m=!1),m=setTimeout(l,75)})}},_getEventCallback:function(a,b,c,e,f,g){var h=this,i=c.toString(),j=function(f){var h=new p(f),i=arguments.callee,j=function(){d.event._eventData.unshift(h),c.apply(a,d.event._eventData),d.event._eventData=[],g&&a.removeEventListener(b,i)};if(e){a.all(e).each(function(a){a._node==h.target._node&&j()});return}j()};return h._cached[i]=h._cached[i]||[],h._cached[i].push({type:b,obj:a,fn:j,raw:c}),j},on:function(a,b,c,d,e,f){return a.addEventListener(b,this._getEventCallback.apply(this,arguments)),a},off:function(a,b,c){var d=c.toString();if(this._cached[d])for(var e=0,f=this._cached[d].length;e<f;e++)this._cached[d][e].raw===c&&a.removeEventListener(b,this._cached[d][e].fn)},ready:function(c){var d=!1,e=!0,f=b.documentElement,g=b.attachEvent?"attachEvent":"addEventListener",h=b.attachEvent?"detachEvent":"removeEventListener",i=b.attachEvent?"on":"",j=function(e){if(e.type=="readystatechange"&&b.readyState!="complete")return;(e.type=="load"?a:b)[h](i+e.type,j,!1),!d&&(d=!0)&&c.call(a,e.type||e)},k=function(){try{if(!f.doScroll("left")){setTimeout(k,50);return}}catch(a){setTimeout(k,50);return}j("poll")};if(b.readyState=="complete")c.call(a,"lazy");else{if(b.createEventObject&&f.doScroll){try{e=!a.frameElement}catch(l){}e&&k()}b[g](i+"DOMContentLoaded",j,!1),b[g](i+"readystatechange",j,!1),a[g](i+"load",j,!1)}}},d.event=new q,d.ready=d.event.ready}(window,document)