webgui/www/extras/yui-ext/build/anim/Animator-min.js
JT Smith 4f68a0933c added YUI and YUI-ext
fixed the resizable text area with IE problem
fixed the ad space with IE problem
merged the 7.2.0 and 7.1.4 change logs
2006-11-07 23:15:57 +00:00

20 lines
No EOL
4.3 KiB
JavaScript

/*
* YUI Extensions
* Copyright(c) 2006, Jack Slocum.
*
* This code is licensed under BSD license.
* http://www.opensource.org/licenses/bsd-license.php
*/
YAHOO.ext.Animator=function(){this.actors=[];this.playlist=new YAHOO.ext.Animator.AnimSequence();this.captureDelegate=this.capture.createDelegate(this);this.playDelegate=this.play.createDelegate(this);this.syncing=false;this.stopping=false;this.playing=false;for(var i=0;i<arguments.length;i++){this.addActor(arguments[i]);}};YAHOO.ext.Animator.prototype={capture:function(actor,action){if(this.syncing){if(!this.syncMap[actor.id]){this.syncMap[actor.id]=new YAHOO.ext.Animator.AnimSequence();}
this.syncMap[actor.id].add(action);}else{this.playlist.add(action);}},addActor:function(actor){actor.onCapture.subscribe(this.captureDelegate);this.actors.push(actor);},startCapture:function(clearPlaylist){for(var i=0;i<this.actors.length;i++){var a=this.actors[i];if(!this.isCapturing(a)){a.onCapture.subscribe(this.captureDelegate);}
a.capturing=true;}
if(clearPlaylist){this.playlist=new YAHOO.ext.Animator.AnimSequence();}},isCapturing:function(actor){var subscribers=actor.onCapture.subscribers;if(subscribers){for(var i=0;i<subscribers.length;i++){if(subscribers[i]&&subscribers[i].contains(this.captureDelegate)){return true;}}}
return false;},stopCapture:function(){for(var i=0;i<this.actors.length;i++){var a=this.actors[i];a.onCapture.unsubscribe(this.captureDelegate);a.capturing=false;}},beginSync:function(){this.syncing=true;this.syncMap={};},endSync:function(){this.syncing=false;var composite=new YAHOO.ext.Animator.CompositeSequence();for(key in this.syncMap){if(typeof this.syncMap[key]!='function'){composite.add(this.syncMap[key]);}}
this.playlist.add(composite);this.syncMap=null;},play:function(oncomplete){if(this.playing)return;this.stopCapture();this.playlist.play(oncomplete);},stop:function(){this.playlist.stop();},isPlaying:function(){return this.playlist.isPlaying();},clear:function(){this.playlist=new YAHOO.ext.Animator.AnimSequence();},addCall:function(fcn,args,scope){this.playlist.add(new YAHOO.ext.Actor.Action(scope,fcn,args||[]));},addAsyncCall:function(fcn,callbackIndex,args,scope){this.playlist.add(new YAHOO.ext.Actor.AsyncAction(scope,fcn,args||[],callbackIndex));},pause:function(seconds){this.playlist.add(new YAHOO.ext.Actor.PauseAction(seconds));}};YAHOO.ext.Animator.AnimSequence=function(){this.actions=[];this.nextDelegate=this.next.createDelegate(this);this.playDelegate=this.play.createDelegate(this);this.oncomplete=null;this.playing=false;this.stopping=false;this.actionIndex=-1;};YAHOO.ext.Animator.AnimSequence.prototype={add:function(action){this.actions.push(action);},next:function(){if(this.stopping){this.playing=false;if(this.oncomplete){this.oncomplete(this,false);}
return;}
var nextAction=this.actions[++this.actionIndex];if(nextAction){nextAction.play(this.nextDelegate);}else{this.playing=false;if(this.oncomplete){this.oncomplete(this,true);}}},play:function(oncomplete){if(this.playing)return;this.oncomplete=oncomplete;this.stopping=false;this.playing=true;this.actionIndex=-1;this.next();},stop:function(){this.stopping=true;},isPlaying:function(){return this.playing;},clear:function(){this.actions=[];},addCall:function(fcn,args,scope){this.actions.push(new YAHOO.ext.Actor.Action(scope,fcn,args||[]));},addAsyncCall:function(fcn,callbackIndex,args,scope){this.actions.push(new YAHOO.ext.Actor.AsyncAction(scope,fcn,args||[],callbackIndex));},pause:function(seconds){this.actions.push(new YAHOO.ext.Actor.PauseAction(seconds));}};YAHOO.ext.Animator.CompositeSequence=function(){this.sequences=[];this.completed=0;this.trackDelegate=this.trackCompletion.createDelegate(this);}
YAHOO.ext.Animator.CompositeSequence.prototype={add:function(sequence){this.sequences.push(sequence);},play:function(onComplete){this.completed=0;if(this.sequences.length<1){if(onComplete)onComplete();return;}
this.onComplete=onComplete;for(var i=0;i<this.sequences.length;i++){this.sequences[i].play(this.trackDelegate);}},trackCompletion:function(){++this.completed;if(this.completed>=this.sequences.length&&this.onComplete){this.onComplete();}},stop:function(){for(var i=0;i<this.sequences.length;i++){this.sequences[i].stop();}},isPlaying:function(){for(var i=0;i<this.sequences.length;i++){if(this.sequences[i].isPlaying()){return true;}}
return false;}};