]> source.dussan.org Git - jquery-ui.git/commitdiff
effects: removed effect 'fade' (honestly not needed)
authorPaul Bakaus <paul.bakaus@googlemail.com>
Wed, 28 May 2008 18:23:55 +0000 (18:23 +0000)
committerPaul Bakaus <paul.bakaus@googlemail.com>
Wed, 28 May 2008 18:23:55 +0000 (18:23 +0000)
demos: added effects demo page
effects: fixed many callback issues and other small issues

ui/demos/real-world/effects/demo.js [new file with mode: 0644]
ui/demos/real-world/effects/index.html [new file with mode: 0644]
ui/demos/real-world/effects/style.css [new file with mode: 0644]
ui/source/effects.blind.js
ui/source/effects.explode.js
ui/source/effects.fade.js [deleted file]
ui/source/effects.fold.js
ui/source/effects.transfer.js

diff --git a/ui/demos/real-world/effects/demo.js b/ui/demos/real-world/effects/demo.js
new file mode 100644 (file)
index 0000000..ebf0ad0
--- /dev/null
@@ -0,0 +1,65 @@
+$(document).ready(function() {\r
+       \r
+       $("div.effect")\r
+               .hover(function() {\r
+                       $(this).addClass("hover");\r
+               }, function() {\r
+                       $(this).removeClass("hover");\r
+               })\r
+               ;\r
+       \r
+       \r
+       var effect = function(el, n, o) {\r
+               \r
+               $.extend(o, {\r
+                       easing: "easeOutQuint"\r
+               });\r
+               \r
+               $(el).bind("click", function() {\r
+                       \r
+                       $(this).addClass("current").hide(n, o, 1000, function() {\r
+                               var self = this;\r
+                               window.setTimeout(function() {\r
+                                       $(self).show(n, o, 1000, function() { $(this).removeClass("current"); });\r
+                               },500);\r
+                       });\r
+               });\r
+               \r
+       };\r
+               \r
+\r
+       effect("#blindHorizontally", "blind", { direction: "horizontal" });\r
+       effect("#blindVertically", "blind", { direction: "vertical" });\r
+       \r
+       effect("#bounce3times", "bounce", { times: 3 });\r
+       \r
+       effect("#clipHorizontally", "clip", { direction: "horizontal" });\r
+       effect("#clipVertically", "clip", { direction: "vertical" });\r
+       \r
+       effect("#dropDown", "drop", { direction: "down" });\r
+       effect("#dropUp", "drop", { direction: "up" });\r
+       effect("#dropLeft", "drop", { direction: "left" });\r
+       effect("#dropRight", "drop", { direction: "right" });\r
+       \r
+       effect("#explode9", "explode", {  });\r
+       effect("#explode36", "explode", { pieces: 36 });\r
+       \r
+       effect("#fold", "fold", { size: 50 });\r
+       \r
+       effect("#highlight", "highlight", {  });\r
+       \r
+       effect("#pulsate", "pulsate", { times: 2 });\r
+       \r
+       effect("#puff", "puff", { times: 2 });\r
+       effect("#scale", "scale", {  });\r
+       \r
+       $("#shake").bind("click", function() { $(this).addClass("current").effect("shake", {}, 100, function() { $(this).removeClass("current"); }); });\r
+       \r
+       effect("#slideDown", "slide", { direction: "down" });\r
+       effect("#slideUp", "slide", { direction: "up" });\r
+       effect("#slideLeft", "slide", { direction: "left" });\r
+       effect("#slideRight", "slide", { direction: "right" });\r
+       \r
+       $("#transfer").bind("click", function() { $(this).addClass("current").effect("transfer", { to: "div:eq(0)" }, 1000, function() { $(this).removeClass("current"); }); });\r
+       \r
+});
\ No newline at end of file
diff --git a/ui/demos/real-world/effects/index.html b/ui/demos/real-world/effects/index.html
new file mode 100644 (file)
index 0000000..bffad17
--- /dev/null
@@ -0,0 +1,120 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"\r
+       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\r
+<html>\r
+       <head>\r
+               <meta http-equiv="Content-type" content="text/html; charset=utf-8" />\r
+               <title>Effects Test Suite</title>\r
+               <link rel="stylesheet" href="style.css" type="text/css" media="screen" title="no title" charset="utf-8" />\r
+               \r
+               <script type="text/javascript" src="../../../../jquery/jquery-1.2.6.js"></script>\r
+               <script type="text/javascript" src="../../../source/effects.core.js"></script>\r
+               \r
+               <script type="text/javascript" src="../../../source/effects.blind.js"></script>\r
+               <script type="text/javascript" src="../../../source/effects.bounce.js"></script>\r
+               <script type="text/javascript" src="../../../source/effects.clip.js"></script>\r
+               <script type="text/javascript" src="../../../source/effects.drop.js"></script>\r
+               <script type="text/javascript" src="../../../source/effects.explode.js"></script>\r
+               <script type="text/javascript" src="../../../source/effects.fold.js"></script>\r
+               <script type="text/javascript" src="../../../source/effects.highlight.js"></script>\r
+               <script type="text/javascript" src="../../../source/effects.pulsate.js"></script>\r
+               <script type="text/javascript" src="../../../source/effects.scale.js"></script>\r
+               <script type="text/javascript" src="../../../source/effects.shake.js"></script>\r
+               <script type="text/javascript" src="../../../source/effects.slide.js"></script>\r
+               <script type="text/javascript" src="../../../source/effects.transfer.js"></script>\r
+               \r
+               <script type="text/javascript" src="demo.js"></script>\r
+       \r
+\r
+       </head>\r
+       <body>\r
+               \r
+               <div class="effect" id="blindHorizontally">\r
+                       <p>Blind horizontally</p>\r
+               </div>\r
+               \r
+               <div class="effect" id="blindVertically">\r
+                       <p>Blind vertically</p>\r
+               </div>\r
+               \r
+               <div class="effect" id="bounce3times">\r
+                       <p>Bounce 3 times</p>\r
+               </div>\r
+               \r
+               <div class="effect" id="clipHorizontally">\r
+                       <p>Clip horizontally</p>\r
+               </div>\r
+               \r
+               <div class="effect" id="clipVertically">\r
+                       <p>Clip vertically</p>\r
+               </div>\r
+               \r
+               <div class="effect" id="dropDown">\r
+                       <p>Drop down</p>\r
+               </div>\r
+               \r
+               <div class="effect" id="dropUp">\r
+                       <p>Drop up</p>\r
+               </div>\r
+               \r
+               <div class="effect" id="dropLeft">\r
+                       <p>Drop left</p>\r
+               </div>\r
+               \r
+               <div class="effect" id="dropRight">\r
+                       <p>Drop right</p>\r
+               </div>\r
+               \r
+               <div class="effect" id="explode9">\r
+                       <p>Explode in 9 pieces</p>\r
+               </div>\r
+               \r
+               <div class="effect" id="explode36">\r
+                       <p>Explode in 36 pieces</p>\r
+               </div>\r
+               \r
+               <div class="effect" id="fold">\r
+                       <p>Fold</p>\r
+               </div>\r
+               \r
+               <div class="effect" id="highlight">\r
+                       <p>Highlight</p>\r
+               </div>\r
+               \r
+               <div class="effect" id="pulsate">\r
+                       <p>Pulsate 2 times</p>\r
+               </div>\r
+               \r
+               <div class="effect" id="puff">\r
+                       <p>Puff</p>\r
+               </div>\r
+               \r
+               <div class="effect" id="scale">\r
+                       <p>Scale</p>\r
+               </div>\r
+               \r
+               <div class="effect" id="shake">\r
+                       <p>Shake</p>\r
+               </div>\r
+               \r
+               <div class="effect" id="slideDown">\r
+                       <p>Slide down</p>\r
+               </div>\r
+               \r
+               <div class="effect" id="slideUp">\r
+                       <p>Slide up</p>\r
+               </div>\r
+               \r
+               <div class="effect" id="slideLeft">\r
+                       <p>Slide left</p>\r
+               </div>\r
+               \r
+               <div class="effect" id="slideRight">\r
+                       <p>Slide right</p>\r
+               </div>\r
+               \r
+               <div class="effect" id="transfer">\r
+                       <p>Transfer to first element</p>\r
+               </div>\r
+               \r
+       </body>\r
+</html>
\ No newline at end of file
diff --git a/ui/demos/real-world/effects/style.css b/ui/demos/real-world/effects/style.css
new file mode 100644 (file)
index 0000000..e2a1844
--- /dev/null
@@ -0,0 +1,36 @@
+body,html {\r
+       margin: 0;\r
+       padding: 0;\r
+       font-size: 12px;\r
+       font-family: Arial;\r
+       background: #000;\r
+}\r
+\r
+div.effect {\r
+       width: 120px;\r
+       height: 100px;\r
+       background: #333;\r
+       border: 5px outset #aaa;\r
+       float: left;\r
+       margin-top: 20px;\r
+       margin-left: 20px;\r
+       cursor: pointer;\r
+       cursor: hand;\r
+}\r
+\r
+div.current {\r
+       border: 5px outset #FF0000;\r
+       background: #660000;\r
+}\r
+\r
+div.effect p {\r
+       color: #eee;\r
+       margin: 0px;\r
+       padding: 10px;\r
+}\r
+\r
+.ui-effects-transfer {\r
+       border: 1px dotted #fff;\r
+       background: #666;\r
+       opacity: 0.5;\r
+}
\ No newline at end of file
index 1681ae28697b8be202d09c186f28268be4320966..32486430067b00c29e6f1b6d0b902ea682443154 100644 (file)
@@ -26,7 +26,7 @@
       wrapper.animate(animation, o.duration, o.options.easing, function() {
         if(mode == 'hide') el.hide(); // Hide
         $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
-        if(o.callback) o.callback.apply(this, arguments); // Callback
+        if(o.callback) o.callback.apply(el[0], arguments); // Callback
         el.dequeue();
       });
       
index 4962c5d933fb8074c37924d9e7eb52cac0192fa7..78d37e7ff2af45e03bf9d927dcb4dc75d1079dbb 100644 (file)
                o.options.mode = o.options.mode == 'toggle' ? ($(this).is(':visible') ? 'hide' : 'show') : o.options.mode;\r
                var el = $(this).show().css('visibility', 'hidden');\r
                var offset = el.offset();\r
-               var width = el.outerWidth();\r
-               var height = el.outerHeight();\r
+               \r
+               //Substract the margins - not fixing the problem yet.\r
+               offset.top -= parseInt(el.css("marginTop")) || 0;\r
+               offset.left -= parseInt(el.css("marginLeft")) || 0;\r
+               \r
+               var width = el.outerWidth(true);\r
+               var height = el.outerHeight(true);\r
 \r
                for(var i=0;i<rows;i++) { // =\r
                        for(var j=0;j<cells;j++) { // ||\r
diff --git a/ui/source/effects.fade.js b/ui/source/effects.fade.js
deleted file mode 100644 (file)
index 2d265bf..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-;(function($) {
-  
-  $.effects.fade = function(o) {
-
-    return this.queue(function() {
-      
-      // Create element
-      var el = $(this), props = ['opacity'];
-      
-      // Set options
-      var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode
-      if (mode == 'toggle') mode = el.is(':hidden') ? 'show' : 'hide'; // Set for toggle
-      var opacity = o.options.opacity || 0; // Default fade opacity
-      var original_opacity = el.css('opacity');
-      
-      // Adjust
-      $.effects.save(el, props); el.show(); // Save & Show
-      if(mode == 'show') el.css({opacity: 0}); // Shift
-      
-      // Animation
-      var animation = {opacity: mode == 'show' ? original_opacity : opacity};
-      
-      // Animate
-      el.animate(animation, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() {
-        if(mode == 'hide') el.hide(); // Hide
-        if(mode == 'hide') $.effects.restore(el, props); // Restore
-        if(o.callback) o.callback.apply(this, arguments); // Callback
-        el.dequeue();
-      }});
-      
-    });
-    
-  };
-  
-})(jQuery);
\ No newline at end of file
index f2738c2aac718e5e622d235b4ff37c2c5ef2165b..a57593d8cf0932d16f06c210050b89cdc95c43a9 100644 (file)
@@ -28,7 +28,7 @@
       .animate(animation2, o.duration / 2, o.options.easing, function() {
         if(mode == 'hide') el.hide(); // Hide
         $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
-        if(o.callback) o.callback.apply(this, arguments); // Callback
+        if(o.callback) o.callback.apply(el[0], arguments); // Callback
         el.dequeue();
       });
       
index f83700c0d8a89f8295bcb6d1c9d36290e8fe94e4..c2a26128acba07e06a9352c1e68b166f2b5474a9 100644 (file)
       // Set options\r
       var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode\r
       var target = $(o.options.to); // Find Target\r
-      var position = el.position();\r
-         var transfer = $('<div id="fxTransfer"></div>').appendTo(document.body)\r
+      var position = el.offset();\r
+         var transfer = $('<div class="ui-effects-transfer"></div>').appendTo(document.body);\r
       \r
       // Set target css\r
       transfer.addClass(o.options.className);\r
       transfer.css({\r
-        top: position['top'],\r
-        left: position['left'],\r
-        height: el.outerHeight({margin:true}) - parseInt(transfer.css('borderTopWidth')) - parseInt(transfer.css('borderBottomWidth')),\r
-        width: el.outerWidth({margin:true}) - parseInt(transfer.css('borderLeftWidth')) - parseInt(transfer.css('borderRightWidth')),\r
+        top: position.top,\r
+        left: position.left,\r
+        height: el.outerHeight(true) - parseInt(transfer.css('borderTopWidth')) - parseInt(transfer.css('borderBottomWidth')),\r
+        width: el.outerWidth(true) - parseInt(transfer.css('borderLeftWidth')) - parseInt(transfer.css('borderRightWidth')),\r
         position: 'absolute'\r
       });\r
       \r
       // Animation\r
-      position = target.position();\r
+      position = target.offset();\r
       animation = {\r
-        top: position['top'],\r
-        left: position['left'],\r
+        top: position.top,\r
+        left: position.top,\r
         height: target.outerHeight() - parseInt(transfer.css('borderTopWidth')) - parseInt(transfer.css('borderBottomWidth')),\r
         width: target.outerWidth() - parseInt(transfer.css('borderLeftWidth')) - parseInt(transfer.css('borderRightWidth'))\r
       };\r
@@ -35,7 +35,7 @@
       // Animate\r
       transfer.animate(animation, o.duration, o.options.easing, function() {\r
         transfer.remove(); // Remove div\r
-        if(o.callback) o.callback.apply(this, arguments); // Callback\r
+        if(o.callback) o.callback.apply(el[0], arguments); // Callback\r
         el.dequeue();\r
       }); \r
       \r