Bug Tracker

Changeset 3855

Show
Ignore:
Timestamp:
11/19/07 16:05:40 (1 year ago)
Author:
aaronchi
Message:

fixed effects to use new 'ec' scope

Location:
trunk/fx/experimental
Files:
13 modified

Legend:

Unmodified
Added
Removed
  • trunk/fx/experimental/fx.blind.js

    r3838 r3855  
    11(function($) { 
    22   
    3   $.fx.blind = function(o) { 
     3  $.ec.blind = function(o) { 
    44 
    55    this.each(function() { 
     
    1414       
    1515      // Set options 
    16       var direction = o.options.direction || "vertical"; 
    17       var ref = (direction == "vertical") ? "height" : "width"; 
    18       var distance = (direction == "vertical") ? wrapper.height() : wrapper.width(); 
     16      var direction = o.options.direction || 'vertical'; 
     17      var ref = (direction == 'vertical') ? 'height' : 'width'; 
     18      var distance = (direction == 'vertical') ? wrapper.height() : wrapper.width(); 
    1919       
    2020      // Adjust 
    21       if(o.method == "show") wrapper.css(ref, 0); 
     21      if(o.method == 'show') wrapper.css(ref, 0); 
    2222      el.show(); 
    2323       
    2424      // Animation 
    2525      var animation = {}; 
    26       animation[ref] = o.method == "show" ? distance : 0; 
     26      animation[ref] = o.method == 'show' ? distance : 0; 
    2727       
    2828      // Animate 
    2929      wrapper.animate(animation, o.speed, o.options.easing, function() { 
    30         if(o.method != "show") el.hide(); //if we want to hide the element, set display to none after the animation 
    31         wrapper.replaceWith(el); // remove the wrapper 
    32         if(o.callback) callback.apply(this, arguments); //And optionally apply the callback 
     30        if(o.method != 'show') el.hide(); 
     31        wrapper.replaceWith(el); 
     32        if(o.callback) callback.apply(this, arguments); 
    3333      });    
    3434   
  • trunk/fx/experimental/fx.drop.js

    r3838 r3855  
    11(function($) { 
    22   
    3   $.fx.drop = function(o) { 
     3  $.ec.drop = function(o) { 
    44 
    55    this.each(function() { 
     
    77      // Create element 
    88      var el = $(this); 
    9       $.fx.relativize(el); 
    10       $.fx.save(el, ["top","left","opacity"]); 
     9      var props = ['position','opacity']; 
    1110       
    1211      // Set options 
    13       var direction = o.options.direction || "left"; 
    14       var ref = (direction == "up" || direction == "down") ? "top" : "left"; 
    15       var motion = (direction == "up" || direction == "left") ? "pos" : "neg"; 
    16       var distance = o.options.distance || ref == "top" ? (el.height() / 2) : (el.width() / 2); 
    17       var shift = !parseInt(el.css(ref)) ? 0 : parseInt(el.css(ref)); // Need this for IE 
     12      var direction = o.options.direction || 'left'; 
     13      var s = $.ec.findSides(el), ref = { left: s[0], right: s[0], up: s[1], down: s[1] }; 
     14      props.push(ref[direction]); // Add side to props 
     15      var motion = (ref[direction] == 'top' || ref[direction] == 'left') ? 'pos' : 'neg'; 
     16      var distance = o.options.distance || (ref == 'top' ? (el.height() / 2) : (el.width() / 2)); 
     17      var shift = parseInt(el.css(ref[direction])) || 0; 
    1818       
    1919      // Adjust 
    20       if (o.method == "show") el.css('opacity', 0).css(ref, shift + (motion == "pos" ? -distance : distance)); 
     20      $.ec.save(el, props); 
     21      el.makeRelative(); 
     22      if (o.method == 'show') el.css('opacity', 0).css(ref[direction], shift + (motion == 'pos' ? -distance : distance)); 
    2123      el.show(); 
    2224       
    2325      // Animation 
    2426      var animation = {}; 
    25       animation['opacity'] = o.method == "show" ? 1 : 0; 
    26       animation[ref] = (o.method == "show" ? (motion == "pos" ? '+=' : '-=') : (motion == "pos" ? '-=' : '+='))  + distance; 
     27      animation['opacity'] = o.method == 'show' ? 1 : 0; 
     28      animation[ref[direction]] = (o.method == 'show' ? (motion == 'pos' ? '+=' : '-=') : (motion == 'pos' ? '-=' : '+='))  + distance; 
    2729       
    2830      // Animate 
    29       el.animate(animation, o.speed, o.options.easing, function() { //Animate 
    30         if(o.method != "show") el.hide(); 
    31         $.fx.restore(el, ["left","top","opacity"]); 
     31      el.animate(animation, o.speed, o.options.easing, function() { 
     32        if(o.method != 'show') el.hide(); 
     33        $.ec.restore(el, props); 
    3234        if(o.callback) callback.apply(this, arguments); 
    3335      }); 
  • trunk/fx/experimental/fx.fold.js

    r3838 r3855  
    11(function($) { 
    22   
    3   $.fx.fold = function(o) { 
     3  $.ec.fold = function(o) { 
    44 
    55    this.each(function() { 
     
    1414       
    1515      // Set options 
    16       var direction = o.options.direction || "vertical"; 
    17       var ref = (o.method == "show") ? ["width", "height"] : ["height", "width"]; 
     16      var ref = (o.method == 'show') ? ['width', 'height'] : ['height', 'width']; 
    1817      var size = o.options.size || 15; 
    19       var distance = (o.method == "show") ? [wrapper.width(), wrapper.height()] : [wrapper.height(), wrapper.width()]; 
     18      var distance = (o.method == 'show') ? [wrapper.width(), wrapper.height()] : [wrapper.height(), wrapper.width()]; 
    2019       
    2120      // Adjust 
    22       if(o.method == "show") wrapper.css({height: size, width: 0}); 
     21      if(o.method == 'show') wrapper.css({height: size, width: 0}); 
    2322      el.show(); 
    2423       
    2524      // Animation 
    26       var animation1 = {}; animation1[ref[0]] = o.method == "show" ? distance[0] : size; 
    27       var animation2 = {}; animation2[ref[1]] = o.method == "show" ? distance[1] : 0; 
     25      var animation1 = {}; animation1[ref[0]] = o.method == 'show' ? distance[0] : size; 
     26      var animation2 = {}; animation2[ref[1]] = o.method == 'show' ? distance[1] : 0; 
    2827       
    29       // Animate 
     28      // Animate & Restore 
    3029      wrapper.animate(animation1, o.speed, o.options.easing) 
    3130      .animate(animation2, o.speed, o.options.easing, function() { 
    32         if(o.method != "show") el.hide(); //if we want to hide the element, set display to none after the animation 
    33         wrapper.replaceWith(el); // remove the wrapper 
    34         if(o.callback) callback.apply(this, arguments); //And optionally apply the callback 
     31        if(o.method != 'show') el.hide(); 
     32        wrapper.replaceWith(el); 
     33        if(o.callback) callback.apply(this, arguments); 
    3534      });    
    3635   
  • trunk/fx/experimental/fx.highlight.js

    r3838 r3855  
    11(function($) { 
    22   
    3   $.fx.highlight = function(o) { 
     3  $.ec.highlight = function(o) { 
    44 
    55    this.each(function() { 
     
    77      // Create element 
    88      var el = $(this); 
    9       $.fx.save(el, ["backgroundImage","backgroundColor","opacity"]); 
     9      var props = ['backgroundImage','backgroundColor','opacity']; 
    1010       
    1111      // Set options 
    1212      var color = o.options.color || "#ffff99" 
    1313       
    14       // Adjust 
    15       el.css({backgroundImage: 'none', backgroundColor: color}) 
     14      // Adjust & Save 
     15      $.ec.save(el, props); 
     16      el.css({backgroundImage: 'none', backgroundColor: color}); 
    1617      el.show(); 
    1718       
    1819      // Animation 
    1920      var animation = {}; 
    20       animation['backgroundColor'] = $.data(this, "fx.storage.backgroundColor"); 
     21      animation['backgroundColor'] = $.data(this, "ec.storage.backgroundColor"); 
    2122      if (o.method == "hide") animation['opacity'] = 0; 
    2223       
     
    2425      el.animate(animation, o.speed, o.options.easing, function() { //Animate 
    2526        if(o.method == "hide") el.hide(); 
    26         $.fx.restore(el, ["backgroundImage","backgroundColor","opacity"]); 
     27        $.ec.restore(el, props); 
    2728        if(o.callback) callback.apply(this, arguments); 
    2829      }); 
  • trunk/fx/experimental/fx.js

    r3838 r3855  
    11(function($) { 
    22 
    3   $.fx = $.fx || {}; //Add the 'fx' scope 
     3  $.ec = $.ec || {}; //Add the 'ec' scope 
    44 
    5   /* 
    6    * Public methods (jQuery FX scope) 
    7    */ 
    8  
    9   $.extend($.fx, { 
    10     relativize: function(el) { 
    11       if(!el.css("position") || !el.css("position").match(/fixed|absolute|relative/)) el.css("position", "relative"); //Relativize 
    12     }, 
     5  $.extend($.ec, { 
    136    save: function(el, set) { 
    147      for(var i=0;i<set.length;i++) { 
    15         if(set[i] !== null) $.data(el[0], "fx.storage."+set[i], el.css(set[i]));   
     8        if(set[i] !== null) $.data(el[0], "ec.storage."+set[i], el.css(set[i]));   
    169      } 
    1710    }, 
     
    1912      if(ret) var obj = {}; 
    2013      for(var i=0;i<set.length;i++) { 
    21         if(ret) obj[set[i]] = $.data(el[0], "fx.storage."+set[i]); 
    22         if(set[i] !== null && !ret) el.css(set[i], $.data(el[0], "fx.storage."+set[i]));   
     14        if(ret) obj[set[i]] = $.data(el[0], "ec.storage."+set[i]); 
     15        if(set[i] !== null && !ret) el.css(set[i], $.data(el[0], "ec.storage."+set[i]));   
    2316      } 
    2417      if(ret) return obj; 
    2518    }, 
     19    findSides: function(el) { //Very nifty function (especially for IE!) 
     20      return [ !!parseInt(el.css("left")) ? "left" : "right", !!parseInt(el.css("top")) ? "top" : "bottom" ]; 
     21    }, 
     22    setTransition: function(el, list, factor, val) { 
     23    val = val || {}; 
     24    $.each(list,function(i, x){ 
     25      unit = el.cssUnit(x); 
     26      if (unit[0] > 0) val[x] = unit[0] * factor + unit[1]; 
     27    }); 
     28    return val; 
     29  }, 
    2630    animateClass: function(value, duration, easing, callback) { 
    2731   
     
    6165    } 
    6266  }); 
    63    
     67  
    6468  //Extend the methods of jQuery 
    6569  $.fn.extend({ 
    66     //effect: function(fx,o) { if($.fx[fx]) this.each(function() { $.fx[fx].apply(this, [o]); }); }, //This just forwards single used effects 
    67     effect: function(fx,o,speed,callback) { if($.fx[fx]) $.fx[fx].apply(this, [{method: fx, options: o, speed: speed, callback: callback}])}, 
     70    //Save old methods 
    6871    _show: $.fn.show, 
    6972    _hide: $.fn.hide, 
     
    7275    _removeClass: $.fn.removeClass, 
    7376    _toggleClass: $.fn.toggleClass, 
     77    // New ec methods 
     78    effect: function(fx,o,speed,callback) {  
     79      if($.ec[fx]) $.ec[fx].apply(this, [{method: fx, options: o, speed: speed, callback: callback}]) 
     80    }, 
    7481    show: function(obj,speed,callback){ 
    75       return typeof obj == 'string' || typeof obj == 'undefined' ? this._show(obj, speed) : $.fx[obj.method].apply(this, [{method: 'show', options: obj, duration: speed, callback: callback }]); 
     82      return typeof obj == 'string' || typeof obj == 'undefined' ? this._show(obj, speed) : $.ec[obj.method].apply(this, [{method: 'show', options: obj, duration: speed, callback: callback }]); 
    7683    }, 
    7784    hide: function(obj,speed,callback){ 
    78       return typeof obj == 'string' || typeof obj == 'undefined' ? this._hide(obj, speed) : $.fx[obj.method].apply(this, [{method: 'hide', options: obj, duration: speed, callback: callback }]); 
     85      return typeof obj == 'string' || typeof obj == 'undefined' ? this._hide(obj, speed) : $.ec[obj.method].apply(this, [{method: 'hide', options: obj, duration: speed, callback: callback }]); 
    7986    }, 
    8087    toggle: function(obj,speed,callback){ 
    81       return jQuery(this).is(":hidden") ? this.show(obj,speed,callback) : this.hide(obj,speed,callback) 
     88      return $(this).is(':hidden') ? this.show(obj,speed,callback) : this.hide(obj,speed,callback) 
    8289    }, 
    8390    addClass: function(classNames,speed,easing,callback) { 
    84       return speed ? $.fx.animateClass.apply(this, [{ add: classNames },speed,easing,callback]) : this._addClass(classNames); 
     91      return speed ? $.ec.animateClass.apply(this, [{ add: classNames },speed,easing,callback]) : this._addClass(classNames); 
    8592    }, 
    8693    removeClass: function(classNames,speed,easing,callback) { 
    87       return speed ? $.fx.animateClass.apply(this, [{ remove: classNames },speed,easing,callback]) : this._removeClass(classNames); 
     94      return speed ? $.ec.animateClass.apply(this, [{ remove: classNames },speed,easing,callback]) : this._removeClass(classNames); 
    8895    }, 
    8996    toggleClass: function(classNames,speed,easing,callback) { 
    90       return speed ? $.fx.animateClass.apply(this, [{ toggle: classNames },speed,easing,callback]) : this._toggleClass(classNames); 
     97      return speed ? $.ec.animateClass.apply(this, [{ toggle: classNames },speed,easing,callback]) : this._toggleClass(classNames); 
    9198    }, 
    9299    morph: function(remove,add,speed,easing,callback) { 
    93       return $.fx.animateClass.apply(this, [{ add: add, remove: remove },speed,easing,callback]); 
     100      return $.ec.animateClass.apply(this, [{ add: add, remove: remove },speed,easing,callback]); 
    94101    }, 
    95     switchClass: function() { this.morph.apply(this, arguments); }, 
     102    switchClass: function() {  
     103      this.morph.apply(this, arguments); 
     104    }, 
     105    // helper functions 
     106    makeRelative: function() { //Relativize 
     107      var pos = this.css('position'); 
     108      if (!pos || pos == 'static') { 
     109        this.css('position', 'relative'); 
     110        if (window.opera) { 
     111          element.style.top = 0; 
     112          element.style.left = 0; 
     113        }; 
     114      }; 
     115    }, 
    96116    cssUnit: function(key) {  
    97117      var style = this.css(key), val = []; 
  • trunk/fx/experimental/fx.pulsate.js

    r3838 r3855  
    11(function($) { 
    22   
    3   $.fx.pulsate = function(o) { 
     3  $.ec.pulsate = function(o) { 
    44 
    55    this.each(function() { 
     
    1212       
    1313      // Adjust 
    14       if (jQuery(el).is(":hidden")) { 
     14      if (jQuery(el).is(':hidden')) { 
    1515        el.fadeIn(o.speed, o.options.easing); 
    1616        times--; 
     
    2121        el.fadeOut(o.speed, o.options.easing).fadeIn(o.speed, o.options.easing); 
    2222      }; 
    23       if (o.method == "hide") el.fadeOut(o.speed, o.options.easing); 
     23      if (o.method == 'hide') el.fadeOut(o.speed, o.options.easing); 
    2424      if(o.callback) callback.apply(this, arguments); 
    2525    }); 
  • trunk/fx/experimental/fx.slide.js

    r3838 r3855  
    11(function($) { 
    22   
    3   $.fx.slide = function(o) { 
     3  $.ec.slide = function(o) { 
    44 
    55    this.each(function() { 
     
    77      // Create element 
    88      var el = $(this); 
    9       $.fx.save(el, ["marginTop","marginLeft"]); 
     9      var props = []; 
    1010       
    1111      // Create a wrapper 
     
    1515       
    1616      // Set options 
    17       var direction = o.options.direction || "left"; 
    18       var ref = (direction == "up" || direction == "down") ? "marginTop" : "marginLeft"; 
    19       var motion = (direction == "down" || direction == "right") ? "pos" : "neg"; 
    20       var distance = distance || ref == "marginTop" ? wrapper.height() : wrapper.width(); 
    21       var shift = !parseInt(el.css(ref)) ? 0 : parseInt(el.css(ref)); // Need this for IE 
     17      var direction = o.options.direction || 'left'; 
     18      var ref = (direction == 'up' || direction == 'down') ? 'marginTop' : 'marginLeft'; 
     19      props.push(ref); 
     20      var motion = (direction == 'down' || direction == 'right') ? 'pos' : 'neg'; 
     21      var distance = distance || ref == 'marginTop' ? wrapper.height() : wrapper.width(); 
     22      var shift = parseInt(el.css(ref)) || 0; 
    2223       
    2324      // Adjust 
    24       if (o.method == "show") el.css(ref, shift + (motion == "pos" ? distance : -distance)); 
     25      $.ec.save(el, props); 
     26      if (o.method == 'show') el.css(ref, shift + (motion == 'pos' ? distance : -distance)); 
    2527      el.show(); 
    2628       
    2729      // Animation 
    2830      var animation = {}; 
    29       animation[ref] = (o.method == "show" ? (motion == "pos" ? '-=' : '+=') : (motion == "pos" ? '+=' : '-=')) + distance; 
     31      animation[ref] = (o.method == 'show' ? (motion == 'pos' ? '-=' : '+=') : (motion == 'pos' ? '+=' : '-=')) + distance; 
    3032       
    3133      // Animate 
    3234      el.animate(animation, o.speed, o.options.easing, function() { //Animate 
    33         if(o.method != "show") el.hide(); 
    34         $.fx.restore(el, ["marginTop","marginLeft"]); 
     35        if(o.method != 'show') el.hide(); 
     36        $.ec.restore(el, props); 
    3537        wrapper.replaceWith(el); 
    3638        if(o.callback) callback.apply(this, arguments); 
  • trunk/fx/experimental/tests/blind.html

    r3838 r3855  
    2828.controls div {padding:10px;clear:both;} 
    2929.text {font-size: 12px;margin:5px 0;background:#f7f7f7;border:1px dotted #aaa;padding:4px;} 
    30 #container {height:420px; width:510px;margin:0 auto; text-align:center;} 
    31 #fx {width:500px;background:#efefef;border:5px solid #aaa;}  
     30#container {height:420px; width:510px; margin:0 auto;} 
     31#fx {width:500px;background:#efefef;border:5px solid #aaa; text-align:center;}  
    3232</style> 
    3333</head> 
  • trunk/fx/experimental/tests/drop.html

    r3838 r3855  
    1212<script type="text/javascript" src="../../../jquery/src/fx.js"></script> 
    1313<script type="text/javascript" src="../../../jquery/src/offset.js"></script> 
     14<script type="text/javascript" src="../../../plugins/dimensions/jquery.dimensions.js"></script> 
    1415 
    1516<script type="text/javascript" src="../fx.js"></script> 
     
    2728.controls div {padding:10px;clear:both;} 
    2829.text {font-size: 12px;margin:5px 0;background:#f7f7f7;border:1px dotted #aaa;padding:4px;} 
    29 #container {height:420px; width:510px;margin:0 auto; text-align:center;} 
    30 #fx {width:500px;background:#efefef;border:5px solid #aaa;}  
     30#container {height:420px; width:510px; margin:0 auto;} 
     31#fx {width:500px;background:#efefef;border:5px solid #aaa; text-align:center;}  
    3132</style> 
    3233</head> 
  • trunk/fx/experimental/tests/fold.html

    r3838 r3855  
    2828.controls div {padding:10px;clear:both;} 
    2929.text {font-size: 12px;margin:5px 0;background:#f7f7f7;border:1px dotted #aaa;padding:4px;} 
    30 #container {height:420px; width:510px;margin:0 auto; text-align:center;} 
    31 #fx {width:500px;background:#efefef;border:5px solid #aaa;}  
     30#container {height:420px; width:510px; margin:0 auto;} 
     31#fx {width:500px;background:#efefef;border:5px solid #aaa; text-align:center;}  
    3232</style> 
    3333</head> 
  • trunk/fx/experimental/tests/highlight.html

    r3838 r3855  
    2828.controls div {padding:10px;clear:both;} 
    2929.text {font-size: 12px;margin:5px 0;background:#f7f7f7;border:1px dotted #aaa;padding:4px;} 
    30 #container {height:420px; width:510px;margin:0 auto; text-align:center;} 
    31 #fx {width:500px;background:#efefef;border:5px solid #aaa;}  
     30#container {height:420px; width:510px; margin:0 auto;} 
     31#fx {width:500px;background:#efefef;border:5px solid #aaa; text-align:center;}  
    3232</style> 
    3333</head> 
  • trunk/fx/experimental/tests/pulsate.html

    r3838 r3855  
    2727.controls div {padding:10px;clear:both;} 
    2828.text {font-size: 12px;margin:5px 0;background:#f7f7f7;border:1px dotted #aaa;padding:4px;} 
    29 #container {height:420px; width:510px;margin:0 auto; text-align:center;} 
    30 #fx {width:500px;background:#efefef;border:5px solid #aaa;}  
     29#container {height:420px; width:510px; margin:0 auto;} 
     30#fx {width:500px;background:#efefef;border:5px solid #aaa; text-align:center;}  
    3131</style> 
    3232</head> 
  • trunk/fx/experimental/tests/slide.html

    r3838 r3855  
    2828.controls div {padding:10px;clear:both;} 
    2929.text {font-size: 12px;margin:5px 0;background:#f7f7f7;border:1px dotted #aaa;padding:4px;} 
    30 #container {height:420px; width:510px;margin:0 auto; text-align:center;} 
    31 #fx {width:500px;background:#efefef;border:5px solid #aaa;}  
     30#container {height:420px; width:510px; margin:0 auto;} 
     31#fx {width:500px;background:#efefef;border:5px solid #aaa; text-align:center;}  
    3232</style> 
    3333</head>