[ Index ]
 

Code source de LifeType 1.2.4

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/js/moo.fx/ -> moo.fx.pack.js (source)

   1  /*
   2  moo.fx pack, effects extensions for moo.fx.
   3  by Valerio Proietti (http://mad4milk.net) MIT-style LICENSE
   4  for more info visit (http://moofx.mad4milk.net).
   5  Friday, February 24, 2006
   6  v 1.2.2
   7  */
   8  
   9  //smooth scroll
  10  fx.Scroll = Class.create();
  11  fx.Scroll.prototype = Object.extend(new fx.Base(), {
  12      initialize: function(options) {
  13          this.setOptions(options);
  14      },
  15  
  16      scrollTo: function(el){
  17          var dest = Position.cumulativeOffset($(el))[1];
  18          var client = window.innerHeight || document.documentElement.clientHeight;
  19          var full = document.documentElement.scrollHeight;
  20          var top = window.pageYOffset || document.body.scrollTop || document.documentElement.scrollTop;
  21          if (dest+client > full) this.custom(top, dest - client + (full-dest));
  22          else this.custom(top, dest);
  23      },
  24  
  25      increase: function(){
  26          window.scrollTo(0, this.now);
  27      }
  28  });
  29  
  30  //text size modify, now works with pixels too.
  31  fx.Text = Class.create();
  32  fx.Text.prototype = Object.extend(new fx.Base(), {
  33      initialize: function(el, options) {
  34          this.el = $(el);
  35          this.setOptions(options);
  36          if (!this.options.unit) this.options.unit = "em";
  37      },
  38  
  39      increase: function() {
  40          this.el.style.fontSize = this.now + this.options.unit;
  41      }
  42  });
  43  
  44  //composition effect: widht/height/opacity
  45  fx.Combo = Class.create();
  46  fx.Combo.prototype = {
  47      setOptions: function(options) {
  48          this.options = {
  49              opacity: true,
  50              height: true,
  51              width: false
  52          }
  53          Object.extend(this.options, options || {});
  54      },
  55  
  56      initialize: function(el, options) {
  57          this.el = $(el);
  58          this.setOptions(options);
  59          if (this.options.opacity) {
  60              this.el.o = new fx.Opacity(el, options);
  61              options.onComplete = null;
  62          }
  63          if (this.options.height) {
  64              this.el.h = new fx.Height(el, options);
  65              options.onComplete = null;    
  66          }
  67          if (this.options.width) this.el.w = new fx.Width(el, options);
  68      },
  69      
  70      toggle: function() { this.checkExec('toggle'); },
  71  
  72      hide: function(){ this.checkExec('hide'); },
  73      
  74      clearTimer: function(){ this.checkExec('clearTimer'); },
  75      
  76      checkExec: function(func){
  77          if (this.el.o) this.el.o[func]();
  78          if (this.el.h) this.el.h[func]();
  79          if (this.el.w) this.el.w[func]();
  80      },
  81      
  82      //only if width+height
  83      resizeTo: function(hto, wto) {
  84          if (this.el.h && this.el.w) {
  85              this.el.h.custom(this.el.offsetHeight, this.el.offsetHeight + hto);
  86              this.el.w.custom(this.el.offsetWidth, this.el.offsetWidth + wto);
  87          }
  88      },
  89  
  90      customSize: function(hto, wto) {
  91          if (this.el.h && this.el.w) {
  92              this.el.h.custom(this.el.offsetHeight, hto);
  93              this.el.w.custom(this.el.offsetWidth, wto);
  94          }
  95      }
  96  }
  97  
  98  fx.Accordion = Class.create();
  99  fx.Accordion.prototype = {
 100      setOptions: function(options) {
 101          this.options = {
 102              delay: 100,
 103              opacity: false
 104          }
 105          Object.extend(this.options, options || {});
 106      },
 107  
 108      initialize: function(togglers, elements, options) {
 109          this.elements = elements;
 110          this.setOptions(options);
 111          var options = options || '';
 112          elements.each(function(el, i){
 113              options.onComplete = function(){
 114                  if (el.offsetHeight > 0) el.style.height = '1%';
 115              }
 116              el.fx = new fx.Combo(el, options);
 117              el.fx.hide();
 118          });
 119  
 120          togglers.each(function(tog, i){
 121              tog.onclick = function(){
 122                  this.showThisHideOpen(elements[i]);
 123              }.bind(this);
 124          }.bind(this));
 125      },
 126  
 127      showThisHideOpen: function(toShow){
 128          if (toShow.offsetHeight == 0) setTimeout(function(){this.clearAndToggle(toShow);}.bind(this), this.options.delay);
 129          this.elements.each(function(el, i){
 130              if (el.offsetHeight > 0 && el != toShow) this.clearAndToggle(el);
 131          }.bind(this));
 132      },
 133  
 134      clearAndToggle: function(el){
 135          el.fx.clearTimer();
 136          el.fx.toggle();
 137      }
 138  }
 139  
 140  var Remember = new Object();
 141  Remember = function(){};
 142  Remember.prototype = {
 143      initialize: function(el, options){
 144          this.el = $(el);
 145          this.days = 365;
 146          this.options = options;
 147          this.effect();
 148          var cookie = this.readCookie();
 149          if (cookie) {
 150              this.fx.now = cookie;
 151              this.fx.increase();
 152          }
 153      },
 154  
 155      //cookie functions based on code by Peter-Paul Koch
 156      setCookie: function(value) {
 157          var date = new Date();
 158          date.setTime(date.getTime()+(this.days*24*60*60*1000));
 159          var expires = "; expires="+date.toGMTString();
 160          document.cookie = this.el+this.el.id+this.prefix+"="+value+expires+"; path=/";
 161      },
 162  
 163      readCookie: function() {
 164          var nameEQ = this.el+this.el.id+this.prefix + "=";
 165          var ca = document.cookie.split(';');
 166          for(var i=0;c=ca[i];i++) {
 167              while (c.charAt(0)==' ') c = c.substring(1,c.length);
 168              if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
 169          }
 170          return false;
 171      },
 172  
 173      custom: function(from, to){
 174          if (this.fx.now != to) {
 175              this.setCookie(to);
 176              this.fx.custom(from, to);
 177          }
 178      }
 179  }
 180  
 181  fx.RememberHeight = Class.create();
 182  fx.RememberHeight.prototype = Object.extend(new Remember(), {
 183      effect: function(){
 184          this.fx = new fx.Height(this.el, this.options);
 185          this.prefix = 'height';
 186      },
 187      
 188      toggle: function(){
 189          if (this.el.offsetHeight == 0) this.setCookie(this.el.scrollHeight);
 190          else this.setCookie(0);
 191          this.fx.toggle();
 192      },
 193      
 194      resize: function(to){
 195          this.setCookie(this.el.offsetHeight+to);
 196          this.fx.custom(this.el.offsetHeight,this.el.offsetHeight+to);
 197      },
 198  
 199      hide: function(){
 200          if (!this.readCookie()) {
 201              this.fx.hide();
 202          }
 203      }
 204  });
 205  
 206  fx.RememberText = Class.create();
 207  fx.RememberText.prototype = Object.extend(new Remember(), {
 208      effect: function(){
 209          this.fx = new fx.Text(this.el, this.options);
 210          this.prefix = 'text';
 211      }
 212  });
 213  
 214  //useful for-replacement
 215  Array.prototype.each = function(func){
 216      for(var i=0;ob=this[i];i++) func(ob, i);
 217  }
 218  
 219  //Easing Equations (c) 2003 Robert Penner, all rights reserved.
 220  //This work is subject to the terms in http://www.robertpenner.com/easing_terms_of_use.html.
 221  
 222  //expo
 223  fx.expoIn = function(pos){
 224      return Math.pow(2, 10 * (pos - 1));
 225  }
 226  fx.expoOut = function(pos){
 227      return (-Math.pow(2, -10 * pos) + 1);
 228  }
 229  
 230  //quad
 231  fx.quadIn = function(pos){
 232      return Math.pow(pos, 2);
 233  }
 234  fx.quadOut = function(pos){
 235      return -(pos)*(pos-2);
 236  }
 237  
 238  //circ
 239  fx.circOut = function(pos){
 240      return Math.sqrt(1 - Math.pow(pos-1,2));
 241  }
 242  fx.circIn = function(pos){
 243      return -(Math.sqrt(1 - Math.pow(pos, 2)) - 1);
 244  }
 245  
 246  //back
 247  fx.backIn = function(pos){
 248      return (pos)*pos*((2.7)*pos - 1.7);
 249  }
 250  fx.backOut = function(pos){
 251      return ((pos-1)*(pos-1)*((2.7)*(pos-1) + 1.7) + 1);
 252  }
 253  
 254  //sine
 255  fx.sineOut = function(pos){
 256      return Math.sin(pos * (Math.PI/2));
 257  }
 258  fx.sineIn = function(pos){
 259      return -Math.cos(pos * (Math.PI/2)) + 1;
 260  }
 261  fx.sineInOut = function(pos){
 262      return -(Math.cos(Math.PI*pos) - 1)/2;
 263  }


Généré le : Mon Nov 26 21:04:15 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics