/
dollardom-chain-animate.min.js
11 lines (11 loc) · 8.63 KB
/
dollardom-chain-animate.min.js
1
2
3
4
5
6
7
8
9
10
11
/**
* $dom library (v0.9.2b) copyright 2009, 2010, 2011 Keith Clark
* Licensed under the MIT License.
* http://www.keithclark.co.uk/
*
* Copyright 2011, 2012 Julien Wajsberg
* Licensed under the MIT License
* https://github.com/julienw/dollardom
* @preserve
*/
!function(t){function n(t,n,r){var i=e(n),a=M[i];return a&&a.set?a.set(t,r):t.style[i]=r}function e(t){return H[t]||(H[t]=t.replace(I,function(t,n){return n.toUpperCase()}))}function r(t,e,r){if(r===q){if("string"==typeof e)return z(t,e)||0;for(var i in e)n(t,i,e[i])}else n(t,e,r)}function i(t){var n,e=[];if("string"==typeof t)for(;t&&(n=t.match(j),""!==n[0]);)e.push({rel:n[1],uTag:(n[2]||"").toUpperCase(),id:n[3],classes:n[4]?n[4].split("."):q}),t=t.substring(n[0].length);return e}function a(t,n){for(;(t=t.parentNode)&&t!==n;);return null!==t}function o(t,n){function e(t,n){var e,i=n.id?(e=(t&&t.ownerDocument||D).getElementById(n.id))&&a(e,t)?[e]:[]:r(t.getElementsByTagName(n.uTag||"*"));if(e=i.length,e>0&&(n.id||n.classes))for(;e--;)u(i[e],n)||i.splice(e,1);return i}function r(t){try{return Array.prototype.slice.call(t)}catch(n){for(var e=[],r=0,i=t.length;i>r;r++)e.push(t[r]);return e}}function o(t){for(var n=v.length;n--;)if(v[n]===t)return R;return V}var s,c,f,l,h,d,p,g,m,v=[],y=[t],b=i(n);for(b.length||(b=[{}]),s=0,c=b.length;c>s;s++){for(p=b[s],f=0,l=y.length;l>f;f++)switch(g=y[f],p.rel){case">":var E=g.childNodes;for(h=0,d=E.length;d>h;h++)u(E[h],p)&&v.push(E[h]);break;case"~":for(;g=g.nextSibling;)if(u(g,p)){if(o(g))break;v.push(g)}break;case"+":for(;(g=g.nextSibling)&&1!==g.nodeType;);g&&u(g,p)&&v.push(g);break;default:if(m=e(g,p),s>0)for(h=0,d=m.length;d>h;h++)o(m[h])||v.push(m[h]);else v=v.concat(m)}if(!v.length)return[];y=v.splice(0,v.length)}return y}function u(t,n){if(!n)return!0;var e=n.uTag,r=n.id,i=n.classes;return!(1!==t.nodeType||e&&e!==t.tagName||r&&r!==t.id||i&&!l(t,i))}function s(t,n,e){for(e=i(e)[0];t&&!u(t,e)&&(t=t[n]););return t}function c(t,n){return n=i(n)[0],t&&u(t,n)}function f(t,n,e){return s(t[n],n,e)}function l(t,n){if(""===t.className)return V;for(var e=0;e<n.length;e++)if(!C(t,n[e]))return V;return R}function h(){function n(){if(!r){r=!0,i&&(i=t.clearTimeout(i));for(var n=0,e=W.length;e>n;n++)W[n]()}}function e(){try{$.doScroll("left")}catch(r){return void t.setTimeout(e,20)}n()}var r,i;if(D.addEventListener)D.addEventListener("DOMContentLoaded",n,V),D.addEventListener("load",n,V);else if(D.attachEvent){D.attachEvent("onload",n);var a=!1;try{a=null===t.frameElement}catch(o){}a&&$.doScroll&&e()}}function d(t,n){var e=i(t)[0],r=e.uTag;if(!r)return null;var a=(n||D).createElement(r),o=e.id,u=e.classes;return o&&(a.id=o),u&&(a.className=u.join(" ")),a}function p(n){/loaded|complete|interactive/.test(D.readyState)?t.setTimeout(n,0):W.push(n)}function g(t,n){return o(n||$,t)}function m(t,n){return f(t,"parentNode",n)}function v(t,n){return f(t,"nextSibling",n)}function y(t,n){return f(t,"previousSibling",n)}function b(t,n){return t=t.parentNode.firstChild,s(t,"nextSibling",n)}function E(t,n){return t=t.parentNode.lastChild,s(t,"previousSibling",n)}function C(t,n){return(" "+t.className+" ").indexOf(" "+n+" ")>-1}function x(t,n){C(t,n)||(t.className+=" "+n)}function w(t,n){C(t,n)&&(t.className=t.className.replace(RegExp("(^|\\s)"+n+"(\\s|$)")," ").replace(/\s$/,""))}function T(t,n,e){(e?x:w)(t,n)}function N(t){return D.createTextNode(t)}function A(t,n,e){t.setAttribute(n,""+e)}function S(t,n){return t.getAttribute(n)||null}function F(t,n,e){if("object"!=typeof n)return e===q?S(t,n):void A(t,n,e);for(var r in n)A(t,r,n[r])}function k(t){for(;t.firstChild;)t.removeChild(t.firstChild)}function L(t,n){n||(n=t,t=this);for(var e in n)t[e]=n[e]}var q,D=t.document,$=D.documentElement,R=!0,V=!1,j=/^\s*([>+~])?\s*([*\w-]+)?(?:#([\w-]+))?(?:\.([\w.-]+))?\s*/,I=/-(\w)/g,W=[],B=[],H={"float":"cssFloat"in $.style?"cssFloat":"styleFloat"},M={borderWidth:{get:function(t){return z(t,"border-left-width")}},padding:{get:function(t){return z(t,"padding-left")}},margin:{get:function(t){return z(t,"margin-left")}}};!("opacity"in $.style)&&"filters"in $&&(M.opacity={set:function(t,n){var e=t.filters.alpha;e?e.opacity=100*n:t.style.filter+=" Alpha(opacity="+100*n+")"},get:function(t){var n=t.filters.alpha;return n?n.opacity/100:1}}),"clientWidth"in $&&(M.width={get:function(t){return t.style.width||t.clientWidth||t.offsetWidth}}),"clientHeight"in $&&(M.height={get:function(t){return t.style.height||t.clientHeight||t.offsetHeight}});var O=t.addEventListener?function(t,n,e){t.addEventListener(n,e,!1)}:function(n,e,r){var i=n.uniqueID+e+r;B[i]=function(){var e=t.event;return e.target=e.srcElement||D,e.currentTarget=n,e.preventDefault=function(){e.returnValue=!1},e.stopPropagation=function(){e.cancelBubble=!0},r.call(n,e)},n.attachEvent("on"+e,B[i])},P=t.removeEventListener?function(t,n,e){t.removeEventListener(n,e,!1)}:function(t,n,e){var r=t.uniqueID+n+e;t.detachEvent("on"+n,B[r]),delete B[r]},z=D.defaultView&&D.defaultView.getComputedStyle?function(t,n){var r=e(n),i=M[r];return i&&i.get?i.get(t):t.ownerDocument.defaultView.getComputedStyle(t,null).getPropertyValue(n)}:function(t,n){var r=e(n),i=M[r];return i&&i.get?i.get(t):t.currentStyle[r]},U={create:d,onready:p,addEvent:O,removeEvent:P,get:g,descendants:o,ancestor:m,next:v,previous:y,first:b,last:E,empty:k,is:c,text:N,attr:F,hasClass:C,addClass:x,removeClass:w,toggleClass:T,style:r,extend:L};t.$dom=U,h()}(this),function(t){function n(t,n){var e=u.splice(t,1)[0];e.callback&&e.callback(n,e.elm)}function e(t){t=t||+new Date;for(var r=u.length-1;r>=0;r--){var i,a,c={},f=u[r];f.startTime=f.startTime||t;var l=f.duration,h=f.properties,d=t-f.startTime,p=.5-Math.cos(d/l*Math.PI)/2;for(i in h)a=h[i],c[i]=""+(d>=l?a.e:a.s+(a.e-a.s)*p)+a.u,"NaNpx"===c[i]&&(c[i]=0);o(f.elm,c),d>=l&&n(r,!0)}u.length&&s(e)}function r(t,r,a,f){var l,h,d,p,g=[],m=-1;for(p=u.length-1;p>=0;p--)if(u[p].elm===t){m=p;break}if(r===i)return m>-1;m>-1&&n(m,!1),a===i&&(a=500);for(l in r)h=c.exec(o(t,l)),d=c.exec(r[l]),g[l]={s:parseFloat(h[1])||0,e:parseFloat(d[1])||0,u:d[2]||h[2]||""};u.push({elm:t,properties:g,callback:f,duration:a}),s(e)}var i,a=t.$dom,o=a.style,u=[],s=t.requestAnimationFrame||t.webkitRequestAnimationFrame||t.mozRequestAnimationFrame||t.oRequestAnimationFrame||t.msRequestAnimationFrame||function(n){t.setTimeout(function(){n()},16)},c=/^(.*?)(px|deg)?$/;a.transform=a.animate=r}(this),function(t){function n(t,n){for(var e=0,r=t.length;r>e;e++)n(t[e])}function e(t,n){for(var e=[],r=0,i=t.length;i>r;r++)e.push(n(t[r]));return e}function r(t){for(var n,e,r,i,a=0,o=[],u=[t];a<u.length;){for(n=u[a],e=0,r=n.length;r>e;e++)i=n[e],h(i)?u.push(i):o.push(i);a++}return o}function i(t){return"[object Array]"===Object.prototype.toString.call(t)}function a(t){this.a=t}function o(t,n){return new a(c.get(t,n))}function u(t,n){return new a([c.create(t,n)])}function s(t){return t=h(t)?t:[t],new a(t)}var c=t.$dom,f=Array.prototype.forEach?function(t,n){t.forEach(n)}:n,l=Array.prototype.map?function(t,n){return t.map(n)}:e,h=Array.isArray||i,d=c.fn=a.prototype={addEvent:function(t,n){return f(this.a,function(e){c.addEvent(e,t,n)}),this},removeEvent:function(t,n){return f(this.a,function(e){c.removeEvent(e,t,n)}),this},descendants:function(t){return s(r(l(this.a,function(n){return c.descendants(n,t)})))},ancestor:function(t){return s(l(this.a,function(n){return c.ancestor(n,t)}))},next:function(t){return s(l(this.a,function(n){return c.next(n,t)}))},previous:function(t){return s(l(this.a,function(n){return c.previous(n,t)}))},first:function(t){return s(l(this.a,function(n){return c.first(n,t)}))},last:function(t){return s(l(this.a,function(n){return c.last(n,t)}))},empty:function(){return f(this.a,c.empty),this},is:function(t){return this.a.length&&c.is(this.a[0],t)},hasClass:function(t){return this.a.length&&c.hasClass(this.a[0],t)},addClass:function(t){return f(this.a,function(n){c.addClass(n,t)}),this},removeClass:function(t){return f(this.a,function(n){c.removeClass(n,t)}),this},toggleClass:function(t,n){return f(this.a,function(e){c.toggleClass(e,t,n)}),this},style:function(t,n){return f(this.a,function(e){c.style(e,t,n)}),this},dom:function(t){return"number"==typeof t?this.a[t]:this.a},append:function(t){return t instanceof a&&(t=t.a),h(t)||(t=[t]),f(this.a,function(n){f(t,function(t){n.appendChild(t)})}),this},appendTo:function(t){return t instanceof a||(t=s(t)),t.append(this),this},size:function(){return this.a.length},each:function(t){return f(this.a,t),this},text:function(t){return this.append(c.text(t))},extend:c.extend,attr:function(t,n){return this.a.length&&c.attr(this.a[0],t,n)}};c.transform&&(d.transform=d.animate=function(t,n,e){return f(this.a,function(r){c.transform(r,t,n,e),e=null}),this}),c.extend({Get:o,select:o,Create:u,element:u,From:s,from:s,each:f,map:l})}(this);