📄 animationbehavior.js
字号:
// (c) Copyright Microsoft Corporation.
// This source is subject to the Microsoft Permissive License.
// See http://www.microsoft.com/resources/sharedsource/licensingbasics/sharedsourcelicenses.mspx.
// All other rights reserved.
/// <reference name="MicrosoftAjax.debug.js" />
/// <reference name="MicrosoftAjaxTimer.debug.js" />
/// <reference name="MicrosoftAjaxWebForms.debug.js" />
/// <reference path="../ExtenderBase/BaseScripts.js" />
/// <reference path="../Compat/Timer/Timer.js" />
/// <reference path="../Common/Common.js" />
/// <reference path="../Animation/Animations.js" />
Type.registerNamespace('AjaxControlToolkit.Animation');
AjaxControlToolkit.Animation.AnimationBehavior = function(element) {
/// <summary>
/// The AnimationBehavior allows us to associate animations (described by JSON) with events and
/// have them play when the events are fired. It relies heavily on the AJAX Control Toolkit
/// animation framework provided in Animation.js, and the GenericAnimationBehavior defined below.
/// </summary>
/// <param name="element" type="Sys.UI.DomElement" domElement="true">
/// The DOM element the behavior is associated with
/// </param>
AjaxControlToolkit.Animation.AnimationBehavior.initializeBase(this, [element]);
// Generic animation behaviors that automatically build animations from JSON descriptions
this._onLoad = null;
this._onClick = null;
this._onMouseOver = null;
this._onMouseOut = null;
this._onHoverOver = null;
this._onHoverOut = null;
// Handlers for the events
this._onClickHandler = null;
this._onMouseOverHandler = null;
this._onMouseOutHandler = null;
}
AjaxControlToolkit.Animation.AnimationBehavior.prototype = {
initialize : function() {
/// <summary>
/// Setup the animations/handlers
/// </summary>
/// <returns />
AjaxControlToolkit.Animation.AnimationBehavior.callBaseMethod(this, 'initialize');
// Wireup the event handlers
var element = this.get_element();
if (element) {
this._onClickHandler = Function.createDelegate(this, this.OnClick);
$addHandler(element, 'click', this._onClickHandler);
this._onMouseOverHandler = Function.createDelegate(this, this.OnMouseOver);
$addHandler(element, 'mouseover', this._onMouseOverHandler);
this._onMouseOutHandler = Function.createDelegate(this, this.OnMouseOut);
$addHandler(element, 'mouseout', this._onMouseOutHandler);
}
},
dispose : function() {
/// <summary>
/// Dispose of the animations/handlers
/// </summary>
/// <returns />
// Remove the event handlers
var element = this.get_element();
if (element) {
if (this._onClickHandler) {
$removeHandler(element, 'click', this._onClickHandler);
this._onClickHandler = null;
}
if (this._onMouseOverHandler) {
$removeHandler(element, 'mouseover', this._onMouseOverHandler);
this._onMouseOverHandler = null;
}
if (this._onMouseOutHandler) {
$removeHandler(element, 'mouseout', this._onMouseOutHandler);
this._onMouseOutHandler = null;
}
}
// Wipe the behaviors (we don't need to dispose them because
// that will happen automatically in our base dispose)
this._onLoad = null;
this._onClick = null;
this._onMouseOver = null;
this._onMouseOut = null;
this._onHoverOver = null;
this._onHoverOut = null;
AjaxControlToolkit.Animation.AnimationBehavior.callBaseMethod(this, 'dispose');
},
get_OnLoad : function() {
/// <value type="String" mayBeNull="true">
/// Generic OnLoad Animation's JSON definition
/// </value>
/// <remarks>
/// Setting the OnLoad property will cause it to be played immediately
/// </remarks>
return this._onLoad ? this._onLoad.get_json() : null;
},
set_OnLoad : function(value) {
if (!this._onLoad) {
this._onLoad = new AjaxControlToolkit.Animation.GenericAnimationBehavior(this.get_element());
this._onLoad.initialize();
}
this._onLoad.set_json(value);
this.raisePropertyChanged('OnLoad');
this._onLoad.play();
},
get_OnLoadBehavior : function() {
/// <value type="AjaxControlToolkit.Animation.GenericAnimationBehavior">
/// Generic OnLoad Animation's behavior
/// </value>
return this._onLoad;
},
get_OnClick : function() {
/// <value type="String" mayBeNull="true">
/// Generic OnClick Animation's JSON definition
/// </value>
return this._onClick ? this._onClick.get_json() : null;
},
set_OnClick : function(value) {
if (!this._onClick) {
this._onClick = new AjaxControlToolkit.Animation.GenericAnimationBehavior(this.get_element());
this._onClick.initialize();
}
this._onClick.set_json(value);
this.raisePropertyChanged('OnClick');
},
get_OnClickBehavior : function() {
/// <value type="AjaxControlToolkit.Animation.GenericAnimationBehavior">
/// Generic OnClick Animation's behavior
/// </value>
return this._onClick;
},
OnClick : function() {
/// <summary>
/// Play the OnClick animation
/// </summary>
/// <returns />
if (this._onClick) {
this._onClick.play();
}
},
get_OnMouseOver : function() {
/// <value type="String" mayBeNull="true">
/// Generic OnMouseOver Animation's JSON definition
/// </value>
return this._onMouseOver ? this._onMouseOver.get_json() : null;
},
set_OnMouseOver : function(value) {
if (!this._onMouseOver) {
this._onMouseOver = new AjaxControlToolkit.Animation.GenericAnimationBehavior(this.get_element());
this._onMouseOver.initialize();
}
this._onMouseOver.set_json(value);
this.raisePropertyChanged('OnMouseOver');
},
get_OnMouseOverBehavior : function() {
/// <value type="AjaxControlToolkit.Animation.GenericAnimationBehavior">
/// Generic OnMouseOver Animation's behavior
/// </value>
return this._onMouseOver;
},
OnMouseOver : function() {
/// <summary>
/// Play the OnMouseOver/OnHoverOver animations
/// </summary>
/// <returns />
if (this._onMouseOver) {
this._onMouseOver.play();
}
if (this._onHoverOver) {
if (this._onHoverOut) {
this._onHoverOut.quit();
}
this._onHoverOver.play();
}
},
get_OnMouseOut : function() {
/// <value type="String" mayBeNull="true">
/// Generic OnMouseOut Animation's JSON definition
/// </value>
return this._onMouseOut ? this._onMouseOut.get_json() : null;
},
set_OnMouseOut : function(value) {
if (!this._onMouseOut) {
this._onMouseOut = new AjaxControlToolkit.Animation.GenericAnimationBehavior(this.get_element());
this._onMouseOut.initialize();
}
this._onMouseOut.set_json(value);
this.raisePropertyChanged('OnMouseOut');
},
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -