/* gbTicker v1.0 mit MooTools v1.2 von gb media (www.gb-media.biz) 2009 Vielen Dank an die MooTools Entwickler */ var gbTicker = new Class({ Implements: Options, options: { handler : 'tickerList', btnStop : 'btn_stop', btnPlay : 'btn_play', btnDirect_h : 'btn_hori', btnDirect_v : 'btn_verti', current : 0, intervall : 10, play : true, duration : 1500, transition : Fx.Transitions.Expo.easeOut, direction : 'vertical' }, initialize: function(options){ this.setOptions(options); this.elTicker = $(this.options.handler); this.w = this.elTicker.getSize().x; this.h = this.elTicker.getSize().y; this.newDirection = this.options.direction; this.bound = {}; if ($(this.options.btnStop)){ stopEl = $(this.options.btnStop).getElement('a'); this.bound.stopTicker = this.stopTicker.bindWithEvent(this, stopEl); stopEl.addEvent('click', this.bound.stopTicker); } if ($(this.options.btnPlay)){ playEl = $(this.options.btnPlay).getElement('a'); this.bound.playTicker = this.playTicker.bindWithEvent(this, playEl); playEl.addEvent('click', this.bound.playTicker); } if ($(this.options.btnDirect_h)){ horiEl = $(this.options.btnDirect_h).getElement('a'); this.bound.setHorizontal = this.setHorizontal.bindWithEvent(this, horiEl); horiEl.addEvent('click', this.bound.setHorizontal); } if ($(this.options.btnDirect_v)){ vertiEl = $(this.options.btnDirect_v).getElement('a'); this.bound.setVertical = this.setVertical.bindWithEvent(this, vertiEl); vertiEl.addEvent('click', this.bound.setVertical); } this.setTicker (); }, setTicker: function (){ this.items = this.elTicker.getElements('li'); this.options.current = this.options.current > this.items.length-1 || this.options.current < 0 ? 0 : this.options.current; w = 0; h = 0; if(this.options.direction.toLowerCase()=='horizontal') { this.setBtnDirection('none', 'inline'); h = this.h; this.items.each(function(el,i) { w += el.getSize().x; }); } else { this.setBtnDirection('inline', 'none'); w = this.w; this.items.each(function(el,i) { h += el.getSize().y; }); } pos = this.getPos(); this.elTicker.setStyles({ position: 'absolute', width: w, height: h, top: pos.top, left: pos.left }); this.fx = new Fx.Morph(this.elTicker, { duration: this.options.duration, transition: this.options.transition, onComplete:function() { this.injectEl(); }.bind(this) }); for (i=0; i= this.items.length ? 0 : this.options.current+1; pos = this.getPos(); this.fx.start({ top: pos.top, left: pos.left }).chain(function() { this.playItem(); }.bind(this)); }, getPos: function (){ var el = this.items[this.options.current]; pos = { top: -el.offsetTop, left: -el.offsetLeft } return pos; }, injectEl: function (i){ if (typeof i == 'undefined'){ var i = this.options.current==0 ? this.items.length : this.options.current; i --; } this.items[i].injectInside(this.elTicker); this.elTicker.setStyles({ left:0, top:0 }); } }); gbTicker.implement(new Options); window.addEvent('domready', function(){ if (typeof gbTickerOpt == 'undefined'){ gbTickerOpt = {}; } gbTicker = new gbTicker(gbTickerOpt); });