/* Title: jShowOff: a jQuery Content Rotator Plugin Author: Erik Kallevig Version: 0.1.2 Website: http://ekallevig.com/jshowoff License: Dual licensed under the MIT and GPL licenses. Uwaga dokonane zmiany - uwazac przy aktualizacji do nowszej wersji! */ (function($j) { $j.fn.jshowoff = function(settings) { var config = { animatePause : true, autoPlay : true, changeSpeed : 1200, controls : true, controlText : { play : 'Play', pause : 'Pause', next : 'Next', previous : 'Previous' }, effect : 'fade', hoverPause : true, links : true, speed : 8000 }; if (settings) $j.extend(true, config, settings); if (config.speed < (config.changeSpeed + 20)) { alert('jShowOff: Make speed at least 20ms longer than changeSpeed; the fades aren\'t always right on time.'); return this; } ; this .each(function(i) { var $jcont = $j(this); var gallery = $j(this).children().remove(); var timer = ''; var counter = 0; var preloadedImg = []; var howManyInstances = $j('.jshowoff').length + 1; var uniqueClass = 'jshowoff-' + howManyInstances; var cssClass = config.cssClass != undefined ? config.cssClass : ''; $jcont.css('position', 'relative').wrap( '
'); var $jwrap = $j('.' + uniqueClass); $jwrap.css('position', 'relative').addClass(cssClass); $j(gallery[0]).clone().appendTo($jcont); preloadImg(); if (config.controls) { if (gallery.length > 1) { addControls(); } if (config.autoPlay == false) { $j('.' + uniqueClass + '-play').addClass( uniqueClass + '-paused jshowoff-paused') .text(config.controlText.play); } ; } ; if (config.links) { addSlideLinks(); $j('.' + uniqueClass + '-slidelinks a').eq(0).addClass( uniqueClass + '-active jshowoff-active'); } ; if (config.hoverPause) { $jcont.hover(function() { if (isPlaying()) pause('hover'); }, function() { if (isPlaying()) play('hover'); }); } ; if (config.autoPlay && gallery.length > 1) { timer = setInterval(function() { play(); }, config.speed); } ; if (gallery.length < 1) { $j('.' + uniqueClass) .append( '

For jShowOff to work, the container element must have child elements.

'); } ; function transitionTo(gallery, index) { var oldCounter = counter; if ((counter >= gallery.length) || (index >= gallery.length)) { counter = 0; var e2b = true; } else if ((counter < 0) || (index < 0)) { counter = gallery.length - 1; var b2e = true; } else { counter = index; } if (config.effect == 'slideLeft') { var newSlideDir, oldSlideDir; function slideDir(dir) { newSlideDir = dir == 'right' ? 'left' : 'right'; oldSlideDir = dir == 'left' ? 'left' : 'right'; } ; counter >= oldCounter ? slideDir('left') : slideDir('right'); $j(gallery[counter]).clone().appendTo($jcont) .slideIt({ direction : newSlideDir, changeSpeed : config.changeSpeed }); if ($jcont.children().length > 1) { $jcont.children().eq(0).css('position', 'absolute').slideIt({ direction : oldSlideDir, showHide : 'hide', changeSpeed : config.changeSpeed }, function() { $j(this).remove(); }); } ; } else if (config.effect == 'fade') { $j(gallery[counter]) .clone() .appendTo($jcont) .hide() .fadeIn( config.changeSpeed, function() { if ($j.browser.msie) this.style .removeAttribute('filter'); }); if ($jcont.children().length > 1) { $jcont.children().eq(0).css('position', 'absolute').fadeOut(config.changeSpeed, function() { $j(this).remove(); }); } ; } else if (config.effect == 'none') { $j(gallery[counter]).clone().appendTo($jcont); if ($jcont.children().length > 1) { $jcont.children().eq(0).css('position', 'absolute').remove(); } ; } ; if (config.links) { $j('.' + uniqueClass + '-active').removeClass( uniqueClass + '-active jshowoff-active'); $j('.' + uniqueClass + '-slidelinks a') .eq(counter) .addClass( uniqueClass + '-active jshowoff-active'); } ; } ; function isPlaying() { return $j('.' + uniqueClass + '-play').hasClass( 'jshowoff-paused') ? false : true; } ; function play(src) { if (!isBusy()) { counter++; transitionTo(gallery, counter); if (src == 'hover' || !isPlaying()) { timer = setInterval(function() { play(); }, config.speed); } if (!isPlaying()) { $j('.' + uniqueClass + '-play').text( config.controlText.pause).removeClass( 'jshowoff-paused ' + uniqueClass + '-paused'); } } ; } ; function pause(src) { clearInterval(timer); if (!src || src == 'playBtn') $j('.' + uniqueClass + '-play').text( config.controlText.play).addClass( 'jshowoff-paused ' + uniqueClass + '-paused'); if (config.animatePause && src == 'playBtn') { $j( '

' + config.controlText.pause + '

') .css({ fontSize : '62%', textAlign : 'center', position : 'absolute', top : '40%', lineHeight : '100%', width : '100%' }).appendTo($jwrap).addClass( uniqueClass + 'pauseText').animate( { fontSize : '600%', top : '30%', opacity : 0 }, { duration : 500, complete : function() { $j(this).remove(); } }); } } ; function next() { goToAndPause(counter + 1); } ; function previous() { goToAndPause(counter - 1); } ; function isBusy() { return $jcont.children().length > 1 ? true : false; } ; function goToAndPause(index) { $jcont.children().stop(true, true); if ((counter != index) || ((counter == index) && isBusy())) { if (isBusy()) $jcont.children().eq(0).remove(); transitionTo(gallery, index); pause(); } ; } ; function preloadImg() { $j(gallery) .each( function(i) { $j(this) .find('img') .each( function(i) { preloadedImg[i] = $j( '') .attr( 'src', $j( this) .attr( 'src')); }); }); } ; function addControls() { $jwrap .append('
'
										+ config.controlText.previous
										+ '' + '' +''
										+ config.controlText.next
										+ '
'); $j('.' + uniqueClass + '-controls a').each(function() { if ($j(this).hasClass('jshowoff-prev')) $j(this).click(function() { previous(); return false; }); if ($j(this).hasClass('jshowoff-next')) $j(this).click(function() { next(); return false; }); }); } ; function addSlideLinks() { $j .each( gallery, function(i, val) { var linktext = $j(this) .attr('title') != '' ? $j( this).attr('title') : i + 1; $j( '' + ''
																+ linktext
																+ '' + '') .bind( 'click', { index : i }, function(e) { goToAndPause(e.data.index); return false; }) .appendTo( '.' + uniqueClass + '-slidelinks'); }); } ; }); return this; }; })(jQuery); (function($j) { $j.fn.slideIt = function(settings, callback) { var config = { direction : 'left', showHide : 'show', changeSpeed : 1200 }; if (settings) $j.extend(config, settings); this .each(function(i) { $j(this).css({ left : 'auto', right : 'auto', top : 'auto', bottom : 'auto' }); var measurement = (config.direction == 'left') || (config.direction == 'right') ? $j(this) .outerWidth() : $j(this).outerHeight(); var startStyle = {}; startStyle['position'] = $j(this).css('position') == 'static' ? 'relative' : $j(this).css('position'); startStyle[config.direction] = (config.showHide == 'show') ? '-' + measurement + 'px' : 0; var endStyle = {}; endStyle[config.direction] = config.showHide == 'show' ? 0 : '-' + measurement + 'px'; $j(this).css(startStyle).animate(endStyle, config.changeSpeed, callback); }); return this; }; })(jQuery);