var Bannery_strefa = new Class ({ Implements: [Options], scroll: null, wrapper: null, overlay: null, przesuniecie: 'left', ilewidac: 0, ilemax: 0, pozycja: 0, zapetlenie: 1, dane: [], initialize: function(opcje) { this.setOptions(opcje); var tryb = this.options.tryb; var strefa = $(this.options.strefa); var poprzedni = strefa.getElement(this.options.poprzedni); var nastepny = strefa.getElement(this.options.nastepny); this.wrapper = strefa.getElement(this.options.wraper); this.overlay = strefa.getElement(this.options.overlay); this.sprawdz_bannery(tryb,strefa); this.tryb(tryb); this.scroll = new Fx.Morph(this.wrapper, { duration: 'long', transition: Fx.Transitions.Sine.easeOut }); strefa.addEvents({ mouseover: function() { clearInterval(this.periodicalID); }.bind(this), mouseout: function() { this.petla(); }.bind(this) }); poprzedni.addClass('end'); poprzedni.addEvents({ click: function() { this.poprzedni(nastepny,poprzedni); return false; }.bind(this), mouseover: function() { clearInterval(this.periodicalID); }.bind(this), mouseout: function() { }.bind(this) }); nastepny.addEvents({ click: function() { this.zapetlenie = 0; this.nastepny(nastepny,poprzedni); return false; }.bind(this), mouseover: function() { clearInterval(this.periodicalID); }.bind(this), mouseout: function() { }.bind(this) }); this.petla(); }, sprawdz_bannery: function(tryb,strefa) { var bannery = strefa.getElements(this.options.bannery); var przesuniecie = this.przesuniecie; var dane = []; var licz = 0; bannery.each(function(el,ids){ if (tryb == 'pion') { var szer = parseInt(el.getStyle('height')); var margines = parseInt(el.getStyle('margin-bottom')); } else { var szer = parseInt(el.getStyle('width')); var margines = parseInt(el.getStyle('margin-right')); } licz += szer; licz +=margines; szer += margines; dane.push(szer); }); this.ilemax = licz; this.dane = dane; }, petla: function() { this.zapetlenie = 1; var nastepny = $(this.options.strefa).getElement(this.options.nastepny); var poprzedni = $(this.options.strefa).getElement(this.options.poprzedni); this.periodicalID = (function() { this.nastepny(nastepny,poprzedni); }.bind(this)).periodical(5000); }, tryb: function(tryb) { if (tryb == 'pion') { this.przesuniecie = 'top'; this.ilewidac = this.overlay.getHeight(); this.ilemax = (this.options.wraper_wysokosc == 'auto') ? this.ilemax : this.options.wraper_wysokosc; this.wrapper.setStyle('top',0); } else { this.przesuniecie = 'left'; this.ilewidac = this.overlay.getWidth(); this.ilemax = (this.options.wraper_szerokosc == 'auto') ? this.ilemax : this.options.wraper_szerokosc; this.wrapper.setStyle('left',0); } }, poprzedni: function(dd,pp) { if (this.pozycja>0) { this.pozycja--; } else { return false; } var pozycja_diva = this.pozycja_diva(); var przesuniecie = this.dane[this.pozycja]; var przesun = pozycja_diva+przesuniecie; if (this.pozycja== 0) { pp.addClass('end'); } dd.removeClass('end'); this.przesuniecie_scroll(przesun); }, nastepny: function(dd,pp) { var pozycja_diva = this.pozycja_diva(); var przesuniecie = this.dane[this.pozycja]; var przesun = pozycja_diva-przesuniecie; var ilewidac = parseInt(this.ilewidac); var ilepokaz = -(przesun-ilewidac); if (ilepokaz > (this.ilemax+przesuniecie)) { if (this.zapetlenie) { pp.addClass('end'); dd.removeClass('end'); this.pozycja = 0; this.przesuniecie_scroll(0); return false; } else { dd.addClass('end'); return false; } } pp.removeClass('end'); this.pozycja++; this.przesuniecie_scroll(przesun); if (ilepokaz >= this.ilemax) { dd.addClass('end'); } }, przesuniecie_scroll: function(przesun) { if (przesun > 0) { return false; } if (this.przesuniecie == 'top') { this.scroll.start({top: przesun}).chain(function() { }); } else { this.scroll.start({left: przesun}).chain(function() { }); } }, pozycja_diva: function() { var wrapper = this.wrapper; var przesuniecie = this.przesuniecie; return parseInt(wrapper.getStyle(przesuniecie)); } });