/* moo.fx pack, effects extensions for moo.fx. by valerio proietti (http://mad4milk.net) mit-style license for more info visit (http://moofx.mad4milk.net). friday, april 14, 2006 v 1.2.4 */ //smooth scroll fx.scroll = class.create(); fx.scroll.prototype = object.extend(new fx.base(), { initialize: function(options) { this.setoptions(options); }, scrollto: function(el){ var dest = position.cumulativeoffset($(el))[1]; var client = window.innerheight || document.documentelement.clientheight; var full = document.documentelement.scrollheight; var top = window.pageyoffset || document.body.scrolltop || document.documentelement.scrolltop; if (dest+client > full) this.custom(top, dest - client + (full-dest)); else this.custom(top, dest); }, increase: function(){ window.scrollto(0, this.now); } }); //text size modify, now works with pixels too. fx.text = class.create(); fx.text.prototype = object.extend(new fx.base(), { initialize: function(el, options) { this.el = $(el); this.setoptions(options); if (!this.options.unit) this.options.unit = "em"; }, increase: function() { this.el.style.fontsize = this.now + this.options.unit; } }); //composition effect: widht/height/opacity fx.combo = class.create(); fx.combo.prototype = { setoptions: function(options) { this.options = { opacity: true, height: true, width: false } object.extend(this.options, options || {}); }, initialize: function(el, options) { this.el = $(el); this.setoptions(options); if (this.options.opacity) { this.o = new fx.opacity(el, options); options.oncomplete = null; } if (this.options.height) { this.h = new fx.height(el, options); options.oncomplete = null; } if (this.options.width) this.w = new fx.width(el, options); }, toggle: function() { this.checkexec('toggle'); }, hide: function(){ this.checkexec('hide'); }, cleartimer: function(){ this.checkexec('cleartimer'); }, checkexec: function(func){ if (this.o) this.o[func](); if (this.h) this.h[func](); if (this.w) this.w[func](); }, //only if width+height resizeto: function(hto, wto) { if (this.h && this.w) { this.h.custom(this.el.offsetheight, this.el.offsetheight + hto); this.w.custom(this.el.offsetwidth, this.el.offsetwidth + wto); } }, customsize: function(hto, wto) { if (this.h && this.w) { this.h.custom(this.el.offsetheight, hto); this.w.custom(this.el.offsetwidth, wto); } } } fx.accordion = class.create(); fx.accordion.prototype = { setoptions: function(options) { this.options = { delay: 100, opacity: false } object.extend(this.options, options || {}); }, initialize: function(togglers, elements, options) { this.elements = elements; this.setoptions(options); var options = options || ''; this.fxa = []; if (options && options.oncomplete) options.onfinish = options.oncomplete; elements.each(function(el, i){ options.oncomplete = function(){ if (el.offsetheight > 0) el.style.height = '1%'; if (options.onfinish) options.onfinish(el); } this.fxa[i] = new fx.combo(el, options); this.fxa[i].hide(); }.bind(this)); togglers.each(function(tog, i){ if (typeof tog.onclick == 'function') var exclick = tog.onclick; tog.onclick = function(){ if (exclick) exclick(); this.showthishideopen(elements[i]); }.bind(this); }.bind(this)); }, showthishideopen: function(toshow){ this.elements.each(function(el, j){ if (el.offsetheight > 0 ) this.clearandtoggle(el, j); if (el == toshow && toshow.offsetheight == 0) settimeout(function(){this.clearandtoggle(toshow, j);}.bind(this), this.options.delay); }.bind(this)); }, clearandtoggle: function(el, i){ this.fxa[i].cleartimer(); this.fxa[i].toggle(); } } var remember = new object(); remember = function(){}; remember.prototype = { initialize: function(el, options){ this.el = $(el); this.days = 365; this.options = options; this.effect(); var cookie = this.readcookie(); if (cookie) { this.fx.now = cookie; this.fx.increase(); } }, //cookie functions based on code by peter-paul koch setcookie: function(value) { var date = new date(); date.settime(date.gettime()+(this.days*24*60*60*1000)); var expires = "; expires="+date.togmtstring(); document.cookie = this.el+this.el.id+this.prefix+"="+value+expires+"; path=/"; }, readcookie: function() { var nameeq = this.el+this.el.id+this.prefix + "="; var ca = document.cookie.split(';'); for(var i=0;c=ca[i];i++) { while (c.charat(0)==' ') c = c.substring(1,c.length); if (c.indexof(nameeq) == 0) return c.substring(nameeq.length,c.length); } return false; }, custom: function(from, to){ if (this.fx.now != to) { this.setcookie(to); this.fx.custom(from, to); } } } fx.rememberheight = class.create(); fx.rememberheight.prototype = object.extend(new remember(), { effect: function(){ this.fx = new fx.height(this.el, this.options); this.prefix = 'height'; }, toggle: function(){ if (this.el.offsetheight == 0) this.setcookie(this.el.scrollheight); else this.setcookie(0); this.fx.toggle(); }, resize: function(to){ this.setcookie(this.el.offsetheight+to); this.fx.custom(this.el.offsetheight,this.el.offsetheight+to); }, hide: function(){ if (!this.readcookie()) { this.fx.hide(); } } }); fx.remembertext = class.create(); fx.remembertext.prototype = object.extend(new remember(), { effect: function(){ this.fx = new fx.text(this.el, this.options); this.prefix = 'text'; } }); //useful for-replacement array.prototype.iterate = function(func){ for(var i=0;i