Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

implemented the Über-Deferred

  • Loading branch information...
commit 692810802d81e10f57da2c855473a8ed73d96bc2 1 parent 18780b2
peter authored
View
25 build.xml
@@ -26,18 +26,19 @@
<length file="${script-minimized}" property="bytes-before-shrink" />
<replace file="${script-minimized}" token="_allAction" value="a"/>
- <replace file="${script-minimized}" token="_arguments" value="b"/>
- <replace file="${script-minimized}" token="_callback" value="c"/>
- <replace file="${script-minimized}" token="_canContinue" value="d"/>
- <replace file="${script-minimized}" token="_context" value="e"/>
- <replace file="${script-minimized}" token="_count" value="f"/>
- <replace file="${script-minimized}" token="_fixOpenLoop" value="g"/>
- <replace file="${script-minimized}" token="_method" value="h"/>
- <replace file="${script-minimized}" token="_name" value="i"/>
- <replace file="${script-minimized}" token="_next" value="j"/>
- <replace file="${script-minimized}" token="_openEndAction" value="k"/>
- <replace file="${script-minimized}" token="_triggered" value="l"/>
- <replace file="${script-minimized}" token="_untilAction" value="m"/>
+ <replace file="${script-minimized}" token="_allowPromise" value="b"/>
+ <replace file="${script-minimized}" token="_arguments" value="c"/>
+ <replace file="${script-minimized}" token="_callback" value="d"/>
+ <replace file="${script-minimized}" token="_canContinue" value="e"/>
+ <replace file="${script-minimized}" token="_context" value="f"/>
+ <replace file="${script-minimized}" token="_count" value="g"/>
+ <replace file="${script-minimized}" token="_fixOpenLoop" value="h"/>
+ <replace file="${script-minimized}" token="_method" value="i"/>
+ <replace file="${script-minimized}" token="_name" value="j"/>
+ <replace file="${script-minimized}" token="_next" value="k"/>
+ <replace file="${script-minimized}" token="_openEndAction" value="l"/>
+ <replace file="${script-minimized}" token="_triggered" value="m"/>
+ <replace file="${script-minimized}" token="_untilAction" value="n"/>
<length file="${script-minimized}" property="bytes-after-shrink" />
<echo>Shrinking ${bytes-before-shrink} =&gt; ${bytes-after-shrink} Bytes</echo>
View
71 jquery-timing.js
@@ -89,15 +89,16 @@
_method: methodStack
},
preventRecursion = false,
- method, otherExecutionState;
+ method, otherExecutionState, deferred;
- function hookupToMockup(state, mockup){
+ function hookupToProxy(state, mockup){
state._canContinue = false;
- mockup.then(function(){
+ function fire(){
state._next = sameOrNextJQuery(state._context, state._next);
state._canContinue = true;
timedInvocationChain();
- }, true);
+ }
+ return typeof mockup.promise == "function" ? mockup.promise().then(fire) : mockup.then(fire, true);
}
/**
@@ -116,10 +117,15 @@
}
// leave the chain when waiting for a trigger
if (executionState._canContinue == false) {
- return deferredReturnValue;
+ break;
}
// check end of chain
if (!executionState._method._name) {
+ // resolve any waiting promise
+ if (deferred && (!ongoingLoops.length || ongoingLoops[0]._allowPromise)) {
+ deferred.resolveWith(executionState._context);
+ deferred = null;
+ }
if (!ongoingLoops.length) {
/*
* We've reached the end of our TIC
@@ -135,7 +141,7 @@
otherExecutionState = ongoingLoops[0]._openEndAction && ongoingLoops[0]._openEndAction(timedInvocationChain, executionState, ongoingLoops);
if (!otherExecutionState) {
// if innermost loop can't help us, just leave the chain
- return deferredReturnValue;
+ break;
}
executionState = otherExecutionState;
continue;
@@ -155,8 +161,8 @@
if (!method.timing && !executionState._canContinue) {
// prevent automatic re-trigger in case of loops
executionState._next = executionState._context[executionState._method._name].apply(executionState._context, executionState._method._arguments);
- if (ongoingLoops.length && executionState._next instanceof PredictingProxy) {
- hookupToMockup(executionState, executionState._next);
+ if (ongoingLoops.length && executionState._next && executionState._next instanceof PredictingProxy) {
+ hookupToProxy(executionState, executionState._next);
continue;
}
}
@@ -182,9 +188,20 @@
preventRecursion = !preventRecursion;
throw e;
} finally {
- preventRecursion = !preventRecursion;
+ preventRecursion = !preventRecursion;
}
+ return deferredReturnValue;
};
+ if (jQuery.Deferred) {
+ // add .promise() method to tic
+ timedInvocationChain.promise = function(){
+ var ret = jQuery.Deferred();
+ deferred = deferred || jQuery.Deferred();
+ deferred.then(ret.resolve);
+ timedInvocationChain();
+ return ret;
+ };
+ }
return timedInvocationChain;
}
@@ -211,6 +228,13 @@
}
}
+ // enabling jQuery.when(tic);
+ if (jQuery.Deferred) {
+ PredictingProxy.prototype.promise = function() {
+ return (this['.callback'] && typeof this['.callback'].promise == "function") ? this['.callback'].promise() : jQuery.Deferred().resolveWith(this);
+ };
+ }
+
/**
* Create and return a new placeholder function on the prototype of PredictingProxy.
*/
@@ -232,7 +256,7 @@
if (jQuery.fn[name]) {
var original = jQuery.fn[name];
jQuery.fn[name] = function(){
- var i, methodStack, placeholder, timedInvocationChain;
+ var i, methodStack, placeholder, timedInvocationChain, deferred;
for(i=0; i<arguments.length; i++) {
if (typeof arguments[i] == "function" || (arguments[i] && typeof arguments[i] == "object") || arguments[i] === false) {
if (arguments[i] !== jQuery) {
@@ -247,16 +271,27 @@
}
Array.prototype.splice.call(arguments, i, 1, function(){
timedInvocationChain = createTimedInvocationChain(jQuery(this), methodStack, [{
- _count: jQuery.extend(Array.prototype.shift.apply(arguments), arguments)
+ _count: jQuery.extend(Array.prototype.shift.apply(arguments), arguments),
+ _allowPromise: true
}], function(elements){
placeholder.length = 0;
Array.prototype.push.apply(placeholder, elements);
});
+ if (deferred) {
+ timedInvocationChain.promise().then(deferred.resolve);
+ deferred = null;
+ }
return timedInvocationChain();
});
- return placeholder = new PredictingProxy(original.apply(this, arguments), methodStack = {}, function(){
+ function fire(){
return timedInvocationChain ? timedInvocationChain(placeholder) : placeholder;
- });
+ }
+ if (jQuery.Deferred) {
+ fire.promise = function(){
+ return timedInvocationChain ? timedInvocationChain.promise() : deferred = jQuery.Deferred();
+ };
+ }
+ return placeholder = new PredictingProxy(original.apply(this, arguments), methodStack = {}, fire);
};
}
});
@@ -332,7 +367,7 @@
// wait for each element to reach the current end of its queue
if (promising) {
- executionState._context.promise(queueName == null ? 'fx' : queueName).done(function(){
+ executionState._context.promise(queueName == null ? 'fx' : queueName).then(function(){
executionState._canContinue = true;
timedInvocationChain();
});
@@ -398,9 +433,13 @@
originalOn.call(executionState._context, event = trigger, triggerAction);
- } else if (typeof trigger == "object" && typeof trigger.done == "function") {
+ } else if (trigger && typeof trigger.then == "function") {
+
+ trigger.then(triggerAction, true);
+
+ } else if (trigger && typeof trigger.promise == "function") {
- trigger.done(triggerAction);
+ trigger.promise().then(triggerAction);
} else {
View
BIN  jquery-timing.js.gz
Binary file not shown
View
2  jquery-timing.min.js
@@ -1 +1 @@
-(function(m,j){var d={},e=1,f=m.fn.each,k=m.fn.on||m.fn.bind,n=m.fn.off||m.fn.unbind,l={};function a(p,q){q=m(q);q.prevObject=p;var o=p.length;if(o!==q.length){return q}while(o--){if(p[o]!==q[o]){return q}}return p}function c(o){var p=[],q=o.length;while(q--){p[q]=o[q].f}return p}function h(p,w,t,s){t=t||[];var u={e:p,h:w},q=false,o,x;function v(y,z){y.d=false;z.then(function(){y.j=a(y.e,y.j);y.d=true;r()},true)}function r(z){while(!q){try{q=!q;if(typeof s=="function"){s(m.makeArray(u.j||u.e))}if(u.d==false){return z}if(!u.h.i){if(!t.length){return u.e}x=t[0].k&&t[0].k(r,u,t);if(!x){return z}u=x;continue}o=u.e&&u.e[u.h.i]||l[u.h.i];if(!o){throw'no such method "'+u.h.i+'" on object ('+u.e+")"}if(o.timing&&!u.d){u.d=false;u=o.timing(r,u,t,s)||u}else{if(!o.timing&&!u.d){u.j=u.e[u.h.i].apply(u.e,u.h.b);if(t.length&&u.j instanceof g){v(u,u.j);continue}}x={e:u.j,h:u.h.j};u.d=false;if(typeof u.c=="function"){u.c.apply(u.e,c(t))}u=x}}catch(y){q=!q;throw y}finally{q=!q}}}return r}function g(q,r,p){this[".methods"]=r;this[".callback"]=p;this.length=0;Array.prototype.push.apply(this,m.makeArray(this._=q._=q));for(var o in q){if(!(o in g.prototype)&&typeof q[o]=="function"){this[o]=i(o)}}}function i(o){return g.prototype[o]=function(){this[".methods"].i=o;this[".methods"].b=arguments;this[".methods"]=this[".methods"].j={};return this[".callback"]?this[".callback"](this,o,arguments):this}}m.each(["bind","on","one","live","delegate"],function(p,o){if(m.fn[o]){var q=m.fn[o];m.fn[o]=function(){var s,u,t,r;for(s=0;s<arguments.length;s++){if(typeof arguments[s]=="function"||(arguments[s]&&typeof arguments[s]=="object")||arguments[s]===false){if(arguments[s]!==m){if(typeof arguments[s]=="function"&&m.guid){arguments[s].guid=arguments[s].guid||m.guid++}return q.apply(this,arguments)}break}}Array.prototype.splice.call(arguments,s,1,function(){r=h(m(this),u,[{f:m.extend(Array.prototype.shift.apply(arguments),arguments)}],function(v){t.length=0;Array.prototype.push.apply(t,v)});return r()});return t=new g(q.apply(this,arguments),u={},function(){return r?r(t):t})}}});m.each(["animate","load"],function(p,o){if(m.fn[o]){var q=m.fn[o];m.fn[o]=function(){while(arguments.length&&arguments[arguments.length-1]==null){Array.prototype.pop.apply(arguments)}if(this.length&&arguments.length>1&&arguments[arguments.length-1]===m){var r="_timing"+e++;arguments[arguments.length-1]=function(){m(this).trigger(r)};return this.each().one(r).all(q.apply(this,arguments))}return q.apply(this,arguments)}}});m.each(["wait","repeat","join","then"],function(p,o){m.fn[o]=function(){var r={},q=new g(this,r,h(this,r,[],function(s){q.length=0;Array.prototype.push.apply(q,s)}));return q[o].apply(q,arguments)}});m.fn.join.timing=function(p,r){var q,o,s=r.e.length;if(typeof r.h.b[0]=="string"){q=r.h.b[0];if(typeof r.h.b[1]=="function"){r.c=r.h.b[1]}else{o=r.h.b[1];r.c=r.h.b[2]}}else{if(typeof r.h.b[0]=="function"){r.c=r.h.b[0]}else{o=r.h.b[0];r.c=r.h.b[1]}}r.j=r.e;r.d=!s;if(o){r.e.promise(q==null?"fx":q).done(function(){r.d=true;p()})}else{r.e.queue(q==null?"fx":q,function(t){r.d=!--s;p();t()})}};m.fn.then.timing=function(o,p){p.c=p.h.b[0];p.j=p.e;p.d=true;if(p.h.b[1]){Array.prototype.shift.apply(p.h.b)}};m.fn.wait.timing=function(q,u){var p,s,t;if(typeof u.h.b[0]=="function"){u.c=u.h.b[0]}else{p=u.h.b[0];u.c=u.h.b[1]}function o(){n.call(s?n.call(u.e,s,o):u.e,"unwait",r);u.d=true;q()}function r(){n.call(s?n.call(m(this),s,o):m(this),"unwait",r);u.j=u.e=u.e.not(this);if(!u.e.length){u.d=false;j.clearTimeout(t);u={e:u.e}}q()}if(typeof p=="string"){k.call(u.e,s=p,o)}else{if(typeof p=="object"&&typeof p.done=="function"){p.done(o)}else{t=j.setTimeout(o,Math.max(0,p))}}k.call(u.e,"unwait",r);u.j=u.e};m.fn.each=function(q){if(!q||q===m){var p={},o=new g(this,p,h(this,p,[],function(r){o.length=0;Array.prototype.push.apply(o,r)}));return o.each(q)}return f.apply(this,arguments)};m.fn.each.timing=function(r,u,v,t){if(u.h.b[0]&&u.h.b[0]!==m){u.d=true;u.j=f.apply(u.e,u.hs.b);return}var A=u.e.length,p=0,x,s,z=[],y=[],w={},q=u.h.b[0]===m;function o(){if(q&&p<A){(z[p])()}else{for(var B=0;B<A;B++){(z[B])()}}return w}for(x in g.prototype){w[x]=o}w.length=A;u.e.each(function(B){var C=v.slice();y[B]=[w[B]=this];C.unshift({f:B,a:function(D){p++;if(p==A){s=D.h.j}r()},g:l.all});z[B]=h(m(this),u.h.j,C,function(E){y[B]=E;w.length=0;for(var D=0;D<A;D++){Array.prototype.push.apply(w,y[D])}if(t){t(m.makeArray(w))}})});u.j=w;u.d=true;u.k=function(D,C){if(p==A){v.shift();return{e:a(u.e,w),h:s}}var B=p;o();if(p!=B){return C}};u.f=A;v.unshift(u)};l.all=function(o){m.extend(o.h,{j:m.extend({},o.h),i:"all",b:[]});o.d=null};l.all.timing=function(o,q,p){if(!p.length||!p[0].g){throw".all() method must be used after .each() only"}if(!p[0].a){p[0].g(q);return}p[0].a(q)};m.fn.repeat.timing=function(s,v,w){var q,t,u,o,p;if(typeof v.h.b[0]=="function"){v.c=v.h.b[0]}else{if(typeof v.h.b[1]=="function"){q=v.h.b[0];v.c=v.h.b[1]}else{q=v.h.b[0];t=v.h.b[1];v.c=v.h.b[2]}}function x(){v.j=v.j||v.e;v.d=true;s()}function r(){n.call(o?n.call(m(this),o,x):m(this),"unrepeat",r);var y=v.e.not(this);v.j=(v.j==v.e)?y:v.j;v.e=y;v.d=v.e.length&&v.d;q=v.e.length&&q;j.clearInterval(!v.e.length&&p);s()}v.k=function(z,y){if(v.d||u){v.f++;v.j=v.j||v.e;v.d=v.d||(q&&y.e&&y.e.length);return v}};if(q==null){t=q=true;j.setTimeout(function(){u=true;s()},0)}else{if(typeof q=="string"){k.call(v.e,o=q,x)}else{p=j.setInterval(x,Math.max(0,q))}q=false}k.call(v.e,"unrepeat",r);v.j=v.e;v.f=0;v.m=function(y){if(y){r.apply(v.e)}if(q){x()}};v.g=l.until;if(t){x()}w.unshift(v)};l.until=function(o){m.extend(o.h,{j:m.extend({},o.h),i:"until",b:[]});o.d=null};l.until.timing=function(o,r,q){if(!q.length||!q[0].g){throw".until() method must be used after .repeat() only"}if(!q[0].m){q[0].g(r);return}var s=r.h.b[0],p=r.h.b[1];if(s===m){s=null;p=r.h.b.length<=1||p}if(typeof s=="function"){s=s.apply(r.e,c(q))}if(s==null){s=!r.e.size()}if(typeof s=="object"){s=s.toString()}if(typeof s=="number"){s=q[0].f>=s-1}if(s){r.d=true;r.j=r.e;q.shift().m(s)}else{if(p){q[0].j=r.e}r=q[0];r.f++;r.m(s);return r}};new g(l);m.each(["unwait","unrepeat"],function(p,o){m.fn[o]=function(){return this.trigger(o)}});m.each(["wait","repeat","join","then","unwait","unrepeat"],function(p,o){m[o]=function(){var q=typeof arguments[0]=="string"?Array.prototype.shift.apply(arguments):"";return m.fn[o].apply(d[q]=(d[q]||m("<div>").text(q)),arguments)}});function b(r,u,q){if(typeof r=="string"){q=new Function("x","return ["+r+"\n,x]");r=function(w,v){v=q(w);p.x=v[1];return v[0]}}var o=typeof u=="function",t=typeof r=="function",p=function(v){if(arguments.length==1){p.x=v;if(o){u(v)}}else{return s()}};function s(v){v=o?u():p.x;return t?r(v):v}p.x=0;p._={toString:p.$=p.toString=s.toString=s};p.mod=function(v){return b(function(w){return w%v},p)};p.add=function(v){return b(function(w){return w+v},p)};p.neg=function(){return b("-x",p)};p.X=function(v){return b(v,p)};m.each("abcdefghij",function(v,w){p[v]=p[w]=function(){p(arguments[v])}});return p}m.X=b;m.fn.$=function(){var o=m.apply(j,arguments);o.prevObject=this;return o}})(jQuery,window);
+(function(m,j){var d={},e=1,f=m.fn.each,k=m.fn.on||m.fn.bind,n=m.fn.off||m.fn.unbind,l={};function a(p,q){q=m(q);q.prevObject=p;var o=p.length;if(o!==q.length){return q}while(o--){if(p[o]!==q[o]){return q}}return p}function c(o){var p=[],q=o.length;while(q--){p[q]=o[q].g}return p}function h(p,w,t,s){t=t||[];var u={f:p,i:w},q=false,o,x,y;function v(A,B){A.e=false;function z(){A.k=a(A.f,A.k);A.e=true;r()}return typeof B.promise=="function"?B.promise().then(z):B.then(z,true)}function r(A){while(!q){try{q=!q;if(typeof s=="function"){s(m.makeArray(u.k||u.f))}if(u.e==false){break}if(!u.i.j){if(y&&(!t.length||t[0].b)){y.resolveWith(u.f);y=null}if(!t.length){return u.f}x=t[0].l&&t[0].l(r,u,t);if(!x){break}u=x;continue}o=u.f&&u.f[u.i.j]||l[u.i.j];if(!o){throw'no such method "'+u.i.j+'" on object ('+u.f+")"}if(o.timing&&!u.e){u.e=false;u=o.timing(r,u,t,s)||u}else{if(!o.timing&&!u.e){u.k=u.f[u.i.j].apply(u.f,u.i.c);if(t.length&&u.k&&u.k instanceof g){v(u,u.k);continue}}x={f:u.k,i:u.i.k};u.e=false;if(typeof u.d=="function"){u.d.apply(u.f,c(t))}u=x}}catch(z){q=!q;throw z}finally{q=!q}}return A}if(m.Deferred){r.promise=function(){var z=m.Deferred();y=y||m.Deferred();y.then(z.resolve);r();return z}}return r}function g(q,r,p){this[".methods"]=r;this[".callback"]=p;this.length=0;Array.prototype.push.apply(this,m.makeArray(this._=q._=q));for(var o in q){if(!(o in g.prototype)&&typeof q[o]=="function"){this[o]=i(o)}}}if(m.Deferred){g.prototype.promise=function(){return(this[".callback"]&&typeof this[".callback"].promise=="function")?this[".callback"].promise():m.Deferred().resolveWith(this)}}function i(o){return g.prototype[o]=function(){this[".methods"].j=o;this[".methods"].c=arguments;this[".methods"]=this[".methods"].k={};return this[".callback"]?this[".callback"](this,o,arguments):this}}m.each(["bind","on","one","live","delegate"],function(p,o){if(m.fn[o]){var q=m.fn[o];m.fn[o]=function(){var t,w,v,s,r;for(t=0;t<arguments.length;t++){if(typeof arguments[t]=="function"||(arguments[t]&&typeof arguments[t]=="object")||arguments[t]===false){if(arguments[t]!==m){if(typeof arguments[t]=="function"&&m.guid){arguments[t].guid=arguments[t].guid||m.guid++}return q.apply(this,arguments)}break}}Array.prototype.splice.call(arguments,t,1,function(){s=h(m(this),w,[{g:m.extend(Array.prototype.shift.apply(arguments),arguments),b:true}],function(x){v.length=0;Array.prototype.push.apply(v,x)});if(r){s.promise().then(r.resolve);r=null}return s()});function u(){return s?s(v):v}if(m.Deferred){u.promise=function(){return s?s.promise():r=m.Deferred()}}return v=new g(q.apply(this,arguments),w={},u)}}});m.each(["animate","load"],function(p,o){if(m.fn[o]){var q=m.fn[o];m.fn[o]=function(){while(arguments.length&&arguments[arguments.length-1]==null){Array.prototype.pop.apply(arguments)}if(this.length&&arguments.length>1&&arguments[arguments.length-1]===m){var r="_timing"+e++;arguments[arguments.length-1]=function(){m(this).trigger(r)};return this.each().one(r).all(q.apply(this,arguments))}return q.apply(this,arguments)}}});m.each(["wait","repeat","join","then"],function(p,o){m.fn[o]=function(){var r={},q=new g(this,r,h(this,r,[],function(s){q.length=0;Array.prototype.push.apply(q,s)}));return q[o].apply(q,arguments)}});m.fn.join.timing=function(p,r){var q,o,s=r.f.length;if(typeof r.i.c[0]=="string"){q=r.i.c[0];if(typeof r.i.c[1]=="function"){r.d=r.i.c[1]}else{o=r.i.c[1];r.d=r.i.c[2]}}else{if(typeof r.i.c[0]=="function"){r.d=r.i.c[0]}else{o=r.i.c[0];r.d=r.i.c[1]}}r.k=r.f;r.e=!s;if(o){r.f.promise(q==null?"fx":q).then(function(){r.e=true;p()})}else{r.f.queue(q==null?"fx":q,function(t){r.e=!--s;p();t()})}};m.fn.then.timing=function(o,p){p.d=p.i.c[0];p.k=p.f;p.e=true;if(p.i.c[1]){Array.prototype.shift.apply(p.i.c)}};m.fn.wait.timing=function(q,u){var p,s,t;if(typeof u.i.c[0]=="function"){u.d=u.i.c[0]}else{p=u.i.c[0];u.d=u.i.c[1]}function o(){n.call(s?n.call(u.f,s,o):u.f,"unwait",r);u.e=true;q()}function r(){n.call(s?n.call(m(this),s,o):m(this),"unwait",r);u.k=u.f=u.f.not(this);if(!u.f.length){u.e=false;j.clearTimeout(t);u={f:u.f}}q()}if(typeof p=="string"){k.call(u.f,s=p,o)}else{if(p&&typeof p.then=="function"){p.then(o,true)}else{if(p&&typeof p.promise=="function"){p.promise().then(o)}else{t=j.setTimeout(o,Math.max(0,p))}}}k.call(u.f,"unwait",r);u.k=u.f};m.fn.each=function(q){if(!q||q===m){var p={},o=new g(this,p,h(this,p,[],function(r){o.length=0;Array.prototype.push.apply(o,r)}));return o.each(q)}return f.apply(this,arguments)};m.fn.each.timing=function(r,u,v,t){if(u.i.c[0]&&u.i.c[0]!==m){u.e=true;u.k=f.apply(u.f,u.is.c);return}var A=u.f.length,p=0,x,s,z=[],y=[],w={},q=u.i.c[0]===m;function o(){if(q&&p<A){(z[p])()}else{for(var B=0;B<A;B++){(z[B])()}}return w}for(x in g.prototype){w[x]=o}w.length=A;u.f.each(function(B){var C=v.slice();y[B]=[w[B]=this];C.unshift({g:B,a:function(D){p++;if(p==A){s=D.i.k}r()},h:l.all});z[B]=h(m(this),u.i.k,C,function(E){y[B]=E;w.length=0;for(var D=0;D<A;D++){Array.prototype.push.apply(w,y[D])}if(t){t(m.makeArray(w))}})});u.k=w;u.e=true;u.l=function(D,C){if(p==A){v.shift();return{f:a(u.f,w),i:s}}var B=p;o();if(p!=B){return C}};u.g=A;v.unshift(u)};l.all=function(o){m.extend(o.i,{k:m.extend({},o.i),j:"all",c:[]});o.e=null};l.all.timing=function(o,q,p){if(!p.length||!p[0].h){throw".all() method must be used after .each() only"}if(!p[0].a){p[0].h(q);return}p[0].a(q)};m.fn.repeat.timing=function(s,v,w){var q,t,u,o,p;if(typeof v.i.c[0]=="function"){v.d=v.i.c[0]}else{if(typeof v.i.c[1]=="function"){q=v.i.c[0];v.d=v.i.c[1]}else{q=v.i.c[0];t=v.i.c[1];v.d=v.i.c[2]}}function x(){v.k=v.k||v.f;v.e=true;s()}function r(){n.call(o?n.call(m(this),o,x):m(this),"unrepeat",r);var y=v.f.not(this);v.k=(v.k==v.f)?y:v.k;v.f=y;v.e=v.f.length&&v.e;q=v.f.length&&q;j.clearInterval(!v.f.length&&p);s()}v.l=function(z,y){if(v.e||u){v.g++;v.k=v.k||v.f;v.e=v.e||(q&&y.f&&y.f.length);return v}};if(q==null){t=q=true;j.setTimeout(function(){u=true;s()},0)}else{if(typeof q=="string"){k.call(v.f,o=q,x)}else{p=j.setInterval(x,Math.max(0,q))}q=false}k.call(v.f,"unrepeat",r);v.k=v.f;v.g=0;v.n=function(y){if(y){r.apply(v.f)}if(q){x()}};v.h=l.until;if(t){x()}w.unshift(v)};l.until=function(o){m.extend(o.i,{k:m.extend({},o.i),j:"until",c:[]});o.e=null};l.until.timing=function(o,r,q){if(!q.length||!q[0].h){throw".until() method must be used after .repeat() only"}if(!q[0].n){q[0].h(r);return}var s=r.i.c[0],p=r.i.c[1];if(s===m){s=null;p=r.i.c.length<=1||p}if(typeof s=="function"){s=s.apply(r.f,c(q))}if(s==null){s=!r.f.size()}if(typeof s=="object"){s=s.toString()}if(typeof s=="number"){s=q[0].g>=s-1}if(s){r.e=true;r.k=r.f;q.shift().n(s)}else{if(p){q[0].k=r.f}r=q[0];r.g++;r.n(s);return r}};new g(l);m.each(["unwait","unrepeat"],function(p,o){m.fn[o]=function(){return this.trigger(o)}});m.each(["wait","repeat","join","then","unwait","unrepeat"],function(p,o){m[o]=function(){var q=typeof arguments[0]=="string"?Array.prototype.shift.apply(arguments):"";return m.fn[o].apply(d[q]=(d[q]||m("<div>").text(q)),arguments)}});function b(r,u,q){if(typeof r=="string"){q=new Function("x","return ["+r+"\n,x]");r=function(w,v){v=q(w);p.x=v[1];return v[0]}}var o=typeof u=="function",t=typeof r=="function",p=function(v){if(arguments.length==1){p.x=v;if(o){u(v)}}else{return s()}};function s(v){v=o?u():p.x;return t?r(v):v}p.x=0;p._={toString:p.$=p.toString=s.toString=s};p.mod=function(v){return b(function(w){return w%v},p)};p.add=function(v){return b(function(w){return w+v},p)};p.neg=function(){return b("-x",p)};p.X=function(v){return b(v,p)};m.each("abcdefghij",function(v,w){p[v]=p[w]=function(){p(arguments[v])}});return p}m.X=b;m.fn.$=function(){var o=m.apply(j,arguments);o.prevObject=this;return o}})(jQuery,window);
View
BIN  jquery-timing.min.js.gz
Binary file not shown
Please sign in to comment.
Something went wrong with that request. Please try again.