PageRenderTime 46ms CodeModel.GetById 12ms RepoModel.GetById 1ms app.codeStats 0ms

/files/jquery.ui/1.8.14/jquery.effects.core.js

https://gitlab.com/Mirros/jsdelivr
JavaScript | 746 lines | 533 code | 83 blank | 130 comment | 133 complexity | ece098566e8f68eac2a5353dfbb653ee MD5 | raw file
  1. /*
  2. * jQuery UI Effects @VERSION
  3. *
  4. * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
  5. * Dual licensed under the MIT or GPL Version 2 licenses.
  6. * http://jquery.org/license
  7. *
  8. * http://docs.jquery.com/UI/Effects/
  9. */
  10. ;jQuery.effects || (function($, undefined) {
  11. $.effects = {};
  12. /******************************************************************************/
  13. /****************************** COLOR ANIMATIONS ******************************/
  14. /******************************************************************************/
  15. // override the animation for color styles
  16. $.each(['backgroundColor', 'borderBottomColor', 'borderLeftColor',
  17. 'borderRightColor', 'borderTopColor', 'borderColor', 'color', 'outlineColor'],
  18. function(i, attr) {
  19. $.fx.step[attr] = function(fx) {
  20. if (!fx.colorInit) {
  21. fx.start = getColor(fx.elem, attr);
  22. fx.end = getRGB(fx.end);
  23. fx.colorInit = true;
  24. }
  25. fx.elem.style[attr] = 'rgb(' +
  26. Math.max(Math.min(parseInt((fx.pos * (fx.end[0] - fx.start[0])) + fx.start[0], 10), 255), 0) + ',' +
  27. Math.max(Math.min(parseInt((fx.pos * (fx.end[1] - fx.start[1])) + fx.start[1], 10), 255), 0) + ',' +
  28. Math.max(Math.min(parseInt((fx.pos * (fx.end[2] - fx.start[2])) + fx.start[2], 10), 255), 0) + ')';
  29. };
  30. });
  31. // Color Conversion functions from highlightFade
  32. // By Blair Mitchelmore
  33. // http://jquery.offput.ca/highlightFade/
  34. // Parse strings looking for color tuples [255,255,255]
  35. function getRGB(color) {
  36. var result;
  37. // Check if we're already dealing with an array of colors
  38. if ( color && color.constructor == Array && color.length == 3 )
  39. return color;
  40. // Look for rgb(num,num,num)
  41. if (result = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color))
  42. return [parseInt(result[1],10), parseInt(result[2],10), parseInt(result[3],10)];
  43. // Look for rgb(num%,num%,num%)
  44. if (result = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(color))
  45. return [parseFloat(result[1])*2.55, parseFloat(result[2])*2.55, parseFloat(result[3])*2.55];
  46. // Look for #a0b1c2
  47. if (result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color))
  48. return [parseInt(result[1],16), parseInt(result[2],16), parseInt(result[3],16)];
  49. // Look for #fff
  50. if (result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color))
  51. return [parseInt(result[1]+result[1],16), parseInt(result[2]+result[2],16), parseInt(result[3]+result[3],16)];
  52. // Look for rgba(0, 0, 0, 0) == transparent in Safari 3
  53. if (result = /rgba\(0, 0, 0, 0\)/.exec(color))
  54. return colors['transparent'];
  55. // Otherwise, we're most likely dealing with a named color
  56. return colors[$.trim(color).toLowerCase()];
  57. }
  58. function getColor(elem, attr) {
  59. var color;
  60. do {
  61. color = $.curCSS(elem, attr);
  62. // Keep going until we find an element that has color, or we hit the body
  63. if ( color != '' && color != 'transparent' || $.nodeName(elem, "body") )
  64. break;
  65. attr = "backgroundColor";
  66. } while ( elem = elem.parentNode );
  67. return getRGB(color);
  68. };
  69. // Some named colors to work with
  70. // From Interface by Stefan Petre
  71. // http://interface.eyecon.ro/
  72. var colors = {
  73. aqua:[0,255,255],
  74. azure:[240,255,255],
  75. beige:[245,245,220],
  76. black:[0,0,0],
  77. blue:[0,0,255],
  78. brown:[165,42,42],
  79. cyan:[0,255,255],
  80. darkblue:[0,0,139],
  81. darkcyan:[0,139,139],
  82. darkgrey:[169,169,169],
  83. darkgreen:[0,100,0],
  84. darkkhaki:[189,183,107],
  85. darkmagenta:[139,0,139],
  86. darkolivegreen:[85,107,47],
  87. darkorange:[255,140,0],
  88. darkorchid:[153,50,204],
  89. darkred:[139,0,0],
  90. darksalmon:[233,150,122],
  91. darkviolet:[148,0,211],
  92. fuchsia:[255,0,255],
  93. gold:[255,215,0],
  94. green:[0,128,0],
  95. indigo:[75,0,130],
  96. khaki:[240,230,140],
  97. lightblue:[173,216,230],
  98. lightcyan:[224,255,255],
  99. lightgreen:[144,238,144],
  100. lightgrey:[211,211,211],
  101. lightpink:[255,182,193],
  102. lightyellow:[255,255,224],
  103. lime:[0,255,0],
  104. magenta:[255,0,255],
  105. maroon:[128,0,0],
  106. navy:[0,0,128],
  107. olive:[128,128,0],
  108. orange:[255,165,0],
  109. pink:[255,192,203],
  110. purple:[128,0,128],
  111. violet:[128,0,128],
  112. red:[255,0,0],
  113. silver:[192,192,192],
  114. white:[255,255,255],
  115. yellow:[255,255,0],
  116. transparent: [255,255,255]
  117. };
  118. /******************************************************************************/
  119. /****************************** CLASS ANIMATIONS ******************************/
  120. /******************************************************************************/
  121. var classAnimationActions = ['add', 'remove', 'toggle'],
  122. shorthandStyles = {
  123. border: 1,
  124. borderBottom: 1,
  125. borderColor: 1,
  126. borderLeft: 1,
  127. borderRight: 1,
  128. borderTop: 1,
  129. borderWidth: 1,
  130. margin: 1,
  131. padding: 1
  132. };
  133. function getElementStyles() {
  134. var style = document.defaultView
  135. ? document.defaultView.getComputedStyle(this, null)
  136. : this.currentStyle,
  137. newStyle = {},
  138. key,
  139. camelCase;
  140. // webkit enumerates style porperties
  141. if (style && style.length && style[0] && style[style[0]]) {
  142. var len = style.length;
  143. while (len--) {
  144. key = style[len];
  145. if (typeof style[key] == 'string') {
  146. camelCase = key.replace(/\-(\w)/g, function(all, letter){
  147. return letter.toUpperCase();
  148. });
  149. newStyle[camelCase] = style[key];
  150. }
  151. }
  152. } else {
  153. for (key in style) {
  154. if (typeof style[key] === 'string') {
  155. newStyle[key] = style[key];
  156. }
  157. }
  158. }
  159. return newStyle;
  160. }
  161. function filterStyles(styles) {
  162. var name, value;
  163. for (name in styles) {
  164. value = styles[name];
  165. if (
  166. // ignore null and undefined values
  167. value == null ||
  168. // ignore functions (when does this occur?)
  169. $.isFunction(value) ||
  170. // shorthand styles that need to be expanded
  171. name in shorthandStyles ||
  172. // ignore scrollbars (break in IE)
  173. (/scrollbar/).test(name) ||
  174. // only colors or values that can be converted to numbers
  175. (!(/color/i).test(name) && isNaN(parseFloat(value)))
  176. ) {
  177. delete styles[name];
  178. }
  179. }
  180. return styles;
  181. }
  182. function styleDifference(oldStyle, newStyle) {
  183. var diff = { _: 0 }, // http://dev.jquery.com/ticket/5459
  184. name;
  185. for (name in newStyle) {
  186. if (oldStyle[name] != newStyle[name]) {
  187. diff[name] = newStyle[name];
  188. }
  189. }
  190. return diff;
  191. }
  192. $.effects.animateClass = function(value, duration, easing, callback) {
  193. if ($.isFunction(easing)) {
  194. callback = easing;
  195. easing = null;
  196. }
  197. return this.queue(function() {
  198. var that = $(this),
  199. originalStyleAttr = that.attr('style') || ' ',
  200. originalStyle = filterStyles(getElementStyles.call(this)),
  201. newStyle,
  202. className = that.attr('class');
  203. $.each(classAnimationActions, function(i, action) {
  204. if (value[action]) {
  205. that[action + 'Class'](value[action]);
  206. }
  207. });
  208. newStyle = filterStyles(getElementStyles.call(this));
  209. that.attr('class', className);
  210. that.animate(styleDifference(originalStyle, newStyle), {
  211. queue: false,
  212. duration: duration,
  213. easing: easing,
  214. complete: function() {
  215. $.each(classAnimationActions, function(i, action) {
  216. if (value[action]) { that[action + 'Class'](value[action]); }
  217. });
  218. // work around bug in IE by clearing the cssText before setting it
  219. if (typeof that.attr('style') == 'object') {
  220. that.attr('style').cssText = '';
  221. that.attr('style').cssText = originalStyleAttr;
  222. } else {
  223. that.attr('style', originalStyleAttr);
  224. }
  225. if (callback) { callback.apply(this, arguments); }
  226. $.dequeue( this );
  227. }
  228. });
  229. });
  230. };
  231. $.fn.extend({
  232. _addClass: $.fn.addClass,
  233. addClass: function(classNames, speed, easing, callback) {
  234. return speed ? $.effects.animateClass.apply(this, [{ add: classNames },speed,easing,callback]) : this._addClass(classNames);
  235. },
  236. _removeClass: $.fn.removeClass,
  237. removeClass: function(classNames,speed,easing,callback) {
  238. return speed ? $.effects.animateClass.apply(this, [{ remove: classNames },speed,easing,callback]) : this._removeClass(classNames);
  239. },
  240. _toggleClass: $.fn.toggleClass,
  241. toggleClass: function(classNames, force, speed, easing, callback) {
  242. if ( typeof force == "boolean" || force === undefined ) {
  243. if ( !speed ) {
  244. // without speed parameter;
  245. return this._toggleClass(classNames, force);
  246. } else {
  247. return $.effects.animateClass.apply(this, [(force?{add:classNames}:{remove:classNames}),speed,easing,callback]);
  248. }
  249. } else {
  250. // without switch parameter;
  251. return $.effects.animateClass.apply(this, [{ toggle: classNames },force,speed,easing]);
  252. }
  253. },
  254. switchClass: function(remove,add,speed,easing,callback) {
  255. return $.effects.animateClass.apply(this, [{ add: add, remove: remove },speed,easing,callback]);
  256. }
  257. });
  258. /******************************************************************************/
  259. /*********************************** EFFECTS **********************************/
  260. /******************************************************************************/
  261. $.extend($.effects, {
  262. version: "@VERSION",
  263. // Saves a set of properties in a data storage
  264. save: function(element, set) {
  265. for(var i=0; i < set.length; i++) {
  266. if(set[i] !== null) element.data("ec.storage."+set[i], element[0].style[set[i]]);
  267. }
  268. },
  269. // Restores a set of previously saved properties from a data storage
  270. restore: function(element, set) {
  271. for(var i=0; i < set.length; i++) {
  272. if(set[i] !== null) element.css(set[i], element.data("ec.storage."+set[i]));
  273. }
  274. },
  275. setMode: function(el, mode) {
  276. if (mode == 'toggle') mode = el.is(':hidden') ? 'show' : 'hide'; // Set for toggle
  277. return mode;
  278. },
  279. getBaseline: function(origin, original) { // Translates a [top,left] array into a baseline value
  280. // this should be a little more flexible in the future to handle a string & hash
  281. var y, x;
  282. switch (origin[0]) {
  283. case 'top': y = 0; break;
  284. case 'middle': y = 0.5; break;
  285. case 'bottom': y = 1; break;
  286. default: y = origin[0] / original.height;
  287. };
  288. switch (origin[1]) {
  289. case 'left': x = 0; break;
  290. case 'center': x = 0.5; break;
  291. case 'right': x = 1; break;
  292. default: x = origin[1] / original.width;
  293. };
  294. return {x: x, y: y};
  295. },
  296. // Wraps the element around a wrapper that copies position properties
  297. createWrapper: function(element) {
  298. // if the element is already wrapped, return it
  299. if (element.parent().is('.ui-effects-wrapper')) {
  300. return element.parent();
  301. }
  302. // wrap the element
  303. var props = {
  304. width: element.outerWidth(true),
  305. height: element.outerHeight(true),
  306. 'float': element.css('float')
  307. },
  308. wrapper = $('<div></div>')
  309. .addClass('ui-effects-wrapper')
  310. .css({
  311. fontSize: '100%',
  312. background: 'transparent',
  313. border: 'none',
  314. margin: 0,
  315. padding: 0
  316. });
  317. element.wrap(wrapper);
  318. wrapper = element.parent(); //Hotfix for jQuery 1.4 since some change in wrap() seems to actually loose the reference to the wrapped element
  319. // transfer positioning properties to the wrapper
  320. if (element.css('position') == 'static') {
  321. wrapper.css({ position: 'relative' });
  322. element.css({ position: 'relative' });
  323. } else {
  324. $.extend(props, {
  325. position: element.css('position'),
  326. zIndex: element.css('z-index')
  327. });
  328. $.each(['top', 'left', 'bottom', 'right'], function(i, pos) {
  329. props[pos] = element.css(pos);
  330. if (isNaN(parseInt(props[pos], 10))) {
  331. props[pos] = 'auto';
  332. }
  333. });
  334. element.css({position: 'relative', top: 0, left: 0, right: 'auto', bottom: 'auto' });
  335. }
  336. return wrapper.css(props).show();
  337. },
  338. removeWrapper: function(element) {
  339. if (element.parent().is('.ui-effects-wrapper'))
  340. return element.parent().replaceWith(element);
  341. return element;
  342. },
  343. setTransition: function(element, list, factor, value) {
  344. value = value || {};
  345. $.each(list, function(i, x){
  346. unit = element.cssUnit(x);
  347. if (unit[0] > 0) value[x] = unit[0] * factor + unit[1];
  348. });
  349. return value;
  350. }
  351. });
  352. function _normalizeArguments(effect, options, speed, callback) {
  353. // shift params for method overloading
  354. if (typeof effect == 'object') {
  355. callback = options;
  356. speed = null;
  357. options = effect;
  358. effect = options.effect;
  359. }
  360. if ($.isFunction(options)) {
  361. callback = options;
  362. speed = null;
  363. options = {};
  364. }
  365. if (typeof options == 'number' || $.fx.speeds[options]) {
  366. callback = speed;
  367. speed = options;
  368. options = {};
  369. }
  370. if ($.isFunction(speed)) {
  371. callback = speed;
  372. speed = null;
  373. }
  374. options = options || {};
  375. speed = speed || options.duration;
  376. speed = $.fx.off ? 0 : typeof speed == 'number'
  377. ? speed : speed in $.fx.speeds ? $.fx.speeds[speed] : $.fx.speeds._default;
  378. callback = callback || options.complete;
  379. return [effect, options, speed, callback];
  380. }
  381. function standardSpeed( speed ) {
  382. // valid standard speeds
  383. if ( !speed || typeof speed === "number" || $.fx.speeds[ speed ] ) {
  384. return true;
  385. }
  386. // invalid strings - treat as "normal" speed
  387. if ( typeof speed === "string" && !$.effects[ speed ] ) {
  388. return true;
  389. }
  390. return false;
  391. }
  392. $.fn.extend({
  393. effect: function(effect, options, speed, callback) {
  394. var args = _normalizeArguments.apply(this, arguments),
  395. // TODO: make effects take actual parameters instead of a hash
  396. args2 = {
  397. options: args[1],
  398. duration: args[2],
  399. callback: args[3]
  400. },
  401. mode = args2.options.mode,
  402. effectMethod = $.effects[effect];
  403. if ( $.fx.off || !effectMethod ) {
  404. // delegate to the original method (e.g., .show()) if possible
  405. if ( mode ) {
  406. return this[ mode ]( args2.duration, args2.callback );
  407. } else {
  408. return this.each(function() {
  409. if ( args2.callback ) {
  410. args2.callback.call( this );
  411. }
  412. });
  413. }
  414. }
  415. return effectMethod.call(this, args2);
  416. },
  417. _show: $.fn.show,
  418. show: function(speed) {
  419. if ( standardSpeed( speed ) ) {
  420. return this._show.apply(this, arguments);
  421. } else {
  422. var args = _normalizeArguments.apply(this, arguments);
  423. args[1].mode = 'show';
  424. return this.effect.apply(this, args);
  425. }
  426. },
  427. _hide: $.fn.hide,
  428. hide: function(speed) {
  429. if ( standardSpeed( speed ) ) {
  430. return this._hide.apply(this, arguments);
  431. } else {
  432. var args = _normalizeArguments.apply(this, arguments);
  433. args[1].mode = 'hide';
  434. return this.effect.apply(this, args);
  435. }
  436. },
  437. // jQuery core overloads toggle and creates _toggle
  438. __toggle: $.fn.toggle,
  439. toggle: function(speed) {
  440. if ( standardSpeed( speed ) || typeof speed === "boolean" || $.isFunction( speed ) ) {
  441. return this.__toggle.apply(this, arguments);
  442. } else {
  443. var args = _normalizeArguments.apply(this, arguments);
  444. args[1].mode = 'toggle';
  445. return this.effect.apply(this, args);
  446. }
  447. },
  448. // helper functions
  449. cssUnit: function(key) {
  450. var style = this.css(key), val = [];
  451. $.each( ['em','px','%','pt'], function(i, unit){
  452. if(style.indexOf(unit) > 0)
  453. val = [parseFloat(style), unit];
  454. });
  455. return val;
  456. }
  457. });
  458. /******************************************************************************/
  459. /*********************************** EASING ***********************************/
  460. /******************************************************************************/
  461. /*
  462. * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
  463. *
  464. * Uses the built in easing capabilities added In jQuery 1.1
  465. * to offer multiple easing options
  466. *
  467. * TERMS OF USE - jQuery Easing
  468. *
  469. * Open source under the BSD License.
  470. *
  471. * Copyright 2008 George McGinley Smith
  472. * All rights reserved.
  473. *
  474. * Redistribution and use in source and binary forms, with or without modification,
  475. * are permitted provided that the following conditions are met:
  476. *
  477. * Redistributions of source code must retain the above copyright notice, this list of
  478. * conditions and the following disclaimer.
  479. * Redistributions in binary form must reproduce the above copyright notice, this list
  480. * of conditions and the following disclaimer in the documentation and/or other materials
  481. * provided with the distribution.
  482. *
  483. * Neither the name of the author nor the names of contributors may be used to endorse
  484. * or promote products derived from this software without specific prior written permission.
  485. *
  486. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
  487. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  488. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  489. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  490. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  491. * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  492. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  493. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
  494. * OF THE POSSIBILITY OF SUCH DAMAGE.
  495. *
  496. */
  497. // t: current time, b: begInnIng value, c: change In value, d: duration
  498. $.easing.jswing = $.easing.swing;
  499. $.extend($.easing,
  500. {
  501. def: 'easeOutQuad',
  502. swing: function (x, t, b, c, d) {
  503. //alert($.easing.default);
  504. return $.easing[$.easing.def](x, t, b, c, d);
  505. },
  506. easeInQuad: function (x, t, b, c, d) {
  507. return c*(t/=d)*t + b;
  508. },
  509. easeOutQuad: function (x, t, b, c, d) {
  510. return -c *(t/=d)*(t-2) + b;
  511. },
  512. easeInOutQuad: function (x, t, b, c, d) {
  513. if ((t/=d/2) < 1) return c/2*t*t + b;
  514. return -c/2 * ((--t)*(t-2) - 1) + b;
  515. },
  516. easeInCubic: function (x, t, b, c, d) {
  517. return c*(t/=d)*t*t + b;
  518. },
  519. easeOutCubic: function (x, t, b, c, d) {
  520. return c*((t=t/d-1)*t*t + 1) + b;
  521. },
  522. easeInOutCubic: function (x, t, b, c, d) {
  523. if ((t/=d/2) < 1) return c/2*t*t*t + b;
  524. return c/2*((t-=2)*t*t + 2) + b;
  525. },
  526. easeInQuart: function (x, t, b, c, d) {
  527. return c*(t/=d)*t*t*t + b;
  528. },
  529. easeOutQuart: function (x, t, b, c, d) {
  530. return -c * ((t=t/d-1)*t*t*t - 1) + b;
  531. },
  532. easeInOutQuart: function (x, t, b, c, d) {
  533. if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
  534. return -c/2 * ((t-=2)*t*t*t - 2) + b;
  535. },
  536. easeInQuint: function (x, t, b, c, d) {
  537. return c*(t/=d)*t*t*t*t + b;
  538. },
  539. easeOutQuint: function (x, t, b, c, d) {
  540. return c*((t=t/d-1)*t*t*t*t + 1) + b;
  541. },
  542. easeInOutQuint: function (x, t, b, c, d) {
  543. if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
  544. return c/2*((t-=2)*t*t*t*t + 2) + b;
  545. },
  546. easeInSine: function (x, t, b, c, d) {
  547. return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
  548. },
  549. easeOutSine: function (x, t, b, c, d) {
  550. return c * Math.sin(t/d * (Math.PI/2)) + b;
  551. },
  552. easeInOutSine: function (x, t, b, c, d) {
  553. return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
  554. },
  555. easeInExpo: function (x, t, b, c, d) {
  556. return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
  557. },
  558. easeOutExpo: function (x, t, b, c, d) {
  559. return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
  560. },
  561. easeInOutExpo: function (x, t, b, c, d) {
  562. if (t==0) return b;
  563. if (t==d) return b+c;
  564. if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
  565. return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
  566. },
  567. easeInCirc: function (x, t, b, c, d) {
  568. return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
  569. },
  570. easeOutCirc: function (x, t, b, c, d) {
  571. return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
  572. },
  573. easeInOutCirc: function (x, t, b, c, d) {
  574. if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
  575. return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
  576. },
  577. easeInElastic: function (x, t, b, c, d) {
  578. var s=1.70158;var p=0;var a=c;
  579. if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
  580. if (a < Math.abs(c)) { a=c; var s=p/4; }
  581. else var s = p/(2*Math.PI) * Math.asin (c/a);
  582. return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
  583. },
  584. easeOutElastic: function (x, t, b, c, d) {
  585. var s=1.70158;var p=0;var a=c;
  586. if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
  587. if (a < Math.abs(c)) { a=c; var s=p/4; }
  588. else var s = p/(2*Math.PI) * Math.asin (c/a);
  589. return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
  590. },
  591. easeInOutElastic: function (x, t, b, c, d) {
  592. var s=1.70158;var p=0;var a=c;
  593. if (t==0) return b; if ((t/=d/2)==2) return b+c; if (!p) p=d*(.3*1.5);
  594. if (a < Math.abs(c)) { a=c; var s=p/4; }
  595. else var s = p/(2*Math.PI) * Math.asin (c/a);
  596. if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
  597. return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
  598. },
  599. easeInBack: function (x, t, b, c, d, s) {
  600. if (s == undefined) s = 1.70158;
  601. return c*(t/=d)*t*((s+1)*t - s) + b;
  602. },
  603. easeOutBack: function (x, t, b, c, d, s) {
  604. if (s == undefined) s = 1.70158;
  605. return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
  606. },
  607. easeInOutBack: function (x, t, b, c, d, s) {
  608. if (s == undefined) s = 1.70158;
  609. if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
  610. return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
  611. },
  612. easeInBounce: function (x, t, b, c, d) {
  613. return c - $.easing.easeOutBounce (x, d-t, 0, c, d) + b;
  614. },
  615. easeOutBounce: function (x, t, b, c, d) {
  616. if ((t/=d) < (1/2.75)) {
  617. return c*(7.5625*t*t) + b;
  618. } else if (t < (2/2.75)) {
  619. return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
  620. } else if (t < (2.5/2.75)) {
  621. return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
  622. } else {
  623. return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
  624. }
  625. },
  626. easeInOutBounce: function (x, t, b, c, d) {
  627. if (t < d/2) return $.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
  628. return $.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
  629. }
  630. });
  631. /*
  632. *
  633. * TERMS OF USE - EASING EQUATIONS
  634. *
  635. * Open source under the BSD License.
  636. *
  637. * Copyright 2001 Robert Penner
  638. * All rights reserved.
  639. *
  640. * Redistribution and use in source and binary forms, with or without modification,
  641. * are permitted provided that the following conditions are met:
  642. *
  643. * Redistributions of source code must retain the above copyright notice, this list of
  644. * conditions and the following disclaimer.
  645. * Redistributions in binary form must reproduce the above copyright notice, this list
  646. * of conditions and the following disclaimer in the documentation and/or other materials
  647. * provided with the distribution.
  648. *
  649. * Neither the name of the author nor the names of contributors may be used to endorse
  650. * or promote products derived from this software without specific prior written permission.
  651. *
  652. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
  653. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  654. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  655. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  656. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  657. * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  658. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  659. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
  660. * OF THE POSSIBILITY OF SUCH DAMAGE.
  661. *
  662. */
  663. })(jQuery);