|
|
|
|
Type.registerNamespace("AjaxControlToolkit.Animation");var $AA=AjaxControlToolkit.Animation;$AA.registerAnimation=function(b,a){if(a&&(a===$AA.Animation||a.inheritsFrom&&a.inheritsFrom($AA.Animation))){if(!$AA.__animations)$AA.__animations={};$AA.__animations[b.toLowerCase()]=a;a.play=function(){var b=new a;a.apply(b,arguments);b.initialize();var c=Function.createDelegate(b,function(){b.remove_ended(c);c=null;b.dispose()});b.add_ended(c);b.play()}}else throw Error.argumentType("type",a,$AA.Animation,AjaxControlToolkit.Resources.Animation_InvalidBaseType);};$AA.buildAnimation=function(a,c){if(!a||a==="")return null;var b;a="("+a+")";if(!Sys.Debug.isDebug)try{b=Sys.Serialization.JavaScriptSerializer.deserialize(a)}catch(d){}else b=Sys.Serialization.JavaScriptSerializer.deserialize(a);return $AA.createAnimation(b,c)};$AA.createAnimation=function(c,l){var g="obj";if(!c||!c.AnimationName)throw Error.argument(g,AjaxControlToolkit.Resources.Animation_MissingAnimationName);var b=$AA.__animations[c.AnimationName.toLowerCase()];if(!b)throw Error.argument("type",String.format(AjaxControlToolkit.Resources.Animation_UknownAnimationName,c.AnimationName));var d=new b;l&&d.set_target(l);if(c.AnimationChildren&&c.AnimationChildren.length)if($AA.ParentAnimation.isInstanceOfType(d))for(var k=0;k<c.AnimationChildren.length;k++){var m=$AA.createAnimation(c.AnimationChildren[k]);m&&d.add(m)}else throw Error.argument(g,String.format(AjaxControlToolkit.Resources.Animation_ChildrenNotAllowed,b.getName()));var h=b.__animationProperties;if(!h){b.__animationProperties={};b.resolveInheritance();for(var j in b.prototype)if(j.startsWith("set_"))b.__animationProperties[j.substr(4).toLowerCase()]=j;delete b.__animationProperties["id"];h=b.__animationProperties}for(var e in c){var f=e.toLowerCase();if(f=="animationname"||f=="animationchildren")continue;var i=c[e],a=h[f];if(a&&String.isInstanceOfType(a)&&d[a])if(!Sys.Debug.isDebug)try{d[a](i)}catch(n){}else d[a](i);else if(f.endsWith("script")){a=h[f.substr(0,e.length-6)];if(a&&String.isInstanceOfType(a)&&d[a])d.DynamicProperties[a]=i;else if(Sys.Debug.isDebug)throw Error.argument(g,String.format(AjaxControlToolkit.Resources.Animation_NoDynamicPropertyFound,e,e.substr(0,e.length-5)));}else if(Sys.Debug.isDebug)throw Error.argument(g,String.format(AjaxControlToolkit.Resources.Animation_NoPropertyFound,e));}return d};$AA.Animation=function(d,c,e){var b=null,a=this;$AA.Animation.initializeBase(a);a._duration=1;a._fps=25;a._target=b;a._tickHandler=b;a._timer=b;a._percentComplete=0;a._percentDelta=b;a._owner=b;a._parentAnimation=b;a.DynamicProperties={};d&&a.set_target(d);c&&a.set_duration(c);e&&a.set_fps(e)};$AA.Animation.prototype={dispose:function(){var a=this;if(a._timer){a._timer.dispose();a._timer=null}a._tickHandler=null;a._target=null;$AA.Animation.callBaseMethod(a,"dispose")},play:function(){var a=this;if(!a._owner){var b=true;if(!a._timer){b=false;if(!a._tickHandler)a._tickHandler=Function.createDelegate(a,a._onTimerTick);a._timer=new Sys.Timer;a._timer.add_tick(a._tickHandler);a.onStart();a._timer.set_interval(1e3/a._fps);a._percentDelta=100/(a._duration*a._fps);a._updatePercentComplete(0,true)}a._timer.set_enabled(true);a.raisePropertyChanged("isPlaying");!b&&a.raisePropertyChanged("isActive")}},pause:function(){var a=this;if(!a._owner)if(a._timer){a._timer.set_enabled(false);a.raisePropertyChanged("isPlaying")}},stop:function(b){var a=this;if(!a._owner){var c=a._timer;a._timer=null;if(c){c.dispose();if(a._percentComplete!==100){a._percentComplete=100;a.raisePropertyChanged("percentComplete");(b||b===undefined)&&a.onStep(100)}a.onEnd();a.raisePropertyChanged("isPlaying");a.raisePropertyChanged("isActive")}}},onStart:function(){var a=this;a.raiseStarted();for(var property in a.DynamicProperties)try{a[property](eval(a.DynamicProperties[property]))}catch(a){if(Sys.Debug.isDebug)throw a;}},onStep:function(a){this.setValue(this.getAnimatedValue(a));this.raiseStep()},onEnd:function(){this.raiseEnded()},getAnimatedValue:function(){throw Error.notImplemented();},setValue:function(){throw Error.notImple
|