jqplot.effects.blind.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * jQuery UI Effects Blind 1.9pre
  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/Blind
  9. *
  10. * Depends:
  11. * jquery.effects.core.js
  12. */
  13. //////
  14. // jquery ui blind effect used for series animation in jqplot.
  15. //////
  16. (function($) {
  17. var rvertical = /up|down|vertical/,
  18. rpositivemotion = /up|left|vertical|horizontal/;
  19. $.jqplot.effects.effect.blind = function( o, done ) {
  20. // Create element
  21. var el = $( this ),
  22. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  23. mode = $.jqplot.effects.setMode( el, o.mode || "hide" ),
  24. direction = o.direction || "up",
  25. vertical = rvertical.test( direction ),
  26. ref = vertical ? "height" : "width",
  27. ref2 = vertical ? "top" : "left",
  28. motion = rpositivemotion.test( direction ),
  29. animation = {},
  30. show = mode === "show",
  31. wrapper, distance, top;
  32. // // if already wrapped, the wrapper's properties are my property. #6245
  33. if ( el.parent().is( ".ui-effects-wrapper" ) ) {
  34. $.jqplot.effects.save( el.parent(), props );
  35. } else {
  36. $.jqplot.effects.save( el, props );
  37. }
  38. el.show();
  39. top = parseInt(el.css('top'), 10);
  40. wrapper = $.jqplot.effects.createWrapper( el ).css({
  41. overflow: "hidden"
  42. });
  43. distance = vertical ? wrapper[ ref ]() + top : wrapper[ ref ]();
  44. animation[ ref ] = show ? String(distance) : '0';
  45. if ( !motion ) {
  46. el
  47. .css( vertical ? "bottom" : "right", 0 )
  48. .css( vertical ? "top" : "left", "" )
  49. .css({ position: "absolute" });
  50. animation[ ref2 ] = show ? '0' : String(distance);
  51. }
  52. // // start at 0 if we are showing
  53. if ( show ) {
  54. wrapper.css( ref, 0 );
  55. if ( ! motion ) {
  56. wrapper.css( ref2, distance );
  57. }
  58. }
  59. // // Animate
  60. wrapper.animate( animation, {
  61. duration: o.duration,
  62. easing: o.easing,
  63. queue: false,
  64. complete: function() {
  65. if ( mode === "hide" ) {
  66. el.hide();
  67. }
  68. $.jqplot.effects.restore( el, props );
  69. $.jqplot.effects.removeWrapper( el );
  70. done();
  71. }
  72. });
  73. };
  74. })(jQuery);