1// (c) Copyright Microsoft Corporation. 2// This source is subject to the Microsoft Permissive License. 3// See http://www.microsoft.com/resources/sharedsource/licensingbasics/sharedsourcelicenses.mspx. 4// All other rights reserved. 5 6 7/// <reference name="MicrosoftAjax.debug.js" /> 8/// <reference name="MicrosoftAjaxTimer.debug.js" /> 9/// <reference name="MicrosoftAjaxWebForms.debug.js" /> 10/// <reference path="../ExtenderBase/BaseScripts.js" /> 11/// <reference path="../Compat/Timer/Timer.js" /> 12/// <reference path="../Common/Common.js" /> 13/// <reference path="../Animation/Animations.js" /> 14 15 16Type.registerNamespace('AjaxControlToolkit.Animation'); 17 18AjaxControlToolkit.Animation.AnimationBehavior = function(element) { 19 /// <summary> 20 /// The AnimationBehavior allows us to associate animations (described by JSON) with events and 21 /// have them play when the events are fired. It relies heavily on the AJAX Control Toolkit 22 /// animation framework provided in Animation.js, and the GenericAnimationBehavior defined below. 23 /// </summary> 24 /// <param name="element" type="Sys.UI.DomElement" domElement="true"> 25 /// The DOM element the behavior is associated with 26 /// </param> 27 AjaxControlToolkit.Animation.AnimationBehavior.initializeBase(this, [element]); 28 29 // Generic animation behaviors that automatically build animations from JSON descriptions 30 this._onLoad = null; 31 this._onClick = null; 32 this._onMouseOver = null; 33 this._onMouseOut = null; 34 this._onHoverOver = null; 35 this._onHoverOut = null; 36 37 // Handlers for the events 38 this._onClickHandler = null; 39 this._onMouseOverHandler = null; 40 this._onMouseOutHandler = null; 41} 42AjaxControlToolkit.Animation.AnimationBehavior.prototype = { 43 initialize : function() { 44 /// <summary> 45 /// Setup the animations/handlers 46 /// </summary> 47 /// <returns /> 48 AjaxControlToolkit.Animation.AnimationBehavior.callBaseMethod(this, 'initialize'); 49 50 // Wireup the event handlers 51 var element = this.get_element(); 52 if (element) { 53 this._onClickHandler = Function.createDelegate(this, this.OnClick); 54 $addHandler(element, 'click', this._onClickHandler); 55 this._onMouseOverHandler = Function.createDelegate(this, this.OnMouseOver); 56 $addHandler(element, 'mouseover', this._onMouseOverHandler); 57 this._onMouseOutHandler = Function.createDelegate(this, this.OnMouseOut); 58 $addHandler(element, 'mouseout', this._onMouseOutHandler); 59 } 60 }, 61 62 dispose : function() { 63 /// <summary> 64 /// Dispose of the animations/handlers 65 /// </summary> 66 /// <returns /> 67 68 // Remove the event handlers 69 var element = this.get_element(); 70 if (element) { 71 if (this._onClickHandler) { 72 $removeHandler(element, 'click', this._onClickHandler); 73 this._onClickHandler = null; 74 } 75 if (this._onMouseOverHandler) { 76 $removeHandler(element, 'mouseover', this._onMouseOverHandler); 77 this._onMouseOverHandler = null; 78 } 79 if (this._onMouseOutHandler) { 80 $removeHandler(element, 'mouseout', this._onMouseOutHandler); 81 this._onMouseOutHandler = null; 82 } 83 } 84 85 // Wipe the behaviors (we don't need to dispose them because 86 // that will happen automatically in our base dispose) 87 this._onLoad = null; 88 this._onClick = null; 89 this._onMouseOver = null; 90 this._onMouseOut = null; 91 this._onHoverOver = null; 92 this._onHoverOut = null; 93 94 AjaxControlToolkit.Animation.AnimationBehavior.callBaseMethod(this, 'dispose'); 95 }, 96 97 98 99 get_OnLoad : function() { 100 /// <value type="String" mayBeNull="true"> 101 /// Generic OnLoad Animation's JSON definition 102 /// </value> 103 /// <remarks> 104 /// Setting the OnLoad property will cause it to be played immediately 105 /// </remarks> 106 return this._onLoad ? this._onLoad.get_json() : null; 107 }, 108 set_OnLoad : function(value) { 109 if (!this._onLoad) { 110 this._onLoad = new AjaxControlToolkit.Animation.GenericAnimationBehavior(this.get_element
110()); 111 this._onLoad.initialize(); 112 } 113 this._onLoad.set_json(value); 114 this.raisePropertyChanged('OnLoad'); 115 this._onLoad.play(); 116 }, 117 118 get_OnLoadBehavior : function() { 119 /// <value type="AjaxControlToolkit.Animation.GenericAnimationBehavior"> 120 /// Generic OnLoad Animation's behavior 121 /// </value> 122 return this._onLoad; 123 }, 124 125 126 127 get_OnClick : function() { 128 /// <value type="String" mayBeNull="true"> 129 /// Generic OnClick Animation's JSON definition 130 /// </value> 131 return this._onClick ? this._onClick.get_json() : null; 132 }, 133 set_OnClick : function(value) { 134 if (!this._onClick) { 135 this._onClick = new AjaxControlToolkit.Animation.GenericAnimationBehavior(this.get_element()); 136 this._onClick.initialize(); 137 } 138 this._onClick.set_json(value); 139 this.raisePropertyChanged('OnClick'); 140 }, 141 142 get_OnClickBehavior : function() { 143 /// <value type="AjaxControlToolkit.Animation.GenericAnimationBehavior"> 144 /// Generic OnClick Animation's behavior 145 /// </value> 146 return this._onClick; 147 }, 148 149 OnClick : function() { 150 /// <summary> 151 /// Play the OnClick animation 152 /// </summary> 153 /// <returns /> 154 if (this._onClick) { 155 this._onClick.play(); 156 } 157 }, 158 159 160 161 get_OnMouseOver : function() { 162 /// <value type="String" mayBeNull="true"> 163 /// Generic OnMouseOver Animation's JSON definition 164 /// </value> 165 return this._onMouseOver ? this._onMouseOver.get_json() : null; 166 }, 167 set_OnMouseOver : function(value) { 168 if (!this._onMouseOver) { 169 this._onMouseOver = new AjaxControlToolkit.Animation.GenericAnimationBehavior(this.get_element()); 170 this._onMouseOver.initialize(); 171 } 172 this._onMouseOver.set_json(value); 173 this.raisePropertyChanged('OnMouseOver'); 174 }, 175 176 get_OnMouseOverBehavior : function() { 177 /// <value type="AjaxControlToolkit.Animation.GenericAnimationBehavior"> 178 /// Generic OnMouseOver Animation's behavior 179 /// </value> 180 return this._onMouseOver; 181 }, 182 183 OnMouseOver : function() { 184 /// <summary> 185 /// Play the OnMouseOver/OnHoverOver animations 186 /// </summary> 187 /// <returns /> 188 if (this._onMouseOver) { 189 this._onMouseOver.play(); 190 } 191 if (this._onHoverOver) { 192 if (this._onHoverOut) { 193 this._onHoverOut.quit(); 194 } 195 this._onHoverOver.play(); 196 } 197 }, 198 199 200 201 get_OnMouseOut : function() { 202 /// <value type="String" mayBeNull="true"> 203 /// Generic OnMouseOut Animation's JSON definition 204 /// </value> 205 return this._onMouseOut ? this._onMouseOut.get_json() : null; 206 }, 207 set_OnMouseOut : function(value) { 208 if (!this._onMouseOut) { 209 this._onMouseOut = new AjaxControlToolkit.Animation.GenericAnimationBehavior(this.get_element()); 210 this._onMouseOut.initialize(); 211 } 212 this._onMouseOut.set_json(value); 213 this.raisePropertyChanged('OnMouseOut'); 214 }, 215 216 get_OnMouseOutBehavior : function() { 217 /// <value type="AjaxControlToolkit.Animation.GenericAnimationBehavior"> 218 /// Generic OnMouseOut Animation's behavior 219 /// </value> 220 return this._onMouseOut; 221 }, 222 223 OnMouseOut : function() { 224 /// <summary> 225 /// Play the OnMouseOver/OnHoverOver animations 226 /// </summary> 227 /// <returns /> 228 if (this._onMouseOut) { 229 this._onMouseOut.play(); 230 } 231 if (this._onHoverOut) { 232 if (this._onHoverOver) { 233 this._onHoverOver.quit(); 234 } 235 this._onHoverOut.play(); 236 } 237 }, 238 239 240 241 get_OnHoverOver : function() { 242 /// <value type="String" mayBeNull="true"> 243 /// Generic OnHoverOver Animation's JSON definition 244 /// </value> 245 return this._onHoverOver ? this._onHoverOver.get_json() : null; 246 }, 247 set_OnHoverOver : function(value) { 248 if (!this._onHoverOver) { 249 this._onHoverOver = new AjaxControlToolkit.Animation.GenericAnimationBehavior(this.get_element
249()); 250 this._onHoverOver.initialize(); 251 } 252 this._onHoverOver.set_json(value); 253 this.raisePropertyChanged('OnHoverOver'); 254 }, 255 256 get_OnHoverOverBehavior : function() { 257 /// <value type="AjaxControlToolkit.Animation.GenericAnimationBehavior"> 258 /// Generic OnHoverOver Animation's behavior 259 /// </value> 260 return this._onHoverOver; 261 }, 262 263 264 265 get_OnHoverOut : function() { 266 /// <value type="String" mayBeNull="true"> 267 /// Generic OnHoverOut Animation's JSON definition 268 /// </value> 269 return this._onHoverOut ? this._onHoverOut.get_json() : null; 270 }, 271 set_OnHoverOut : function(value) { 272 if (!this._onHoverOut) { 273 this._onHoverOut = new AjaxControlToolkit.Animation.GenericAnimationBehavior(this.get_element()); 274 this._onHoverOut.initialize(); 275 } 276 this._onHoverOut.set_json(value); 277 this.raisePropertyChanged('OnHoverOut'); 278 }, 279 280 get_OnHoverOutBehavior : function() { 281 /// <value type="AjaxControlToolkit.Animation.GenericAnimationBehavior"> 282 /// Generic OnHoverOut Animation's behavior 283 /// </value> 284 return this._onHoverOut; 285 } 286} 287AjaxControlToolkit.Animation.AnimationBehavior.registerClass('AjaxControlToolkit.Animation.AnimationBehavior', AjaxControlToolkit.BehaviorBase); 288// getDescriptor : function() { 289// /// <summary> 290// /// Create a type descriptor 291// /// </summary> 292// /// <returns type="???">Type descriptor</returns> 293// 294// var descriptor = AjaxControlToolkit.Animation.AnimationBehavior.callBaseMethod(this, 'getDescriptor'); 295// descriptor.addProperty('OnLoad', String); 296// descriptor.addProperty('OnClick', String); 297// descriptor.addProperty('OnMouseOver', String); 298// descriptor.addProperty('OnMouseOut', String); 299// descriptor.addProperty('OnHoverOver', String); 300// descriptor.addProperty('OnHoverOut', String); 301// return descriptor; 302// }, 303 304 305AjaxControlToolkit.Animation.GenericAnimationBehavior = function(element) { 306 /// <summary> 307 /// The GenericAnimationBehavior handles the creation, playing, and disposing of animations 308 /// created from a JSON description. As we intend to expose a lot of generic animations 309 /// across the Toolkit, this behavior serves to simplify the amount of work required. 310 /// </summary> 311 /// <param name="element" type="Sys.UI.DomElement" domElement="true"> 312 /// The DOM element the behavior is associated with 313 /// </param> 314 AjaxControlToolkit.Animation.GenericAnimationBehavior.initializeBase(this, [element]); 315 316 // JSON description of the animation that will be used to create it 317 this._json = null; 318 319 // Animation created from the JSON description that will be played 320 this._animation = null; 321} 322AjaxControlToolkit.Animation.GenericAnimationBehavior.prototype = { 323 dispose : function() { 324 /// <summary> 325 /// Dispose the behavior and its animation 326 /// </summary> 327 /// <returns /> 328 this.disposeAnimation(); 329 AjaxControlToolkit.Animation.GenericAnimationBehavior.callBaseMethod(this, 'dispose'); 330 }, 331 332 disposeAnimation : function() { 333 /// <summary> 334 /// Dispose the animation 335 /// </summary> 336 /// <returns /> 337 if (this._animation) { 338 this._animation.dispose(); 339 } 340 this._animation = null; 341 }, 342 343 play : function() { 344 /// <summary> 345 /// Play the animation if it isn't already playing. If it's already playing, this does nothing. 346 /// </summary> 347 /// <returns /> 348 if (this._animation && !this._animation.get_isPlaying()) { 349 this.stop(); 350 this._animation.play(); 351 } 352 }, 353 354 stop : function() { 355 /// <summary> 356 /// Stop the animation if it's already playing 357 /// </summary> 358 /// <returns /> 359 if (this._animation) { 360 if (this._animation.get_isPlaying()) { 361 this._animation.stop(true); 362 } 363 } 364 }, 365 366 quit : function() { 367 /// <summary> 368 /// Quit playing the animation without updating the final state (i.e. if 369 /// the animation was moving, this would leave it in the middle of its path). 370 /// </summary> 371 /// <returns /> 372 /// <remarks> 373 /// This differs from the stop function which will update the final state. The 374 /// quit function is most useful for scenarios where you're toggling back and forth 375 /// between two animations (like those used in OnHoverOver/OnHoverOut) and you don't 376 /// want to completely finish one animation if its counterpart is triggered. 377 /// </remarks> 378 if (this._animation) { 379 if (this._animation.get_isPlaying()) { 380 this._animation.stop(false); 381 } 382 } 383 }, 384 385 get_json : function() { 386 /// <value type="String" mayBeNull="true"> 387 /// JSON animation description 388 /// </value> 389 return this._json; 390 }, 391 set_json : function(value) { 392 // Only wipe and rebuild if they're changing the value 393 if (this._json != value) { 394 this._json = value; 395 this.raisePropertyChanged('json'); 396 397 // Build the new animation 398 this.disposeAnimation();
399 var element = this.get_element(); 400 if (element) { 401 this._animation = AjaxControlToolkit.Animation.buildAnimation(this._json, element); 402 if (this._animation) { 403 this._animation.initialize(); 404 } 405 this.raisePropertyChanged('animation'); 406 } 407 } 408 }, 409 410 get_animation : function() { 411 /// <value type="AjaxControlToolkit.Animation.Animation"> 412 /// Animation created from the JSON description 413 /// </value> 414 return this._animation; 415 } 416} 417AjaxControlToolkit.Animation.GenericAnimationBehavior.registerClass('AjaxControlToolkit.Animation.GenericAnimationBehavior', AjaxControlToolkit.BehaviorBase); 418// getDescriptor : function() { 419// /// <summary> 420// /// Get a type descriptor 421// /// </summary> 422// /// <returns type="???>Type descriptor</returns> 423// 424// var descriptor = AjaxControlToolkit.Animation.AnimationBehavior.callBaseMethod(this, 'getDescriptor'); 425// descriptor.addProperty('json', String); 426// descriptor.addProperty('animation', Object, true); 427// return descriptor; 428// },
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.