Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 
 

972 righe
24 KiB

  1. /*!
  2. * jQuery UI Effects 1.13.1
  3. * http://jqueryui.com
  4. *
  5. * Copyright jQuery Foundation and other contributors
  6. * Released under the MIT license.
  7. * http://jquery.org/license
  8. */
  9. //>>label: Effects Core
  10. //>>group: Effects
  11. /* eslint-disable max-len */
  12. //>>description: Extends the internal jQuery effects. Includes morphing and easing. Required by all other effects.
  13. /* eslint-enable max-len */
  14. //>>docs: http://api.jqueryui.com/category/effects-core/
  15. //>>demos: http://jqueryui.com/effect/
  16. ( function( factory ) {
  17. "use strict";
  18. if ( typeof define === "function" && define.amd ) {
  19. // AMD. Register as an anonymous module.
  20. define( [
  21. "jquery",
  22. "./jquery-var-for-color",
  23. "./vendor/jquery-color/jquery.color",
  24. "./version"
  25. ], factory );
  26. } else {
  27. // Browser globals
  28. factory( jQuery );
  29. }
  30. } )( function( $ ) {
  31. "use strict";
  32. var dataSpace = "ui-effects-",
  33. dataSpaceStyle = "ui-effects-style",
  34. dataSpaceAnimated = "ui-effects-animated";
  35. $.effects = {
  36. effect: {}
  37. };
  38. /******************************************************************************/
  39. /****************************** CLASS ANIMATIONS ******************************/
  40. /******************************************************************************/
  41. ( function() {
  42. var classAnimationActions = [ "add", "remove", "toggle" ],
  43. shorthandStyles = {
  44. border: 1,
  45. borderBottom: 1,
  46. borderColor: 1,
  47. borderLeft: 1,
  48. borderRight: 1,
  49. borderTop: 1,
  50. borderWidth: 1,
  51. margin: 1,
  52. padding: 1
  53. };
  54. $.each(
  55. [ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ],
  56. function( _, prop ) {
  57. $.fx.step[ prop ] = function( fx ) {
  58. if ( fx.end !== "none" && !fx.setAttr || fx.pos === 1 && !fx.setAttr ) {
  59. jQuery.style( fx.elem, prop, fx.end );
  60. fx.setAttr = true;
  61. }
  62. };
  63. }
  64. );
  65. function camelCase( string ) {
  66. return string.replace( /-([\da-z])/gi, function( all, letter ) {
  67. return letter.toUpperCase();
  68. } );
  69. }
  70. function getElementStyles( elem ) {
  71. var key, len,
  72. style = elem.ownerDocument.defaultView ?
  73. elem.ownerDocument.defaultView.getComputedStyle( elem, null ) :
  74. elem.currentStyle,
  75. styles = {};
  76. if ( style && style.length && style[ 0 ] && style[ style[ 0 ] ] ) {
  77. len = style.length;
  78. while ( len-- ) {
  79. key = style[ len ];
  80. if ( typeof style[ key ] === "string" ) {
  81. styles[ camelCase( key ) ] = style[ key ];
  82. }
  83. }
  84. // Support: Opera, IE <9
  85. } else {
  86. for ( key in style ) {
  87. if ( typeof style[ key ] === "string" ) {
  88. styles[ key ] = style[ key ];
  89. }
  90. }
  91. }
  92. return styles;
  93. }
  94. function styleDifference( oldStyle, newStyle ) {
  95. var diff = {},
  96. name, value;
  97. for ( name in newStyle ) {
  98. value = newStyle[ name ];
  99. if ( oldStyle[ name ] !== value ) {
  100. if ( !shorthandStyles[ name ] ) {
  101. if ( $.fx.step[ name ] || !isNaN( parseFloat( value ) ) ) {
  102. diff[ name ] = value;
  103. }
  104. }
  105. }
  106. }
  107. return diff;
  108. }
  109. // Support: jQuery <1.8
  110. if ( !$.fn.addBack ) {
  111. $.fn.addBack = function( selector ) {
  112. return this.add( selector == null ?
  113. this.prevObject : this.prevObject.filter( selector )
  114. );
  115. };
  116. }
  117. $.effects.animateClass = function( value, duration, easing, callback ) {
  118. var o = $.speed( duration, easing, callback );
  119. return this.queue( function() {
  120. var animated = $( this ),
  121. baseClass = animated.attr( "class" ) || "",
  122. applyClassChange,
  123. allAnimations = o.children ? animated.find( "*" ).addBack() : animated;
  124. // Map the animated objects to store the original styles.
  125. allAnimations = allAnimations.map( function() {
  126. var el = $( this );
  127. return {
  128. el: el,
  129. start: getElementStyles( this )
  130. };
  131. } );
  132. // Apply class change
  133. applyClassChange = function() {
  134. $.each( classAnimationActions, function( i, action ) {
  135. if ( value[ action ] ) {
  136. animated[ action + "Class" ]( value[ action ] );
  137. }
  138. } );
  139. };
  140. applyClassChange();
  141. // Map all animated objects again - calculate new styles and diff
  142. allAnimations = allAnimations.map( function() {
  143. this.end = getElementStyles( this.el[ 0 ] );
  144. this.diff = styleDifference( this.start, this.end );
  145. return this;
  146. } );
  147. // Apply original class
  148. animated.attr( "class", baseClass );
  149. // Map all animated objects again - this time collecting a promise
  150. allAnimations = allAnimations.map( function() {
  151. var styleInfo = this,
  152. dfd = $.Deferred(),
  153. opts = $.extend( {}, o, {
  154. queue: false,
  155. complete: function() {
  156. dfd.resolve( styleInfo );
  157. }
  158. } );
  159. this.el.animate( this.diff, opts );
  160. return dfd.promise();
  161. } );
  162. // Once all animations have completed:
  163. $.when.apply( $, allAnimations.get() ).done( function() {
  164. // Set the final class
  165. applyClassChange();
  166. // For each animated element,
  167. // clear all css properties that were animated
  168. $.each( arguments, function() {
  169. var el = this.el;
  170. $.each( this.diff, function( key ) {
  171. el.css( key, "" );
  172. } );
  173. } );
  174. // This is guarnteed to be there if you use jQuery.speed()
  175. // it also handles dequeuing the next anim...
  176. o.complete.call( animated[ 0 ] );
  177. } );
  178. } );
  179. };
  180. $.fn.extend( {
  181. addClass: ( function( orig ) {
  182. return function( classNames, speed, easing, callback ) {
  183. return speed ?
  184. $.effects.animateClass.call( this,
  185. { add: classNames }, speed, easing, callback ) :
  186. orig.apply( this, arguments );
  187. };
  188. } )( $.fn.addClass ),
  189. removeClass: ( function( orig ) {
  190. return function( classNames, speed, easing, callback ) {
  191. return arguments.length > 1 ?
  192. $.effects.animateClass.call( this,
  193. { remove: classNames }, speed, easing, callback ) :
  194. orig.apply( this, arguments );
  195. };
  196. } )( $.fn.removeClass ),
  197. toggleClass: ( function( orig ) {
  198. return function( classNames, force, speed, easing, callback ) {
  199. if ( typeof force === "boolean" || force === undefined ) {
  200. if ( !speed ) {
  201. // Without speed parameter
  202. return orig.apply( this, arguments );
  203. } else {
  204. return $.effects.animateClass.call( this,
  205. ( force ? { add: classNames } : { remove: classNames } ),
  206. speed, easing, callback );
  207. }
  208. } else {
  209. // Without force parameter
  210. return $.effects.animateClass.call( this,
  211. { toggle: classNames }, force, speed, easing );
  212. }
  213. };
  214. } )( $.fn.toggleClass ),
  215. switchClass: function( remove, add, speed, easing, callback ) {
  216. return $.effects.animateClass.call( this, {
  217. add: add,
  218. remove: remove
  219. }, speed, easing, callback );
  220. }
  221. } );
  222. } )();
  223. /******************************************************************************/
  224. /*********************************** EFFECTS **********************************/
  225. /******************************************************************************/
  226. ( function() {
  227. if ( $.expr && $.expr.pseudos && $.expr.pseudos.animated ) {
  228. $.expr.pseudos.animated = ( function( orig ) {
  229. return function( elem ) {
  230. return !!$( elem ).data( dataSpaceAnimated ) || orig( elem );
  231. };
  232. } )( $.expr.pseudos.animated );
  233. }
  234. if ( $.uiBackCompat !== false ) {
  235. $.extend( $.effects, {
  236. // Saves a set of properties in a data storage
  237. save: function( element, set ) {
  238. var i = 0, length = set.length;
  239. for ( ; i < length; i++ ) {
  240. if ( set[ i ] !== null ) {
  241. element.data( dataSpace + set[ i ], element[ 0 ].style[ set[ i ] ] );
  242. }
  243. }
  244. },
  245. // Restores a set of previously saved properties from a data storage
  246. restore: function( element, set ) {
  247. var val, i = 0, length = set.length;
  248. for ( ; i < length; i++ ) {
  249. if ( set[ i ] !== null ) {
  250. val = element.data( dataSpace + set[ i ] );
  251. element.css( set[ i ], val );
  252. }
  253. }
  254. },
  255. setMode: function( el, mode ) {
  256. if ( mode === "toggle" ) {
  257. mode = el.is( ":hidden" ) ? "show" : "hide";
  258. }
  259. return mode;
  260. },
  261. // Wraps the element around a wrapper that copies position properties
  262. createWrapper: function( element ) {
  263. // If the element is already wrapped, return it
  264. if ( element.parent().is( ".ui-effects-wrapper" ) ) {
  265. return element.parent();
  266. }
  267. // Wrap the element
  268. var props = {
  269. width: element.outerWidth( true ),
  270. height: element.outerHeight( true ),
  271. "float": element.css( "float" )
  272. },
  273. wrapper = $( "<div></div>" )
  274. .addClass( "ui-effects-wrapper" )
  275. .css( {
  276. fontSize: "100%",
  277. background: "transparent",
  278. border: "none",
  279. margin: 0,
  280. padding: 0
  281. } ),
  282. // Store the size in case width/height are defined in % - Fixes #5245
  283. size = {
  284. width: element.width(),
  285. height: element.height()
  286. },
  287. active = document.activeElement;
  288. // Support: Firefox
  289. // Firefox incorrectly exposes anonymous content
  290. // https://bugzilla.mozilla.org/show_bug.cgi?id=561664
  291. try {
  292. // eslint-disable-next-line no-unused-expressions
  293. active.id;
  294. } catch ( e ) {
  295. active = document.body;
  296. }
  297. element.wrap( wrapper );
  298. // Fixes #7595 - Elements lose focus when wrapped.
  299. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  300. $( active ).trigger( "focus" );
  301. }
  302. // Hotfix for jQuery 1.4 since some change in wrap() seems to actually
  303. // lose the reference to the wrapped element
  304. wrapper = element.parent();
  305. // Transfer positioning properties to the wrapper
  306. if ( element.css( "position" ) === "static" ) {
  307. wrapper.css( { position: "relative" } );
  308. element.css( { position: "relative" } );
  309. } else {
  310. $.extend( props, {
  311. position: element.css( "position" ),
  312. zIndex: element.css( "z-index" )
  313. } );
  314. $.each( [ "top", "left", "bottom", "right" ], function( i, pos ) {
  315. props[ pos ] = element.css( pos );
  316. if ( isNaN( parseInt( props[ pos ], 10 ) ) ) {
  317. props[ pos ] = "auto";
  318. }
  319. } );
  320. element.css( {
  321. position: "relative",
  322. top: 0,
  323. left: 0,
  324. right: "auto",
  325. bottom: "auto"
  326. } );
  327. }
  328. element.css( size );
  329. return wrapper.css( props ).show();
  330. },
  331. removeWrapper: function( element ) {
  332. var active = document.activeElement;
  333. if ( element.parent().is( ".ui-effects-wrapper" ) ) {
  334. element.parent().replaceWith( element );
  335. // Fixes #7595 - Elements lose focus when wrapped.
  336. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  337. $( active ).trigger( "focus" );
  338. }
  339. }
  340. return element;
  341. }
  342. } );
  343. }
  344. $.extend( $.effects, {
  345. version: "1.13.1",
  346. define: function( name, mode, effect ) {
  347. if ( !effect ) {
  348. effect = mode;
  349. mode = "effect";
  350. }
  351. $.effects.effect[ name ] = effect;
  352. $.effects.effect[ name ].mode = mode;
  353. return effect;
  354. },
  355. scaledDimensions: function( element, percent, direction ) {
  356. if ( percent === 0 ) {
  357. return {
  358. height: 0,
  359. width: 0,
  360. outerHeight: 0,
  361. outerWidth: 0
  362. };
  363. }
  364. var x = direction !== "horizontal" ? ( ( percent || 100 ) / 100 ) : 1,
  365. y = direction !== "vertical" ? ( ( percent || 100 ) / 100 ) : 1;
  366. return {
  367. height: element.height() * y,
  368. width: element.width() * x,
  369. outerHeight: element.outerHeight() * y,
  370. outerWidth: element.outerWidth() * x
  371. };
  372. },
  373. clipToBox: function( animation ) {
  374. return {
  375. width: animation.clip.right - animation.clip.left,
  376. height: animation.clip.bottom - animation.clip.top,
  377. left: animation.clip.left,
  378. top: animation.clip.top
  379. };
  380. },
  381. // Injects recently queued functions to be first in line (after "inprogress")
  382. unshift: function( element, queueLength, count ) {
  383. var queue = element.queue();
  384. if ( queueLength > 1 ) {
  385. queue.splice.apply( queue,
  386. [ 1, 0 ].concat( queue.splice( queueLength, count ) ) );
  387. }
  388. element.dequeue();
  389. },
  390. saveStyle: function( element ) {
  391. element.data( dataSpaceStyle, element[ 0 ].style.cssText );
  392. },
  393. restoreStyle: function( element ) {
  394. element[ 0 ].style.cssText = element.data( dataSpaceStyle ) || "";
  395. element.removeData( dataSpaceStyle );
  396. },
  397. mode: function( element, mode ) {
  398. var hidden = element.is( ":hidden" );
  399. if ( mode === "toggle" ) {
  400. mode = hidden ? "show" : "hide";
  401. }
  402. if ( hidden ? mode === "hide" : mode === "show" ) {
  403. mode = "none";
  404. }
  405. return mode;
  406. },
  407. // Translates a [top,left] array into a baseline value
  408. getBaseline: function( origin, original ) {
  409. var y, x;
  410. switch ( origin[ 0 ] ) {
  411. case "top":
  412. y = 0;
  413. break;
  414. case "middle":
  415. y = 0.5;
  416. break;
  417. case "bottom":
  418. y = 1;
  419. break;
  420. default:
  421. y = origin[ 0 ] / original.height;
  422. }
  423. switch ( origin[ 1 ] ) {
  424. case "left":
  425. x = 0;
  426. break;
  427. case "center":
  428. x = 0.5;
  429. break;
  430. case "right":
  431. x = 1;
  432. break;
  433. default:
  434. x = origin[ 1 ] / original.width;
  435. }
  436. return {
  437. x: x,
  438. y: y
  439. };
  440. },
  441. // Creates a placeholder element so that the original element can be made absolute
  442. createPlaceholder: function( element ) {
  443. var placeholder,
  444. cssPosition = element.css( "position" ),
  445. position = element.position();
  446. // Lock in margins first to account for form elements, which
  447. // will change margin if you explicitly set height
  448. // see: http://jsfiddle.net/JZSMt/3/ https://bugs.webkit.org/show_bug.cgi?id=107380
  449. // Support: Safari
  450. element.css( {
  451. marginTop: element.css( "marginTop" ),
  452. marginBottom: element.css( "marginBottom" ),
  453. marginLeft: element.css( "marginLeft" ),
  454. marginRight: element.css( "marginRight" )
  455. } )
  456. .outerWidth( element.outerWidth() )
  457. .outerHeight( element.outerHeight() );
  458. if ( /^(static|relative)/.test( cssPosition ) ) {
  459. cssPosition = "absolute";
  460. placeholder = $( "<" + element[ 0 ].nodeName + ">" ).insertAfter( element ).css( {
  461. // Convert inline to inline block to account for inline elements
  462. // that turn to inline block based on content (like img)
  463. display: /^(inline|ruby)/.test( element.css( "display" ) ) ?
  464. "inline-block" :
  465. "block",
  466. visibility: "hidden",
  467. // Margins need to be set to account for margin collapse
  468. marginTop: element.css( "marginTop" ),
  469. marginBottom: element.css( "marginBottom" ),
  470. marginLeft: element.css( "marginLeft" ),
  471. marginRight: element.css( "marginRight" ),
  472. "float": element.css( "float" )
  473. } )
  474. .outerWidth( element.outerWidth() )
  475. .outerHeight( element.outerHeight() )
  476. .addClass( "ui-effects-placeholder" );
  477. element.data( dataSpace + "placeholder", placeholder );
  478. }
  479. element.css( {
  480. position: cssPosition,
  481. left: position.left,
  482. top: position.top
  483. } );
  484. return placeholder;
  485. },
  486. removePlaceholder: function( element ) {
  487. var dataKey = dataSpace + "placeholder",
  488. placeholder = element.data( dataKey );
  489. if ( placeholder ) {
  490. placeholder.remove();
  491. element.removeData( dataKey );
  492. }
  493. },
  494. // Removes a placeholder if it exists and restores
  495. // properties that were modified during placeholder creation
  496. cleanUp: function( element ) {
  497. $.effects.restoreStyle( element );
  498. $.effects.removePlaceholder( element );
  499. },
  500. setTransition: function( element, list, factor, value ) {
  501. value = value || {};
  502. $.each( list, function( i, x ) {
  503. var unit = element.cssUnit( x );
  504. if ( unit[ 0 ] > 0 ) {
  505. value[ x ] = unit[ 0 ] * factor + unit[ 1 ];
  506. }
  507. } );
  508. return value;
  509. }
  510. } );
  511. // Return an effect options object for the given parameters:
  512. function _normalizeArguments( effect, options, speed, callback ) {
  513. // Allow passing all options as the first parameter
  514. if ( $.isPlainObject( effect ) ) {
  515. options = effect;
  516. effect = effect.effect;
  517. }
  518. // Convert to an object
  519. effect = { effect: effect };
  520. // Catch (effect, null, ...)
  521. if ( options == null ) {
  522. options = {};
  523. }
  524. // Catch (effect, callback)
  525. if ( typeof options === "function" ) {
  526. callback = options;
  527. speed = null;
  528. options = {};
  529. }
  530. // Catch (effect, speed, ?)
  531. if ( typeof options === "number" || $.fx.speeds[ options ] ) {
  532. callback = speed;
  533. speed = options;
  534. options = {};
  535. }
  536. // Catch (effect, options, callback)
  537. if ( typeof speed === "function" ) {
  538. callback = speed;
  539. speed = null;
  540. }
  541. // Add options to effect
  542. if ( options ) {
  543. $.extend( effect, options );
  544. }
  545. speed = speed || options.duration;
  546. effect.duration = $.fx.off ? 0 :
  547. typeof speed === "number" ? speed :
  548. speed in $.fx.speeds ? $.fx.speeds[ speed ] :
  549. $.fx.speeds._default;
  550. effect.complete = callback || options.complete;
  551. return effect;
  552. }
  553. function standardAnimationOption( option ) {
  554. // Valid standard speeds (nothing, number, named speed)
  555. if ( !option || typeof option === "number" || $.fx.speeds[ option ] ) {
  556. return true;
  557. }
  558. // Invalid strings - treat as "normal" speed
  559. if ( typeof option === "string" && !$.effects.effect[ option ] ) {
  560. return true;
  561. }
  562. // Complete callback
  563. if ( typeof option === "function" ) {
  564. return true;
  565. }
  566. // Options hash (but not naming an effect)
  567. if ( typeof option === "object" && !option.effect ) {
  568. return true;
  569. }
  570. // Didn't match any standard API
  571. return false;
  572. }
  573. $.fn.extend( {
  574. effect: function( /* effect, options, speed, callback */ ) {
  575. var args = _normalizeArguments.apply( this, arguments ),
  576. effectMethod = $.effects.effect[ args.effect ],
  577. defaultMode = effectMethod.mode,
  578. queue = args.queue,
  579. queueName = queue || "fx",
  580. complete = args.complete,
  581. mode = args.mode,
  582. modes = [],
  583. prefilter = function( next ) {
  584. var el = $( this ),
  585. normalizedMode = $.effects.mode( el, mode ) || defaultMode;
  586. // Sentinel for duck-punching the :animated pseudo-selector
  587. el.data( dataSpaceAnimated, true );
  588. // Save effect mode for later use,
  589. // we can't just call $.effects.mode again later,
  590. // as the .show() below destroys the initial state
  591. modes.push( normalizedMode );
  592. // See $.uiBackCompat inside of run() for removal of defaultMode in 1.14
  593. if ( defaultMode && ( normalizedMode === "show" ||
  594. ( normalizedMode === defaultMode && normalizedMode === "hide" ) ) ) {
  595. el.show();
  596. }
  597. if ( !defaultMode || normalizedMode !== "none" ) {
  598. $.effects.saveStyle( el );
  599. }
  600. if ( typeof next === "function" ) {
  601. next();
  602. }
  603. };
  604. if ( $.fx.off || !effectMethod ) {
  605. // Delegate to the original method (e.g., .show()) if possible
  606. if ( mode ) {
  607. return this[ mode ]( args.duration, complete );
  608. } else {
  609. return this.each( function() {
  610. if ( complete ) {
  611. complete.call( this );
  612. }
  613. } );
  614. }
  615. }
  616. function run( next ) {
  617. var elem = $( this );
  618. function cleanup() {
  619. elem.removeData( dataSpaceAnimated );
  620. $.effects.cleanUp( elem );
  621. if ( args.mode === "hide" ) {
  622. elem.hide();
  623. }
  624. done();
  625. }
  626. function done() {
  627. if ( typeof complete === "function" ) {
  628. complete.call( elem[ 0 ] );
  629. }
  630. if ( typeof next === "function" ) {
  631. next();
  632. }
  633. }
  634. // Override mode option on a per element basis,
  635. // as toggle can be either show or hide depending on element state
  636. args.mode = modes.shift();
  637. if ( $.uiBackCompat !== false && !defaultMode ) {
  638. if ( elem.is( ":hidden" ) ? mode === "hide" : mode === "show" ) {
  639. // Call the core method to track "olddisplay" properly
  640. elem[ mode ]();
  641. done();
  642. } else {
  643. effectMethod.call( elem[ 0 ], args, done );
  644. }
  645. } else {
  646. if ( args.mode === "none" ) {
  647. // Call the core method to track "olddisplay" properly
  648. elem[ mode ]();
  649. done();
  650. } else {
  651. effectMethod.call( elem[ 0 ], args, cleanup );
  652. }
  653. }
  654. }
  655. // Run prefilter on all elements first to ensure that
  656. // any showing or hiding happens before placeholder creation,
  657. // which ensures that any layout changes are correctly captured.
  658. return queue === false ?
  659. this.each( prefilter ).each( run ) :
  660. this.queue( queueName, prefilter ).queue( queueName, run );
  661. },
  662. show: ( function( orig ) {
  663. return function( option ) {
  664. if ( standardAnimationOption( option ) ) {
  665. return orig.apply( this, arguments );
  666. } else {
  667. var args = _normalizeArguments.apply( this, arguments );
  668. args.mode = "show";
  669. return this.effect.call( this, args );
  670. }
  671. };
  672. } )( $.fn.show ),
  673. hide: ( function( orig ) {
  674. return function( option ) {
  675. if ( standardAnimationOption( option ) ) {
  676. return orig.apply( this, arguments );
  677. } else {
  678. var args = _normalizeArguments.apply( this, arguments );
  679. args.mode = "hide";
  680. return this.effect.call( this, args );
  681. }
  682. };
  683. } )( $.fn.hide ),
  684. toggle: ( function( orig ) {
  685. return function( option ) {
  686. if ( standardAnimationOption( option ) || typeof option === "boolean" ) {
  687. return orig.apply( this, arguments );
  688. } else {
  689. var args = _normalizeArguments.apply( this, arguments );
  690. args.mode = "toggle";
  691. return this.effect.call( this, args );
  692. }
  693. };
  694. } )( $.fn.toggle ),
  695. cssUnit: function( key ) {
  696. var style = this.css( key ),
  697. val = [];
  698. $.each( [ "em", "px", "%", "pt" ], function( i, unit ) {
  699. if ( style.indexOf( unit ) > 0 ) {
  700. val = [ parseFloat( style ), unit ];
  701. }
  702. } );
  703. return val;
  704. },
  705. cssClip: function( clipObj ) {
  706. if ( clipObj ) {
  707. return this.css( "clip", "rect(" + clipObj.top + "px " + clipObj.right + "px " +
  708. clipObj.bottom + "px " + clipObj.left + "px)" );
  709. }
  710. return parseClip( this.css( "clip" ), this );
  711. },
  712. transfer: function( options, done ) {
  713. var element = $( this ),
  714. target = $( options.to ),
  715. targetFixed = target.css( "position" ) === "fixed",
  716. body = $( "body" ),
  717. fixTop = targetFixed ? body.scrollTop() : 0,
  718. fixLeft = targetFixed ? body.scrollLeft() : 0,
  719. endPosition = target.offset(),
  720. animation = {
  721. top: endPosition.top - fixTop,
  722. left: endPosition.left - fixLeft,
  723. height: target.innerHeight(),
  724. width: target.innerWidth()
  725. },
  726. startPosition = element.offset(),
  727. transfer = $( "<div class='ui-effects-transfer'></div>" );
  728. transfer
  729. .appendTo( "body" )
  730. .addClass( options.className )
  731. .css( {
  732. top: startPosition.top - fixTop,
  733. left: startPosition.left - fixLeft,
  734. height: element.innerHeight(),
  735. width: element.innerWidth(),
  736. position: targetFixed ? "fixed" : "absolute"
  737. } )
  738. .animate( animation, options.duration, options.easing, function() {
  739. transfer.remove();
  740. if ( typeof done === "function" ) {
  741. done();
  742. }
  743. } );
  744. }
  745. } );
  746. function parseClip( str, element ) {
  747. var outerWidth = element.outerWidth(),
  748. outerHeight = element.outerHeight(),
  749. clipRegex = /^rect\((-?\d*\.?\d*px|-?\d+%|auto),?\s*(-?\d*\.?\d*px|-?\d+%|auto),?\s*(-?\d*\.?\d*px|-?\d+%|auto),?\s*(-?\d*\.?\d*px|-?\d+%|auto)\)$/,
  750. values = clipRegex.exec( str ) || [ "", 0, outerWidth, outerHeight, 0 ];
  751. return {
  752. top: parseFloat( values[ 1 ] ) || 0,
  753. right: values[ 2 ] === "auto" ? outerWidth : parseFloat( values[ 2 ] ),
  754. bottom: values[ 3 ] === "auto" ? outerHeight : parseFloat( values[ 3 ] ),
  755. left: parseFloat( values[ 4 ] ) || 0
  756. };
  757. }
  758. $.fx.step.clip = function( fx ) {
  759. if ( !fx.clipInit ) {
  760. fx.start = $( fx.elem ).cssClip();
  761. if ( typeof fx.end === "string" ) {
  762. fx.end = parseClip( fx.end, fx.elem );
  763. }
  764. fx.clipInit = true;
  765. }
  766. $( fx.elem ).cssClip( {
  767. top: fx.pos * ( fx.end.top - fx.start.top ) + fx.start.top,
  768. right: fx.pos * ( fx.end.right - fx.start.right ) + fx.start.right,
  769. bottom: fx.pos * ( fx.end.bottom - fx.start.bottom ) + fx.start.bottom,
  770. left: fx.pos * ( fx.end.left - fx.start.left ) + fx.start.left
  771. } );
  772. };
  773. } )();
  774. /******************************************************************************/
  775. /*********************************** EASING ***********************************/
  776. /******************************************************************************/
  777. ( function() {
  778. // Based on easing equations from Robert Penner (http://www.robertpenner.com/easing)
  779. var baseEasings = {};
  780. $.each( [ "Quad", "Cubic", "Quart", "Quint", "Expo" ], function( i, name ) {
  781. baseEasings[ name ] = function( p ) {
  782. return Math.pow( p, i + 2 );
  783. };
  784. } );
  785. $.extend( baseEasings, {
  786. Sine: function( p ) {
  787. return 1 - Math.cos( p * Math.PI / 2 );
  788. },
  789. Circ: function( p ) {
  790. return 1 - Math.sqrt( 1 - p * p );
  791. },
  792. Elastic: function( p ) {
  793. return p === 0 || p === 1 ? p :
  794. -Math.pow( 2, 8 * ( p - 1 ) ) * Math.sin( ( ( p - 1 ) * 80 - 7.5 ) * Math.PI / 15 );
  795. },
  796. Back: function( p ) {
  797. return p * p * ( 3 * p - 2 );
  798. },
  799. Bounce: function( p ) {
  800. var pow2,
  801. bounce = 4;
  802. while ( p < ( ( pow2 = Math.pow( 2, --bounce ) ) - 1 ) / 11 ) {}
  803. return 1 / Math.pow( 4, 3 - bounce ) - 7.5625 * Math.pow( ( pow2 * 3 - 2 ) / 22 - p, 2 );
  804. }
  805. } );
  806. $.each( baseEasings, function( name, easeIn ) {
  807. $.easing[ "easeIn" + name ] = easeIn;
  808. $.easing[ "easeOut" + name ] = function( p ) {
  809. return 1 - easeIn( 1 - p );
  810. };
  811. $.easing[ "easeInOut" + name ] = function( p ) {
  812. return p < 0.5 ?
  813. easeIn( p * 2 ) / 2 :
  814. 1 - easeIn( p * -2 + 2 ) / 2;
  815. };
  816. } );
  817. } )();
  818. return $.effects;
  819. } );