Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MDL-28454 backport YUI 2.9.0 and 3.4.1 from master

  • Loading branch information...
commit a6bb03641e5db4bbcf9eadc877c6bf2afde47d1f 1 parent 263c528
@skodak skodak authored
Showing with 28 additions and 56,894 deletions.
  1. +25 −11 lib/outputrequirementslib.php
  2. +2 −2 lib/setup.php
  3. +1 −1  lib/thirdpartylibs.xml
  4. +0 −1,396 lib/yui/2.8.2/build/animation/animation-debug.js
  5. +0 −23 lib/yui/2.8.2/build/animation/animation-min.js
  6. +0 −1,392 lib/yui/2.8.2/build/animation/animation.js
  7. +0 −7 lib/yui/2.8.2/build/assets/skins/sam/autocomplete.css
  8. +0 −7 lib/yui/2.8.2/build/assets/skins/sam/button.css
  9. +0 −8 lib/yui/2.8.2/build/assets/skins/sam/calendar.css
  10. +0 −7 lib/yui/2.8.2/build/assets/skins/sam/carousel.css
  11. +0 −7 lib/yui/2.8.2/build/assets/skins/sam/colorpicker.css
  12. +0 −7 lib/yui/2.8.2/build/assets/skins/sam/container.css
  13. +0 −8 lib/yui/2.8.2/build/assets/skins/sam/datatable.css
  14. +0 −10 lib/yui/2.8.2/build/assets/skins/sam/editor.css
  15. +0 −7 lib/yui/2.8.2/build/assets/skins/sam/imagecropper.css
  16. +0 −7 lib/yui/2.8.2/build/assets/skins/sam/layout.css
  17. +0 −7 lib/yui/2.8.2/build/assets/skins/sam/logger.css
  18. +0 −7 lib/yui/2.8.2/build/assets/skins/sam/menu.css
  19. +0 −7 lib/yui/2.8.2/build/assets/skins/sam/paginator.css
  20. +0 −7 lib/yui/2.8.2/build/assets/skins/sam/profilerviewer.css
  21. +0 −7 lib/yui/2.8.2/build/assets/skins/sam/progressbar.css
  22. +0 −7 lib/yui/2.8.2/build/assets/skins/sam/resize.css
  23. +0 −10 lib/yui/2.8.2/build/assets/skins/sam/simpleeditor.css
  24. +0 −36 lib/yui/2.8.2/build/assets/skins/sam/skin.css
  25. +0 −7 lib/yui/2.8.2/build/assets/skins/sam/slider.css
  26. +0 −8 lib/yui/2.8.2/build/assets/skins/sam/tabview.css
  27. +0 −7 lib/yui/2.8.2/build/assets/skins/sam/treeview.css
  28. +0 −7 lib/yui/2.8.2/build/assets/skins/sam/yuitest.css
  29. +0 −7 lib/yui/2.8.2/build/autocomplete/assets/autocomplete-core.css
  30. +0 −57 lib/yui/2.8.2/build/autocomplete/assets/skins/sam/autocomplete-skin.css
  31. +0 −7 lib/yui/2.8.2/build/autocomplete/assets/skins/sam/autocomplete.css
  32. +0 −3,009 lib/yui/2.8.2/build/autocomplete/autocomplete-debug.js
  33. +0 −12 lib/yui/2.8.2/build/autocomplete/autocomplete-min.js
  34. +0 −2,966 lib/yui/2.8.2/build/autocomplete/autocomplete.js
  35. +0 −7 lib/yui/2.8.2/build/base/base-min.css
  36. +0 −131 lib/yui/2.8.2/build/base/base.css
  37. +0 −44 lib/yui/2.8.2/build/button/assets/button-core.css
  38. +0 −219 lib/yui/2.8.2/build/button/assets/skins/sam/button-skin.css
  39. +0 −7 lib/yui/2.8.2/build/button/assets/skins/sam/button.css
  40. +0 −4,694 lib/yui/2.8.2/build/button/button-debug.js
  41. +0 −11 lib/yui/2.8.2/build/button/button-min.js
  42. +0 −4,633 lib/yui/2.8.2/build/button/button.js
  43. +0 −132 lib/yui/2.8.2/build/calendar/assets/calendar-core.css
  44. +0 −320 lib/yui/2.8.2/build/calendar/assets/calendar.css
  45. +0 −361 lib/yui/2.8.2/build/calendar/assets/skins/sam/calendar-skin.css
  46. +0 −8 lib/yui/2.8.2/build/calendar/assets/skins/sam/calendar.css
  47. +0 −7,324 lib/yui/2.8.2/build/calendar/calendar-debug.js
  48. +0 −18 lib/yui/2.8.2/build/calendar/calendar-min.js
  49. +0 −7,294 lib/yui/2.8.2/build/calendar/calendar.js
  50. +0 −88 lib/yui/2.8.2/build/carousel/assets/carousel-core.css
  51. +0 −142 lib/yui/2.8.2/build/carousel/assets/skins/sam/carousel-skin.css
  52. +0 −7 lib/yui/2.8.2/build/carousel/assets/skins/sam/carousel.css
  53. +0 −4,390 lib/yui/2.8.2/build/carousel/carousel-debug.js
  54. +0 −12 lib/yui/2.8.2/build/carousel/carousel-min.js
  55. +0 −4,349 lib/yui/2.8.2/build/carousel/carousel.js
  56. BIN  lib/yui/2.8.2/build/charts/assets/charts.swf
  57. +0 −2,061 lib/yui/2.8.2/build/charts/charts-debug.js
  58. +0 −9 lib/yui/2.8.2/build/charts/charts-min.js
  59. +0 −2,060 lib/yui/2.8.2/build/charts/charts.js
  60. +0 −6 lib/yui/2.8.2/build/colorpicker/assets/colorpicker-core.css
  61. +0 −105 lib/yui/2.8.2/build/colorpicker/assets/skins/sam/colorpicker-skin.css
  62. +0 −7 lib/yui/2.8.2/build/colorpicker/assets/skins/sam/colorpicker.css
  63. +0 −1,783 lib/yui/2.8.2/build/colorpicker/colorpicker-debug.js
  64. +0 −9 lib/yui/2.8.2/build/colorpicker/colorpicker-min.js
  65. +0 −1,763 lib/yui/2.8.2/build/colorpicker/colorpicker.js
  66. +0 −1,576 lib/yui/2.8.2/build/connection/connection-debug.js
  67. +0 −9 lib/yui/2.8.2/build/connection/connection-min.js
  68. +0 −1,546 lib/yui/2.8.2/build/connection/connection.js
  69. +0 −980 lib/yui/2.8.2/build/connection/connection_core-debug.js
  70. +0 −8 lib/yui/2.8.2/build/connection/connection_core-min.js
  71. +0 −957 lib/yui/2.8.2/build/connection/connection_core.js
  72. +0 −176 lib/yui/2.8.2/build/container/assets/container-core.css
  73. +0 −324 lib/yui/2.8.2/build/container/assets/container.css
  74. +0 −242 lib/yui/2.8.2/build/container/assets/skins/sam/container-skin.css
  75. +0 −7 lib/yui/2.8.2/build/container/assets/skins/sam/container.css
Sorry, we could not display the entire diff because too many files (3,009) changed.
View
36 lib/outputrequirementslib.php
@@ -105,7 +105,7 @@ class page_requirements_manager {
protected $yui2loader;
/** YUI PHPLoader instance responsible for YUI3 loading from PHP only */
protected $yui3loader;
- /** YUI PHPLoader instance responsible for YUI3 loading from javascript */
+ /** YUI loader information for YUI3 loading from javascript */
protected $M_yui_loader;
/** some config vars exposed in JS, please no secret stuff there */
protected $M_cfg;
@@ -120,7 +120,7 @@ public function __construct() {
require_once("$CFG->libdir/yui/phploader/phploader/loader.php");
- $this->yui3loader = new YAHOO_util_Loader($CFG->yui3version);
+ $this->yui3loader = new stdClass();
$this->yui2loader = new YAHOO_util_Loader($CFG->yui2version);
// set up some loader options
@@ -201,11 +201,6 @@ public function __construct() {
$this->js_module($this->find_module('core_filepicker'));
$this->js_module($this->find_module('core_dock'));
- // YUI3 init code
- $libs = array('cssreset', 'cssbase', 'cssfonts', 'cssgrids', 'node', 'loader'); // full CSS reset + basic libs
- foreach ($libs as $lib) {
- $this->yui3loader->load($lib);
- }
}
/**
@@ -965,10 +960,29 @@ protected function get_javascript_init_code() {
* @return string
*/
protected function get_yui3lib_headcode() {
- $code = $this->yui3loader->tags();
- // unfortunately yui loader does not produce xhtml strict code, so let's fix it for now
- $code = str_replace('&', '&', $code);
- $code = str_replace('&', '&', $code);
+ global $CFG;
+
+ $code = '';
+
+ if ($this->yui3loader->combine) {
+ $code .= '<link rel="stylesheet" type="text/css" href="'.$this->yui3loader->comboBase
+ .$CFG->yui3version.'/build/cssreset/reset-min.css&amp;'
+ .$CFG->yui3version.'/build/cssfonts/fonts-min.css&amp;'
+ .$CFG->yui3version.'/build/cssgrids/grids-min.css&amp;'
+ .$CFG->yui3version.'/build/cssbase/base-min.css" />';
+ } else {
+ $code .= '<link rel="stylesheet" type="text/css" href="'.$this->yui3loader->base.'cssreset/reset-min.css" />';
+ $code .= '<link rel="stylesheet" type="text/css" href="'.$this->yui3loader->base.'cssfonts/fonts-min.css" />';
+ $code .= '<link rel="stylesheet" type="text/css" href="'.$this->yui3loader->base.'cssgrids/grids-min.css" />';
+ $code .= '<link rel="stylesheet" type="text/css" href="'.$this->yui3loader->base.'cssbase/base-min.css" />';
+ }
+
+ if (debugging('', DEBUG_DEVELOPER)) {
+ $code .= '<script src="'.$this->yui3loader->base.'yui/yui-debug.js"></script>';
+ } else {
+ $code .= '<script src="'.$this->yui3loader->base.'yui/yui-min.js"></script>';
+ }
+
return $code;
}
View
4 lib/setup.php
@@ -210,8 +210,8 @@
umask(0000);
// exact version of currently used yui2 and 3 library
-$CFG->yui2version = '2.8.2';
-$CFG->yui3version = '3.2.0';
+$CFG->yui2version = '2.9.0';
+$CFG->yui3version = '3.4.1';
// special support for highly optimised scripts that do not need libraries and DB connection
View
2  lib/thirdpartylibs.xml
@@ -228,7 +228,7 @@
<location>yui</location>
<name>YUI</name>
<license>BSD</license>
- <version>3.3.2</version>
+ <version>3.4.1</version>
<licenseversion></licenseversion>
</library>
<library>
View
1,396 lib/yui/2.8.2/build/animation/animation-debug.js
@@ -1,1396 +0,0 @@
-/*
-Copyright (c) 2010, Yahoo! Inc. All rights reserved.
-Code licensed under the BSD License:
-http://developer.yahoo.com/yui/license.html
-version: 2.8.1
-*/
-(function() {
-
-var Y = YAHOO.util;
-
-/*
-Copyright (c) 2006, Yahoo! Inc. All rights reserved.
-Code licensed under the BSD License:
-http://developer.yahoo.net/yui/license.txt
-*/
-
-/**
- * The animation module provides allows effects to be added to HTMLElements.
- * @module animation
- * @requires yahoo, event, dom
- */
-
-/**
- *
- * Base animation class that provides the interface for building animated effects.
- * <p>Usage: var myAnim = new YAHOO.util.Anim(el, { width: { from: 10, to: 100 } }, 1, YAHOO.util.Easing.easeOut);</p>
- * @class Anim
- * @namespace YAHOO.util
- * @requires YAHOO.util.AnimMgr
- * @requires YAHOO.util.Easing
- * @requires YAHOO.util.Dom
- * @requires YAHOO.util.Event
- * @requires YAHOO.util.CustomEvent
- * @constructor
- * @param {String | HTMLElement} el Reference to the element that will be animated
- * @param {Object} attributes The attribute(s) to be animated.
- * Each attribute is an object with at minimum a "to" or "by" member defined.
- * Additional optional members are "from" (defaults to current value), "units" (defaults to "px").
- * All attribute names use camelCase.
- * @param {Number} duration (optional, defaults to 1 second) Length of animation (frames or seconds), defaults to time-based
- * @param {Function} method (optional, defaults to YAHOO.util.Easing.easeNone) Computes the values that are applied to the attributes per frame (generally a YAHOO.util.Easing method)
- */
-
-var Anim = function(el, attributes, duration, method) {
- if (!el) {
- YAHOO.log('element required to create Anim instance', 'error', 'Anim');
- }
- this.init(el, attributes, duration, method);
-};
-
-Anim.NAME = 'Anim';
-
-Anim.prototype = {
- /**
- * Provides a readable name for the Anim instance.
- * @method toString
- * @return {String}
- */
- toString: function() {
- var el = this.getEl() || {};
- var id = el.id || el.tagName;
- return (this.constructor.NAME + ': ' + id);
- },
-
- patterns: { // cached for performance
- noNegatives: /width|height|opacity|padding/i, // keep at zero or above
- offsetAttribute: /^((width|height)|(top|left))$/, // use offsetValue as default
- defaultUnit: /width|height|top$|bottom$|left$|right$/i, // use 'px' by default
- offsetUnit: /\d+(em|%|en|ex|pt|in|cm|mm|pc)$/i // IE may return these, so convert these to offset
- },
-
- /**
- * Returns the value computed by the animation's "method".
- * @method doMethod
- * @param {String} attr The name of the attribute.
- * @param {Number} start The value this attribute should start from for this animation.
- * @param {Number} end The value this attribute should end at for this animation.
- * @return {Number} The Value to be applied to the attribute.
- */
- doMethod: function(attr, start, end) {
- return this.method(this.currentFrame, start, end - start, this.totalFrames);
- },
-
- /**
- * Applies a value to an attribute.
- * @method setAttribute
- * @param {String} attr The name of the attribute.
- * @param {Number} val The value to be applied to the attribute.
- * @param {String} unit The unit ('px', '%', etc.) of the value.
- */
- setAttribute: function(attr, val, unit) {
- var el = this.getEl();
- if ( this.patterns.noNegatives.test(attr) ) {
- val = (val > 0) ? val : 0;
- }
-
- if (attr in el && !('style' in el && attr in el.style)) {
- el[attr] = val;
- } else {
- Y.Dom.setStyle(el, attr, val + unit);
- }
- },
-
- /**
- * Returns current value of the attribute.
- * @method getAttribute
- * @param {String} attr The name of the attribute.
- * @return {Number} val The current value of the attribute.
- */
- getAttribute: function(attr) {
- var el = this.getEl();
- var val = Y.Dom.getStyle(el, attr);
-
- if (val !== 'auto' && !this.patterns.offsetUnit.test(val)) {
- return parseFloat(val);
- }
-
- var a = this.patterns.offsetAttribute.exec(attr) || [];
- var pos = !!( a[3] ); // top or left
- var box = !!( a[2] ); // width or height
-
- if ('style' in el) {
- // use offsets for width/height and abs pos top/left
- if ( box || (Y.Dom.getStyle(el, 'position') == 'absolute' && pos) ) {
- val = el['offset' + a[0].charAt(0).toUpperCase() + a[0].substr(1)];
- } else { // default to zero for other 'auto'
- val = 0;
- }
- } else if (attr in el) {
- val = el[attr];
- }
-
- return val;
- },
-
- /**
- * Returns the unit to use when none is supplied.
- * @method getDefaultUnit
- * @param {attr} attr The name of the attribute.
- * @return {String} The default unit to be used.
- */
- getDefaultUnit: function(attr) {
- if ( this.patterns.defaultUnit.test(attr) ) {
- return 'px';
- }
-
- return '';
- },
-
- /**
- * Sets the actual values to be used during the animation. Should only be needed for subclass use.
- * @method setRuntimeAttribute
- * @param {Object} attr The attribute object
- * @private
- */
- setRuntimeAttribute: function(attr) {
- var start;
- var end;
- var attributes = this.attributes;
-
- this.runtimeAttributes[attr] = {};
-
- var isset = function(prop) {
- return (typeof prop !== 'undefined');
- };
-
- if ( !isset(attributes[attr]['to']) && !isset(attributes[attr]['by']) ) {
- return false; // note return; nothing to animate to
- }
-
- start = ( isset(attributes[attr]['from']) ) ? attributes[attr]['from'] : this.getAttribute(attr);
-
- // To beats by, per SMIL 2.1 spec
- if ( isset(attributes[attr]['to']) ) {
- end = attributes[attr]['to'];
- } else if ( isset(attributes[attr]['by']) ) {
- if (start.constructor == Array) {
- end = [];
- for (var i = 0, len = start.length; i < len; ++i) {
- end[i] = start[i] + attributes[attr]['by'][i] * 1; // times 1 to cast "by"
- }
- } else {
- end = start + attributes[attr]['by'] * 1;
- }
- }
-
- this.runtimeAttributes[attr].start = start;
- this.runtimeAttributes[attr].end = end;
-
- // set units if needed
- this.runtimeAttributes[attr].unit = ( isset(attributes[attr].unit) ) ?
- attributes[attr]['unit'] : this.getDefaultUnit(attr);
- return true;
- },
-
- /**
- * Constructor for Anim instance.
- * @method init
- * @param {String | HTMLElement} el Reference to the element that will be animated
- * @param {Object} attributes The attribute(s) to be animated.
- * Each attribute is an object with at minimum a "to" or "by" member defined.
- * Additional optional members are "from" (defaults to current value), "units" (defaults to "px").
- * All attribute names use camelCase.
- * @param {Number} duration (optional, defaults to 1 second) Length of animation (frames or seconds), defaults to time-based
- * @param {Function} method (optional, defaults to YAHOO.util.Easing.easeNone) Computes the values that are applied to the attributes per frame (generally a YAHOO.util.Easing method)
- */
- init: function(el, attributes, duration, method) {
- /**
- * Whether or not the animation is running.
- * @property isAnimated
- * @private
- * @type Boolean
- */
- var isAnimated = false;
-
- /**
- * A Date object that is created when the animation begins.
- * @property startTime
- * @private
- * @type Date
- */
- var startTime = null;
-
- /**
- * The number of frames this animation was able to execute.
- * @property actualFrames
- * @private
- * @type Int
- */
- var actualFrames = 0;
-
- /**
- * The element to be animated.
- * @property el
- * @private
- * @type HTMLElement
- */
- el = Y.Dom.get(el);
-
- /**
- * The collection of attributes to be animated.
- * Each attribute must have at least a "to" or "by" defined in order to animate.
- * If "to" is supplied, the animation will end with the attribute at that value.
- * If "by" is supplied, the animation will end at that value plus its starting value.
- * If both are supplied, "to" is used, and "by" is ignored.
- * Optional additional member include "from" (the value the attribute should start animating from, defaults to current value), and "unit" (the units to apply to the values).
- * @property attributes
- * @type Object
- */
- this.attributes = attributes || {};
-
- /**
- * The length of the animation. Defaults to "1" (second).
- * @property duration
- * @type Number
- */
- this.duration = !YAHOO.lang.isUndefined(duration) ? duration : 1;
-
- /**
- * The method that will provide values to the attribute(s) during the animation.
- * Defaults to "YAHOO.util.Easing.easeNone".
- * @property method
- * @type Function
- */
- this.method = method || Y.Easing.easeNone;
-
- /**
- * Whether or not the duration should be treated as seconds.
- * Defaults to true.
- * @property useSeconds
- * @type Boolean
- */
- this.useSeconds = true; // default to seconds
-
- /**
- * The location of the current animation on the timeline.
- * In time-based animations, this is used by AnimMgr to ensure the animation finishes on time.
- * @property currentFrame
- * @type Int
- */
- this.currentFrame = 0;
-
- /**
- * The total number of frames to be executed.
- * In time-based animations, this is used by AnimMgr to ensure the animation finishes on time.
- * @property totalFrames
- * @type Int
- */
- this.totalFrames = Y.AnimMgr.fps;
-
- /**
- * Changes the animated element
- * @method setEl
- */
- this.setEl = function(element) {
- el = Y.Dom.get(element);
- };
-
- /**
- * Returns a reference to the animated element.
- * @method getEl
- * @return {HTMLElement}
- */
- this.getEl = function() { return el; };
-
- /**
- * Checks whether the element is currently animated.
- * @method isAnimated
- * @return {Boolean} current value of isAnimated.
- */
- this.isAnimated = function() {
- return isAnimated;
- };
-
- /**
- * Returns the animation start time.
- * @method getStartTime
- * @return {Date} current value of startTime.
- */
- this.getStartTime = function() {
- return startTime;
- };
-
- this.runtimeAttributes = {};
-
- var logger = {};
- logger.log = function() {YAHOO.log.apply(window, arguments)};
-
- logger.log('creating new instance of ' + this);
-
- /**
- * Starts the animation by registering it with the animation manager.
- * @method animate
- */
- this.animate = function() {
- if ( this.isAnimated() ) {
- return false;
- }
-
- this.currentFrame = 0;
-
- this.totalFrames = ( this.useSeconds ) ? Math.ceil(Y.AnimMgr.fps * this.duration) : this.duration;
-
- if (this.duration === 0 && this.useSeconds) { // jump to last frame if zero second duration
- this.totalFrames = 1;
- }
- Y.AnimMgr.registerElement(this);
- return true;
- };
-
- /**
- * Stops the animation. Normally called by AnimMgr when animation completes.
- * @method stop
- * @param {Boolean} finish (optional) If true, animation will jump to final frame.
- */
- this.stop = function(finish) {
- if (!this.isAnimated()) { // nothing to stop
- return false;
- }
-
- if (finish) {
- this.currentFrame = this.totalFrames;
- this._onTween.fire();
- }
- Y.AnimMgr.stop(this);
- };
-
- var onStart = function() {
- this.onStart.fire();
-
- this.runtimeAttributes = {};
- for (var attr in this.attributes) {
- this.setRuntimeAttribute(attr);
- }
-
- isAnimated = true;
- actualFrames = 0;
- startTime = new Date();
- };
-
- /**
- * Feeds the starting and ending values for each animated attribute to doMethod once per frame, then applies the resulting value to the attribute(s).
- * @private
- */
-
- var onTween = function() {
- var data = {
- duration: new Date() - this.getStartTime(),
- currentFrame: this.currentFrame
- };
-
- data.toString = function() {
- return (
- 'duration: ' + data.duration +
- ', currentFrame: ' + data.currentFrame
- );
- };
-
- this.onTween.fire(data);
-
- var runtimeAttributes = this.runtimeAttributes;
-
- for (var attr in runtimeAttributes) {
- this.setAttribute(attr, this.doMethod(attr, runtimeAttributes[attr].start, runtimeAttributes[attr].end), runtimeAttributes[attr].unit);
- }
-
- actualFrames += 1;
- };
-
- var onComplete = function() {
- var actual_duration = (new Date() - startTime) / 1000 ;
-
- var data = {
- duration: actual_duration,
- frames: actualFrames,
- fps: actualFrames / actual_duration
- };
-
- data.toString = function() {
- return (
- 'duration: ' + data.duration +
- ', frames: ' + data.frames +
- ', fps: ' + data.fps
- );
- };
-
- isAnimated = false;
- actualFrames = 0;
- this.onComplete.fire(data);
- };
-
- /**
- * Custom event that fires after onStart, useful in subclassing
- * @private
- */
- this._onStart = new Y.CustomEvent('_start', this, true);
-
- /**
- * Custom event that fires when animation begins
- * Listen via subscribe method (e.g. myAnim.onStart.subscribe(someFunction)
- * @event onStart
- */
- this.onStart = new Y.CustomEvent('start', this);
-
- /**
- * Custom event that fires between each frame
- * Listen via subscribe method (e.g. myAnim.onTween.subscribe(someFunction)
- * @event onTween
- */
- this.onTween = new Y.CustomEvent('tween', this);
-
- /**
- * Custom event that fires after onTween
- * @private
- */
- this._onTween = new Y.CustomEvent('_tween', this, true);
-
- /**
- * Custom event that fires when animation ends
- * Listen via subscribe method (e.g. myAnim.onComplete.subscribe(someFunction)
- * @event onComplete
- */
- this.onComplete = new Y.CustomEvent('complete', this);
- /**
- * Custom event that fires after onComplete
- * @private
- */
- this._onComplete = new Y.CustomEvent('_complete', this, true);
-
- this._onStart.subscribe(onStart);
- this._onTween.subscribe(onTween);
- this._onComplete.subscribe(onComplete);
- }
-};
-
- Y.Anim = Anim;
-})();
-/**
- * Handles animation queueing and threading.
- * Used by Anim and subclasses.
- * @class AnimMgr
- * @namespace YAHOO.util
- */
-YAHOO.util.AnimMgr = new function() {
- /**
- * Reference to the animation Interval.
- * @property thread
- * @private
- * @type Int
- */
- var thread = null;
-
- /**
- * The current queue of registered animation objects.
- * @property queue
- * @private
- * @type Array
- */
- var queue = [];
-
- /**
- * The number of active animations.
- * @property tweenCount
- * @private
- * @type Int
- */
- var tweenCount = 0;
-
- /**
- * Base frame rate (frames per second).
- * Arbitrarily high for better x-browser calibration (slower browsers drop more frames).
- * @property fps
- * @type Int
- *
- */
- this.fps = 1000;
-
- /**
- * Interval delay in milliseconds, defaults to fastest possible.
- * @property delay
- * @type Int
- *
- */
- this.delay = 1;
-
- /**
- * Adds an animation instance to the animation queue.
- * All animation instances must be registered in order to animate.
- * @method registerElement
- * @param {object} tween The Anim instance to be be registered
- */
- this.registerElement = function(tween) {
- queue[queue.length] = tween;
- tweenCount += 1;
- tween._onStart.fire();
- this.start();
- };
-
- /**
- * removes an animation instance from the animation queue.
- * All animation instances must be registered in order to animate.
- * @method unRegister
- * @param {object} tween The Anim instance to be be registered
- * @param {Int} index The index of the Anim instance
- * @private
- */
- this.unRegister = function(tween, index) {
- index = index || getIndex(tween);
- if (!tween.isAnimated() || index === -1) {
- return false;
- }
-
- tween._onComplete.fire();
- queue.splice(index, 1);
-
- tweenCount -= 1;
- if (tweenCount <= 0) {
- this.stop();
- }
-
- return true;
- };
-
- /**
- * Starts the animation thread.
- * Only one thread can run at a time.
- * @method start
- */
- this.start = function() {
- if (thread === null) {
- thread = setInterval(this.run, this.delay);
- }
- };
-
- /**
- * Stops the animation thread or a specific animation instance.
- * @method stop
- * @param {object} tween A specific Anim instance to stop (optional)
- * If no instance given, Manager stops thread and all animations.
- */
- this.stop = function(tween) {
- if (!tween) {
- clearInterval(thread);
-
- for (var i = 0, len = queue.length; i < len; ++i) {
- this.unRegister(queue[0], 0);
- }
-
- queue = [];
- thread = null;
- tweenCount = 0;
- }
- else {
- this.unRegister(tween);
- }
- };
-
- /**
- * Called per Interval to handle each animation frame.
- * @method run
- */
- this.run = function() {
- for (var i = 0, len = queue.length; i < len; ++i) {
- var tween = queue[i];
- if ( !tween || !tween.isAnimated() ) { continue; }
-
- if (tween.currentFrame < tween.totalFrames || tween.totalFrames === null)
- {
- tween.currentFrame += 1;
-
- if (tween.useSeconds) {
- correctFrame(tween);
- }
- tween._onTween.fire();
- }
- else { YAHOO.util.AnimMgr.stop(tween, i); }
- }
- };
-
- var getIndex = function(anim) {
- for (var i = 0, len = queue.length; i < len; ++i) {
- if (queue[i] === anim) {
- return i; // note return;
- }
- }
- return -1;
- };
-
- /**
- * On the fly frame correction to keep animation on time.
- * @method correctFrame
- * @private
- * @param {Object} tween The Anim instance being corrected.
- */
- var correctFrame = function(tween) {
- var frames = tween.totalFrames;
- var frame = tween.currentFrame;
- var expected = (tween.currentFrame * tween.duration * 1000 / tween.totalFrames);
- var elapsed = (new Date() - tween.getStartTime());
- var tweak = 0;
-
- if (elapsed < tween.duration * 1000) { // check if falling behind
- tweak = Math.round((elapsed / expected - 1) * tween.currentFrame);
- } else { // went over duration, so jump to end
- tweak = frames - (frame + 1);
- }
- if (tweak > 0 && isFinite(tweak)) { // adjust if needed
- if (tween.currentFrame + tweak >= frames) {// dont go past last frame
- tweak = frames - (frame + 1);
- }
-
- tween.currentFrame += tweak;
- }
- };
- this._queue = queue;
- this._getIndex = getIndex;
-};
-/**
- * Used to calculate Bezier splines for any number of control points.
- * @class Bezier
- * @namespace YAHOO.util
- *
- */
-YAHOO.util.Bezier = new function() {
- /**
- * Get the current position of the animated element based on t.
- * Each point is an array of "x" and "y" values (0 = x, 1 = y)
- * At least 2 points are required (start and end).
- * First point is start. Last point is end.
- * Additional control points are optional.
- * @method getPosition
- * @param {Array} points An array containing Bezier points
- * @param {Number} t A number between 0 and 1 which is the basis for determining current position
- * @return {Array} An array containing int x and y member data
- */
- this.getPosition = function(points, t) {
- var n = points.length;
- var tmp = [];
-
- for (var i = 0; i < n; ++i){
- tmp[i] = [points[i][0], points[i][1]]; // save input
- }
-
- for (var j = 1; j < n; ++j) {
- for (i = 0; i < n - j; ++i) {
- tmp[i][0] = (1 - t) * tmp[i][0] + t * tmp[parseInt(i + 1, 10)][0];
- tmp[i][1] = (1 - t) * tmp[i][1] + t * tmp[parseInt(i + 1, 10)][1];
- }
- }
-
- return [ tmp[0][0], tmp[0][1] ];
-
- };
-};
-(function() {
-/**
- * Anim subclass for color transitions.
- * <p>Usage: <code>var myAnim = new Y.ColorAnim(el, { backgroundColor: { from: '#FF0000', to: '#FFFFFF' } }, 1, Y.Easing.easeOut);</code> Color values can be specified with either 112233, #112233,
- * [255,255,255], or rgb(255,255,255)</p>
- * @class ColorAnim
- * @namespace YAHOO.util
- * @requires YAHOO.util.Anim
- * @requires YAHOO.util.AnimMgr
- * @requires YAHOO.util.Easing
- * @requires YAHOO.util.Bezier
- * @requires YAHOO.util.Dom
- * @requires YAHOO.util.Event
- * @constructor
- * @extends YAHOO.util.Anim
- * @param {HTMLElement | String} el Reference to the element that will be animated
- * @param {Object} attributes The attribute(s) to be animated.
- * Each attribute is an object with at minimum a "to" or "by" member defined.
- * Additional optional members are "from" (defaults to current value), "units" (defaults to "px").
- * All attribute names use camelCase.
- * @param {Number} duration (optional, defaults to 1 second) Length of animation (frames or seconds), defaults to time-based
- * @param {Function} method (optional, defaults to YAHOO.util.Easing.easeNone) Computes the values that are applied to the attributes per frame (generally a YAHOO.util.Easing method)
- */
- var ColorAnim = function(el, attributes, duration, method) {
- ColorAnim.superclass.constructor.call(this, el, attributes, duration, method);
- };
-
- ColorAnim.NAME = 'ColorAnim';
-
- ColorAnim.DEFAULT_BGCOLOR = '#fff';
- // shorthand
- var Y = YAHOO.util;
- YAHOO.extend(ColorAnim, Y.Anim);
-
- var superclass = ColorAnim.superclass;
- var proto = ColorAnim.prototype;
-
- proto.patterns.color = /color$/i;
- proto.patterns.rgb = /^rgb\(([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\)$/i;
- proto.patterns.hex = /^#?([0-9A-F]{2})([0-9A-F]{2})([0-9A-F]{2})$/i;
- proto.patterns.hex3 = /^#?([0-9A-F]{1})([0-9A-F]{1})([0-9A-F]{1})$/i;
- proto.patterns.transparent = /^transparent|rgba\(0, 0, 0, 0\)$/; // need rgba for safari
-
- /**
- * Attempts to parse the given string and return a 3-tuple.
- * @method parseColor
- * @param {String} s The string to parse.
- * @return {Array} The 3-tuple of rgb values.
- */
- proto.parseColor = function(s) {
- if (s.length == 3) { return s; }
-
- var c = this.patterns.hex.exec(s);
- if (c && c.length == 4) {
- return [ parseInt(c[1], 16), parseInt(c[2], 16), parseInt(c[3], 16) ];
- }
-
- c = this.patterns.rgb.exec(s);
- if (c && c.length == 4) {
- return [ parseInt(c[1], 10), parseInt(c[2], 10), parseInt(c[3], 10) ];
- }
-
- c = this.patterns.hex3.exec(s);
- if (c && c.length == 4) {
- return [ parseInt(c[1] + c[1], 16), parseInt(c[2] + c[2], 16), parseInt(c[3] + c[3], 16) ];
- }
-
- return null;
- };
-
- proto.getAttribute = function(attr) {
- var el = this.getEl();
- if (this.patterns.color.test(attr) ) {
- var val = YAHOO.util.Dom.getStyle(el, attr);
-
- var that = this;
- if (this.patterns.transparent.test(val)) { // bgcolor default
- var parent = YAHOO.util.Dom.getAncestorBy(el, function(node) {
- return !that.patterns.transparent.test(val);
- });
-
- if (parent) {
- val = Y.Dom.getStyle(parent, attr);
- } else {
- val = ColorAnim.DEFAULT_BGCOLOR;
- }
- }
- } else {
- val = superclass.getAttribute.call(this, attr);
- }
-
- return val;
- };
-
- proto.doMethod = function(attr, start, end) {
- var val;
-
- if ( this.patterns.color.test(attr) ) {
- val = [];
- for (var i = 0, len = start.length; i < len; ++i) {
- val[i] = superclass.doMethod.call(this, attr, start[i], end[i]);
- }
-
- val = 'rgb('+Math.floor(val[0])+','+Math.floor(val[1])+','+Math.floor(val[2])+')';
- }
- else {
- val = superclass.doMethod.call(this, attr, start, end);
- }
-
- return val;
- };
-
- proto.setRuntimeAttribute = function(attr) {
- superclass.setRuntimeAttribute.call(this, attr);
-
- if ( this.patterns.color.test(attr) ) {
- var attributes = this.attributes;
- var start = this.parseColor(this.runtimeAttributes[attr].start);
- var end = this.parseColor(this.runtimeAttributes[attr].end);
- // fix colors if going "by"
- if ( typeof attributes[attr]['to'] === 'undefined' && typeof attributes[attr]['by'] !== 'undefined' ) {
- end = this.parseColor(attributes[attr].by);
-
- for (var i = 0, len = start.length; i < len; ++i) {
- end[i] = start[i] + end[i];
- }
- }
-
- this.runtimeAttributes[attr].start = start;
- this.runtimeAttributes[attr].end = end;
- }
- };
-
- Y.ColorAnim = ColorAnim;
-})();
-/*!
-TERMS OF USE - EASING EQUATIONS
-Open source under the BSD License.
-Copyright 2001 Robert Penner All rights reserved.
-
-Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- * Neither the name of the author nor the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-/**
- * Singleton that determines how an animation proceeds from start to end.
- * @class Easing
- * @namespace YAHOO.util
-*/
-
-YAHOO.util.Easing = {
-
- /**
- * Uniform speed between points.
- * @method easeNone
- * @param {Number} t Time value used to compute current value
- * @param {Number} b Starting value
- * @param {Number} c Delta between start and end values
- * @param {Number} d Total length of animation
- * @return {Number} The computed value for the current animation frame
- */
- easeNone: function (t, b, c, d) {
- return c*t/d + b;
- },
-
- /**
- * Begins slowly and accelerates towards end.
- * @method easeIn
- * @param {Number} t Time value used to compute current value
- * @param {Number} b Starting value
- * @param {Number} c Delta between start and end values
- * @param {Number} d Total length of animation
- * @return {Number} The computed value for the current animation frame
- */
- easeIn: function (t, b, c, d) {
- return c*(t/=d)*t + b;
- },
-
- /**
- * Begins quickly and decelerates towards end.
- * @method easeOut
- * @param {Number} t Time value used to compute current value
- * @param {Number} b Starting value
- * @param {Number} c Delta between start and end values
- * @param {Number} d Total length of animation
- * @return {Number} The computed value for the current animation frame
- */
- easeOut: function (t, b, c, d) {
- return -c *(t/=d)*(t-2) + b;
- },
-
- /**
- * Begins slowly and decelerates towards end.
- * @method easeBoth
- * @param {Number} t Time value used to compute current value
- * @param {Number} b Starting value
- * @param {Number} c Delta between start and end values
- * @param {Number} d Total length of animation
- * @return {Number} The computed value for the current animation frame
- */
- easeBoth: function (t, b, c, d) {
- if ((t/=d/2) < 1) {
- return c/2*t*t + b;
- }
-
- return -c/2 * ((--t)*(t-2) - 1) + b;
- },
-
- /**
- * Begins slowly and accelerates towards end.
- * @method easeInStrong
- * @param {Number} t Time value used to compute current value
- * @param {Number} b Starting value
- * @param {Number} c Delta between start and end values
- * @param {Number} d Total length of animation
- * @return {Number} The computed value for the current animation frame
- */
- easeInStrong: function (t, b, c, d) {
- return c*(t/=d)*t*t*t + b;
- },
-
- /**
- * Begins quickly and decelerates towards end.
- * @method easeOutStrong
- * @param {Number} t Time value used to compute current value
- * @param {Number} b Starting value
- * @param {Number} c Delta between start and end values
- * @param {Number} d Total length of animation
- * @return {Number} The computed value for the current animation frame
- */
- easeOutStrong: function (t, b, c, d) {
- return -c * ((t=t/d-1)*t*t*t - 1) + b;
- },
-
- /**
- * Begins slowly and decelerates towards end.
- * @method easeBothStrong
- * @param {Number} t Time value used to compute current value
- * @param {Number} b Starting value
- * @param {Number} c Delta between start and end values
- * @param {Number} d Total length of animation
- * @return {Number} The computed value for the current animation frame
- */
- easeBothStrong: function (t, b, c, d) {
- if ((t/=d/2) < 1) {
- return c/2*t*t*t*t + b;
- }
-
- return -c/2 * ((t-=2)*t*t*t - 2) + b;
- },
-
- /**
- * Snap in elastic effect.
- * @method elasticIn
- * @param {Number} t Time value used to compute current value
- * @param {Number} b Starting value
- * @param {Number} c Delta between start and end values
- * @param {Number} d Total length of animation
- * @param {Number} a Amplitude (optional)
- * @param {Number} p Period (optional)
- * @return {Number} The computed value for the current animation frame
- */
-
- elasticIn: function (t, b, c, d, a, p) {
- if (t == 0) {
- return b;
- }
- if ( (t /= d) == 1 ) {
- return b+c;
- }
- if (!p) {
- p=d*.3;
- }
-
- if (!a || a < Math.abs(c)) {
- a = c;
- var s = p/4;
- }
- else {
- var s = p/(2*Math.PI) * Math.asin (c/a);
- }
-
- return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
- },
-
- /**
- * Snap out elastic effect.
- * @method elasticOut
- * @param {Number} t Time value used to compute current value
- * @param {Number} b Starting value
- * @param {Number} c Delta between start and end values
- * @param {Number} d Total length of animation
- * @param {Number} a Amplitude (optional)
- * @param {Number} p Period (optional)
- * @return {Number} The computed value for the current animation frame
- */
- elasticOut: function (t, b, c, d, a, p) {
- if (t == 0) {
- return b;
- }
- if ( (t /= d) == 1 ) {
- return b+c;
- }
- if (!p) {
- p=d*.3;
- }
-
- if (!a || a < Math.abs(c)) {
- a = c;
- var s = p / 4;
- }
- else {
- var s = p/(2*Math.PI) * Math.asin (c/a);
- }
-
- return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
- },
-
- /**
- * Snap both elastic effect.
- * @method elasticBoth
- * @param {Number} t Time value used to compute current value
- * @param {Number} b Starting value
- * @param {Number} c Delta between start and end values
- * @param {Number} d Total length of animation
- * @param {Number} a Amplitude (optional)
- * @param {Number} p Period (optional)
- * @return {Number} The computed value for the current animation frame
- */
- elasticBoth: function (t, b, c, d, a, p) {
- if (t == 0) {
- return b;
- }
-
- if ( (t /= d/2) == 2 ) {
- return b+c;
- }
-
- if (!p) {
- p = d*(.3*1.5);
- }
-
- if ( !a || a < Math.abs(c) ) {
- a = c;
- var s = p/4;
- }
- else {
- var s = p/(2*Math.PI) * Math.asin (c/a);
- }
-
- if (t < 1) {
- return -.5*(a*Math.pow(2,10*(t-=1)) *
- Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
- }
- return a*Math.pow(2,-10*(t-=1)) *
- Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
- },
-
-
- /**
- * Backtracks slightly, then reverses direction and moves to end.
- * @method backIn
- * @param {Number} t Time value used to compute current value
- * @param {Number} b Starting value
- * @param {Number} c Delta between start and end values
- * @param {Number} d Total length of animation
- * @param {Number} s Overshoot (optional)
- * @return {Number} The computed value for the current animation frame
- */
- backIn: function (t, b, c, d, s) {
- if (typeof s == 'undefined') {
- s = 1.70158;
- }
- return c*(t/=d)*t*((s+1)*t - s) + b;
- },
-
- /**
- * Overshoots end, then reverses and comes back to end.
- * @method backOut
- * @param {Number} t Time value used to compute current value
- * @param {Number} b Starting value
- * @param {Number} c Delta between start and end values
- * @param {Number} d Total length of animation
- * @param {Number} s Overshoot (optional)
- * @return {Number} The computed value for the current animation frame
- */
- backOut: function (t, b, c, d, s) {
- if (typeof s == 'undefined') {
- s = 1.70158;
- }
- return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
- },
-
- /**
- * Backtracks slightly, then reverses direction, overshoots end,
- * then reverses and comes back to end.
- * @method backBoth
- * @param {Number} t Time value used to compute current value
- * @param {Number} b Starting value
- * @param {Number} c Delta between start and end values
- * @param {Number} d Total length of animation
- * @param {Number} s Overshoot (optional)
- * @return {Number} The computed value for the current animation frame
- */
- backBoth: function (t, b, c, d, s) {
- if (typeof s == 'undefined') {
- s = 1.70158;
- }
-
- if ((t /= d/2 ) < 1) {
- return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
- }
- return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
- },
-
- /**
- * Bounce off of start.
- * @method bounceIn
- * @param {Number} t Time value used to compute current value
- * @param {Number} b Starting value
- * @param {Number} c Delta between start and end values
- * @param {Number} d Total length of animation
- * @return {Number} The computed value for the current animation frame
- */
- bounceIn: function (t, b, c, d) {
- return c - YAHOO.util.Easing.bounceOut(d-t, 0, c, d) + b;
- },
-
- /**
- * Bounces off end.
- * @method bounceOut
- * @param {Number} t Time value used to compute current value
- * @param {Number} b Starting value
- * @param {Number} c Delta between start and end values
- * @param {Number} d Total length of animation
- * @return {Number} The computed value for the current animation frame
- */
- bounceOut: function (t, b, c, d) {
- if ((t/=d) < (1/2.75)) {
- return c*(7.5625*t*t) + b;
- } else if (t < (2/2.75)) {
- return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
- } else if (t < (2.5/2.75)) {
- return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
- }
- return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
- },
-
- /**
- * Bounces off start and end.
- * @method bounceBoth
- * @param {Number} t Time value used to compute current value
- * @param {Number} b Starting value
- * @param {Number} c Delta between start and end values
- * @param {Number} d Total length of animation
- * @return {Number} The computed value for the current animation frame
- */
- bounceBoth: function (t, b, c, d) {
- if (t < d/2) {
- return YAHOO.util.Easing.bounceIn(t*2, 0, c, d) * .5 + b;
- }
- return YAHOO.util.Easing.bounceOut(t*2-d, 0, c, d) * .5 + c*.5 + b;
- }
-};
-
-(function() {
-/**
- * Anim subclass for moving elements along a path defined by the "points"
- * member of "attributes". All "points" are arrays with x, y coordinates.
- * <p>Usage: <code>var myAnim = new YAHOO.util.Motion(el, { points: { to: [800, 800] } }, 1, YAHOO.util.Easing.easeOut);</code></p>
- * @class Motion
- * @namespace YAHOO.util
- * @requires YAHOO.util.Anim
- * @requires YAHOO.util.AnimMgr
- * @requires YAHOO.util.Easing
- * @requires YAHOO.util.Bezier
- * @requires YAHOO.util.Dom
- * @requires YAHOO.util.Event
- * @requires YAHOO.util.CustomEvent
- * @constructor
- * @extends YAHOO.util.ColorAnim
- * @param {String | HTMLElement} el Reference to the element that will be animated
- * @param {Object} attributes The attribute(s) to be animated.
- * Each attribute is an object with at minimum a "to" or "by" member defined.
- * Additional optional members are "from" (defaults to current value), "units" (defaults to "px").
- * All attribute names use camelCase.
- * @param {Number} duration (optional, defaults to 1 second) Length of animation (frames or seconds), defaults to time-based
- * @param {Function} method (optional, defaults to YAHOO.util.Easing.easeNone) Computes the values that are applied to the attributes per frame (generally a YAHOO.util.Easing method)
- */
- var Motion = function(el, attributes, duration, method) {
- if (el) { // dont break existing subclasses not using YAHOO.extend
- Motion.superclass.constructor.call(this, el, attributes, duration, method);
- }
- };
-
-
- Motion.NAME = 'Motion';
-
- // shorthand
- var Y = YAHOO.util;
- YAHOO.extend(Motion, Y.ColorAnim);
-
- var superclass = Motion.superclass;
- var proto = Motion.prototype;
-
- proto.patterns.points = /^points$/i;
-
- proto.setAttribute = function(attr, val, unit) {
- if ( this.patterns.points.test(attr) ) {
- unit = unit || 'px';
- superclass.setAttribute.call(this, 'left', val[0], unit);
- superclass.setAttribute.call(this, 'top', val[1], unit);
- } else {
- superclass.setAttribute.call(this, attr, val, unit);
- }
- };
-
- proto.getAttribute = function(attr) {
- if ( this.patterns.points.test(attr) ) {
- var val = [
- superclass.getAttribute.call(this, 'left'),
- superclass.getAttribute.call(this, 'top')
- ];
- } else {
- val = superclass.getAttribute.call(this, attr);
- }
-
- return val;
- };
-
- proto.doMethod = function(attr, start, end) {
- var val = null;
-
- if ( this.patterns.points.test(attr) ) {
- var t = this.method(this.currentFrame, 0, 100, this.totalFrames) / 100;
- val = Y.Bezier.getPosition(this.runtimeAttributes[attr], t);
- } else {
- val = superclass.doMethod.call(this, attr, start, end);
- }
- return val;
- };
-
- proto.setRuntimeAttribute = function(attr) {
- if ( this.patterns.points.test(attr) ) {
- var el = this.getEl();
- var attributes = this.attributes;
- var start;
- var control = attributes['points']['control'] || [];
- var end;
- var i, len;
-
- if (control.length > 0 && !(control[0] instanceof Array) ) { // could be single point or array of points
- control = [control];
- } else { // break reference to attributes.points.control
- var tmp = [];
- for (i = 0, len = control.length; i< len; ++i) {
- tmp[i] = control[i];
- }
- control = tmp;
- }
-
- if (Y.Dom.getStyle(el, 'position') == 'static') { // default to relative
- Y.Dom.setStyle(el, 'position', 'relative');
- }
-
- if ( isset(attributes['points']['from']) ) {
- Y.Dom.setXY(el, attributes['points']['from']); // set position to from point
- }
- else { Y.Dom.setXY( el, Y.Dom.getXY(el) ); } // set it to current position
-
- start = this.getAttribute('points'); // get actual top & left
-
- // TO beats BY, per SMIL 2.1 spec
- if ( isset(attributes['points']['to']) ) {
- end = translateValues.call(this, attributes['points']['to'], start);
-
- var pageXY = Y.Dom.getXY(this.getEl());
- for (i = 0, len = control.length; i < len; ++i) {
- control[i] = translateValues.call(this, control[i], start);
- }
-
-
- } else if ( isset(attributes['points']['by']) ) {
- end = [ start[0] + attributes['points']['by'][0], start[1] + attributes['points']['by'][1] ];
-
- for (i = 0, len = control.length; i < len; ++i) {
- control[i] = [ start[0] + control[i][0], start[1] + control[i][1] ];
- }
- }
-
- this.runtimeAttributes[attr] = [start];
-
- if (control.length > 0) {
- this.runtimeAttributes[attr] = this.runtimeAttributes[attr].concat(control);
- }
-
- this.runtimeAttributes[attr][this.runtimeAttributes[attr].length] = end;
- }
- else {
- superclass.setRuntimeAttribute.call(this, attr);
- }
- };
-
- var translateValues = function(val, start) {
- var pageXY = Y.Dom.getXY(this.getEl());
- val = [ val[0] - pageXY[0] + start[0], val[1] - pageXY[1] + start[1] ];
-
- return val;
- };
-
- var isset = function(prop) {
- return (typeof prop !== 'undefined');
- };
-
- Y.Motion = Motion;
-})();
-(function() {
-/**
- * Anim subclass for scrolling elements to a position defined by the "scroll"
- * member of "attributes". All "scroll" members are arrays with x, y scroll positions.
- * <p>Usage: <code>var myAnim = new YAHOO.util.Scroll(el, { scroll: { to: [0, 800] } }, 1, YAHOO.util.Easing.easeOut);</code></p>
- * @class Scroll
- * @namespace YAHOO.util
- * @requires YAHOO.util.Anim
- * @requires YAHOO.util.AnimMgr
- * @requires YAHOO.util.Easing
- * @requires YAHOO.util.Bezier
- * @requires YAHOO.util.Dom
- * @requires YAHOO.util.Event
- * @requires YAHOO.util.CustomEvent
- * @extends YAHOO.util.ColorAnim
- * @constructor
- * @param {String or HTMLElement} el Reference to the element that will be animated
- * @param {Object} attributes The attribute(s) to be animated.
- * Each attribute is an object with at minimum a "to" or "by" member defined.
- * Additional optional members are "from" (defaults to current value), "units" (defaults to "px").
- * All attribute names use camelCase.
- * @param {Number} duration (optional, defaults to 1 second) Length of animation (frames or seconds), defaults to time-based
- * @param {Function} method (optional, defaults to YAHOO.util.Easing.easeNone) Computes the values that are applied to the attributes per frame (generally a YAHOO.util.Easing method)
- */
- var Scroll = function(el, attributes, duration, method) {
- if (el) { // dont break existing subclasses not using YAHOO.extend
- Scroll.superclass.constructor.call(this, el, attributes, duration, method);
- }
- };
-
- Scroll.NAME = 'Scroll';
-
- // shorthand
- var Y = YAHOO.util;
- YAHOO.extend(Scroll, Y.ColorAnim);
-
- var superclass = Scroll.superclass;
- var proto = Scroll.prototype;
-
- proto.doMethod = function(attr, start, end) {
- var val = null;
-
- if (attr == 'scroll') {
- val = [
- this.method(this.currentFrame, start[0], end[0] - start[0], this.totalFrames),
- this.method(this.currentFrame, start[1], end[1] - start[1], this.totalFrames)
- ];
-
- } else {
- val = superclass.doMethod.call(this, attr, start, end);
- }
- return val;
- };
-
- proto.getAttribute = function(attr) {
- var val = null;
- var el = this.getEl();
-
- if (attr == 'scroll') {
- val = [ el.scrollLeft, el.scrollTop ];
- } else {
- val = superclass.getAttribute.call(this, attr);
- }
-
- return val;
- };
-
- proto.setAttribute = function(attr, val, unit) {
- var el = this.getEl();
-
- if (attr == 'scroll') {
- el.scrollLeft = val[0];
- el.scrollTop = val[1];
- } else {
- superclass.setAttribute.call(this, attr, val, unit);
- }
- };
-
- Y.Scroll = Scroll;
-})();
-YAHOO.register("animation", YAHOO.util.Anim, {version: "2.8.1", build: "19"});
View
23 lib/yui/2.8.2/build/animation/animation-min.js
@@ -1,23 +0,0 @@
-/*
-Copyright (c) 2010, Yahoo! Inc. All rights reserved.
-Code licensed under the BSD License:
-http://developer.yahoo.com/yui/license.html
-version: 2.8.1
-*/
-(function(){var B=YAHOO.util;var A=function(D,C,E,F){if(!D){}this.init(D,C,E,F);};A.NAME="Anim";A.prototype={toString:function(){var C=this.getEl()||{};var D=C.id||C.tagName;return(this.constructor.NAME+": "+D);},patterns:{noNegatives:/width|height|opacity|padding/i,offsetAttribute:/^((width|height)|(top|left))$/,defaultUnit:/width|height|top$|bottom$|left$|right$/i,offsetUnit:/\d+(em|%|en|ex|pt|in|cm|mm|pc)$/i},doMethod:function(C,E,D){return this.method(this.currentFrame,E,D-E,this.totalFrames);},setAttribute:function(C,F,E){var D=this.getEl();if(this.patterns.noNegatives.test(C)){F=(F>0)?F:0;}if(C in D&&!("style" in D&&C in D.style)){D[C]=F;}else{B.Dom.setStyle(D,C,F+E);}},getAttribute:function(C){var E=this.getEl();var G=B.Dom.getStyle(E,C);if(G!=="auto"&&!this.patterns.offsetUnit.test(G)){return parseFloat(G);}var D=this.patterns.offsetAttribute.exec(C)||[];var H=!!(D[3]);var F=!!(D[2]);if("style" in E){if(F||(B.Dom.getStyle(E,"position")=="absolute"&&H)){G=E["offset"+D[0].charAt(0).toUpperCase()+D[0].substr(1)];}else{G=0;}}else{if(C in E){G=E[C];}}return G;},getDefaultUnit:function(C){if(this.patterns.defaultUnit.test(C)){return"px";}return"";},setRuntimeAttribute:function(D){var I;var E;var F=this.attributes;this.runtimeAttributes[D]={};var H=function(J){return(typeof J!=="undefined");};if(!H(F[D]["to"])&&!H(F[D]["by"])){return false;}I=(H(F[D]["from"]))?F[D]["from"]:this.getAttribute(D);if(H(F[D]["to"])){E=F[D]["to"];}else{if(H(F[D]["by"])){if(I.constructor==Array){E=[];for(var G=0,C=I.length;G<C;++G){E[G]=I[G]+F[D]["by"][G]*1;}}else{E=I+F[D]["by"]*1;}}}this.runtimeAttributes[D].start=I;this.runtimeAttributes[D].end=E;this.runtimeAttributes[D].unit=(H(F[D].unit))?F[D]["unit"]:this.getDefaultUnit(D);return true;},init:function(E,J,I,C){var D=false;var F=null;var H=0;E=B.Dom.get(E);this.attributes=J||{};this.duration=!YAHOO.lang.isUndefined(I)?I:1;this.method=C||B.Easing.easeNone;this.useSeconds=true;this.currentFrame=0;this.totalFrames=B.AnimMgr.fps;this.setEl=function(M){E=B.Dom.get(M);};this.getEl=function(){return E;};this.isAnimated=function(){return D;};this.getStartTime=function(){return F;};this.runtimeAttributes={};this.animate=function(){if(this.isAnimated()){return false;}this.currentFrame=0;this.totalFrames=(this.useSeconds)?Math.ceil(B.AnimMgr.fps*this.duration):this.duration;if(this.duration===0&&this.useSeconds){this.totalFrames=1;}B.AnimMgr.registerElement(this);return true;};this.stop=function(M){if(!this.isAnimated()){return false;}if(M){this.currentFrame=this.totalFrames;this._onTween.fire();}B.AnimMgr.stop(this);};var L=function(){this.onStart.fire();this.runtimeAttributes={};for(var M in this.attributes){this.setRuntimeAttribute(M);}D=true;H=0;F=new Date();};var K=function(){var O={duration:new Date()-this.getStartTime(),currentFrame:this.currentFrame};O.toString=function(){return("duration: "+O.duration+", currentFrame: "+O.currentFrame);};this.onTween.fire(O);var N=this.runtimeAttributes;for(var M in N){this.setAttribute(M,this.doMethod(M,N[M].start,N[M].end),N[M].unit);}H+=1;};var G=function(){var M=(new Date()-F)/1000;var N={duration:M,frames:H,fps:H/M};N.toString=function(){return("duration: "+N.duration+", frames: "+N.frames+", fps: "+N.fps);};D=false;H=0;this.onComplete.fire(N);};this._onStart=new B.CustomEvent("_start",this,true);this.onStart=new B.CustomEvent("start",this);this.onTween=new B.CustomEvent("tween",this);this._onTween=new B.CustomEvent("_tween",this,true);this.onComplete=new B.CustomEvent("complete",this);this._onComplete=new B.CustomEvent("_complete",this,true);this._onStart.subscribe(L);this._onTween.subscribe(K);this._onComplete.subscribe(G);}};B.Anim=A;})();YAHOO.util.AnimMgr=new function(){var C=null;var B=[];var A=0;this.fps=1000;this.delay=1;this.registerElement=function(F){B[B.length]=F;A+=1;F._onStart.fire();this.start();};this.unRegister=function(G,F){F=F||E(G);if(!G.isAnimated()||F===-1){return false;}G._onComplete.fire();B.splice(F,1);A-=1;if(A<=0){this.stop();}return true;};this.start=function(){if(C===null){C=setInterval(this.run,this.delay);}};this.stop=function(H){if(!H){clearInterval(C);for(var G=0,F=B.length;G<F;++G){this.unRegister(B[0],0);}B=[];C=null;A=0;}else{this.unRegister(H);}};this.run=function(){for(var H=0,F=B.length;H<F;++H){var G=B[H];if(!G||!G.isAnimated()){continue;}if(G.currentFrame<G.totalFrames||G.totalFrames===null){G.currentFrame+=1;if(G.useSeconds){D(G);}G._onTween.fire();}else{YAHOO.util.AnimMgr.stop(G,H);}}};var E=function(H){for(var G=0,F=B.length;G<F;++G){if(B[G]===H){return G;}}return -1;};var D=function(G){var J=G.totalFrames;var I=G.currentFrame;var H=(G.currentFrame*G.duration*1000/G.totalFrames);var F=(new Date()-G.getStartTime());var K=0;if(F<G.duration*1000){K=Math.round((F/H-1)*G.currentFrame);}else{K=J-(I+1);}if(K>0&&isFinite(K)){if(G.currentFrame+K>=J){K=J-(I+1);}G.currentFrame+=K;}};this._queue=B;this._getIndex=E;};YAHOO.util.Bezier=new function(){this.getPosition=function(E,D){var F=E.length;var C=[];for(var B=0;B<F;++B){C[B]=[E[B][0],E[B][1]];}for(var A=1;A<F;++A){for(B=0;B<F-A;++B){C[B][0]=(1-D)*C[B][0]+D*C[parseInt(B+1,10)][0];C[B][1]=(1-D)*C[B][1]+D*C[parseInt(B+1,10)][1];}}return[C[0][0],C[0][1]];};};(function(){var A=function(F,E,G,H){A.superclass.constructor.call(this,F,E,G,H);};A.NAME="ColorAnim";A.DEFAULT_BGCOLOR="#fff";var C=YAHOO.util;YAHOO.extend(A,C.Anim);var D=A.superclass;var B=A.prototype;B.patterns.color=/color$/i;B.patterns.rgb=/^rgb\(([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\)$/i;B.patterns.hex=/^#?([0-9A-F]{2})([0-9A-F]{2})([0-9A-F]{2})$/i;B.patterns.hex3=/^#?([0-9A-F]{1})([0-9A-F]{1})([0-9A-F]{1})$/i;B.patterns.transparent=/^transparent|rgba\(0, 0, 0, 0\)$/;B.parseColor=function(E){if(E.length==3){return E;}var F=this.patterns.hex.exec(E);if(F&&F.length==4){return[parseInt(F[1],16),parseInt(F[2],16),parseInt(F[3],16)];}F=this.patterns.rgb.exec(E);if(F&&F.length==4){return[parseInt(F[1],10),parseInt(F[2],10),parseInt(F[3],10)];}F=this.patterns.hex3.exec(E);if(F&&F.length==4){return[parseInt(F[1]+F[1],16),parseInt(F[2]+F[2],16),parseInt(F[3]+F[3],16)];
-}return null;};B.getAttribute=function(E){var G=this.getEl();if(this.patterns.color.test(E)){var I=YAHOO.util.Dom.getStyle(G,E);var H=this;if(this.patterns.transparent.test(I)){var F=YAHOO.util.Dom.getAncestorBy(G,function(J){return !H.patterns.transparent.test(I);});if(F){I=C.Dom.getStyle(F,E);}else{I=A.DEFAULT_BGCOLOR;}}}else{I=D.getAttribute.call(this,E);}return I;};B.doMethod=function(F,J,G){var I;if(this.patterns.color.test(F)){I=[];for(var H=0,E=J.length;H<E;++H){I[H]=D.doMethod.call(this,F,J[H],G[H]);}I="rgb("+Math.floor(I[0])+","+Math.floor(I[1])+","+Math.floor(I[2])+")";}else{I=D.doMethod.call(this,F,J,G);}return I;};B.setRuntimeAttribute=function(F){D.setRuntimeAttribute.call(this,F);if(this.patterns.color.test(F)){var H=this.attributes;var J=this.parseColor(this.runtimeAttributes[F].start);var G=this.parseColor(this.runtimeAttributes[F].end);if(typeof H[F]["to"]==="undefined"&&typeof H[F]["by"]!=="undefined"){G=this.parseColor(H[F].by);for(var I=0,E=J.length;I<E;++I){G[I]=J[I]+G[I];}}this.runtimeAttributes[F].start=J;this.runtimeAttributes[F].end=G;}};C.ColorAnim=A;})();
-/*
-TERMS OF USE - EASING EQUATIONS
-Open source under the BSD License.
-Copyright 2001 Robert Penner All rights reserved.
-
-Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- * Neither the name of the author nor the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-YAHOO.util.Easing={easeNone:function(B,A,D,C){return D*B/C+A;},easeIn:function(B,A,D,C){return D*(B/=C)*B+A;},easeOut:function(B,A,D,C){return -D*(B/=C)*(B-2)+A;},easeBoth:function(B,A,D,C){if((B/=C/2)<1){return D/2*B*B+A;}return -D/2*((--B)*(B-2)-1)+A;},easeInStrong:function(B,A,D,C){return D*(B/=C)*B*B*B+A;},easeOutStrong:function(B,A,D,C){return -D*((B=B/C-1)*B*B*B-1)+A;},easeBothStrong:function(B,A,D,C){if((B/=C/2)<1){return D/2*B*B*B*B+A;}return -D/2*((B-=2)*B*B*B-2)+A;},elasticIn:function(C,A,G,F,B,E){if(C==0){return A;}if((C/=F)==1){return A+G;}if(!E){E=F*0.3;}if(!B||B<Math.abs(G)){B=G;var D=E/4;}else{var D=E/(2*Math.PI)*Math.asin(G/B);}return -(B*Math.pow(2,10*(C-=1))*Math.sin((C*F-D)*(2*Math.PI)/E))+A;},elasticOut:function(C,A,G,F,B,E){if(C==0){return A;}if((C/=F)==1){return A+G;}if(!E){E=F*0.3;}if(!B||B<Math.abs(G)){B=G;var D=E/4;}else{var D=E/(2*Math.PI)*Math.asin(G/B);}return B*Math.pow(2,-10*C)*Math.sin((C*F-D)*(2*Math.PI)/E)+G+A;},elasticBoth:function(C,A,G,F,B,E){if(C==0){return A;}if((C/=F/2)==2){return A+G;}if(!E){E=F*(0.3*1.5);}if(!B||B<Math.abs(G)){B=G;var D=E/4;}else{var D=E/(2*Math.PI)*Math.asin(G/B);}if(C<1){return -0.5*(B*Math.pow(2,10*(C-=1))*Math.sin((C*F-D)*(2*Math.PI)/E))+A;}return B*Math.pow(2,-10*(C-=1))*Math.sin((C*F-D)*(2*Math.PI)/E)*0.5+G+A;},backIn:function(B,A,E,D,C){if(typeof C=="undefined"){C=1.70158;}return E*(B/=D)*B*((C+1)*B-C)+A;},backOut:function(B,A,E,D,C){if(typeof C=="undefined"){C=1.70158;}return E*((B=B/D-1)*B*((C+1)*B+C)+1)+A;},backBoth:function(B,A,E,D,C){if(typeof C=="undefined"){C=1.70158;}if((B/=D/2)<1){return E/2*(B*B*(((C*=(1.525))+1)*B-C))+A;}return E/2*((B-=2)*B*(((C*=(1.525))+1)*B+C)+2)+A;},bounceIn:function(B,A,D,C){return D-YAHOO.util.Easing.bounceOut(C-B,0,D,C)+A;},bounceOut:function(B,A,D,C){if((B/=C)<(1/2.75)){return D*(7.5625*B*B)+A;}else{if(B<(2/2.75)){return D*(7.5625*(B-=(1.5/2.75))*B+0.75)+A;}else{if(B<(2.5/2.75)){return D*(7.5625*(B-=(2.25/2.75))*B+0.9375)+A;}}}return D*(7.5625*(B-=(2.625/2.75))*B+0.984375)+A;},bounceBoth:function(B,A,D,C){if(B<C/2){return YAHOO.util.Easing.bounceIn(B*2,0,D,C)*0.5+A;}return YAHOO.util.Easing.bounceOut(B*2-C,0,D,C)*0.5+D*0.5+A;}};(function(){var A=function(H,G,I,J){if(H){A.superclass.constructor.call(this,H,G,I,J);}};A.NAME="Motion";var E=YAHOO.util;YAHOO.extend(A,E.ColorAnim);var F=A.superclass;var C=A.prototype;C.patterns.points=/^points$/i;C.setAttribute=function(G,I,H){if(this.patterns.points.test(G)){H=H||"px";F.setAttribute.call(this,"left",I[0],H);F.setAttribute.call(this,"top",I[1],H);}else{F.setAttribute.call(this,G,I,H);}};C.getAttribute=function(G){if(this.patterns.points.test(G)){var H=[F.getAttribute.call(this,"left"),F.getAttribute.call(this,"top")];}else{H=F.getAttribute.call(this,G);}return H;};C.doMethod=function(G,K,H){var J=null;if(this.patterns.points.test(G)){var I=this.method(this.currentFrame,0,100,this.totalFrames)/100;J=E.Bezier.getPosition(this.runtimeAttributes[G],I);}else{J=F.doMethod.call(this,G,K,H);}return J;};C.setRuntimeAttribute=function(P){if(this.patterns.points.test(P)){var H=this.getEl();var J=this.attributes;var G;var L=J["points"]["control"]||[];var I;var M,O;if(L.length>0&&!(L[0] instanceof Array)){L=[L];}else{var K=[];for(M=0,O=L.length;M<O;++M){K[M]=L[M];}L=K;}if(E.Dom.getStyle(H,"position")=="static"){E.Dom.setStyle(H,"position","relative");}if(D(J["points"]["from"])){E.Dom.setXY(H,J["points"]["from"]);
-}else{E.Dom.setXY(H,E.Dom.getXY(H));}G=this.getAttribute("points");if(D(J["points"]["to"])){I=B.call(this,J["points"]["to"],G);var N=E.Dom.getXY(this.getEl());for(M=0,O=L.length;M<O;++M){L[M]=B.call(this,L[M],G);}}else{if(D(J["points"]["by"])){I=[G[0]+J["points"]["by"][0],G[1]+J["points"]["by"][1]];for(M=0,O=L.length;M<O;++M){L[M]=[G[0]+L[M][0],G[1]+L[M][1]];}}}this.runtimeAttributes[P]=[G];if(L.length>0){this.runtimeAttributes[P]=this.runtimeAttributes[P].concat(L);}this.runtimeAttributes[P][this.runtimeAttributes[P].length]=I;}else{F.setRuntimeAttribute.call(this,P);}};var B=function(G,I){var H=E.Dom.getXY(this.getEl());G=[G[0]-H[0]+I[0],G[1]-H[1]+I[1]];return G;};var D=function(G){return(typeof G!=="undefined");};E.Motion=A;})();(function(){var D=function(F,E,G,H){if(F){D.superclass.constructor.call(this,F,E,G,H);}};D.NAME="Scroll";var B=YAHOO.util;YAHOO.extend(D,B.ColorAnim);var C=D.superclass;var A=D.prototype;A.doMethod=function(E,H,F){var G=null;if(E=="scroll"){G=[this.method(this.currentFrame,H[0],F[0]-H[0],this.totalFrames),this.method(this.currentFrame,H[1],F[1]-H[1],this.totalFrames)];}else{G=C.doMethod.call(this,E,H,F);}return G;};A.getAttribute=function(E){var G=null;var F=this.getEl();if(E=="scroll"){G=[F.scrollLeft,F.scrollTop];}else{G=C.getAttribute.call(this,E);}return G;};A.setAttribute=function(E,H,G){var F=this.getEl();if(E=="scroll"){F.scrollLeft=H[0];F.scrollTop=H[1];}else{C.setAttribute.call(this,E,H,G);}};B.Scroll=D;})();YAHOO.register("animation",YAHOO.util.Anim,{version:"2.8.1",build:"19"});
View
1,392 lib/yui/2.8.2/build/animation/animation.js
@@ -1,1392 +0,0 @@
-/*
-Copyright (c) 2010, Yahoo! Inc. All rights reserved.
-Code licensed under the BSD License:
-http://developer.yahoo.com/yui/license.html
-version: 2.8.1
-*/
-(function() {
-
-var Y = YAHOO.util;
-
-/*
-Copyright (c) 2006, Yahoo! Inc. All rights reserved.
-Code licensed under the BSD License:
-http://developer.yahoo.net/yui/license.txt
-*/
-
-/**
- * The animation module provides allows effects to be added to HTMLElements.
- * @module animation
- * @requires yahoo, event, dom
- */
-
-/**
- *
- * Base animation class that provides the interface for building animated effects.
- * <p>Usage: var myAnim = new YAHOO.util.Anim(el, { width: { from: 10, to: 100 } }, 1, YAHOO.util.Easing.easeOut);</p>
- * @class Anim
- * @namespace YAHOO.util
- * @requires YAHOO.util.AnimMgr
- * @requires YAHOO.util.Easing
- * @requires YAHOO.util.Dom
- * @requires YAHOO.util.Event
- * @requires YAHOO.util.CustomEvent
- * @constructor
- * @param {String | HTMLElement} el Reference to the element that will be animated
- * @param {Object} attributes The attribute(s) to be animated.
- * Each attribute is an object with at minimum a "to" or "by" member defined.
- * Additional optional members are "from" (defaults to current value), "units" (defaults to "px").
- * All attribute names use camelCase.
- * @param {Number} duration (optional, defaults to 1 second) Length of animation (frames or seconds), defaults to time-based
- * @param {Function} method (optional, defaults to YAHOO.util.Easing.easeNone) Computes the values that are applied to the attributes per frame (generally a YAHOO.util.Easing method)
- */
-
-var Anim = function(el, attributes, duration, method) {
- if (!el) {
- }
- this.init(el, attributes, duration, method);
-};
-
-Anim.NAME = 'Anim';
-
-Anim.prototype = {
- /**
- * Provides a readable name for the Anim instance.
- * @method toString
- * @return {String}
- */
- toString: function() {
- var el = this.getEl() || {};
- var id = el.id || el.tagName;
- return (this.constructor.NAME + ': ' + id);
- },
-
- patterns: { // cached for performance
- noNegatives: /width|height|opacity|padding/i, // keep at zero or above
- offsetAttribute: /^((width|height)|(top|left))$/, // use offsetValue as default
- defaultUnit: /width|height|top$|bottom$|left$|right$/i, // use 'px' by default
- offsetUnit: /\d+(em|%|en|ex|pt|in|cm|mm|pc)$/i // IE may return these, so convert these to offset
- },
-
- /**
- * Returns the value computed by the animation's "method".
- * @method doMethod
- * @param {String} attr The name of the attribute.
- * @param {Number} start The value this attribute should start from for this animation.
- * @param {Number} end The value this attribute should end at for this animation.
- * @return {Number} The Value to be applied to the attribute.
- */
- doMethod: function(attr, start, end) {
- return this.method(this.currentFrame, start, end - start, this.totalFrames);
- },
-
- /**
- * Applies a value to an attribute.
- * @method setAttribute
- * @param {String} attr The name of the attribute.
- * @param {Number} val The value to be applied to the attribute.
- * @param {String} unit The unit ('px', '%', etc.) of the value.
- */
- setAttribute: function(attr, val, unit) {
- var el = this.getEl();
- if ( this.patterns.noNegatives.test(attr) ) {
- val = (val > 0) ? val : 0;
- }
-
- if (attr in el && !('style' in el && attr in el.style)) {
- el[attr] = val;
- } else {
- Y.Dom.setStyle(el, attr, val + unit);
- }
- },
-
- /**
- * Returns current value of the attribute.
- * @method getAttribute
- * @param {String} attr The name of the attribute.
- * @return {Number} val The current value of the attribute.
- */
- getAttribute: function(attr) {
- var el = this.getEl();
- var val = Y.Dom.getStyle(el, attr);
-
- if (val !== 'auto' && !this.patterns.offsetUnit.test(val)) {
- return parseFloat(val);
- }
-
- var a = this.patterns.offsetAttribute.exec(attr) || [];
- var pos = !!( a[3] ); // top or left
- var box = !!( a[2] ); // width or height
-
- if ('style' in el) {
- // use offsets for width/height and abs pos top/left
- if ( box || (Y.Dom.getStyle(el, 'position') == 'absolute' && pos) ) {
- val = el['offset' + a[0].charAt(0).toUpperCase() + a[0].substr(1)];
- } else { // default to zero for other 'auto'
- val = 0;
- }
- } else if (attr in el) {
- val = el[attr];
- }
-
- return val;
- },
-
- /**
- * Returns the unit to use when none is supplied.
- * @method getDefaultUnit
- * @param {attr} attr The name of the attribute.
- * @return {String} The default unit to be used.
- */
- getDefaultUnit: function(attr) {
- if ( this.patterns.defaultUnit.test(attr) ) {
- return 'px';
- }
-
- return '';
- },
-
- /**
- * Sets the actual values to be used during the animation. Should only be needed for subclass use.
- * @method setRuntimeAttribute
- * @param {Object} attr The attribute object
- * @private
- */
- setRuntimeAttribute: function(attr) {
- var start;
- var end;
- var attributes = this.attributes;
-
- this.runtimeAttributes[attr] = {};
-
- var isset = function(prop) {
- return (typeof prop !== 'undefined');
- };
-
- if ( !isset(attributes[attr]['to']) && !isset(attributes[attr]['by']) ) {
- return false; // note return; nothing to animate to
- }
-
- start = ( isset(attributes[attr]['from']) ) ? attributes[attr]['from'] : this.getAttribute(attr);
-
- // To beats by, per SMIL 2.1 spec
- if ( isset(attributes[attr]['to']) ) {
- end = attributes[attr]['to'];
- } else if ( isset(attributes[attr]['by']) ) {
- if (start.constructor == Array) {
- end = [];
- for (var i = 0, len = start.length; i < len; ++i) {
- end[i] = start[i] + attributes[attr]['by'][i] * 1; // times 1 to cast "by"
- }
- } else {
- end = start + attributes[attr]['by'] * 1;
- }
- }
-
- this.runtimeAttributes[attr].start = start;
- this.runtimeAttributes[attr].end = end;
-
- // set units if needed
- this.runtimeAttributes[attr].unit = ( isset(attributes[attr].unit) ) ?
- attributes[attr]['unit'] : this.getDefaultUnit(attr);
- return true;
- },
-
- /**
- * Constructor for Anim instance.
- * @method init
- * @param {String | HTMLElement} el Reference to the element that will be animated
- * @param {Object} attributes The attribute(s) to be animated.
- * Each attribute is an object with at minimum a "to" or "by" member defined.
- * Additional optional members are "from" (defaults to current value), "units" (defaults to "px").
- * All attribute names use camelCase.
- * @param {Number} duration (optional, defaults to 1 second) Length of animation (frames or seconds), defaults to time-based
- * @param {Function} method (optional, defaults to YAHOO.util.Easing.easeNone) Computes the values that are applied to the attributes per frame (generally a YAHOO.util.Easing method)
- */
- init: function(el, attributes, duration, method) {
- /**
- * Whether or not the animation is running.
- * @property isAnimated
- * @private
- * @type Boolean
- */
- var isAnimated = false;
-
- /**
- * A Date object that is created when the animation begins.
- * @property startTime
- * @private
- * @type Date
- */
- var startTime = null;
-
- /**
- * The number of frames this animation was able to execute.
- * @property actualFrames
- * @private
- * @type Int
- */
- var actualFrames = 0;
-
- /**
- * The element to be animated.
- * @property el
- * @private
- * @type HTMLElement
- */
- el = Y.Dom.get(el);
-
- /**
- * The collection of attributes to be animated.
- * Each attribute must have at least a "to" or "by" defined in order to animate.
- * If "to" is supplied, the animation will end with the attribute at that value.
- * If "by" is supplied, the animation will end at that value plus its starting value.
- * If both are supplied, "to" is used, and "by" is ignored.
- * Optional additional member include "from" (the value the attribute should start animating from, defaults to current value), and "unit" (the units to apply to the values).
- * @property attributes
- * @type Object
- */
- this.attributes = attributes || {};
-
- /**
- * The length of the animation. Defaults to "1" (second).
- * @property duration
- * @type Number
- */
- this.duration = !YAHOO.lang.isUndefined(duration) ? duration : 1;
-
- /**
- * The method that will provide values to the attribute(s) during the animation.
- * Defaults to "YAHOO.util.Easing.easeNone".
- * @property method
- * @type Function
- */
- this.method = method || Y.Easing.easeNone;
-
- /**
- * Whether or not the duration should be treated as seconds.
- * Defaults to true.
- * @property useSeconds
- * @type Boolean
- */
- this.useSeconds = true; // default to seconds
-
- /**
- * The location of the current animation on the timeline.
- * In time-based animations, this is used by AnimMgr to ensure the animation finishes on time.
- * @property currentFrame
- * @type Int
- */
- this.currentFrame = 0;
-
- /**
- * The total number of frames to be executed.
- * In time-based animations, this is used by AnimMgr to ensure the animation finishes on time.
- * @property totalFrames
- * @type Int
- */
- this.totalFrames = Y.AnimMgr.fps;
-
- /**
- * Changes the animated element
- * @method setEl
- */
- this.setEl = function(element) {
- el = Y.Dom.get(element);
- };
-
- /**
- * Returns a reference to the animated element.
- * @method getEl
- * @return {HTMLElement}
- */
- this.getEl = function() { return el; };
-
- /**
- * Checks whether the element is currently animated.
- * @method isAnimated
- * @return {Boolean} current value of isAnimated.
- */
- this.isAnimated = function() {
- return isAnimated;
- };
-
- /**
- * Returns the animation start time.
- * @method getStartTime
- * @return {Date} current value of startTime.
- */
- this.getStartTime = function() {
- return startTime;
- };
-
- this.runtimeAttributes = {};
-
-
-
- /**
- * Starts the animation by registering it with the animation manager.
- * @method animate
- */
- this.animate = function() {
- if ( this.isAnimated() ) {
- return false;
- }
-
- this.currentFrame = 0;
-
- this.totalFrames = ( this.useSeconds ) ? Math.ceil(Y.AnimMgr.fps * this.duration) : this.duration;
-
- if (this.duration === 0 && this.useSeconds) { // jump to last frame if zero second duration
- this.totalFrames = 1;
- }
- Y.AnimMgr.registerElement(this);
- return true;
- };
-
- /**
- * Stops the animation. Normally called by AnimMgr when animation completes.
- * @method stop
- * @param {Boolean} finish (optional) If true, animation will jump to final frame.
- */
- this.stop = function(finish) {
- if (!this.isAnimated()) { // nothing to stop
- return false;
- }
-
- if (finish) {
- this.currentFrame = this.totalFrames;
- this._onTween.fire();
- }
- Y.AnimMgr.stop(this);
- };
-
- var onStart = function() {
- this.onStart.fire();
-
- this.runtimeAttributes = {};
- for (var attr in this.attributes) {
- this.setRuntimeAttribute(attr);
- }
-
- isAnimated = true;
- actualFrames = 0;
- startTime = new Date();
- };
-
- /**
- * Feeds the starting and ending values for each animated attribute to doMethod once per frame, then applies the resulting value to the attribute(s).
- * @private
- */
-
- var onTween = function() {
- var data = {
- duration: new Date() - this.getStartTime(),
- currentFrame: this.currentFrame
- };
-
- data.toString = function() {
- return (
- 'duration: ' + data.duration +
- ', currentFrame: ' + data.currentFrame
- );
- };
-
- this.onTween.fire(data);
-
- var runtimeAttributes = this.runtimeAttributes;
-
- for (var attr in runtimeAttributes) {
- this.setAttribute(attr, this.doMethod(attr, runtimeAttributes[attr].start, runtimeAttributes[attr].end), runtimeAttributes[attr].unit);
- }
-
- actualFrames += 1;
- };
-
- var onComplete = function() {
- var actual_duration = (new Date() - startTime) / 1000 ;
-
- var data = {
- duration: actual_duration,
- frames: actualFrames,
- fps: actualFrames / actual_duration
- };
-
- data.toString = function() {
- return (
- 'duration: ' + data.duration +
- ', frames: ' + data.frames +
- ', fps: ' + data.fps
- );
- };
-
- isAnimated = false;
- actualFrames = 0;
- this.onComplete.fire(data);
- };
-
- /**
- * Custom event that fires after onStart, useful in subclassing
- * @private
- */
- this._onStart = new Y.CustomEvent('_start', this, true);
-
- /**
- * Custom event that fires when animation begins
- * Listen via subscribe method (e.g. myAnim.onStart.subscribe(someFunction)
- * @event onStart
- */
- this.onStart = new Y.CustomEvent('start', this);
-
- /**
- * Custom event that fires between each frame
- * Listen via subscribe method (e.g. myAnim.onTween.subscribe(someFunction)
- * @event onTween
- */
- this.onTween = new Y.CustomEvent('tween', this);
-
- /**
- * Custom event that fires after onTween
- * @private
- */
- this._onTween = new Y.CustomEvent('_tween', this, true);
-
- /**
- * Custom event that fires when animation ends
- * Listen via subscribe method (e.g. myAnim.onComplete.subscribe(someFunction)
- * @event onComplete
- */
- this.onComplete = new Y.CustomEvent('complete', this);
- /**
- * Custom event that fires after onComplete
- * @private
- */
- this._onComplete = new Y.CustomEvent('_complete', this, true);
-
- this._onStart.subscribe(onStart);
- this._onTween.subscribe(onTween);
- this._onComplete.subscribe(onComplete);
- }
-};
-
- Y.Anim = Anim;
-})();
-/**
- * Handles animation queueing and threading.
- * Used by Anim and subclasses.
- * @class AnimMgr
- * @namespace YAHOO.util
- */
-YAHOO.util.AnimMgr = new function() {
- /**
- * Reference to the animation Interval.
- * @property thread
- * @private
- * @type Int
- */
- var thread = null;
-
- /**
- * The current queue of registered animation objects.
- * @property queue
- * @private
- * @type Array
- */
- var queue = [];
-
- /**
- * The number of active animations.
- * @property tweenCount
- * @private
- * @type Int
- */
- var tweenCount = 0;
-
- /**
- * Base frame rate (frames per second).
- * Arbitrarily high for better x-browser calibration (slower browsers drop more frames).
- * @property fps
- * @type Int
- *
- */
- this.fps = 1000;
-
- /**
- * Interval delay in milliseconds, defaults to fastest possible.
- * @property delay
- * @type Int
- *
- */
- this.delay = 1;
-
- /**
- * Adds an animation instance to the animation queue.
- * All animation instances must be registered in order to animate.
- * @method registerElement
- * @param {object} tween The Anim instance to be be registered
- */
- this.registerElement = function(tween) {
- queue[queue.length] = tween;
- tweenCount += 1;
- tween._onStart.fire();
- this.start();
- };
-
- /**
- * removes an animation instance from the animation queue.
- * All animation instances must be registered in order to animate.
- * @method unRegister
- * @param {object} tween The Anim instance to be be registered
- * @param {Int} index The index of the Anim instance
- * @private
- */
- this.unRegister = function(tween, index) {
- index = index || getIndex(tween);
- if (!tween.isAnimated() || index === -1) {
- return false;
- }
-
- tween._onComplete.fire();
- queue.splice(index, 1);
-
- tweenCount -= 1;
- if (tweenCount <= 0) {
- this.stop();
- }
-
- return true;
- };
-
- /**
- * Starts the animation thread.
- * Only one thread can run at a time.
- * @method start
- */
- this.start = function() {
- if (thread === null) {
- thread = setInterval(this.run, this.delay);
- }
- };
-
- /**
- * Stops the animation thread or a specific animation instance.
- * @method stop
- * @param {object} tween A specific Anim instance to stop (optional)
- * If no instance given, Manager stops thread and all animations.
- */
- this.stop = function(tween) {
- if (!tween) {
- clearInterval(thread);
-
- for (var i = 0, len = queue.length; i < len; ++i) {
- this.unRegister(queue[0], 0);
- }
-
- queue = [];
- thread = null;
- tweenCount = 0;
- }
- else {
- this.unRegister(tween);
- }
- };
-
- /**
- * Called per Interval to handle each animation frame.
- * @method run
- */
- this.run = function() {
- for (var i = 0, len = queue.length; i < len; ++i) {
- var tween = queue[i];
- if ( !tween || !tween.isAnimated() ) { continue; }
-
- if (tween.currentFrame < tween.totalFrames || tween.totalFrames === null)
- {
- tween.currentFrame += 1;
-
- if (tween.useSeconds) {
- correctFrame(tween);
- }
- tween._onTween.fire();
- }
- else { YAHOO.util.AnimMgr.stop(tween, i); }
- }
- };
-
- var getIndex = function(anim) {
- for (var i = 0, len = queue.length; i < len; ++i) {
- if (queue[i] === anim) {
- return i; // note return;
- }
- }
- return -1;
- };
-
- /**
- * On the fly frame correction to keep animation on time.
- * @method correctFrame
- * @private
- * @param {Object} tween The Anim instance being corrected.
- */
- var correctFrame = function(tween) {
- var frames = tween.totalFrames;
- var frame = tween.currentFrame;
- var expected = (tween.currentFrame * tween.duration * 1000 / tween.totalFrames);
- var elapsed = (new Date() - tween.getStartTime());
- var tweak = 0;
-
- if (elapsed < tween.duration * 1000) { // check if falling behind
- tweak = Math.round((elapsed / expected - 1) * tween.currentFrame);
- } else { // went over duration, so jump to end
- tweak = frames - (frame + 1);
- }
- if (tweak > 0 && isFinite(tweak)) { // adjust if needed
- if (tween.currentFrame + tweak >= frames) {// dont go past last frame
- tweak = frames - (frame + 1);
- }
-
- tween.currentFrame += tweak;
- }
- };
- this._queue = queue;
- this._getIndex = getIndex;
-};
-/**
- * Used to calculate Bezier splines for any number of control points.
- * @class Bezier
- * @namespace YAHOO.util
- *
- */
-YAHOO.util.Bezier = new function() {
- /**
- * Get the current position of the animated element based on t.
- * Each point is an array of "x" and "y" values (0 = x, 1 = y)
- * At least 2 points are required (start and end).
- * First point is start. Last point is end.
- * Additional control points are optional.
- * @method getPosition
- * @param {Array} points An array containing Bezier points
- * @param {Number} t A number between 0 and 1 which is the basis for determining current position
- * @return {Array} An array containing int x and y member data
- */
- this.getPosition = function(points, t) {
- var n = points.length;
- var tmp = [];
-
- for (var i = 0; i < n; ++i){
- tmp[i] = [points[i][0], points[i][1]]; // save input
- }
-
- for (var j = 1; j < n; ++j) {
- for (i = 0; i < n - j; ++i) {
- tmp[i][0] = (1 - t) * tmp[i][0] + t * tmp[parseInt(i + 1, 10)][0];
- tmp[i][1] = (1 - t) * tmp[i][1] + t * tmp[parseInt(i + 1, 10)][1];
- }
- }
-
- return [ tmp[0][0], tmp[0][1] ];
-
- };
-};
-(function() {
-/**
- * Anim subclass for color transitions.
- * <p>Usage: <code>var myAnim = new Y.ColorAnim(el, { backgroundColor: { from: '#FF0000', to: '#FFFFFF' } }, 1, Y.Easing.easeOut);</code> Color values can be specified with either 112233, #112233,
- * [255,255,255], or rgb(255,255,255)</p>
- * @class ColorAnim
- * @namespace YAHOO.util
- * @requires YAHOO.util.Anim
- * @requires YAHOO.util.AnimMgr
- * @requires YAHOO.util.Easing
- * @requires YAHOO.util.Bezier
- * @requires YAHOO.util.Dom
- * @requires YAHOO.util.Event
- * @constructor
- * @extends YAHOO.util.Anim
- * @param {HTMLElement | String} el Reference to the element that will be animated
- * @param {Object} attributes The attribute(s) to be animated.
- * Each attribute is an object with at minimum a "to" or "by" member defined.
- * Additional optional members are "from" (defaults to current value), "units" (defaults to "px").
- * All attribute names use camelCase.
- * @param {Number} duration (optional, defaults to 1 second) Length of animation (frames or seconds), defaults to time-based
- * @param {Function} method (optional, defaults to YAHOO.util.Easing.easeNone) Computes the values that are applied to the attributes per frame (generally a YAHOO.util.Easing method)
- */
- var ColorAnim = function(el, attributes, duration, method) {