From 8262613b25b481f2eaa68ca8c434145a902c5df5 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Thu, 26 May 2022 16:44:35 +0000 Subject: [PATCH] Bug 13614: Replace usage of YUI on basket groups page This patch updates the basket groups interface so that it doesn't rely on YUI to move baskets in and out of groups. The patch also removes all YUI assets and many long-obsolete references to YUI-related classes and IDs. To test, apply the patch and rebuild the staff interface CSS (https://wiki.koha-community.org/wiki/Working_with_SCSS_in_the_OPAC_and_staff_client) - Go to Acquisitions. - Locate a vendor with multiple closed baskets. - Click "Basket groups" in the sidebar menu. - Create or edit a basket group. - On the basket group page you should see the basket group form in one column and ungrouped baskets in another. - Both grouped and ungrouped baskets should be in a sortable DataTable. - Test that when you click the "Add to group" button on an ungrouped basket the row is removed from the table of ungrouped baskets and added to the table of grouped baskets. - The button text on the row should now read "Remove." - Test the reverse operation: Clicking "Remove" on a grouped basket should move it to the table of ungrouped baskets. - Test that when all baskets are moved out of either of the tables a row is displayed with a message specific to that table, e.g. "There are no ungrouped baskets." - Test that the basket group saves correctly when zero or more baskets are added to the group. Signed-off-by: David Nind Signed-off-by: Katrin Fischer Signed-off-by: Tomas Cohen Arazi --- .../lib/yui/animation/animation-debug.js | 1396 --- .../lib/yui/animation/animation-min.js | 23 - .../lib/yui/animation/animation.js | 1392 --- .../lib/yui/button/assets/button-core.css | 44 - .../button/assets/skins/sam/button-skin.css | 219 - .../yui/button/assets/skins/sam/button.css | 7 - .../skins/sam/menu-button-arrow-disabled.png | Bin 173 -> 0 bytes .../assets/skins/sam/menu-button-arrow.png | Bin 173 -> 0 bytes .../skins/sam/split-button-arrow-active.png | Bin 280 -> 0 bytes .../skins/sam/split-button-arrow-disabled.png | Bin 185 -> 0 bytes .../skins/sam/split-button-arrow-focus.png | Bin 185 -> 0 bytes .../skins/sam/split-button-arrow-hover.png | Bin 185 -> 0 bytes .../assets/skins/sam/split-button-arrow.png | Bin 185 -> 0 bytes .../lib/yui/button/button-beta-min.js | 11 - .../lib/yui/button/button-debug.js | 4694 -------- .../lib/yui/button/button-min.js | 11 - .../intranet-tmpl/lib/yui/button/button.js | 4633 -------- .../lib/yui/container/assets/alrt16_1.gif | Bin 971 -> 0 bytes .../lib/yui/container/assets/blck16_1.gif | Bin 591 -> 0 bytes .../lib/yui/container/assets/close12_1.gif | Bin 85 -> 0 bytes .../yui/container/assets/container-core.css | 176 - .../lib/yui/container/assets/container.css | 324 - .../lib/yui/container/assets/hlp16_1.gif | Bin 928 -> 0 bytes .../lib/yui/container/assets/info16_1.gif | Bin 601 -> 0 bytes .../assets/skins/sam/container-skin.css | 242 - .../container/assets/skins/sam/container.css | 7 - .../lib/yui/container/assets/tip16_1.gif | Bin 552 -> 0 bytes .../lib/yui/container/assets/warn16_1.gif | Bin 580 -> 0 bytes .../lib/yui/container/container-debug.js | 9076 --------------- .../lib/yui/container/container-min.js | 19 - .../lib/yui/container/container.js | 9052 --------------- .../lib/yui/container/container_core-debug.js | 5136 --------- .../lib/yui/container/container_core-min.js | 14 - .../lib/yui/container/container_core.js | 5126 --------- .../lib/yui/dragdrop/dragdrop-debug.js | 3710 ------- .../lib/yui/dragdrop/dragdrop-min.js | 10 - .../lib/yui/dragdrop/dragdrop.js | 3601 ------ .../lib/yui/element/element-beta-min.js | 8 - .../lib/yui/element/element-debug.js | 1106 -- .../lib/yui/element/element-min.js | 8 - .../intranet-tmpl/lib/yui/element/element.js | 1090 -- .../intranet-tmpl/lib/yui/json/json-debug.js | 538 - .../intranet-tmpl/lib/yui/json/json-min.js | 7 - koha-tmpl/intranet-tmpl/lib/yui/json/json.js | 538 - .../lib/yui/menu-button-arrow-disabled.png | Bin 173 -> 0 bytes .../lib/yui/menu-button-arrow.png | Bin 173 -> 0 bytes .../lib/yui/menu/assets/menu-core.css | 242 - .../lib/yui/menu/assets/menu.css | 503 - .../lib/yui/menu/assets/menu_down_arrow.png | Bin 3624 -> 0 bytes .../menu/assets/menu_down_arrow_disabled.png | Bin 3621 -> 0 bytes .../lib/yui/menu/assets/menu_up_arrow.png | Bin 936 -> 0 bytes .../menu/assets/menu_up_arrow_disabled.png | Bin 936 -> 0 bytes .../assets/menubaritem_submenuindicator.png | Bin 3623 -> 0 bytes .../menubaritem_submenuindicator_disabled.png | Bin 3623 -> 0 bytes .../menubaritem_submenuindicator_selected.png | Bin 3623 -> 0 bytes .../lib/yui/menu/assets/menuitem_checkbox.png | Bin 956 -> 0 bytes .../assets/menuitem_checkbox_disabled.png | Bin 956 -> 0 bytes .../assets/menuitem_checkbox_selected.png | Bin 956 -> 0 bytes .../menu/assets/menuitem_submenuindicator.png | Bin 942 -> 0 bytes .../menuitem_submenuindicator_disabled.png | Bin 942 -> 0 bytes .../menuitem_submenuindicator_selected.png | Bin 942 -> 0 bytes .../yui/menu/assets/skins/sam/menu-skin.css | 339 - .../lib/yui/menu/assets/skins/sam/menu.css | 7 - .../sam/menubaritem_submenuindicator.png | Bin 3618 -> 0 bytes .../menubaritem_submenuindicator_disabled.png | Bin 3618 -> 0 bytes .../assets/skins/sam/menuitem_checkbox.png | Bin 3625 -> 0 bytes .../skins/sam/menuitem_checkbox_disabled.png | Bin 3625 -> 0 bytes .../skins/sam/menuitem_submenuindicator.png | Bin 3617 -> 0 bytes .../menuitem_submenuindicator_disabled.png | Bin 3617 -> 0 bytes .../intranet-tmpl/lib/yui/menu/menu-debug.js | 9870 ----------------- .../intranet-tmpl/lib/yui/menu/menu-min.js | 16 - koha-tmpl/intranet-tmpl/lib/yui/menu/menu.js | 9823 ---------------- .../lib/yui/plugins/bubbling-min.js | 12 - .../lib/yui/plugins/loading-min.js | 9 - .../lib/yui/split-button-arrow-active.png | Bin 280 -> 0 bytes .../lib/yui/split-button-arrow-disabled.png | Bin 185 -> 0 bytes .../lib/yui/split-button-arrow-focus.png | Bin 185 -> 0 bytes .../lib/yui/split-button-arrow-hover.png | Bin 185 -> 0 bytes .../lib/yui/split-button-arrow.png | Bin 185 -> 0 bytes koha-tmpl/intranet-tmpl/lib/yui/sprite.png | Bin 3123 -> 0 bytes .../lib/yui/utilities/utilities.js | 39 - .../yui/yahoo-dom-event/yahoo-dom-event.js | 14 - .../intranet-tmpl/prog/css/preferences.css | 3 - koha-tmpl/intranet-tmpl/prog/css/print.css | 7 - .../prog/css/printreceiptinvoice.css | 10 - .../intranet-tmpl/prog/css/right-to-left.css | 147 +- .../intranet-tmpl/prog/css/src/_tables.scss | 4 - .../intranet-tmpl/prog/en/modules/about.tt | 4 - .../prog/en/modules/acqui/basketgroup.tt | 265 +- .../prog/en/modules/circ/offline-mf.tt | 1 - .../prog/en/modules/members/search.tt | 2 +- .../prog/en/modules/tools/import_borrowers.tt | 1 - 92 files changed, 137 insertions(+), 73399 deletions(-) delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/animation/animation-debug.js delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/animation/animation-min.js delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/animation/animation.js delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/button/assets/button-core.css delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/button/assets/skins/sam/button-skin.css delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/button/assets/skins/sam/button.css delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/button/assets/skins/sam/menu-button-arrow-disabled.png delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/button/assets/skins/sam/menu-button-arrow.png delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/button/assets/skins/sam/split-button-arrow-active.png delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/button/assets/skins/sam/split-button-arrow-disabled.png delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/button/assets/skins/sam/split-button-arrow-focus.png delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/button/assets/skins/sam/split-button-arrow-hover.png delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/button/assets/skins/sam/split-button-arrow.png delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/button/button-beta-min.js delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/button/button-debug.js delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/button/button-min.js delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/button/button.js delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/container/assets/alrt16_1.gif delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/container/assets/blck16_1.gif delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/container/assets/close12_1.gif delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/container/assets/container-core.css delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/container/assets/container.css delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/container/assets/hlp16_1.gif delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/container/assets/info16_1.gif delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/container/assets/skins/sam/container-skin.css delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/container/assets/skins/sam/container.css delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/container/assets/tip16_1.gif delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/container/assets/warn16_1.gif delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/container/container-debug.js delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/container/container-min.js delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/container/container.js delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/container/container_core-debug.js delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/container/container_core-min.js delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/container/container_core.js delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/dragdrop/dragdrop-debug.js delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/dragdrop/dragdrop-min.js delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/dragdrop/dragdrop.js delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/element/element-beta-min.js delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/element/element-debug.js delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/element/element-min.js delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/element/element.js delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/json/json-debug.js delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/json/json-min.js delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/json/json.js delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/menu-button-arrow-disabled.png delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/menu-button-arrow.png delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/menu/assets/menu-core.css delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/menu/assets/menu.css delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/menu/assets/menu_down_arrow.png delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/menu/assets/menu_down_arrow_disabled.png delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/menu/assets/menu_up_arrow.png delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/menu/assets/menu_up_arrow_disabled.png delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/menu/assets/menubaritem_submenuindicator.png delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/menu/assets/menubaritem_submenuindicator_disabled.png delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/menu/assets/menubaritem_submenuindicator_selected.png delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/menu/assets/menuitem_checkbox.png delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/menu/assets/menuitem_checkbox_disabled.png delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/menu/assets/menuitem_checkbox_selected.png delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/menu/assets/menuitem_submenuindicator.png delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/menu/assets/menuitem_submenuindicator_disabled.png delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/menu/assets/menuitem_submenuindicator_selected.png delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/menu/assets/skins/sam/menu-skin.css delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/menu/assets/skins/sam/menu.css delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/menu/assets/skins/sam/menubaritem_submenuindicator.png delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/menu/assets/skins/sam/menubaritem_submenuindicator_disabled.png delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/menu/assets/skins/sam/menuitem_checkbox.png delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/menu/assets/skins/sam/menuitem_checkbox_disabled.png delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/menu/assets/skins/sam/menuitem_submenuindicator.png delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/menu/assets/skins/sam/menuitem_submenuindicator_disabled.png delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/menu/menu-debug.js delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/menu/menu-min.js delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/menu/menu.js delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/plugins/bubbling-min.js delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/plugins/loading-min.js delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/split-button-arrow-active.png delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/split-button-arrow-disabled.png delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/split-button-arrow-focus.png delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/split-button-arrow-hover.png delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/split-button-arrow.png delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/sprite.png delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/utilities/utilities.js delete mode 100644 koha-tmpl/intranet-tmpl/lib/yui/yahoo-dom-event/yahoo-dom-event.js diff --git a/koha-tmpl/intranet-tmpl/lib/yui/animation/animation-debug.js b/koha-tmpl/intranet-tmpl/lib/yui/animation/animation-debug.js deleted file mode 100644 index 58451e7802..0000000000 --- a/koha-tmpl/intranet-tmpl/lib/yui/animation/animation-debug.js +++ /dev/null @@ -1,1396 +0,0 @@ -/* -Copyright (c) 2009, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.8.0r4 -*/ -(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. - *

Usage: var myAnim = new YAHOO.util.Anim(el, { width: { from: 10, to: 100 } }, 1, YAHOO.util.Easing.easeOut);

- * @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. - *

Usage: var myAnim = new Y.ColorAnim(el, { backgroundColor: { from: '#FF0000', to: '#FFFFFF' } }, 1, Y.Easing.easeOut); Color values can be specified with either 112233, #112233, - * [255,255,255], or rgb(255,255,255)

- * @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. - *

Usage: var myAnim = new YAHOO.util.Motion(el, { points: { to: [800, 800] } }, 1, YAHOO.util.Easing.easeOut);

- * @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. - *

Usage: var myAnim = new YAHOO.util.Scroll(el, { scroll: { to: [0, 800] } }, 1, YAHOO.util.Easing.easeOut);

- * @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.0r4", build: "2449"}); diff --git a/koha-tmpl/intranet-tmpl/lib/yui/animation/animation-min.js b/koha-tmpl/intranet-tmpl/lib/yui/animation/animation-min.js deleted file mode 100644 index 9fe8c62d1f..0000000000 --- a/koha-tmpl/intranet-tmpl/lib/yui/animation/animation-min.js +++ /dev/null @@ -1,23 +0,0 @@ -/* -Copyright (c) 2009, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.8.0r4 -*/ -(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;G0&&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;B0&&!(L[0] instanceof Array)){L=[L];}else{var K=[];for(M=0,O=L.length;M0){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.0r4",build:"2449"}); \ No newline at end of file diff --git a/koha-tmpl/intranet-tmpl/lib/yui/animation/animation.js b/koha-tmpl/intranet-tmpl/lib/yui/animation/animation.js deleted file mode 100644 index 5737b68bb2..0000000000 --- a/koha-tmpl/intranet-tmpl/lib/yui/animation/animation.js +++ /dev/null @@ -1,1392 +0,0 @@ -/* -Copyright (c) 2009, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.8.0r4 -*/ -(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. - *

Usage: var myAnim = new YAHOO.util.Anim(el, { width: { from: 10, to: 100 } }, 1, YAHOO.util.Easing.easeOut);

- * @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. - *

Usage: var myAnim = new Y.ColorAnim(el, { backgroundColor: { from: '#FF0000', to: '#FFFFFF' } }, 1, Y.Easing.easeOut); Color values can be specified with either 112233, #112233, - * [255,255,255], or rgb(255,255,255)

- * @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. - *

Usage: var myAnim = new YAHOO.util.Motion(el, { points: { to: [800, 800] } }, 1, YAHOO.util.Easing.easeOut);

- * @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. - *

Usage: var myAnim = new YAHOO.util.Scroll(el, { scroll: { to: [0, 800] } }, 1, YAHOO.util.Easing.easeOut);

- * @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.0r4", build: "2449"}); diff --git a/koha-tmpl/intranet-tmpl/lib/yui/button/assets/button-core.css b/koha-tmpl/intranet-tmpl/lib/yui/button/assets/button-core.css deleted file mode 100644 index 0aeeb9de68..0000000000 --- a/koha-tmpl/intranet-tmpl/lib/yui/button/assets/button-core.css +++ /dev/null @@ -1,44 +0,0 @@ -/* -Copyright (c) 2009, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.8.0r4 -*/ -.yui-button { - - display: -moz-inline-box; /* Gecko */ - display: inline-block; /* IE, Opera and Safari */ - vertical-align: text-bottom; - -} - -.yui-button .first-child { - - display: block; - *display: inline-block; /* IE */ - -} - -.yui-button button, -.yui-button a { - - display: block; - *display: inline-block; /* IE */ - border: none; - margin: 0; - -} - -.yui-button button { - - background-color: transparent; - *overflow: visible; /* Remove superfluous padding for IE */ - cursor: pointer; - -} - -.yui-button a { - - text-decoration: none; - -} \ No newline at end of file diff --git a/koha-tmpl/intranet-tmpl/lib/yui/button/assets/skins/sam/button-skin.css b/koha-tmpl/intranet-tmpl/lib/yui/button/assets/skins/sam/button-skin.css deleted file mode 100644 index 9aeaba813e..0000000000 --- a/koha-tmpl/intranet-tmpl/lib/yui/button/assets/skins/sam/button-skin.css +++ /dev/null @@ -1,219 +0,0 @@ -/* -Copyright (c) 2009, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.8.0r4 -*/ -.yui-skin-sam .yui-button { - - border-width: 1px 0; - border-style: solid; - border-color: #808080; - background: url(../../../../assets/skins/sam/sprite.png) repeat-x 0 0; - margin: auto .25em; - -} - -.yui-skin-sam .yui-button .first-child { - - border-width: 0 1px; - border-style: solid; - border-color: #808080; - margin: 0 -1px; - - /* - Using negative margins for rounded corners won't work in IE 6 and IE 7 - (Quirks Mode Only), so set the "margin" property to "0" for those - browsers. - */ - _margin: 0; - -} - -.yui-skin-sam .yui-button button, -.yui-skin-sam .yui-button a, -.yui-skin-sam .yui-button a:visited { - - padding: 0 10px; - font-size: 93%; /* 12px */ - line-height: 2; /* ~24px */ - *line-height: 1.7; /* For IE */ - min-height: 2em; /* For Gecko */ - *min-height: auto; /* For IE */ - color: #000; - -} - -.yui-skin-sam .yui-button a { - - /* - Necessary to get Buttons of type "link" to be the correct - height in IE. - */ - *line-height: 1.875; - *padding-bottom: 1px; - -} - -.yui-skin-sam .yui-split-button button, -.yui-skin-sam .yui-menu-button button { - - padding-right: 20px; - background-position: right center; - background-repeat: no-repeat; - -} - -.yui-skin-sam .yui-menu-button button { - - background-image: url(menu-button-arrow.png); - -} - -.yui-skin-sam .yui-split-button button { - - background-image: url(split-button-arrow.png); - -} - - -/* Focus state */ - - -.yui-skin-sam .yui-button-focus { - - border-color: #7D98B8; - background-position: 0 -1300px; - -} - -.yui-skin-sam .yui-button-focus .first-child { - - border-color: #7D98B8; - -} - -.yui-skin-sam .yui-split-button-focus button { - - background-image: url(split-button-arrow-focus.png); - -} - - -/* Hover state */ - -.yui-skin-sam .yui-button-hover { - - border-color: #7D98B8; - background-position: 0 -1300px; - -} - -.yui-skin-sam .yui-button-hover .first-child { - - border-color: #7D98B8; - -} - -.yui-skin-sam .yui-split-button-hover button { - - background-image: url(split-button-arrow-hover.png); - -} - - -/* Active state */ - -.yui-skin-sam .yui-button-active { - - border-color: #7D98B8; - background-position: 0 -1700px; - -} - -.yui-skin-sam .yui-button-active .first-child { - - border-color: #7D98B8; - -} - -.yui-skin-sam .yui-split-button-activeoption { - - border-color: #808080; - background-position: 0 0; - -} - -.yui-skin-sam .yui-split-button-activeoption .first-child { - - border-color: #808080; - -} - -.yui-skin-sam .yui-split-button-activeoption button { - - background-image: url(split-button-arrow-active.png); - -} - - -/* Checked state */ - -.yui-skin-sam .yui-radio-button-checked, -.yui-skin-sam .yui-checkbox-button-checked { - - border-color: #304369; - background-position: 0 -1400px; - -} - -.yui-skin-sam .yui-radio-button-checked .first-child, -.yui-skin-sam .yui-checkbox-button-checked .first-child { - - border-color: #304369; - -} - -.yui-skin-sam .yui-radio-button-checked button, -.yui-skin-sam .yui-checkbox-button-checked button { - - color: #fff; - -} - - -/* Disabled state */ - -.yui-skin-sam .yui-button-disabled { - - border-color: #ccc; - background-position: 0 -1500px; - -} - -.yui-skin-sam .yui-button-disabled .first-child { - - border-color: #ccc; - -} - -.yui-skin-sam .yui-button-disabled button, -.yui-skin-sam .yui-button-disabled a, -.yui-skin-sam .yui-button-disabled a:visited { - - color: #A6A6A6; - cursor: default; - -} - -.yui-skin-sam .yui-menu-button-disabled button { - - background-image: url(menu-button-arrow-disabled.png); - -} - -.yui-skin-sam .yui-split-button-disabled button { - - background-image: url(split-button-arrow-disabled.png); - -} \ No newline at end of file diff --git a/koha-tmpl/intranet-tmpl/lib/yui/button/assets/skins/sam/button.css b/koha-tmpl/intranet-tmpl/lib/yui/button/assets/skins/sam/button.css deleted file mode 100644 index b3b6c64d42..0000000000 --- a/koha-tmpl/intranet-tmpl/lib/yui/button/assets/skins/sam/button.css +++ /dev/null @@ -1,7 +0,0 @@ -/* -Copyright (c) 2009, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.8.0r4 -*/ -.yui-button{display:-moz-inline-box;display:inline-block;vertical-align:text-bottom;}.yui-button .first-child{display:block;*display:inline-block;}.yui-button button,.yui-button a{display:block;*display:inline-block;border:none;margin:0;}.yui-button button{background-color:transparent;*overflow:visible;cursor:pointer;}.yui-button a{text-decoration:none;}.yui-skin-sam .yui-button{border-width:1px 0;border-style:solid;border-color:#808080;background:url(../../../../assets/skins/sam/sprite.png) repeat-x 0 0;margin:auto .25em;}.yui-skin-sam .yui-button .first-child{border-width:0 1px;border-style:solid;border-color:#808080;margin:0 -1px;_margin:0;}.yui-skin-sam .yui-button button,.yui-skin-sam .yui-button a,.yui-skin-sam .yui-button a:visited{padding:0 10px;font-size:93%;line-height:2;*line-height:1.7;min-height:2em;*min-height:auto;color:#000;}.yui-skin-sam .yui-button a{*line-height:1.875;*padding-bottom:1px;}.yui-skin-sam .yui-split-button button,.yui-skin-sam .yui-menu-button button{padding-right:20px;background-position:right center;background-repeat:no-repeat;}.yui-skin-sam .yui-menu-button button{background-image:url(menu-button-arrow.png);}.yui-skin-sam .yui-split-button button{background-image:url(split-button-arrow.png);}.yui-skin-sam .yui-button-focus{border-color:#7D98B8;background-position:0 -1300px;}.yui-skin-sam .yui-button-focus .first-child{border-color:#7D98B8;}.yui-skin-sam .yui-split-button-focus button{background-image:url(split-button-arrow-focus.png);}.yui-skin-sam .yui-button-hover{border-color:#7D98B8;background-position:0 -1300px;}.yui-skin-sam .yui-button-hover .first-child{border-color:#7D98B8;}.yui-skin-sam .yui-split-button-hover button{background-image:url(split-button-arrow-hover.png);}.yui-skin-sam .yui-button-active{border-color:#7D98B8;background-position:0 -1700px;}.yui-skin-sam .yui-button-active .first-child{border-color:#7D98B8;}.yui-skin-sam .yui-split-button-activeoption{border-color:#808080;background-position:0 0;}.yui-skin-sam .yui-split-button-activeoption .first-child{border-color:#808080;}.yui-skin-sam .yui-split-button-activeoption button{background-image:url(split-button-arrow-active.png);}.yui-skin-sam .yui-radio-button-checked,.yui-skin-sam .yui-checkbox-button-checked{border-color:#304369;background-position:0 -1400px;}.yui-skin-sam .yui-radio-button-checked .first-child,.yui-skin-sam .yui-checkbox-button-checked .first-child{border-color:#304369;}.yui-skin-sam .yui-radio-button-checked button,.yui-skin-sam .yui-checkbox-button-checked button{color:#fff;}.yui-skin-sam .yui-button-disabled{border-color:#ccc;background-position:0 -1500px;}.yui-skin-sam .yui-button-disabled .first-child{border-color:#ccc;}.yui-skin-sam .yui-button-disabled button,.yui-skin-sam .yui-button-disabled a,.yui-skin-sam .yui-button-disabled a:visited{color:#A6A6A6;cursor:default;}.yui-skin-sam .yui-menu-button-disabled button{background-image:url(menu-button-arrow-disabled.png);}.yui-skin-sam .yui-split-button-disabled button{background-image:url(split-button-arrow-disabled.png);} diff --git a/koha-tmpl/intranet-tmpl/lib/yui/button/assets/skins/sam/menu-button-arrow-disabled.png b/koha-tmpl/intranet-tmpl/lib/yui/button/assets/skins/sam/menu-button-arrow-disabled.png deleted file mode 100644 index 8cef2abb31170a370c7062c839ea9d5e9de18948..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 173 zcmeAS@N?(olHy`uVBq!ia0vp^0zk~d!3-ofWcl9%anc=q9T^y|-MHc(VFct$mbgZg z1m~xflqVLYGB~E>C#5QQ<|d}62BjvZR2H60wE-$(3-AeXt*@{D|Np;u@pDC#5QQ<|d}62BjvZR2H60wE-$(3-AeX1=9cj|6h7@{#_u8sU*lR z_&>wb?FL>zp1h}vV@SoVq=W_rH;IGN~-|K;%i-0c73 z@c-iO|KRQa-|hd~QeFE1003M`L_t(|+U&?l5`sVg1i`WZK}Epr|6dhmytLs92=mel z9uoULP6;mwyM%qhIpHzkHQ|(SNO(*5TD8?y@wq9xG<+26t_AN^`$=39HtEMPCOjwP e%l`;(0R{kdKn;SADLBOd00006$Gh9E#3p9{H-P6S}q~camLV^=3&tj%#_Xa_x2_Xl57U&w-9pX85Q9;Im dv4Me^VIeE)+1pK9I)PdkJYD@<);T3K0RYcxInw|D diff --git a/koha-tmpl/intranet-tmpl/lib/yui/button/assets/skins/sam/split-button-arrow-focus.png b/koha-tmpl/intranet-tmpl/lib/yui/button/assets/skins/sam/split-button-arrow-focus.png deleted file mode 100644 index 167d71eb721ba9b85c6601f9077d5c39faa4ebd2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 185 zcmeAS@N?(olHy`uVBq!ia0vp^0zhoU!3-pmJXhxdDVB6cUq=RpYd5a=M;HP5k|nMY zCBgY=CFO}lsSJ)O`AMk?p1FzXsX?iUDV2pMQ*D5XI0Jk_Tx)0S05bpo|DSu#^)isf zToU9L{Qp10^;5h+0~ypkT^vIyZY3ooII;39W@>hC5M-JVa^Poyu7TYlo?{mkWE>b9 b7?>Frva+7N-L$0>sD;7P)z4*}Q$iB}D9ShR diff --git a/koha-tmpl/intranet-tmpl/lib/yui/button/assets/skins/sam/split-button-arrow-hover.png b/koha-tmpl/intranet-tmpl/lib/yui/button/assets/skins/sam/split-button-arrow-hover.png deleted file mode 100644 index 167d71eb721ba9b85c6601f9077d5c39faa4ebd2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 185 zcmeAS@N?(olHy`uVBq!ia0vp^0zhoU!3-pmJXhxdDVB6cUq=RpYd5a=M;HP5k|nMY zCBgY=CFO}lsSJ)O`AMk?p1FzXsX?iUDV2pMQ*D5XI0Jk_Tx)0S05bpo|DSu#^)isf zToU9L{Qp10^;5h+0~ypkT^vIyZY3ooII;39W@>hC5M-JVa^Poyu7TYlo?{mkWE>b9 b7?>Frva+7N-L$0>sD;7P)z4*}Q$iB}D9ShR diff --git a/koha-tmpl/intranet-tmpl/lib/yui/button/assets/skins/sam/split-button-arrow.png b/koha-tmpl/intranet-tmpl/lib/yui/button/assets/skins/sam/split-button-arrow.png deleted file mode 100644 index b33a93ff2dc2039bd24e4ea3b75ecf4bb3295f84..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 185 zcmeAS@N?(olHy`uVBq!ia0vp^0zhoU!3-pmJXhxdDVB6cUq=RpYd5a=M;HP5k|nMY zCBgY=CFO}lsSJ)O`AMk?p1FzXsX?iUDV2pMQ*D5XI0Jk_TpJo1fXx5@|JyBHuocK+ zE(!7r{{Nrh`YB$Zfeh-NE{-7;w~`VPoLG4lGc~(62r^9wIqgTe~DWM4f1sXSq diff --git a/koha-tmpl/intranet-tmpl/lib/yui/button/button-beta-min.js b/koha-tmpl/intranet-tmpl/lib/yui/button/button-beta-min.js deleted file mode 100644 index c5aee13826..0000000000 --- a/koha-tmpl/intranet-tmpl/lib/yui/button/button-beta-min.js +++ /dev/null @@ -1,11 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.3.1 -*/ -(function(){var G=YAHOO.util.Dom,L=YAHOO.util.Event,I=YAHOO.lang,B=YAHOO.widget.Overlay,J=YAHOO.widget.Menu,D={},K=null,E=null,C=null;function F(N,M,Q,O){var R,P;if(I.isString(N)&&I.isString(M)){if(YAHOO.env.ua.ie){P="0){T.label=P;}}}function A(O){var N=O.attributes,M=N.srcelement,Q=M.nodeName.toUpperCase(),P=this;if(Q==this.NODE_NAME){O.element=M;O.id=M.id;G.getElementsBy(function(R){switch(R.nodeName.toUpperCase()){case"BUTTON":case"A":case"INPUT":H.call(P,R,N);break;}},"*",M);}else{switch(Q){case"BUTTON":case"A":case"INPUT":H.call(this,M,N);break;}}}YAHOO.widget.Button=function(Q,N){var P=YAHOO.widget.Button.superclass.constructor,O,M;if(arguments.length==1&&!I.isString(Q)&&!Q.nodeName){if(!Q.id){Q.id=G.generateId();}P.call(this,(this.createButtonElement(Q.type)),Q);}else{O={element:null,attributes:(N||{})};if(I.isString(Q)){M=G.get(Q);if(M){if(!O.attributes.id){O.attributes.id=Q;}O.attributes.srcelement=M;A.call(this,O);if(!O.element){O.element=this.createButtonElement(O.attributes.type);}P.call(this,O.element,O.attributes);}}else{if(Q.nodeName){if(!O.attributes.id){if(Q.id){O.attributes.id=Q.id;}else{O.attributes.id=G.generateId();}}O.attributes.srcelement=Q;A.call(this,O);if(!O.element){O.element=this.createButtonElement(O.attributes.type);}P.call(this,O.element,O.attributes);}}}};YAHOO.extend(YAHOO.widget.Button,YAHOO.util.Element,{_button:null,_menu:null,_hiddenFields:null,_onclickAttributeValue:null,_activationKeyPressed:false,_activationButtonPressed:false,_hasKeyEventHandlers:false,_hasMouseEventHandlers:false,NODE_NAME:"SPAN",CHECK_ACTIVATION_KEYS:[32],ACTIVATION_KEYS:[13,32],OPTION_AREA_WIDTH:20,CSS_CLASS_NAME:"yui-button",RADIO_DEFAULT_TITLE:"Unchecked. Click to check.",RADIO_CHECKED_TITLE:"Checked. Click to uncheck.",CHECKBOX_DEFAULT_TITLE:"Unchecked. Click to check.",CHECKBOX_CHECKED_TITLE:"Checked. Click to uncheck.",MENUBUTTON_DEFAULT_TITLE:"Menu collapsed. Click to expand.",MENUBUTTON_MENU_VISIBLE_TITLE:"Menu expanded. Click or press Esc to collapse.",SPLITBUTTON_DEFAULT_TITLE:("Menu collapsed. Click inside option region or press Ctrl + Shift + M to show the menu."),SPLITBUTTON_OPTION_VISIBLE_TITLE:"Menu expanded. Press Esc or Ctrl + Shift + M to hide the menu.",SUBMIT_TITLE:"Click to submit form.",_setType:function(M){if(M=="split"){this.on("option",this._onOption);}},_setLabel:function(M){this._button.innerHTML=M;var O,N;if(YAHOO.env.ua.gecko&&G.inDocument(this.get("element"))){N=this;O=this.CSS_CLASS_NAME;this.removeClass(O);window.setTimeout(function(){N.addClass(O);},0);}},_setTabIndex:function(M){this._button.tabIndex=M;},_setTitle:function(N){var M=N;if(this.get("type")!="link"){if(!M){switch(this.get("type")){case"radio":M=this.RADIO_DEFAULT_TITLE;break;case"checkbox":M=this.CHECKBOX_DEFAULT_TITLE;break;case"menu":M=this.MENUBUTTON_DEFAULT_TITLE;break;case"split":M=this.SPLITBUTTON_DEFAULT_TITLE;break;case"submit":M=this.SUBMIT_TITLE;break;}}this._button.title=M;}},_setDisabled:function(M){if(this.get("type")!="link"){if(M){if(this._menu){this._menu.hide();}if(this.hasFocus()){this.blur();}this._button.setAttribute("disabled","disabled");this.addStateCSSClasses("disabled");this.removeStateCSSClasses("hover");this.removeStateCSSClasses("active");this.removeStateCSSClasses("focus");}else{this._button.removeAttribute("disabled");this.removeStateCSSClasses("disabled");}}},_setHref:function(M){if(this.get("type")=="link"){this._button.href=M;}},_setTarget:function(M){if(this.get("type")=="link"){this._button.setAttribute("target",M);}},_setChecked:function(N){var O=this.get("type"),M;if(O=="checkbox"||O=="radio"){if(N){this.addStateCSSClasses("checked");M=(O=="radio")?this.RADIO_CHECKED_TITLE:this.CHECKBOX_CHECKED_TITLE;}else{this.removeStateCSSClasses("checked");M=(O=="radio")?this.RADIO_DEFAULT_TITLE:this.CHECKBOX_DEFAULT_TITLE;}this.set("title",M);}},_setMenu:function(W){var Q=this.get("lazyloadmenu"),T=this.get("element"),M=J.prototype.CSS_CLASS_NAME,Y=false,Z,P,S,O,N,V,R;if(!B){return false;}if(!J){return false;}function X(){Z.render(T.parentNode);this.removeListener("appendTo",X);}function U(){if(Z){G.addClass(Z.element,this.get("menuclassname"));G.addClass(Z.element,"yui-"+this.get("type")+"-button-menu");Z.showEvent.subscribe(this._onMenuShow,null,this);Z.hideEvent.subscribe(this._onMenuHide,null,this);Z.renderEvent.subscribe(this._onMenuRender,null,this);if(Z instanceof J){Z.keyDownEvent.subscribe(this._onMenuKeyDown,this,true);Z.subscribe("click",this._onMenuClick,this,true);Z.itemAddedEvent.subscribe(this._onMenuItemAdded,this,true);S=Z.srcElement;if(S&&S.nodeName.toUpperCase()=="SELECT"){S.style.display="none";S.parentNode.removeChild(S);}}else{if(Z instanceof B){if(!K){K=new YAHOO.widget.OverlayManager();}K.register(Z);}}this._menu=Z;if(!Y){if(Q&&!(Z instanceof J)){Z.beforeShowEvent.subscribe(this._onOverlayBeforeShow,null,this);}else{if(!Q){if(G.inDocument(T)){Z.render(T.parentNode);}else{this.on("appendTo",X);}}}}}}if(W&&(W instanceof J)){Z=W;O=Z.getItems(); -N=O.length;Y=true;if(N>0){R=N-1;do{V=O[R];if(V){V.cfg.subscribeToConfigEvent("selected",this._onMenuItemSelected,V,this);}}while(R--);}U.call(this);}else{if(W&&(W instanceof B)){Z=W;Y=true;Z.cfg.setProperty("visible",false);Z.cfg.setProperty("context",[T,"tl","bl"]);U.call(this);}else{if(I.isArray(W)){this.on("appendTo",function(){Z=new J(G.generateId(),{lazyload:Q,itemdata:W});U.call(this);});}else{if(I.isString(W)){P=G.get(W);if(P){if(G.hasClass(P,M)||P.nodeName.toUpperCase()=="SELECT"){Z=new J(W,{lazyload:Q});U.call(this);}else{Z=new B(W,{visible:false,context:[T,"tl","bl"]});U.call(this);}}}else{if(W&&W.nodeName){if(G.hasClass(W,M)||W.nodeName.toUpperCase()=="SELECT"){Z=new J(W,{lazyload:Q});U.call(this);}else{if(!W.id){G.generateId(W);}Z=new B(W,{visible:false,context:[T,"tl","bl"]});U.call(this);}}}}}}},_setOnClick:function(M){if(this._onclickAttributeValue&&(this._onclickAttributeValue!=M)){this.removeListener("click",this._onclickAttributeValue.fn);this._onclickAttributeValue=null;}if(!this._onclickAttributeValue&&I.isObject(M)&&I.isFunction(M.fn)){this.on("click",M.fn,M.obj,M.scope);this._onclickAttributeValue=M;}},_setSelectedMenuItem:function(N){var M=this._menu,O;if(M&&M instanceof J){O=M.getItem(N);if(O&&!O.cfg.getProperty("selected")){O.cfg.setProperty("selected",true);}}},_isActivationKey:function(M){var Q=this.get("type"),N=(Q=="checkbox"||Q=="radio")?this.CHECK_ACTIVATION_KEYS:this.ACTIVATION_KEYS,P=N.length,O;if(P>0){O=P-1;do{if(M==N[O]){return true;}}while(O--);}},_isSplitButtonOptionKey:function(M){return(M.ctrlKey&&M.shiftKey&&L.getCharCode(M)==77);},_addListenersToForm:function(){var S=this.getForm(),R=YAHOO.widget.Button.onFormKeyPress,Q,M,P,O,N;if(S){L.on(S,"reset",this._onFormReset,null,this);L.on(S,"submit",this.createHiddenFields,null,this);M=this.get("srcelement");if(this.get("type")=="submit"||(M&&M.type=="submit")){P=L.getListeners(S,"keypress");Q=false;if(P){O=P.length;if(O>0){N=O-1;do{if(P[N].fn==R){Q=true;break;}}while(N--);}}if(!Q){L.on(S,"keypress",R);}}}},_originalMaxHeight:-1,_showMenu:function(O){YAHOO.widget.MenuManager.hideVisible();if(K){K.hideAll();}var M=this._menu,N=G.getViewportHeight(),Q,R,P;if(M&&(M instanceof J)){M.cfg.applyConfig({context:[this.get("id"),"tl","bl"],constraintoviewport:false,clicktohide:false,visible:true});M.cfg.fireQueue();M.align("tl","bl");if(O.type=="mousedown"){L.stopPropagation(O);}if(this.get("focusmenu")){this._menu.focus();}Q=M.element.offsetHeight;if((M.cfg.getProperty("y")+Q)>N){M.align("bl","tl");P=M.cfg.getProperty("y");R=G.getDocumentScrollTop();if(R>=P){if(this._originalMaxHeight==-1){this._originalMaxHeight=M.cfg.getProperty("maxheight");}M.cfg.setProperty("maxheight",(Q-((R-P)+20)));M.align("bl","tl");}}}else{if(M&&(M instanceof B)){M.show();M.align("tl","bl");Q=M.element.offsetHeight;if((M.cfg.getProperty("y")+Q)>N){M.align("bl","tl");}}}},_hideMenu:function(){var M=this._menu;if(M){M.hide();}},_onMouseOver:function(M){if(!this._hasMouseEventHandlers){this.on("mouseout",this._onMouseOut);this.on("mousedown",this._onMouseDown);this.on("mouseup",this._onMouseUp);this._hasMouseEventHandlers=true;}this.addStateCSSClasses("hover");if(this._activationButtonPressed){this.addStateCSSClasses("active");}if(this._bOptionPressed){this.addStateCSSClasses("activeoption");}},_onMouseOut:function(M){this.removeStateCSSClasses("hover");if(this.get("type")!="menu"){this.removeStateCSSClasses("active");}if(this._activationButtonPressed||this._bOptionPressed){L.on(document,"mouseup",this._onDocumentMouseUp,null,this);}},_onDocumentMouseUp:function(M){this._activationButtonPressed=false;this._bOptionPressed=false;var N=this.get("type");if(N=="menu"||N=="split"){this.removeStateCSSClasses((N=="menu"?"active":"activeoption"));this._hideMenu();}L.removeListener(document,"mouseup",this._onDocumentMouseUp);},_onMouseDown:function(P){var R,N,Q,O;function M(){this._hideMenu();this.removeListener("mouseup",M);}if((P.which||P.button)==1){if(!this.hasFocus()){this.focus();}R=this.get("type");if(R=="split"){N=this.get("element");Q=L.getPageX(P)-G.getX(N);if((N.offsetWidth-this.OPTION_AREA_WIDTH)"+(M=="link"?"":"")+"";return N;},addStateCSSClasses:function(M){var N=this.get("type");if(I.isString(M)){if(M!="activeoption"){this.addClass(this.CSS_CLASS_NAME+("-"+M));}this.addClass("yui-"+N+("-button-"+M));}},removeStateCSSClasses:function(M){var N=this.get("type");if(I.isString(M)){this.removeClass(this.CSS_CLASS_NAME+("-"+M));this.removeClass("yui-"+N+("-button-"+M));}},createHiddenFields:function(){this.removeHiddenFields();var R=this.getForm(),U,N,P,S,T,O,Q,M;if(R&&!this.get("disabled")){N=this.get("type");P=(N=="checkbox"||N=="radio");if(P||(E==this)){U=F((P?N:"hidden"),this.get("name"),this.get("value"),this.get("checked"));if(U){if(P){U.style.display="none";}R.appendChild(U);}}S=this._menu;if(S&&(S instanceof J)){M=S.srcElement;T=S.getItem(this.get("selectedMenuItem"));if(T){if(M&&M.nodeName.toUpperCase()=="SELECT"){R.appendChild(M);M.selectedIndex=T.index;}else{Q=(T.value===null||T.value==="")?T.cfg.getProperty("text"):T.value;O=this.get("name");if(Q&&O){M=F("hidden",(O+"_options"),Q);R.appendChild(M);}}}}if(U&&M){this._hiddenFields=[U,M];}else{if(!U&&M){this._hiddenFields=M;}else{if(U&&!M){this._hiddenFields=U;}}}return this._hiddenFields;}},removeHiddenFields:function(){var P=this._hiddenFields,N,O;function M(Q){if(G.inDocument(Q)){Q.parentNode.removeChild(Q);}}if(P){if(I.isArray(P)){N=P.length;if(N>0){O=N-1;do{M(P[O]);}while(O--);}}else{M(P);}this._hiddenFields=null;}},submitForm:function(){var P=this.getForm(),O=this.get("srcelement"),N=false,M;if(P){if(this.get("type")=="submit"||(O&&O.type=="submit")){E=this;}if(YAHOO.env.ua.ie){N=P.fireEvent("onsubmit");}else{M=document.createEvent("HTMLEvents");M.initEvent("submit",true,true);N=P.dispatchEvent(M);}if((YAHOO.env.ua.ie||YAHOO.env.ua.webkit)&&N){P.submit();}}return N;},init:function(M,T){var O=T.type=="link"?"a":"button",Q=T.srcelement,S=M.getElementsByTagName(O)[0],R;if(!S){R=M.getElementsByTagName("input")[0];if(R){S=document.createElement("button");S.setAttribute("type","button");R.parentNode.replaceChild(S,R);}}this._button=S;YAHOO.widget.Button.superclass.init.call(this,M,T);D[this.get("id")]=this;this.addClass(this.CSS_CLASS_NAME);this.addClass("yui-"+this.get("type")+"-button");L.on(this._button,"focus",this._onFocus,null,this);this.on("mouseover",this._onMouseOver);this.on("click",this._onClick);this.on("appendTo",this._onAppendTo);var V=this.get("container"),N=this.get("element"),U=G.inDocument(N),P;if(V){if(Q&&Q!=N){P=Q.parentNode;if(P){P.removeChild(Q);}}if(I.isString(V)){L.onContentReady(V,function(){this.appendTo(V); -},null,this);}else{this.appendTo(V);}}else{if(!U&&Q&&Q!=N){P=Q.parentNode;if(P){this.fireEvent("beforeAppendTo",{type:"beforeAppendTo",target:P});P.replaceChild(N,Q);this.fireEvent("appendTo",{type:"appendTo",target:P});}}else{if(this.get("type")!="link"&&U&&Q&&Q==N){this._addListenersToForm();}}}},initAttributes:function(N){var M=N||{};YAHOO.widget.Button.superclass.initAttributes.call(this,M);this.setAttributeConfig("type",{value:(M.type||"push"),validator:I.isString,writeOnce:true,method:this._setType});this.setAttributeConfig("label",{value:M.label,validator:I.isString,method:this._setLabel});this.setAttributeConfig("value",{value:M.value});this.setAttributeConfig("name",{value:M.name,validator:I.isString});this.setAttributeConfig("tabindex",{value:M.tabindex,validator:I.isNumber,method:this._setTabIndex});this.configureAttribute("title",{value:M.title,validator:I.isString,method:this._setTitle});this.setAttributeConfig("disabled",{value:(M.disabled||false),validator:I.isBoolean,method:this._setDisabled});this.setAttributeConfig("href",{value:M.href,validator:I.isString,method:this._setHref});this.setAttributeConfig("target",{value:M.target,validator:I.isString,method:this._setTarget});this.setAttributeConfig("checked",{value:(M.checked||false),validator:I.isBoolean,method:this._setChecked});this.setAttributeConfig("container",{value:M.container,writeOnce:true});this.setAttributeConfig("srcelement",{value:M.srcelement,writeOnce:true});this.setAttributeConfig("menu",{value:null,method:this._setMenu,writeOnce:true});this.setAttributeConfig("lazyloadmenu",{value:(M.lazyloadmenu===false?false:true),validator:I.isBoolean,writeOnce:true});this.setAttributeConfig("menuclassname",{value:(M.menuclassname||"yui-button-menu"),validator:I.isString,method:this._setMenuClassName,writeOnce:true});this.setAttributeConfig("selectedMenuItem",{value:0,validator:I.isNumber,method:this._setSelectedMenuItem});this.setAttributeConfig("onclick",{value:M.onclick,method:this._setOnClick});this.setAttributeConfig("focusmenu",{value:(M.focusmenu===false?false:true),validator:I.isBoolean});},focus:function(){if(!this.get("disabled")){this._button.focus();}},blur:function(){if(!this.get("disabled")){this._button.blur();}},hasFocus:function(){return(C==this);},isActive:function(){return this.hasClass(this.CSS_CLASS_NAME+"-active");},getMenu:function(){return this._menu;},getForm:function(){return this._button.form;},getHiddenFields:function(){return this._hiddenFields;},destroy:function(){var O=this.get("element"),N=O.parentNode,M=this._menu,Q;if(M){if(K.find(M)){K.remove(M);}M.destroy();}L.purgeElement(O);L.purgeElement(this._button);L.removeListener(document,"mouseup",this._onDocumentMouseUp);L.removeListener(document,"keyup",this._onDocumentKeyUp);L.removeListener(document,"mousedown",this._onDocumentMouseDown);var P=this.getForm();if(P){L.removeListener(P,"reset",this._onFormReset);L.removeListener(P,"submit",this.createHiddenFields);}this.unsubscribeAll();if(N){N.removeChild(O);}delete D[this.get("id")];Q=G.getElementsByClassName(this.CSS_CLASS_NAME,this.NODE_NAME,P);if(I.isArray(Q)&&Q.length===0){L.removeListener(P,"keypress",YAHOO.widget.Button.onFormKeyPress);}},fireEvent:function(N,M){if(this.DOM_EVENTS[N]&&this.get("disabled")){return ;}YAHOO.widget.Button.superclass.fireEvent.call(this,N,M);},toString:function(){return("Button "+this.get("id"));}});YAHOO.widget.Button.onFormKeyPress=function(Q){var O=L.getTarget(Q),R=L.getCharCode(Q),P=O.nodeName&&O.nodeName.toUpperCase(),M=O.type,S=false,U,V,N,W;function T(Z){var Y,X;switch(Z.nodeName.toUpperCase()){case"INPUT":case"BUTTON":if(Z.type=="submit"&&!Z.disabled){if(!S&&!N){N=Z;}if(V&&!W){W=Z;}}break;default:Y=Z.id;if(Y){U=D[Y];if(U){S=true;if(!U.get("disabled")){X=U.get("srcelement");if(!V&&(U.get("type")=="submit"||(X&&X.type=="submit"))){V=U;}}}}break;}}if(R==13&&((P=="INPUT"&&(M=="text"||M=="password"||M=="checkbox"||M=="radio"||M=="file"))||P=="SELECT")){G.getElementsBy(T,"*",this);if(N){N.focus();}else{if(!N&&V){if(W){L.preventDefault(Q);}V.submitForm();}}}};YAHOO.widget.Button.addHiddenFieldsToForm=function(M){var R=G.getElementsByClassName(YAHOO.widget.Button.prototype.CSS_CLASS_NAME,"*",M),P=R.length,Q,N,O;if(P>0){for(O=0;O0){F=H-1;do{this._buttons[F].set("disabled",G);}while(F--);}},_onKeyDown:function(K){var G=B.getTarget(K),I=B.getCharCode(K),H=G.parentNode.parentNode.id,J=E[H],F=-1;if(I==37||I==38){F=(J.index===0)?(this._buttons.length-1):(J.index-1);}else{if(I==39||I==40){F=(J.index===(this._buttons.length-1))?0:(J.index+1);}}if(F>-1){this.check(F);this.getButton(F).focus();}},_onAppendTo:function(H){var I=this._buttons,G=I.length,F;for(F=0;F0){this.addButtons(J);}function F(K){return(K.type=="radio");}J=C.getElementsBy(F,"input",this.get("element"));if(J.length>0){this.addButtons(J);}this.on("keydown",this._onKeyDown);this.on("appendTo",this._onAppendTo);var G=this.get("container");if(G){if(D.isString(G)){B.onContentReady(G,function(){this.appendTo(G);},null,this);}else{this.appendTo(G);}}},initAttributes:function(G){var F=G||{};YAHOO.widget.ButtonGroup.superclass.initAttributes.call(this,F);this.setAttributeConfig("name",{value:F.name,validator:D.isString});this.setAttributeConfig("disabled",{value:(F.disabled||false),validator:D.isBoolean,method:this._setDisabled});this.setAttributeConfig("value",{value:F.value});this.setAttributeConfig("container",{value:F.container,writeOnce:true});this.setAttributeConfig("checkedButton",{value:null});},addButton:function(J){var L,K,G,F,H,I;if(J instanceof A&&J.get("type")=="radio"){L=J;}else{if(!D.isString(J)&&!J.nodeName){J.type="radio";L=new A(J);}else{L=new A(J,{type:"radio"});}}if(L){F=this._buttons.length;H=L.get("name");I=this.get("name");L.index=F;this._buttons[F]=L;E[L.get("id")]=L;if(H!=I){L.set("name",I);}if(this.get("disabled")){L.set("disabled",true);}if(L.get("checked")){this.set("checkedButton",L);}K=L.get("element");G=this.get("element");if(K.parentNode!=G){G.appendChild(K);}L.on("checkedChange",this._onButtonCheckedChange,L,this);return L;}},addButtons:function(G){var H,I,J,F;if(D.isArray(G)){H=G.length;J=[];if(H>0){for(F=0;F0){return J;}}}},removeButton:function(H){var I=this.getButton(H),G,F;if(I){this._buttons.splice(H,1);delete E[I.get("id")];I.removeListener("checkedChange",this._onButtonCheckedChange);I.destroy();G=this._buttons.length;if(G>0){F=this._buttons.length-1;do{this._buttons[F].index=F;}while(F--);}}},getButton:function(F){if(D.isNumber(F)){return this._buttons[F];}},getButtons:function(){return this._buttons;},getCount:function(){return this._buttons.length;},focus:function(H){var I,G,F;if(D.isNumber(H)){I=this._buttons[H];if(I){I.focus();}}else{G=this.getCount();for(F=0;F0){G=this._buttons.length-1;do{this._buttons[G].destroy();}while(G--);}B.purgeElement(H);F.removeChild(H);},toString:function(){return("ButtonGroup "+this.get("id"));}});})();YAHOO.register("button",YAHOO.widget.Button,{version:"2.3.1",build:"541"}); \ No newline at end of file diff --git a/koha-tmpl/intranet-tmpl/lib/yui/button/button-debug.js b/koha-tmpl/intranet-tmpl/lib/yui/button/button-debug.js deleted file mode 100644 index a79ce3bd18..0000000000 --- a/koha-tmpl/intranet-tmpl/lib/yui/button/button-debug.js +++ /dev/null @@ -1,4694 +0,0 @@ -/* -Copyright (c) 2009, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.8.0r4 -*/ -/** -* @module button -* @description

The Button Control enables the creation of rich, graphical -* buttons that function like traditional HTML form buttons. Unlike -* traditional HTML form buttons, buttons created with the Button Control can have -* a label that is different from its value. With the inclusion of the optional -* Menu Control, the Button Control can also be -* used to create menu buttons and split buttons, controls that are not -* available natively in HTML. The Button Control can also be thought of as a -* way to create more visually engaging implementations of the browser's -* default radio-button and check-box controls.

-*

The Button Control supports the following types:

-*
-*
push
-*
Basic push button that can execute a user-specified command when -* pressed.
-*
link
-*
Navigates to a specified url when pressed.
-*
submit
-*
Submits the parent form when pressed.
-*
reset
-*
Resets the parent form when pressed.
-*
checkbox
-*
Maintains a "checked" state that can be toggled on and off.
-*
radio
-*
Maintains a "checked" state that can be toggled on and off. Use with -* the ButtonGroup class to create a set of controls that are mutually -* exclusive; checking one button in the set will uncheck all others in -* the group.
-*
menu
-*
When pressed will show/hide a menu.
-*
split
-*
Can execute a user-specified command or display a menu when pressed.
-*
-* @title Button -* @namespace YAHOO.widget -* @requires yahoo, dom, element, event -* @optional container, menu -*/ - - -(function () { - - - /** - * The Button class creates a rich, graphical button. - * @param {String} p_oElement String specifying the id attribute of the - * <input>, <button>, - * <a>, or <span> element to - * be used to create the button. - * @param {HTMLInputElement| - * HTMLButtonElement|HTMLElement} p_oElement Object reference for the - * <input>, <button>, - * <a>, or <span> element to be - * used to create the button. - * @param {Object} p_oElement Object literal specifying a set of - * configuration attributes used to create the button. - * @param {Object} p_oAttributes Optional. Object literal specifying a set - * of configuration attributes used to create the button. - * @namespace YAHOO.widget - * @class Button - * @constructor - * @extends YAHOO.util.Element - */ - - - - // Shorthard for utilities - - var Dom = YAHOO.util.Dom, - Event = YAHOO.util.Event, - Lang = YAHOO.lang, - UA = YAHOO.env.ua, - Overlay = YAHOO.widget.Overlay, - Menu = YAHOO.widget.Menu, - - - // Private member variables - - m_oButtons = {}, // Collection of all Button instances - m_oOverlayManager = null, // YAHOO.widget.OverlayManager instance - m_oSubmitTrigger = null, // The button that submitted the form - m_oFocusedButton = null; // The button that has focus - - - - // Private methods - - - - /** - * @method createInputElement - * @description Creates an <input> element of the - * specified type. - * @private - * @param {String} p_sType String specifying the type of - * <input> element to create. - * @param {String} p_sName String specifying the name of - * <input> element to create. - * @param {String} p_sValue String specifying the value of - * <input> element to create. - * @param {String} p_bChecked Boolean specifying if the - * <input> element is to be checked. - * @return {HTMLInputElement} - */ - function createInputElement(p_sType, p_sName, p_sValue, p_bChecked) { - - var oInput, - sInput; - - if (Lang.isString(p_sType) && Lang.isString(p_sName)) { - - if (UA.ie) { - - /* - For IE it is necessary to create the element with the - "type," "name," "value," and "checked" properties set all - at once. - */ - - sInput = "<input> or <a>) that - * map to Button configuration attributes and sets them into a collection - * that is passed to the Button constructor. - * @private - * @param {HTMLInputElement|HTMLAnchorElement} p_oElement Object reference to the HTML - * element (either <input> or <span> - * ) used to create the button. - * @param {Object} p_oAttributes Object reference for the collection of - * configuration attributes used to create the button. - */ - function setAttributesFromSrcElement(p_oElement, p_oAttributes) { - - var sSrcElementNodeName = p_oElement.nodeName.toUpperCase(), - sClass = (this.CLASS_NAME_PREFIX + this.CSS_CLASS_NAME), - me = this, - oAttribute, - oRootNode, - sText; - - - /** - * @method setAttributeFromDOMAttribute - * @description Gets the value of the specified DOM attribute and sets it - * into the collection of configuration attributes used to configure - * the button. - * @private - * @param {String} p_sAttribute String representing the name of the - * attribute to retrieve from the DOM element. - */ - function setAttributeFromDOMAttribute(p_sAttribute) { - - if (!(p_sAttribute in p_oAttributes)) { - - /* - Need to use "getAttributeNode" instead of "getAttribute" - because using "getAttribute," IE will return the innerText - of a <button> for the value attribute - rather than the value of the "value" attribute. - */ - - oAttribute = p_oElement.getAttributeNode(p_sAttribute); - - - if (oAttribute && ("value" in oAttribute)) { - - YAHOO.log("Setting attribute \"" + p_sAttribute + - "\" using source element's attribute value of \"" + - oAttribute.value + "\"", "info", me.toString()); - - p_oAttributes[p_sAttribute] = oAttribute.value; - - } - - } - - } - - - /** - * @method setFormElementProperties - * @description Gets the value of the attributes from the form element - * and sets them into the collection of configuration attributes used to - * configure the button. - * @private - */ - function setFormElementProperties() { - - setAttributeFromDOMAttribute("type"); - - if (p_oAttributes.type == "button") { - - p_oAttributes.type = "push"; - - } - - if (!("disabled" in p_oAttributes)) { - - p_oAttributes.disabled = p_oElement.disabled; - - } - - setAttributeFromDOMAttribute("name"); - setAttributeFromDOMAttribute("value"); - setAttributeFromDOMAttribute("title"); - - } - - - switch (sSrcElementNodeName) { - - case "A": - - p_oAttributes.type = "link"; - - setAttributeFromDOMAttribute("href"); - setAttributeFromDOMAttribute("target"); - - break; - - case "INPUT": - - setFormElementProperties(); - - if (!("checked" in p_oAttributes)) { - - p_oAttributes.checked = p_oElement.checked; - - } - - break; - - case "BUTTON": - - setFormElementProperties(); - - oRootNode = p_oElement.parentNode.parentNode; - - if (Dom.hasClass(oRootNode, sClass + "-checked")) { - - p_oAttributes.checked = true; - - } - - if (Dom.hasClass(oRootNode, sClass + "-disabled")) { - - p_oAttributes.disabled = true; - - } - - p_oElement.removeAttribute("value"); - - p_oElement.setAttribute("type", "button"); - - break; - - } - - p_oElement.removeAttribute("id"); - p_oElement.removeAttribute("name"); - - if (!("tabindex" in p_oAttributes)) { - - p_oAttributes.tabindex = p_oElement.tabIndex; - - } - - if (!("label" in p_oAttributes)) { - - // Set the "label" property - - sText = sSrcElementNodeName == "INPUT" ? - p_oElement.value : p_oElement.innerHTML; - - - if (sText && sText.length > 0) { - - p_oAttributes.label = sText; - - } - - } - - } - - - /** - * @method initConfig - * @description Initializes the set of configuration attributes that are - * used to instantiate the button. - * @private - * @param {Object} Object representing the button's set of - * configuration attributes. - */ - function initConfig(p_oConfig) { - - var oAttributes = p_oConfig.attributes, - oSrcElement = oAttributes.srcelement, - sSrcElementNodeName = oSrcElement.nodeName.toUpperCase(), - me = this; - - - if (sSrcElementNodeName == this.NODE_NAME) { - - p_oConfig.element = oSrcElement; - p_oConfig.id = oSrcElement.id; - - Dom.getElementsBy(function (p_oElement) { - - switch (p_oElement.nodeName.toUpperCase()) { - - case "BUTTON": - case "A": - case "INPUT": - - setAttributesFromSrcElement.call(me, p_oElement, - oAttributes); - - break; - - } - - }, "*", oSrcElement); - - } - else { - - switch (sSrcElementNodeName) { - - case "BUTTON": - case "A": - case "INPUT": - - setAttributesFromSrcElement.call(this, oSrcElement, - oAttributes); - - break; - - } - - } - - } - - - - // Constructor - - YAHOO.widget.Button = function (p_oElement, p_oAttributes) { - - if (!Overlay && YAHOO.widget.Overlay) { - - Overlay = YAHOO.widget.Overlay; - - } - - - if (!Menu && YAHOO.widget.Menu) { - - Menu = YAHOO.widget.Menu; - - } - - - var fnSuperClass = YAHOO.widget.Button.superclass.constructor, - oConfig, - oElement; - - - if (arguments.length == 1 && !Lang.isString(p_oElement) && !p_oElement.nodeName) { - - if (!p_oElement.id) { - - p_oElement.id = Dom.generateId(); - - YAHOO.log("No value specified for the button's \"id\" " + - "attribute. Setting button id to \"" + p_oElement.id + - "\".", "info", this.toString()); - - } - - YAHOO.log("No source HTML element. Building the button " + - "using the set of configuration attributes.", "info", this.toString()); - - fnSuperClass.call(this, (this.createButtonElement(p_oElement.type)), p_oElement); - - } - else { - - oConfig = { element: null, attributes: (p_oAttributes || {}) }; - - - if (Lang.isString(p_oElement)) { - - oElement = Dom.get(p_oElement); - - if (oElement) { - - if (!oConfig.attributes.id) { - - oConfig.attributes.id = p_oElement; - - } - - YAHOO.log("Building the button using an existing " + - "HTML element as a source element.", "info", this.toString()); - - - oConfig.attributes.srcelement = oElement; - - initConfig.call(this, oConfig); - - - if (!oConfig.element) { - - YAHOO.log("Source element could not be used " + - "as is. Creating a new HTML element for " + - "the button.", "info", this.toString()); - - oConfig.element = this.createButtonElement(oConfig.attributes.type); - - } - - fnSuperClass.call(this, oConfig.element, oConfig.attributes); - - } - - } - else if (p_oElement.nodeName) { - - if (!oConfig.attributes.id) { - - if (p_oElement.id) { - - oConfig.attributes.id = p_oElement.id; - - } - else { - - oConfig.attributes.id = Dom.generateId(); - - YAHOO.log("No value specified for the button's " + - "\"id\" attribute. Setting button id to \"" + - oConfig.attributes.id + "\".", "info", this.toString()); - - } - - } - - YAHOO.log("Building the button using an existing HTML " + - "element as a source element.", "info", this.toString()); - - - oConfig.attributes.srcelement = p_oElement; - - initConfig.call(this, oConfig); - - - if (!oConfig.element) { - - YAHOO.log("Source element could not be used as is." + - " Creating a new HTML element for the button.", - "info", this.toString()); - - oConfig.element = this.createButtonElement(oConfig.attributes.type); - - } - - fnSuperClass.call(this, oConfig.element, oConfig.attributes); - - } - - } - - }; - - - - YAHOO.extend(YAHOO.widget.Button, YAHOO.util.Element, { - - - // Protected properties - - - /** - * @property _button - * @description Object reference to the button's internal - * <a> or <button> element. - * @default null - * @protected - * @type HTMLAnchorElement|HTMLButtonElement - */ - _button: null, - - - /** - * @property _menu - * @description Object reference to the button's menu. - * @default null - * @protected - * @type {YAHOO.widget.Overlay| - * YAHOO.widget.Menu} - */ - _menu: null, - - - /** - * @property _hiddenFields - * @description Object reference to the <input> - * element, or array of HTML form elements used to represent the button - * when its parent form is submitted. - * @default null - * @protected - * @type HTMLInputElement|Array - */ - _hiddenFields: null, - - - /** - * @property _onclickAttributeValue - * @description Object reference to the button's current value for the - * "onclick" configuration attribute. - * @default null - * @protected - * @type Object - */ - _onclickAttributeValue: null, - - - /** - * @property _activationKeyPressed - * @description Boolean indicating if the key(s) that toggle the button's - * "active" state have been pressed. - * @default false - * @protected - * @type Boolean - */ - _activationKeyPressed: false, - - - /** - * @property _activationButtonPressed - * @description Boolean indicating if the mouse button that toggles - * the button's "active" state has been pressed. - * @default false - * @protected - * @type Boolean - */ - _activationButtonPressed: false, - - - /** - * @property _hasKeyEventHandlers - * @description Boolean indicating if the button's "blur", "keydown" and - * "keyup" event handlers are assigned - * @default false - * @protected - * @type Boolean - */ - _hasKeyEventHandlers: false, - - - /** - * @property _hasMouseEventHandlers - * @description Boolean indicating if the button's "mouseout," - * "mousedown," and "mouseup" event handlers are assigned - * @default false - * @protected - * @type Boolean - */ - _hasMouseEventHandlers: false, - - - /** - * @property _nOptionRegionX - * @description Number representing the X coordinate of the leftmost edge of the Button's - * option region. Applies only to Buttons of type "split". - * @default 0 - * @protected - * @type Number - */ - _nOptionRegionX: 0, - - - - // Constants - - /** - * @property CLASS_NAME_PREFIX - * @description Prefix used for all class names applied to a Button. - * @default "yui-" - * @final - * @type String - */ - CLASS_NAME_PREFIX: "yui-", - - - /** - * @property NODE_NAME - * @description The name of the node to be used for the button's - * root element. - * @default "SPAN" - * @final - * @type String - */ - NODE_NAME: "SPAN", - - - /** - * @property CHECK_ACTIVATION_KEYS - * @description Array of numbers representing keys that (when pressed) - * toggle the button's "checked" attribute. - * @default [32] - * @final - * @type Array - */ - CHECK_ACTIVATION_KEYS: [32], - - - /** - * @property ACTIVATION_KEYS - * @description Array of numbers representing keys that (when presed) - * toggle the button's "active" state. - * @default [13, 32] - * @final - * @type Array - */ - ACTIVATION_KEYS: [13, 32], - - - /** - * @property OPTION_AREA_WIDTH - * @description Width (in pixels) of the area of a split button that - * when pressed will display a menu. - * @default 20 - * @final - * @type Number - */ - OPTION_AREA_WIDTH: 20, - - - /** - * @property CSS_CLASS_NAME - * @description String representing the CSS class(es) to be applied to - * the button's root element. - * @default "button" - * @final - * @type String - */ - CSS_CLASS_NAME: "button", - - - - // Protected attribute setter methods - - - /** - * @method _setType - * @description Sets the value of the button's "type" attribute. - * @protected - * @param {String} p_sType String indicating the value for the button's - * "type" attribute. - */ - _setType: function (p_sType) { - - if (p_sType == "split") { - - this.on("option", this._onOption); - - } - - }, - - - /** - * @method _setLabel - * @description Sets the value of the button's "label" attribute. - * @protected - * @param {String} p_sLabel String indicating the value for the button's - * "label" attribute. - */ - _setLabel: function (p_sLabel) { - - this._button.innerHTML = p_sLabel; - - - /* - Remove and add the default class name from the root element - for Gecko to ensure that the button shrinkwraps to the label. - Without this the button will not be rendered at the correct - width when the label changes. The most likely cause for this - bug is button's use of the Gecko-specific CSS display type of - "-moz-inline-box" to simulate "inline-block" supported by IE, - Safari and Opera. - */ - - var sClass, - nGeckoVersion = UA.gecko; - - - if (nGeckoVersion && nGeckoVersion < 1.9 && Dom.inDocument(this.get("element"))) { - - sClass = (this.CLASS_NAME_PREFIX + this.CSS_CLASS_NAME); - - this.removeClass(sClass); - - Lang.later(0, this, this.addClass, sClass); - - } - - }, - - - /** - * @method _setTabIndex - * @description Sets the value of the button's "tabindex" attribute. - * @protected - * @param {Number} p_nTabIndex Number indicating the value for the - * button's "tabindex" attribute. - */ - _setTabIndex: function (p_nTabIndex) { - - this._button.tabIndex = p_nTabIndex; - - }, - - - /** - * @method _setTitle - * @description Sets the value of the button's "title" attribute. - * @protected - * @param {String} p_nTabIndex Number indicating the value for - * the button's "title" attribute. - */ - _setTitle: function (p_sTitle) { - - if (this.get("type") != "link") { - - this._button.title = p_sTitle; - - } - - }, - - - /** - * @method _setDisabled - * @description Sets the value of the button's "disabled" attribute. - * @protected - * @param {Boolean} p_bDisabled Boolean indicating the value for - * the button's "disabled" attribute. - */ - _setDisabled: function (p_bDisabled) { - - if (this.get("type") != "link") { - - if (p_bDisabled) { - - if (this._menu) { - - this._menu.hide(); - - } - - if (this.hasFocus()) { - - this.blur(); - - } - - this._button.setAttribute("disabled", "disabled"); - - this.addStateCSSClasses("disabled"); - - this.removeStateCSSClasses("hover"); - this.removeStateCSSClasses("active"); - this.removeStateCSSClasses("focus"); - - } - else { - - this._button.removeAttribute("disabled"); - - this.removeStateCSSClasses("disabled"); - - } - - } - - }, - - - /** - * @method _setHref - * @description Sets the value of the button's "href" attribute. - * @protected - * @param {String} p_sHref String indicating the value for the button's - * "href" attribute. - */ - _setHref: function (p_sHref) { - - if (this.get("type") == "link") { - - this._button.href = p_sHref; - - } - - }, - - - /** - * @method _setTarget - * @description Sets the value of the button's "target" attribute. - * @protected - * @param {String} p_sTarget String indicating the value for the button's - * "target" attribute. - */ - _setTarget: function (p_sTarget) { - - if (this.get("type") == "link") { - - this._button.setAttribute("target", p_sTarget); - - } - - }, - - - /** - * @method _setChecked - * @description Sets the value of the button's "target" attribute. - * @protected - * @param {Boolean} p_bChecked Boolean indicating the value for - * the button's "checked" attribute. - */ - _setChecked: function (p_bChecked) { - - var sType = this.get("type"); - - if (sType == "checkbox" || sType == "radio") { - - if (p_bChecked) { - this.addStateCSSClasses("checked"); - } - else { - this.removeStateCSSClasses("checked"); - } - - } - - }, - - - /** - * @method _setMenu - * @description Sets the value of the button's "menu" attribute. - * @protected - * @param {Object} p_oMenu Object indicating the value for the button's - * "menu" attribute. - */ - _setMenu: function (p_oMenu) { - - var bLazyLoad = this.get("lazyloadmenu"), - oButtonElement = this.get("element"), - sMenuCSSClassName, - - /* - Boolean indicating if the value of p_oMenu is an instance - of YAHOO.widget.Menu or YAHOO.widget.Overlay. - */ - - bInstance = false, - oMenu, - oMenuElement, - oSrcElement; - - - function onAppendTo() { - - oMenu.render(oButtonElement.parentNode); - - this.removeListener("appendTo", onAppendTo); - - } - - - function setMenuContainer() { - - oMenu.cfg.queueProperty("container", oButtonElement.parentNode); - - this.removeListener("appendTo", setMenuContainer); - - } - - - function initMenu() { - - var oContainer; - - if (oMenu) { - - Dom.addClass(oMenu.element, this.get("menuclassname")); - Dom.addClass(oMenu.element, this.CLASS_NAME_PREFIX + this.get("type") + "-button-menu"); - - oMenu.showEvent.subscribe(this._onMenuShow, null, this); - oMenu.hideEvent.subscribe(this._onMenuHide, null, this); - oMenu.renderEvent.subscribe(this._onMenuRender, null, this); - - - if (Menu && oMenu instanceof Menu) { - - if (bLazyLoad) { - - oContainer = this.get("container"); - - if (oContainer) { - - oMenu.cfg.queueProperty("container", oContainer); - - } - else { - - this.on("appendTo", setMenuContainer); - - } - - } - - oMenu.cfg.queueProperty("clicktohide", false); - - oMenu.keyDownEvent.subscribe(this._onMenuKeyDown, this, true); - oMenu.subscribe("click", this._onMenuClick, this, true); - - this.on("selectedMenuItemChange", this._onSelectedMenuItemChange); - - oSrcElement = oMenu.srcElement; - - if (oSrcElement && oSrcElement.nodeName.toUpperCase() == "SELECT") { - - oSrcElement.style.display = "none"; - oSrcElement.parentNode.removeChild(oSrcElement); - - } - - } - else if (Overlay && oMenu instanceof Overlay) { - - if (!m_oOverlayManager) { - - m_oOverlayManager = new YAHOO.widget.OverlayManager(); - - } - - m_oOverlayManager.register(oMenu); - - } - - - this._menu = oMenu; - - - if (!bInstance && !bLazyLoad) { - - if (Dom.inDocument(oButtonElement)) { - - oMenu.render(oButtonElement.parentNode); - - } - else { - - this.on("appendTo", onAppendTo); - - } - - } - - } - - } - - - if (Overlay) { - - if (Menu) { - - sMenuCSSClassName = Menu.prototype.CSS_CLASS_NAME; - - } - - if (p_oMenu && Menu && (p_oMenu instanceof Menu)) { - - oMenu = p_oMenu; - bInstance = true; - - initMenu.call(this); - - } - else if (Overlay && p_oMenu && (p_oMenu instanceof Overlay)) { - - oMenu = p_oMenu; - bInstance = true; - - oMenu.cfg.queueProperty("visible", false); - - initMenu.call(this); - - } - else if (Menu && Lang.isArray(p_oMenu)) { - - oMenu = new Menu(Dom.generateId(), { lazyload: bLazyLoad, itemdata: p_oMenu }); - - this._menu = oMenu; - - this.on("appendTo", initMenu); - - } - else if (Lang.isString(p_oMenu)) { - - oMenuElement = Dom.get(p_oMenu); - - if (oMenuElement) { - - if (Menu && Dom.hasClass(oMenuElement, sMenuCSSClassName) || - oMenuElement.nodeName.toUpperCase() == "SELECT") { - - oMenu = new Menu(p_oMenu, { lazyload: bLazyLoad }); - - initMenu.call(this); - - } - else if (Overlay) { - - oMenu = new Overlay(p_oMenu, { visible: false }); - - initMenu.call(this); - - } - - } - - } - else if (p_oMenu && p_oMenu.nodeName) { - - if (Menu && Dom.hasClass(p_oMenu, sMenuCSSClassName) || - p_oMenu.nodeName.toUpperCase() == "SELECT") { - - oMenu = new Menu(p_oMenu, { lazyload: bLazyLoad }); - - initMenu.call(this); - - } - else if (Overlay) { - - if (!p_oMenu.id) { - - Dom.generateId(p_oMenu); - - } - - oMenu = new Overlay(p_oMenu, { visible: false }); - - initMenu.call(this); - - } - - } - - } - - }, - - - /** - * @method _setOnClick - * @description Sets the value of the button's "onclick" attribute. - * @protected - * @param {Object} p_oObject Object indicating the value for the button's - * "onclick" attribute. - */ - _setOnClick: function (p_oObject) { - - /* - Remove any existing listeners if a "click" event handler - has already been specified. - */ - - if (this._onclickAttributeValue && - (this._onclickAttributeValue != p_oObject)) { - - this.removeListener("click", this._onclickAttributeValue.fn); - - this._onclickAttributeValue = null; - - } - - - if (!this._onclickAttributeValue && - Lang.isObject(p_oObject) && - Lang.isFunction(p_oObject.fn)) { - - this.on("click", p_oObject.fn, p_oObject.obj, p_oObject.scope); - - this._onclickAttributeValue = p_oObject; - - } - - }, - - - - // Protected methods - - - - /** - * @method _isActivationKey - * @description Determines if the specified keycode is one that toggles - * the button's "active" state. - * @protected - * @param {Number} p_nKeyCode Number representing the keycode to - * be evaluated. - * @return {Boolean} - */ - _isActivationKey: function (p_nKeyCode) { - - var sType = this.get("type"), - aKeyCodes = (sType == "checkbox" || sType == "radio") ? - this.CHECK_ACTIVATION_KEYS : this.ACTIVATION_KEYS, - - nKeyCodes = aKeyCodes.length, - bReturnVal = false, - i; - - - if (nKeyCodes > 0) { - - i = nKeyCodes - 1; - - do { - - if (p_nKeyCode == aKeyCodes[i]) { - - bReturnVal = true; - break; - - } - - } - while (i--); - - } - - return bReturnVal; - - }, - - - /** - * @method _isSplitButtonOptionKey - * @description Determines if the specified keycode is one that toggles - * the display of the split button's menu. - * @protected - * @param {Event} p_oEvent Object representing the DOM event object - * passed back by the event utility (YAHOO.util.Event). - * @return {Boolean} - */ - _isSplitButtonOptionKey: function (p_oEvent) { - - var bShowMenu = (Event.getCharCode(p_oEvent) == 40); - - - var onKeyPress = function (p_oEvent) { - - Event.preventDefault(p_oEvent); - - this.removeListener("keypress", onKeyPress); - - }; - - - // Prevent the browser from scrolling the window - if (bShowMenu) { - - if (UA.opera) { - - this.on("keypress", onKeyPress); - - } - - Event.preventDefault(p_oEvent); - } - - return bShowMenu; - - }, - - - /** - * @method _addListenersToForm - * @description Adds event handlers to the button's form. - * @protected - */ - _addListenersToForm: function () { - - var oForm = this.getForm(), - onFormKeyPress = YAHOO.widget.Button.onFormKeyPress, - bHasKeyPressListener, - oSrcElement, - aListeners, - nListeners, - i; - - - if (oForm) { - - Event.on(oForm, "reset", this._onFormReset, null, this); - Event.on(oForm, "submit", this._onFormSubmit, null, this); - - oSrcElement = this.get("srcelement"); - - - if (this.get("type") == "submit" || - (oSrcElement && oSrcElement.type == "submit")) - { - - aListeners = Event.getListeners(oForm, "keypress"); - bHasKeyPressListener = false; - - if (aListeners) { - - nListeners = aListeners.length; - - if (nListeners > 0) { - - i = nListeners - 1; - - do { - - if (aListeners[i].fn == onFormKeyPress) { - - bHasKeyPressListener = true; - break; - - } - - } - while (i--); - - } - - } - - - if (!bHasKeyPressListener) { - - Event.on(oForm, "keypress", onFormKeyPress); - - } - - } - - } - - }, - - - - /** - * @method _showMenu - * @description Shows the button's menu. - * @protected - * @param {Event} p_oEvent Object representing the DOM event object - * passed back by the event utility (YAHOO.util.Event) that triggered - * the display of the menu. - */ - _showMenu: function (p_oEvent) { - - if (YAHOO.widget.MenuManager) { - YAHOO.widget.MenuManager.hideVisible(); - } - - - if (m_oOverlayManager) { - m_oOverlayManager.hideAll(); - } - - - var oMenu = this._menu, - aMenuAlignment = this.get("menualignment"), - bFocusMenu = this.get("focusmenu"), - fnFocusMethod; - - - if (this._renderedMenu) { - - oMenu.cfg.setProperty("context", - [this.get("element"), aMenuAlignment[0], aMenuAlignment[1]]); - - oMenu.cfg.setProperty("preventcontextoverlap", true); - oMenu.cfg.setProperty("constraintoviewport", true); - - } - else { - - oMenu.cfg.queueProperty("context", - [this.get("element"), aMenuAlignment[0], aMenuAlignment[1]]); - - oMenu.cfg.queueProperty("preventcontextoverlap", true); - oMenu.cfg.queueProperty("constraintoviewport", true); - - } - - - /* - Refocus the Button before showing its Menu in case the call to - YAHOO.widget.MenuManager.hideVisible() resulted in another element in the - DOM being focused after another Menu was hidden. - */ - - this.focus(); - - - if (Menu && oMenu && (oMenu instanceof Menu)) { - - // Since Menus automatically focus themselves when made visible, temporarily - // replace the Menu focus method so that the value of the Button's "focusmenu" - // attribute determines if the Menu should be focus when made visible. - - fnFocusMethod = oMenu.focus; - - oMenu.focus = function () {}; - - if (this._renderedMenu) { - - oMenu.cfg.setProperty("minscrollheight", this.get("menuminscrollheight")); - oMenu.cfg.setProperty("maxheight", this.get("menumaxheight")); - - } - else { - - oMenu.cfg.queueProperty("minscrollheight", this.get("menuminscrollheight")); - oMenu.cfg.queueProperty("maxheight", this.get("menumaxheight")); - - } - - - oMenu.show(); - - oMenu.focus = fnFocusMethod; - - oMenu.align(); - - - /* - Stop the propagation of the event so that the MenuManager - doesn't blur the menu after it gets focus. - */ - - if (p_oEvent.type == "mousedown") { - Event.stopPropagation(p_oEvent); - } - - - if (bFocusMenu) { - oMenu.focus(); - } - - } - else if (Overlay && oMenu && (oMenu instanceof Overlay)) { - - if (!this._renderedMenu) { - oMenu.render(this.get("element").parentNode); - } - - oMenu.show(); - oMenu.align(); - - } - - }, - - - /** - * @method _hideMenu - * @description Hides the button's menu. - * @protected - */ - _hideMenu: function () { - - var oMenu = this._menu; - - if (oMenu) { - - oMenu.hide(); - - } - - }, - - - - - // Protected event handlers - - - /** - * @method _onMouseOver - * @description "mouseover" event handler for the button. - * @protected - * @param {Event} p_oEvent Object representing the DOM event object - * passed back by the event utility (YAHOO.util.Event). - */ - _onMouseOver: function (p_oEvent) { - - var sType = this.get("type"), - oElement, - nOptionRegionX; - - - if (sType === "split") { - - oElement = this.get("element"); - nOptionRegionX = - (Dom.getX(oElement) + (oElement.offsetWidth - this.OPTION_AREA_WIDTH)); - - this._nOptionRegionX = nOptionRegionX; - - } - - - if (!this._hasMouseEventHandlers) { - - if (sType === "split") { - - this.on("mousemove", this._onMouseMove); - - } - - this.on("mouseout", this._onMouseOut); - - this._hasMouseEventHandlers = true; - - } - - - this.addStateCSSClasses("hover"); - - - if (sType === "split" && (Event.getPageX(p_oEvent) > nOptionRegionX)) { - - this.addStateCSSClasses("hoveroption"); - - } - - - if (this._activationButtonPressed) { - - this.addStateCSSClasses("active"); - - } - - - if (this._bOptionPressed) { - - this.addStateCSSClasses("activeoption"); - - } - - - if (this._activationButtonPressed || this._bOptionPressed) { - - Event.removeListener(document, "mouseup", this._onDocumentMouseUp); - - } - - }, - - - /** - * @method _onMouseMove - * @description "mousemove" event handler for the button. - * @protected - * @param {Event} p_oEvent Object representing the DOM event object - * passed back by the event utility (YAHOO.util.Event). - */ - _onMouseMove: function (p_oEvent) { - - var nOptionRegionX = this._nOptionRegionX; - - if (nOptionRegionX) { - - if (Event.getPageX(p_oEvent) > nOptionRegionX) { - - this.addStateCSSClasses("hoveroption"); - - } - else { - - this.removeStateCSSClasses("hoveroption"); - - } - - } - - }, - - /** - * @method _onMouseOut - * @description "mouseout" event handler for the button. - * @protected - * @param {Event} p_oEvent Object representing the DOM event object - * passed back by the event utility (YAHOO.util.Event). - */ - _onMouseOut: function (p_oEvent) { - - var sType = this.get("type"); - - this.removeStateCSSClasses("hover"); - - - if (sType != "menu") { - - this.removeStateCSSClasses("active"); - - } - - - if (this._activationButtonPressed || this._bOptionPressed) { - - Event.on(document, "mouseup", this._onDocumentMouseUp, null, this); - - } - - - if (sType === "split" && (Event.getPageX(p_oEvent) > this._nOptionRegionX)) { - - this.removeStateCSSClasses("hoveroption"); - - } - - }, - - - /** - * @method _onDocumentMouseUp - * @description "mouseup" event handler for the button. - * @protected - * @param {Event} p_oEvent Object representing the DOM event object - * passed back by the event utility (YAHOO.util.Event). - */ - _onDocumentMouseUp: function (p_oEvent) { - - this._activationButtonPressed = false; - this._bOptionPressed = false; - - var sType = this.get("type"), - oTarget, - oMenuElement; - - if (sType == "menu" || sType == "split") { - - oTarget = Event.getTarget(p_oEvent); - oMenuElement = this._menu.element; - - if (oTarget != oMenuElement && - !Dom.isAncestor(oMenuElement, oTarget)) { - - this.removeStateCSSClasses((sType == "menu" ? - "active" : "activeoption")); - - this._hideMenu(); - - } - - } - - Event.removeListener(document, "mouseup", this._onDocumentMouseUp); - - }, - - - /** - * @method _onMouseDown - * @description "mousedown" event handler for the button. - * @protected - * @param {Event} p_oEvent Object representing the DOM event object - * passed back by the event utility (YAHOO.util.Event). - */ - _onMouseDown: function (p_oEvent) { - - var sType, - bReturnVal = true; - - - function onMouseUp() { - - this._hideMenu(); - this.removeListener("mouseup", onMouseUp); - - } - - - if ((p_oEvent.which || p_oEvent.button) == 1) { - - - if (!this.hasFocus()) { - - this.focus(); - - } - - - sType = this.get("type"); - - - if (sType == "split") { - - if (Event.getPageX(p_oEvent) > this._nOptionRegionX) { - - this.fireEvent("option", p_oEvent); - bReturnVal = false; - - } - else { - - this.addStateCSSClasses("active"); - - this._activationButtonPressed = true; - - } - - } - else if (sType == "menu") { - - if (this.isActive()) { - - this._hideMenu(); - - this._activationButtonPressed = false; - - } - else { - - this._showMenu(p_oEvent); - - this._activationButtonPressed = true; - - } - - } - else { - - this.addStateCSSClasses("active"); - - this._activationButtonPressed = true; - - } - - - - if (sType == "split" || sType == "menu") { - - this._hideMenuTimer = Lang.later(250, this, this.on, ["mouseup", onMouseUp]); - - } - - } - - return bReturnVal; - - }, - - - /** - * @method _onMouseUp - * @description "mouseup" event handler for the button. - * @protected - * @param {Event} p_oEvent Object representing the DOM event object - * passed back by the event utility (YAHOO.util.Event). - */ - _onMouseUp: function (p_oEvent) { - - var sType = this.get("type"), - oHideMenuTimer = this._hideMenuTimer, - bReturnVal = true; - - - if (oHideMenuTimer) { - - oHideMenuTimer.cancel(); - - } - - - if (sType == "checkbox" || sType == "radio") { - - this.set("checked", !(this.get("checked"))); - - } - - - this._activationButtonPressed = false; - - - if (sType != "menu") { - - this.removeStateCSSClasses("active"); - - } - - - if (sType == "split" && Event.getPageX(p_oEvent) > this._nOptionRegionX) { - - bReturnVal = false; - - } - - return bReturnVal; - - }, - - - /** - * @method _onFocus - * @description "focus" event handler for the button. - * @protected - * @param {Event} p_oEvent Object representing the DOM event object - * passed back by the event utility (YAHOO.util.Event). - */ - _onFocus: function (p_oEvent) { - - var oElement; - - this.addStateCSSClasses("focus"); - - if (this._activationKeyPressed) { - - this.addStateCSSClasses("active"); - - } - - m_oFocusedButton = this; - - - if (!this._hasKeyEventHandlers) { - - oElement = this._button; - - Event.on(oElement, "blur", this._onBlur, null, this); - Event.on(oElement, "keydown", this._onKeyDown, null, this); - Event.on(oElement, "keyup", this._onKeyUp, null, this); - - this._hasKeyEventHandlers = true; - - } - - - this.fireEvent("focus", p_oEvent); - - }, - - - /** - * @method _onBlur - * @description "blur" event handler for the button. - * @protected - * @param {Event} p_oEvent Object representing the DOM event object - * passed back by the event utility (YAHOO.util.Event). - */ - _onBlur: function (p_oEvent) { - - this.removeStateCSSClasses("focus"); - - if (this.get("type") != "menu") { - - this.removeStateCSSClasses("active"); - - } - - if (this._activationKeyPressed) { - - Event.on(document, "keyup", this._onDocumentKeyUp, null, this); - - } - - - m_oFocusedButton = null; - - this.fireEvent("blur", p_oEvent); - - }, - - - /** - * @method _onDocumentKeyUp - * @description "keyup" event handler for the document. - * @protected - * @param {Event} p_oEvent Object representing the DOM event object - * passed back by the event utility (YAHOO.util.Event). - */ - _onDocumentKeyUp: function (p_oEvent) { - - if (this._isActivationKey(Event.getCharCode(p_oEvent))) { - - this._activationKeyPressed = false; - - Event.removeListener(document, "keyup", this._onDocumentKeyUp); - - } - - }, - - - /** - * @method _onKeyDown - * @description "keydown" event handler for the button. - * @protected - * @param {Event} p_oEvent Object representing the DOM event object - * passed back by the event utility (YAHOO.util.Event). - */ - _onKeyDown: function (p_oEvent) { - - var oMenu = this._menu; - - - if (this.get("type") == "split" && - this._isSplitButtonOptionKey(p_oEvent)) { - - this.fireEvent("option", p_oEvent); - - } - else if (this._isActivationKey(Event.getCharCode(p_oEvent))) { - - if (this.get("type") == "menu") { - - this._showMenu(p_oEvent); - - } - else { - - this._activationKeyPressed = true; - - this.addStateCSSClasses("active"); - - } - - } - - - if (oMenu && oMenu.cfg.getProperty("visible") && - Event.getCharCode(p_oEvent) == 27) { - - oMenu.hide(); - this.focus(); - - } - - }, - - - /** - * @method _onKeyUp - * @description "keyup" event handler for the button. - * @protected - * @param {Event} p_oEvent Object representing the DOM event object - * passed back by the event utility (YAHOO.util.Event). - */ - _onKeyUp: function (p_oEvent) { - - var sType; - - if (this._isActivationKey(Event.getCharCode(p_oEvent))) { - - sType = this.get("type"); - - if (sType == "checkbox" || sType == "radio") { - - this.set("checked", !(this.get("checked"))); - - } - - this._activationKeyPressed = false; - - if (this.get("type") != "menu") { - - this.removeStateCSSClasses("active"); - - } - - } - - }, - - - /** - * @method _onClick - * @description "click" event handler for the button. - * @protected - * @param {Event} p_oEvent Object representing the DOM event object - * passed back by the event utility (YAHOO.util.Event). - */ - _onClick: function (p_oEvent) { - - var sType = this.get("type"), - oForm, - oSrcElement, - bReturnVal; - - - switch (sType) { - - case "submit": - - if (p_oEvent.returnValue !== false) { - - this.submitForm(); - - } - - break; - - case "reset": - - oForm = this.getForm(); - - if (oForm) { - - oForm.reset(); - - } - - break; - - - case "split": - - if (this._nOptionRegionX > 0 && - (Event.getPageX(p_oEvent) > this._nOptionRegionX)) { - - bReturnVal = false; - - } - else { - - this._hideMenu(); - - oSrcElement = this.get("srcelement"); - - if (oSrcElement && oSrcElement.type == "submit" && - p_oEvent.returnValue !== false) { - - this.submitForm(); - - } - - } - - break; - - } - - return bReturnVal; - - }, - - - /** - * @method _onDblClick - * @description "dblclick" event handler for the button. - * @protected - * @param {Event} p_oEvent Object representing the DOM event object - * passed back by the event utility (YAHOO.util.Event). - */ - _onDblClick: function (p_oEvent) { - - var bReturnVal = true; - - if (this.get("type") == "split" && Event.getPageX(p_oEvent) > this._nOptionRegionX) { - - bReturnVal = false; - - } - - return bReturnVal; - - }, - - - /** - * @method _onAppendTo - * @description "appendTo" event handler for the button. - * @protected - * @param {Event} p_oEvent Object representing the DOM event object - * passed back by the event utility (YAHOO.util.Event). - */ - _onAppendTo: function (p_oEvent) { - - /* - It is necessary to call "_addListenersToForm" using - "setTimeout" to make sure that the button's "form" property - returns a node reference. Sometimes, if you try to get the - reference immediately after appending the field, it is null. - */ - - Lang.later(0, this, this._addListenersToForm); - - }, - - - /** - * @method _onFormReset - * @description "reset" event handler for the button's form. - * @protected - * @param {Event} p_oEvent Object representing the DOM event - * object passed back by the event utility (YAHOO.util.Event). - */ - _onFormReset: function (p_oEvent) { - - var sType = this.get("type"), - oMenu = this._menu; - - if (sType == "checkbox" || sType == "radio") { - - this.resetValue("checked"); - - } - - - if (Menu && oMenu && (oMenu instanceof Menu)) { - - this.resetValue("selectedMenuItem"); - - } - - }, - - - /** - * @method _onFormSubmit - * @description "submit" event handler for the button's form. - * @protected - * @param {Event} p_oEvent Object representing the DOM event - * object passed back by the event utility (YAHOO.util.Event). - */ - _onFormSubmit: function (p_oEvent) { - - this.createHiddenFields(); - - }, - - - /** - * @method _onDocumentMouseDown - * @description "mousedown" event handler for the document. - * @protected - * @param {Event} p_oEvent Object representing the DOM event object - * passed back by the event utility (YAHOO.util.Event). - */ - _onDocumentMouseDown: function (p_oEvent) { - - var oTarget = Event.getTarget(p_oEvent), - oButtonElement = this.get("element"), - oMenuElement = this._menu.element; - - - if (oTarget != oButtonElement && - !Dom.isAncestor(oButtonElement, oTarget) && - oTarget != oMenuElement && - !Dom.isAncestor(oMenuElement, oTarget)) { - - this._hideMenu(); - - // In IE when the user mouses down on a focusable element - // that element will be focused and become the "activeElement". - // (http://msdn.microsoft.com/en-us/library/ms533065(VS.85).aspx) - // However, there is a bug in IE where if there is a - // positioned element with a focused descendant that is - // hidden in response to the mousedown event, the target of - // the mousedown event will appear to have focus, but will - // not be set as the activeElement. This will result - // in the element not firing key events, even though it - // appears to have focus. The following call to "setActive" - // fixes this bug. - - if (UA.ie && oTarget.focus) { - oTarget.setActive(); - } - - Event.removeListener(document, "mousedown", - this._onDocumentMouseDown); - - } - - }, - - - /** - * @method _onOption - * @description "option" event handler for the button. - * @protected - * @param {Event} p_oEvent Object representing the DOM event object - * passed back by the event utility (YAHOO.util.Event). - */ - _onOption: function (p_oEvent) { - - if (this.hasClass(this.CLASS_NAME_PREFIX + "split-button-activeoption")) { - - this._hideMenu(); - - this._bOptionPressed = false; - - } - else { - - this._showMenu(p_oEvent); - - this._bOptionPressed = true; - - } - - }, - - - /** - * @method _onMenuShow - * @description "show" event handler for the button's menu. - * @private - * @param {String} p_sType String representing the name of the event - * that was fired. - */ - _onMenuShow: function (p_sType) { - - Event.on(document, "mousedown", this._onDocumentMouseDown, - null, this); - - var sState = (this.get("type") == "split") ? "activeoption" : "active"; - - this.addStateCSSClasses(sState); - - }, - - - /** - * @method _onMenuHide - * @description "hide" event handler for the button's menu. - * @private - * @param {String} p_sType String representing the name of the event - * that was fired. - */ - _onMenuHide: function (p_sType) { - - var sState = (this.get("type") == "split") ? "activeoption" : "active"; - - this.removeStateCSSClasses(sState); - - - if (this.get("type") == "split") { - - this._bOptionPressed = false; - - } - - }, - - - /** - * @method _onMenuKeyDown - * @description "keydown" event handler for the button's menu. - * @private - * @param {String} p_sType String representing the name of the event - * that was fired. - * @param {Array} p_aArgs Array of arguments sent when the event - * was fired. - */ - _onMenuKeyDown: function (p_sType, p_aArgs) { - - var oEvent = p_aArgs[0]; - - if (Event.getCharCode(oEvent) == 27) { - - this.focus(); - - if (this.get("type") == "split") { - - this._bOptionPressed = false; - - } - - } - - }, - - - /** - * @method _onMenuRender - * @description "render" event handler for the button's menu. - * @private - * @param {String} p_sType String representing the name of the - * event thatwas fired. - */ - _onMenuRender: function (p_sType) { - - var oButtonElement = this.get("element"), - oButtonParent = oButtonElement.parentNode, - oMenu = this._menu, - oMenuElement = oMenu.element, - oSrcElement = oMenu.srcElement, - oItem; - - - if (oButtonParent != oMenuElement.parentNode) { - - oButtonParent.appendChild(oMenuElement); - - } - - this._renderedMenu = true; - - // If the user has designated an