Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $.widget("ui.slideshow", {
- options: {
- timer: false,
- transform: 'left',
- intervalo: 2000,
- velocidade: 500
- },
- _init: function(){
- this.start();
- },
- start: function(){
- this.stop();
- var slideshowdiv = this.element;
- var largura = $(slideshowdiv).find('img:first').width();
- var altura = $(slideshowdiv).find('img:first').height();
- var totalimagens = $(slideshowdiv).find('img').length;
- var intervalo = this.options.intervalo;
- var transform = this.options.transform;
- var velocidade = this.options.velocidade;
- var wrapper = $('<div id="slideshowwrapper" />').width(largura).height(altura).css({'overflow':'hidden','position':'relative','margin':'0 auto'});
- $(slideshowdiv).wrap(wrapper);
- $(slideshowdiv).children('div').css({'position':'relative','display':'inline-block'});
- ReverseImages = function(direction){
- $(slideshowdiv).children('div').each(function(cont){
- if(cont > 0)
- $(this).prependTo($(slideshowdiv));
- });
- if (direction == 'horizontal')
- $(slideshowdiv).css('margin-left', '-' + largura * (totalimagens - 1) + 'px');
- else if (direction == 'vertical')
- $(slideshowdiv).css('margin-top', '-' + altura * (totalimagens - 1) + 'px');
- };
- switch(this.options.transform){
- case 'left':
- $(slideshowdiv).width(largura * totalimagens).height(altura);
- this.options.timer = window.setInterval("ChangeImageLeft(" + velocidade + ")", intervalo);
- break;
- case 'right':
- $(slideshowdiv).width(largura * totalimagens + 4).height(altura);
- ReverseImages('horizontal');
- this.options.timer = window.setInterval("ChangeImageRight(" + velocidade + ")", intervalo);
- break;
- case 'up':
- $(slideshowdiv).height(altura * totalimagens).width(largura);
- this.options.timer = window.setInterval("ChangeImageUp(" + velocidade + ")", intervalo);
- break;
- case 'down':
- $(slideshowdiv).height(altura * totalimagens).width(largura);
- ReverseImages('vertical');
- this.options.timer = window.setInterval("ChangeImageDown(" + velocidade + ")", intervalo);
- break;
- case 'fade':
- $(slideshowdiv).height(altura).width(largura);
- this.options.timer = window.setInterval("ChangeImageFade(" + velocidade + ")", intervalo);
- break;
- case 'seethrough':
- $(slideshowdiv).children('div').css('position','absolute');
- $(slideshowdiv).height(altura).width(largura);
- this.options.timer = window.setInterval("ChangeImageSeethrough(" + velocidade + ")", intervalo);
- break;
- case 'png':
- if(!$.browser.msie){
- $(slideshowdiv).height(altura).width(largura);
- $(slideshowdiv).children('div').css({'position':'absolute','opacity':'0'});
- $(slideshowdiv).children('div:last').css({'opacity':'1'});
- this.options.timer = window.setInterval("ChangeImagePNG(" + velocidade + ")", intervalo);
- } else{
- $(slideshowdiv).height(altura).width(largura);
- $(slideshowdiv).children('div').css({'position':'absolute'}).hide();
- $(slideshowdiv).children('div:last').show();
- this.options.timer = window.setInterval("ChangeImagePNGIE(" + velocidade + ")", intervalo);
- }
- break;
- }
- ChangeImageLeft = function(velocidade){
- $(slideshowdiv).animate({'margin-left' : '-=' + largura } , velocidade, function(){
- $(slideshowdiv).children('div:first').appendTo($(slideshowdiv));
- $(slideshowdiv).css('margin-left','0');
- }
- );
- };
- ChangeImageRight = function(){
- $(slideshowdiv).animate({'margin-left' : '+=' + largura } , velocidade, function(){
- $(slideshowdiv).children('div:last').prependTo($(slideshowdiv));
- $(slideshowdiv).css('margin-left', '-' + largura * (totalimagens - 1) + 'px');
- }
- );
- };
- ChangeImageUp = function(){
- $(slideshowdiv).animate({'margin-top' : '-=' + altura } , velocidade, function(){
- $(slideshowdiv).children('div:first').appendTo($(slideshowdiv));
- $(slideshowdiv).css('margin-top', '0');
- }
- );
- };
- ChangeImageDown = function(){
- $(slideshowdiv).animate({'margin-top' : '+=' + altura } , velocidade, function(){
- $(slideshowdiv).children('div:last').prependTo($(slideshowdiv));
- $(slideshowdiv).css('margin-top', '-' + altura * (totalimagens - 1) + 'px');
- }
- );
- };
- ChangeImageFade = function(){
- $(slideshowdiv).children('div:first').fadeOut(velocidade/2, function(){
- $(slideshowdiv).children('div:first').appendTo($(slideshowdiv));
- $(slideshowdiv).children('div:first').fadeIn(velocidade/2);
- });
- };
- ChangeImageSeethrough = function(){
- $(slideshowdiv).children('div:last').animate({'opacity': 0.0}, velocidade, function(){
- $(slideshowdiv).children('div:last').css('opacity','1.0');
- $(slideshowdiv).children('div:last').prependTo($(slideshowdiv));
- });
- };
- ChangeImagePNG = function(){
- $(slideshowdiv).children('div:last').animate({'opacity': 0.0}, velocidade, function(){
- $(slideshowdiv).children('div:last').prependTo($(slideshowdiv));
- }).prev('div').animate({'opacity': 1.0}, velocidade);
- };
- ChangeImagePNGIE = function(){
- $(slideshowdiv).children('div:last').hide().prev('div').show();
- $(slideshowdiv).children('div:last').prependTo($(slideshowdiv));
- };
- },
- stop: function(){
- this.element.css('margin-left','0').css('margin-top','0');
- if (this.options.timer) {
- clearInterval(this.options.timer);
- this.options.timer = false;
- }
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement