diff --git a/jquery.nivo.slider.js b/jquery.nivo.slider.js
index 8b0a774..eebca62 100644
--- a/jquery.nivo.slider.js
+++ b/jquery.nivo.slider.js
@@ -24,14 +24,14 @@
};
// Get this slider
- var slider = $(element);
- slider.data('nivo:vars', vars).addClass('nivoSlider');
+ var $slider = $(element);
+ $slider.data('nivo:vars', vars).addClass('nivoSlider');
// Find our slider children
- var kids = slider.children();
+ var kids = $slider.children();
kids.each(function() {
- var child = $(this);
- var link = '';
+ var child = $(this),
+ link = '';
if(!child.is('img')){
if(child.is('a')){
child.addClass('nivo-imageLink');
@@ -44,105 +44,101 @@
childHeight = (childHeight === 0) ? child.attr('height') : child.height();
if(link !== ''){
- link.css('display','none');
+ link.hide();
}
- child.css('display','none');
+ child.hide();
vars.totalSlides++;
});
-
+
// If randomStart
if(settings.randomStart){
settings.startSlide = Math.floor(Math.random() * vars.totalSlides);
}
-
+
// Set startSlide
if(settings.startSlide > 0){
- if(settings.startSlide >= vars.totalSlides) { settings.startSlide = vars.totalSlides - 1; }
+ if(settings.startSlide >= vars.totalSlides) {
+ settings.startSlide = vars.totalSlides - 1;
+ }
vars.currentSlide = settings.startSlide;
}
-
- // Get initial image
- if($(kids[vars.currentSlide]).is('img')){
- vars.currentImage = $(kids[vars.currentSlide]);
- } else {
- vars.currentImage = $(kids[vars.currentSlide]).find('img:first');
+
+ // Get initial image
+ vars.currentImage = $(kids[vars.currentSlide]);
+ if(! vars.currentImage.is('img')){
+ vars.currentImage = vars.currentImage.find('img:first');
}
-
+
// Show initial link
- if($(kids[vars.currentSlide]).is('a')){
- $(kids[vars.currentSlide]).css('display','block');
- }
-
+ vars.currentImage.is('a') && vars.currentImage.show();
+
// Set first background
- var sliderImg = $('
').addClass('nivo-main-image');
- sliderImg.attr('src', vars.currentImage.attr('src')).show();
- slider.append(sliderImg);
+ var $sliderImg = $('
').addClass('nivo-main-image');
+ $sliderImg.attr('src', vars.currentImage.attr('src')).show().appendTo($slider);
// Detect Window Resize
$(window).resize(function() {
- slider.children('img').width(slider.width());
- sliderImg.attr('src', vars.currentImage.attr('src'));
- sliderImg.stop().height('auto');
- $('.nivo-slice').remove();
- $('.nivo-box').remove();
+ $slider.children('img').width($slider.width());
+ $sliderImg.attr('src', vars.currentImage.attr('src')).stop().height('auto');
+ $('.nivo-slice, .nivo-box').remove();
});
//Create caption
- slider.append($('
'));
-
+ var $caption = $('', {class : 'nivo-caption'});
+ $slider.append($caption);
+
// Process caption function
var processCaption = function(settings){
- var nivoCaption = $('.nivo-caption', slider);
+ var nivoCaption = $('.nivo-caption', $slider);
if(vars.currentImage.attr('title') != '' && vars.currentImage.attr('title') != undefined){
var title = vars.currentImage.attr('title');
- if(title.substr(0,1) == '#') title = $(title).html();
+ if(title.substr(0,1) == '#') title = $(title).html();
- if(nivoCaption.css('display') == 'block'){
+ if(nivoCaption.is(':visible')){
setTimeout(function(){
nivoCaption.html(title);
}, settings.animSpeed);
} else {
- nivoCaption.html(title);
- nivoCaption.stop().fadeIn(settings.animSpeed);
+ nivoCaption.html(title).stop().fadeIn(settings.animSpeed);
}
} else {
nivoCaption.stop().fadeOut(settings.animSpeed);
}
}
-
- //Process initial caption
+
+ //Process initial caption
processCaption(settings);
-
+
// In the words of Super Mario "let's a go!"
var timer = 0;
if(!settings.manualAdvance && kids.length > 1){
- timer = setInterval(function(){ nivoRun(slider, kids, settings, false); }, settings.pauseTime);
+ timer = setInterval(function(){
+ nivoRun($slider, kids, settings, false);
+ }, settings.pauseTime);
}
-
+
// Add Direction nav
if(settings.directionNav){
- slider.append('');
-
- $(slider).on('click', 'a.nivo-prevNav', function(){
+ $slider.append('')
+ .on('click', 'a.nivo-prevNav', function(){
if(vars.running) { return false; }
clearInterval(timer);
timer = '';
vars.currentSlide -= 2;
- nivoRun(slider, kids, settings, 'prev');
- });
-
- $(slider).on('click', 'a.nivo-nextNav', function(){
+ nivoRun($slider, kids, settings, 'prev');
+ })
+ .on('click', 'a.nivo-nextNav', function(){
if(vars.running) { return false; }
clearInterval(timer);
timer = '';
- nivoRun(slider, kids, settings, 'next');
+ nivoRun($slider, kids, settings, 'next');
});
}
-
+
// Add Control nav
if(settings.controlNav){
vars.controlNavEl = $('');
- slider.after(vars.controlNavEl);
+ $slider.after(vars.controlNavEl);
for(var i = 0; i < kids.length; i++){
if(settings.controlNavThumbs){
vars.controlNavEl.addClass('nivo-thumbs-enabled');
@@ -150,7 +146,9 @@
if(!child.is('img')){
child = child.find('img:first');
}
- if(child.attr('data-thumb')) vars.controlNavEl.append('
');
+ if(child.attr('data-thumb')) {
+ vars.controlNavEl.append('
');
+ }
} else {
vars.controlNavEl.append(''+ (i + 1) +'');
}
@@ -158,21 +156,20 @@
//Set initial active link
$('a:eq('+ vars.currentSlide +')', vars.controlNavEl).addClass('active');
-
+
$('a', vars.controlNavEl).bind('click', function(){
- if(vars.running) return false;
- if($(this).hasClass('active')) return false;
+ if(vars.running || $(this).hasClass('active')) return false;
clearInterval(timer);
timer = '';
- sliderImg.attr('src', vars.currentImage.attr('src'));
+ $sliderImg.attr('src', vars.currentImage.attr('src'));
vars.currentSlide = $(this).attr('rel') - 1;
- nivoRun(slider, kids, settings, 'control');
+ nivoRun($slider, kids, settings, 'control');
});
}
-
+
//For pauseOnHover setting
if(settings.pauseOnHover){
- slider.hover(function(){
+ $slider.hover(function(){
vars.paused = true;
clearInterval(timer);
timer = '';
@@ -180,24 +177,24 @@
vars.paused = false;
// Restart the timer
if(timer === '' && !settings.manualAdvance){
- timer = setInterval(function(){ nivoRun(slider, kids, settings, false); }, settings.pauseTime);
+ timer = setInterval(function(){ nivoRun($slider, kids, settings, false); }, settings.pauseTime);
}
});
}
-
+
// Event when Animation finishes
- slider.bind('nivo:animFinished', function(){
- sliderImg.attr('src', vars.currentImage.attr('src'));
- vars.running = false;
+ $slider.bind('nivo:animFinished', function(){
+ $sliderImg.attr('src', vars.currentImage.attr('src'));
+ vars.running = false;
// Hide child links
$(kids).each(function(){
if($(this).is('a')){
- $(this).css('display','none');
+ $(this).hide();
}
});
// Show current link
if($(kids[vars.currentSlide]).is('a')){
- $(kids[vars.currentSlide]).css('display','block');
+ $(kids[vars.currentSlide]).show();
}
// Restart the timer
if(timer === '' && !vars.paused && !settings.manualAdvance){
@@ -205,31 +202,34 @@
}
// Trigger the afterChange callback
settings.afterChange.call(this);
- });
-
+ });
+
// Add slices for slice animations
var createSlices = function(slider, settings, vars) {
- if($(vars.currentImage).parent().is('a')) $(vars.currentImage).parent().css('display','block');
+ var $currentParent = $(vars.currentImage).parent();
+ if($currentParent.is('a')){
+ $currentParent.show();
+ }
$('img[src="'+ vars.currentImage.attr('src') +'"]', slider).not('.nivo-main-image,.nivo-control img').width(slider.width()).css('visibility', 'hidden').show();
var sliceHeight = ($('img[src="'+ vars.currentImage.attr('src') +'"]', slider).not('.nivo-main-image,.nivo-control img').parent().is('a')) ? $('img[src="'+ vars.currentImage.attr('src') +'"]', slider).not('.nivo-main-image,.nivo-control img').parent().height() : $('img[src="'+ vars.currentImage.attr('src') +'"]', slider).not('.nivo-main-image,.nivo-control img').height();
for(var i = 0; i < settings.slices; i++){
var sliceWidth = Math.round(slider.width()/settings.slices);
-
+
if(i === settings.slices-1){
slider.append(
- $(' +')
').css({
- left:(sliceWidth*i)+'px',
+ $(' +')
').css({
+ left:(sliceWidth*i)+'px',
width:(slider.width()-(sliceWidth*i))+'px',
- height:sliceHeight+'px',
+ height:sliceHeight+'px',
opacity:'0',
overflow:'hidden'
})
);
} else {
slider.append(
- $(' +')
').css({
- left:(sliceWidth*i)+'px',
+ $(' +')
').css({
+ left:(sliceWidth*i)+'px',
width:sliceWidth+'px',
height:sliceHeight+'px',
opacity:'0',
@@ -238,39 +238,39 @@
);
}
}
-
+
$('.nivo-slice', slider).height(sliceHeight);
- sliderImg.stop().animate({
+ $sliderImg.stop().animate({
height: $(vars.currentImage).height()
}, settings.animSpeed);
};
-
+
// Add boxes for box animations
var createBoxes = function(slider, settings, vars){
- if($(vars.currentImage).parent().is('a')) $(vars.currentImage).parent().css('display','block');
+ if($(vars.currentImage).parent().is('a')) $(vars.currentImage).parent().show();
$('img[src="'+ vars.currentImage.attr('src') +'"]', slider).not('.nivo-main-image,.nivo-control img').width(slider.width()).css('visibility', 'hidden').show();
var boxWidth = Math.round(slider.width()/settings.boxCols),
boxHeight = Math.round($('img[src="'+ vars.currentImage.attr('src') +'"]', slider).not('.nivo-main-image,.nivo-control img').height() / settings.boxRows);
-
-
+
+
for(var rows = 0; rows < settings.boxRows; rows++){
for(var cols = 0; cols < settings.boxCols; cols++){
if(cols === settings.boxCols-1){
slider.append(
- $(' +')
').css({
+ $(' +')
').css({
opacity:0,
- left:(boxWidth*cols)+'px',
+ left:(boxWidth*cols)+'px',
top:(boxHeight*rows)+'px',
width:(slider.width()-(boxWidth*cols))+'px'
-
+
})
);
$('.nivo-box[name="'+ cols +'"]', slider).height($('.nivo-box[name="'+ cols +'"] img', slider).height()+'px');
} else {
slider.append(
- $(' +')
').css({
+ $(' +')
').css({
opacity:0,
- left:(boxWidth*cols)+'px',
+ left:(boxWidth*cols)+'px',
top:(boxHeight*rows)+'px',
width:boxWidth+'px'
})
@@ -279,43 +279,43 @@
}
}
}
-
- sliderImg.stop().animate({
+
+ $sliderImg.stop().animate({
height: $(vars.currentImage).height()
}, settings.animSpeed);
};
// Private run method
- var nivoRun = function(slider, kids, settings, nudge){
+ var nivoRun = function(slider, kids, settings, nudge){
// Get our vars
var vars = slider.data('nivo:vars');
-
+
// Trigger the lastSlide callback
- if(vars && (vars.currentSlide === vars.totalSlides - 1)){
+ if(vars && (vars.currentSlide === vars.totalSlides - 1)){
settings.lastSlide.call(this);
}
-
+
// Stop
if((!vars || vars.stop) && !nudge) { return false; }
-
+
// Trigger the beforeChange callback
settings.beforeChange.call(this);
// Set current background before change
if(!nudge){
- sliderImg.attr('src', vars.currentImage.attr('src'));
+ $sliderImg.attr('src', vars.currentImage.attr('src'));
} else {
if(nudge === 'prev'){
- sliderImg.attr('src', vars.currentImage.attr('src'));
+ $sliderImg.attr('src', vars.currentImage.attr('src'));
}
if(nudge === 'next'){
- sliderImg.attr('src', vars.currentImage.attr('src'));
+ $sliderImg.attr('src', vars.currentImage.attr('src'));
}
}
-
+
vars.currentSlide++;
// Trigger the slideshowEnd callback
- if(vars.currentSlide === vars.totalSlides){
+ if(vars.currentSlide === vars.totalSlides){
vars.currentSlide = 0;
settings.slideshowEnd.call(this);
}
@@ -326,25 +326,25 @@
} else {
vars.currentImage = $(kids[vars.currentSlide]).find('img:first');
}
-
+
// Set active links
if(settings.controlNav){
$('a', vars.controlNavEl).removeClass('active');
$('a:eq('+ vars.currentSlide +')', vars.controlNavEl).addClass('active');
}
-
+
// Process caption
- processCaption(settings);
-
+ processCaption(settings);
+
// Remove any slices from last transition
$('.nivo-slice', slider).remove();
-
+
// Remove any boxes from last transition
$('.nivo-box', slider).remove();
-
+
var currentEffect = settings.effect,
anims = '';
-
+
// Generate random effect
if(settings.effect === 'random'){
anims = new Array('sliceDownRight','sliceDownLeft','sliceUpRight','sliceUpLeft','sliceUpDown','sliceUpDownLeft','fold','fade',
@@ -352,45 +352,50 @@
currentEffect = anims[Math.floor(Math.random()*(anims.length + 1))];
if(currentEffect === undefined) { currentEffect = 'fade'; }
}
-
+
// Run random effect from specified set (eg: effect:'fold,fade')
if(settings.effect.indexOf(',') !== -1){
anims = settings.effect.split(',');
currentEffect = anims[Math.floor(Math.random()*(anims.length))];
- if(currentEffect === undefined) { currentEffect = 'fade'; }
+ if(currentEffect === undefined) {
+ currentEffect = 'fade';
+ }
}
-
+
// Custom transition as defined by "data-transition" attribute
if(vars.currentImage.attr('data-transition')){
currentEffect = vars.currentImage.attr('data-transition');
}
-
+
// Run effects
vars.running = true;
var timeBuff = 0,
i = 0,
slices = '',
- firstSlice = '',
totalBoxes = '',
boxes = '';
-
+
+ var firstSlice = $('.nivo-slice:first', slider);
+
if(currentEffect === 'sliceDown' || currentEffect === 'sliceDownRight' || currentEffect === 'sliceDownLeft'){
createSlices(slider, settings, vars);
timeBuff = 0;
i = 0;
slices = $('.nivo-slice', slider);
if(currentEffect === 'sliceDownLeft') { slices = $('.nivo-slice', slider)._reverse(); }
-
+
slices.each(function(){
var slice = $(this);
- slice.css({ 'top': '0px' });
- if(i === settings.slices-1){
+ slice.css({ 'top': 0 });
+ if(i === settings.slices - 1){
setTimeout(function(){
- slice.animate({opacity:'1.0' }, settings.animSpeed, '', function(){ slider.trigger('nivo:animFinished'); });
+ slice.animate({opacity: 1 }, settings.animSpeed, '', function(){
+ slider.trigger('nivo:animFinished');
+ });
}, (100 + timeBuff));
} else {
setTimeout(function(){
- slice.animate({opacity:'1.0' }, settings.animSpeed);
+ slice.animate({opacity: 1 }, settings.animSpeed);
}, (100 + timeBuff));
}
timeBuff += 50;
@@ -401,18 +406,22 @@
timeBuff = 0;
i = 0;
slices = $('.nivo-slice', slider);
- if(currentEffect === 'sliceUpLeft') { slices = $('.nivo-slice', slider)._reverse(); }
-
+ if(currentEffect === 'sliceUpLeft') {
+ slices = $('.nivo-slice', slider)._reverse();
+ }
+
slices.each(function(){
var slice = $(this);
- slice.css({ 'bottom': '0px' });
- if(i === settings.slices-1){
+ slice.css({ 'bottom': 0 });
+ if(i === settings.slices - 1){
setTimeout(function(){
- slice.animate({opacity:'1.0' }, settings.animSpeed, '', function(){ slider.trigger('nivo:animFinished'); });
+ slice.animate({opacity: 1 }, settings.animSpeed, '', function(){
+ slider.trigger('nivo:animFinished');
+ });
}, (100 + timeBuff));
} else {
setTimeout(function(){
- slice.animate({opacity:'1.0' }, settings.animSpeed);
+ slice.animate({opacity: 1 }, settings.animSpeed);
}, (100 + timeBuff));
}
timeBuff += 50;
@@ -424,25 +433,29 @@
i = 0;
var v = 0;
slices = $('.nivo-slice', slider);
- if(currentEffect === 'sliceUpDownLeft') { slices = $('.nivo-slice', slider)._reverse(); }
-
+ if(currentEffect === 'sliceUpDownLeft') {
+ slices = $('.nivo-slice', slider)._reverse();
+ }
+
slices.each(function(){
var slice = $(this);
if(i === 0){
- slice.css('top','0px');
+ slice.css(top, 0);
i++;
} else {
- slice.css('bottom','0px');
+ slice.css(bottom, 0);
i = 0;
}
-
- if(v === settings.slices-1){
+
+ if(v === settings.slices - 1){
setTimeout(function(){
- slice.animate({opacity:'1.0' }, settings.animSpeed, '', function(){ slider.trigger('nivo:animFinished'); });
+ slice.animate({opacity: 1 }, settings.animSpeed, '', function(){
+ slider.trigger('nivo:animFinished');
+ });
}, (100 + timeBuff));
} else {
setTimeout(function(){
- slice.animate({opacity:'1.0' }, settings.animSpeed);
+ slice.animate({opacity: 1 }, settings.animSpeed);
}, (100 + timeBuff));
}
timeBuff += 50;
@@ -452,18 +465,22 @@
createSlices(slider, settings, vars);
timeBuff = 0;
i = 0;
-
+
$('.nivo-slice', slider).each(function(){
- var slice = $(this);
- var origWidth = slice.width();
- slice.css({ top:'0px', width:'0px' });
- if(i === settings.slices-1){
+ var slice = $(this),
+ origWidth = slice.width();
+
+ slice.css({ top: 0, width: 0 });
+
+ if(i === settings.slices - 1){
setTimeout(function(){
- slice.animate({ width:origWidth, opacity:'1.0' }, settings.animSpeed, '', function(){ slider.trigger('nivo:animFinished'); });
+ slice.animate({ width:origWidth, opacity: 1 }, settings.animSpeed, '', function(){
+ slider.trigger('nivo:animFinished');
+ });
}, (100 + timeBuff));
} else {
setTimeout(function(){
- slice.animate({ width:origWidth, opacity:'1.0' }, settings.animSpeed);
+ slice.animate({ width:origWidth, opacity: 1 }, settings.animSpeed);
}, (100 + timeBuff));
}
timeBuff += 50;
@@ -471,45 +488,42 @@
});
} else if(currentEffect === 'fade'){
createSlices(slider, settings, vars);
-
- firstSlice = $('.nivo-slice:first', slider);
+
firstSlice.css({
- 'width': slider.width() + 'px'
+ width: slider.width()
+ }).animate({ opacity: 1 }, (settings.animSpeed*2), '', function(){
+ slider.trigger('nivo:animFinished');
});
-
- firstSlice.animate({ opacity:'1.0' }, (settings.animSpeed*2), '', function(){ slider.trigger('nivo:animFinished'); });
+
} else if(currentEffect === 'slideInRight'){
createSlices(slider, settings, vars);
-
- firstSlice = $('.nivo-slice:first', slider);
+
firstSlice.css({
- 'width': '0px',
- 'opacity': '1'
+ width: 0,
+ opacity: 1
+ }).animate({width: slider.width() }, (settings.animSpeed*2), '', function(){
+ slider.trigger('nivo:animFinished');
});
- firstSlice.animate({ width: slider.width() + 'px' }, (settings.animSpeed*2), '', function(){ slider.trigger('nivo:animFinished'); });
} else if(currentEffect === 'slideInLeft'){
createSlices(slider, settings, vars);
-
- firstSlice = $('.nivo-slice:first', slider);
- firstSlice.css({
- 'width': '0px',
- 'opacity': '1',
- 'left': '',
- 'right': '0px'
- });
- firstSlice.animate({ width: slider.width() + 'px' }, (settings.animSpeed*2), '', function(){
+ firstSlice.css({
+ width: 0,
+ opacity: 1,
+ left: '',
+ right: 0
+ }).animate({ width: slider.width() }, (settings.animSpeed*2), '', function(){
// Reset positioning
firstSlice.css({
- 'left': '0px',
- 'right': ''
+ left: 0,
+ right: ''
});
- slider.trigger('nivo:animFinished');
+ slider.trigger('nivo:animFinished');
});
} else if(currentEffect === 'boxRandom'){
createBoxes(slider, settings, vars);
-
+
totalBoxes = settings.boxCols * settings.boxRows;
i = 0;
timeBuff = 0;
@@ -519,11 +533,13 @@
var box = $(this);
if(i === totalBoxes-1){
setTimeout(function(){
- box.animate({ opacity:'1' }, settings.animSpeed, '', function(){ slider.trigger('nivo:animFinished'); });
+ box.animate({ opacity: 1 }, settings.animSpeed, '', function(){
+ slider.trigger('nivo:animFinished');
+ });
}, (100 + timeBuff));
} else {
setTimeout(function(){
- box.animate({ opacity:'1' }, settings.animSpeed);
+ box.animate({ opacity: 1 }, settings.animSpeed);
}, (100 + timeBuff));
}
timeBuff += 20;
@@ -531,15 +547,16 @@
});
} else if(currentEffect === 'boxRain' || currentEffect === 'boxRainReverse' || currentEffect === 'boxRainGrow' || currentEffect === 'boxRainGrowReverse'){
createBoxes(slider, settings, vars);
-
+
totalBoxes = settings.boxCols * settings.boxRows;
i = 0;
timeBuff = 0;
-
+
// Split boxes into 2D array
- var rowIndex = 0;
- var colIndex = 0;
- var box2Darr = [];
+ var rowIndex = 0,
+ colIndex = 0,
+ box2Darr = [];
+
box2Darr[rowIndex] = [];
boxes = $('.nivo-box', slider);
if(currentEffect === 'boxRainReverse' || currentEffect === 'boxRainGrowReverse'){
@@ -554,29 +571,29 @@
box2Darr[rowIndex] = [];
}
});
-
+
// Run animation
for(var cols = 0; cols < (settings.boxCols * 2); cols++){
var prevCol = cols;
for(var rows = 0; rows < settings.boxRows; rows++){
if(prevCol >= 0 && prevCol < settings.boxCols){
- /* Due to some weird JS bug with loop vars
+ /* Due to some weird JS bug with loop vars
being used in setTimeout, this is wrapped
with an anonymous function call */
(function(row, col, time, i, totalBoxes) {
- var box = $(box2Darr[row][col]);
- var w = box.width();
- var h = box.height();
+ var box = $(box2Darr[row][col]),
+ w = box.width(),
+ h = box.height();
if(currentEffect === 'boxRainGrow' || currentEffect === 'boxRainGrowReverse'){
box.width(0).height(0);
}
if(i === totalBoxes-1){
setTimeout(function(){
- box.animate({ opacity:'1', width:w, height:h }, settings.animSpeed/1.3, '', function(){ slider.trigger('nivo:animFinished'); });
+ box.animate({ opacity: 1, width:w, height:h }, settings.animSpeed/1.3, '', function(){ slider.trigger('nivo:animFinished'); });
}, (100 + time));
} else {
setTimeout(function(){
- box.animate({ opacity:'1', width:w, height:h }, settings.animSpeed/1.3);
+ box.animate({ opacity: 1, width:w, height:h }, settings.animSpeed/1.3);
}, (100 + time));
}
})(rows, prevCol, timeBuff, i, totalBoxes);
@@ -586,53 +603,55 @@
}
timeBuff += 100;
}
- }
+ }
};
-
+
// Shuffle an array
var shuffle = function(arr){
for(var j, x, i = arr.length; i; j = parseInt(Math.random() * i, 10), x = arr[--i], arr[i] = arr[j], arr[j] = x);
return arr;
};
-
+
// For debugging
var trace = function(msg){
if(this.console && typeof console.log !== 'undefined') { console.log(msg); }
};
-
+
// Start / Stop
+ var nivoVarStop = $(element).data('nivo:vars').stop;
this.stop = function(){
- if(!$(element).data('nivo:vars').stop){
- $(element).data('nivo:vars').stop = true;
+ if(!nivoVarStop){
+ nivoVarStop = true;
trace('Stop Slider');
}
};
-
this.start = function(){
- if($(element).data('nivo:vars').stop){
- $(element).data('nivo:vars').stop = false;
+ if(nivoVarStop){
+ nivoVarStop = false;
trace('Start Slider');
}
};
-
+
// Trigger the afterLoad callback
settings.afterLoad.call(this);
-
+
return this;
};
-
+
$.fn.nivoSlider = function(options) {
return this.each(function(key, value){
var element = $(this);
// Return early if this element already has a plugin instance
- if (element.data('nivoslider')) { return element.data('nivoslider'); }
+ if (element.data('nivoslider')) {
+ return element.data('nivoslider');
+ }
// Pass options to plugin constructor
var nivoslider = new NivoSlider(this, options);
// Store plugin object in this element's data
element.data('nivoslider', nivoslider);
});
};
-
+
//Default settings
$.fn.nivoSlider.defaults = {
effect: 'random',
@@ -658,5 +677,5 @@
};
$.fn._reverse = [].reverse;
-
-})(jQuery);
\ No newline at end of file
+
+})(jQuery);
diff --git a/jquery.nivo.slider.pack.js b/jquery.nivo.slider.pack.js
index f18e2f9..ffb6c57 100644
--- a/jquery.nivo.slider.pack.js
+++ b/jquery.nivo.slider.pack.js
@@ -7,4 +7,4 @@
* http://www.opensource.org/licenses/mit-license.php
*/
-(function(e){var t=function(t,n){var r=e.extend({},e.fn.nivoSlider.defaults,n);var i={currentSlide:0,currentImage:"",totalSlides:0,running:false,paused:false,stop:false,controlNavEl:false};var s=e(t);s.data("nivo:vars",i).addClass("nivoSlider");var o=s.children();o.each(function(){var t=e(this);var n="";if(!t.is("img")){if(t.is("a")){t.addClass("nivo-imageLink");n=t}t=t.find("img:first")}var r=r===0?t.attr("width"):t.width(),s=s===0?t.attr("height"):t.height();if(n!==""){n.css("display","none")}t.css("display","none");i.totalSlides++});if(r.randomStart){r.startSlide=Math.floor(Math.random()*i.totalSlides)}if(r.startSlide>0){if(r.startSlide>=i.totalSlides){r.startSlide=i.totalSlides-1}i.currentSlide=r.startSlide}if(e(o[i.currentSlide]).is("img")){i.currentImage=e(o[i.currentSlide])}else{i.currentImage=e(o[i.currentSlide]).find("img:first")}if(e(o[i.currentSlide]).is("a")){e(o[i.currentSlide]).css("display","block")}var u=e("
").addClass("nivo-main-image");u.attr("src",i.currentImage.attr("src")).show();s.append(u);e(window).resize(function(){s.children("img").width(s.width());u.attr("src",i.currentImage.attr("src"));u.stop().height("auto");e(".nivo-slice").remove();e(".nivo-box").remove()});s.append(e(''));var a=function(t){var n=e(".nivo-caption",s);if(i.currentImage.attr("title")!=""&&i.currentImage.attr("title")!=undefined){var r=i.currentImage.attr("title");if(r.substr(0,1)=="#")r=e(r).html();if(n.css("display")=="block"){setTimeout(function(){n.html(r)},t.animSpeed)}else{n.html(r);n.stop().fadeIn(t.animSpeed)}}else{n.stop().fadeOut(t.animSpeed)}};a(r);var f=0;if(!r.manualAdvance&&o.length>1){f=setInterval(function(){d(s,o,r,false)},r.pauseTime)}if(r.directionNav){s.append('");e(s).on("click","a.nivo-prevNav",function(){if(i.running){return false}clearInterval(f);f="";i.currentSlide-=2;d(s,o,r,"prev")});e(s).on("click","a.nivo-nextNav",function(){if(i.running){return false}clearInterval(f);f="";d(s,o,r,"next")})}if(r.controlNav){i.controlNavEl=e('');s.after(i.controlNavEl);for(var l=0;l
')}else{i.controlNavEl.append(''+(l+1)+"")}}e("a:eq("+i.currentSlide+")",i.controlNavEl).addClass("active");e("a",i.controlNavEl).bind("click",function(){if(i.running)return false;if(e(this).hasClass("active"))return false;clearInterval(f);f="";u.attr("src",i.currentImage.attr("src"));i.currentSlide=e(this).attr("rel")-1;d(s,o,r,"control")})}if(r.pauseOnHover){s.hover(function(){i.paused=true;clearInterval(f);f=""},function(){i.paused=false;if(f===""&&!r.manualAdvance){f=setInterval(function(){d(s,o,r,false)},r.pauseTime)}})}s.bind("nivo:animFinished",function(){u.attr("src",i.currentImage.attr("src"));i.running=false;e(o).each(function(){if(e(this).is("a")){e(this).css("display","none")}});if(e(o[i.currentSlide]).is("a")){e(o[i.currentSlide]).css("display","block")}if(f===""&&!i.paused&&!r.manualAdvance){f=setInterval(function(){d(s,o,r,false)},r.pauseTime)}r.afterChange.call(this)});var h=function(t,n,r){if(e(r.currentImage).parent().is("a"))e(r.currentImage).parent().css("display","block");e('img[src="'+r.currentImage.attr("src")+'"]',t).not(".nivo-main-image,.nivo-control img").width(t.width()).css("visibility","hidden").show();var i=e('img[src="'+r.currentImage.attr("src")+'"]',t).not(".nivo-main-image,.nivo-control img").parent().is("a")?e('img[src="'+r.currentImage.attr("src")+'"]',t).not(".nivo-main-image,.nivo-control img").parent().height():e('img[src="'+r.currentImage.attr("src")+'"]',t).not(".nivo-main-image,.nivo-control img").height();for(var s=0;s
').css({left:o*s+"px",width:t.width()-o*s+"px",height:i+"px",opacity:"0",overflow:"hidden"}))}else{t.append(e('
').css({left:o*s+"px",width:o+"px",height:i+"px",opacity:"0",overflow:"hidden"}))}}e(".nivo-slice",t).height(i);u.stop().animate({height:e(r.currentImage).height()},n.animSpeed)};var p=function(t,n,r){if(e(r.currentImage).parent().is("a"))e(r.currentImage).parent().css("display","block");e('img[src="'+r.currentImage.attr("src")+'"]',t).not(".nivo-main-image,.nivo-control img").width(t.width()).css("visibility","hidden").show();var i=Math.round(t.width()/n.boxCols),s=Math.round(e('img[src="'+r.currentImage.attr("src")+'"]',t).not(".nivo-main-image,.nivo-control img").height()/n.boxRows);for(var o=0;o
').css({opacity:0,left:i*a+"px",top:s*o+"px",width:t.width()-i*a+"px"}));e('.nivo-box[name="'+a+'"]',t).height(e('.nivo-box[name="'+a+'"] img',t).height()+"px")}else{t.append(e('
').css({opacity:0,left:i*a+"px",top:s*o+"px",width:i+"px"}));e('.nivo-box[name="'+a+'"]',t).height(e('.nivo-box[name="'+a+'"] img',t).height()+"px")}}}u.stop().animate({height:e(r.currentImage).height()},n.animSpeed)};var d=function(t,n,r,i){var s=t.data("nivo:vars");if(s&&s.currentSlide===s.totalSlides-1){r.lastSlide.call(this)}if((!s||s.stop)&&!i){return false}r.beforeChange.call(this);if(!i){u.attr("src",s.currentImage.attr("src"))}else{if(i==="prev"){u.attr("src",s.currentImage.attr("src"))}if(i==="next"){u.attr("src",s.currentImage.attr("src"))}}s.currentSlide++;if(s.currentSlide===s.totalSlides){s.currentSlide=0;r.slideshowEnd.call(this)}if(s.currentSlide<0){s.currentSlide=s.totalSlides-1}if(e(n[s.currentSlide]).is("img")){s.currentImage=e(n[s.currentSlide])}else{s.currentImage=e(n[s.currentSlide]).find("img:first")}if(r.controlNav){e("a",s.controlNavEl).removeClass("active");e("a:eq("+s.currentSlide+")",s.controlNavEl).addClass("active")}a(r);e(".nivo-slice",t).remove();e(".nivo-box",t).remove();var o=r.effect,f="";if(r.effect==="random"){f=new Array("sliceDownRight","sliceDownLeft","sliceUpRight","sliceUpLeft","sliceUpDown","sliceUpDownLeft","fold","fade","boxRandom","boxRain","boxRainReverse","boxRainGrow","boxRainGrowReverse");o=f[Math.floor(Math.random()*(f.length+1))];if(o===undefined){o="fade"}}if(r.effect.indexOf(",")!==-1){f=r.effect.split(",");o=f[Math.floor(Math.random()*f.length)];if(o===undefined){o="fade"}}if(s.currentImage.attr("data-transition")){o=s.currentImage.attr("data-transition")}s.running=true;var l=0,c=0,d="",m="",g="",y="";if(o==="sliceDown"||o==="sliceDownRight"||o==="sliceDownLeft"){h(t,r,s);l=0;c=0;d=e(".nivo-slice",t);if(o==="sliceDownLeft"){d=e(".nivo-slice",t)._reverse()}d.each(function(){var n=e(this);n.css({top:"0px"});if(c===r.slices-1){setTimeout(function(){n.animate({opacity:"1.0"},r.animSpeed,"",function(){t.trigger("nivo:animFinished")})},100+l)}else{setTimeout(function(){n.animate({opacity:"1.0"},r.animSpeed)},100+l)}l+=50;c++})}else if(o==="sliceUp"||o==="sliceUpRight"||o==="sliceUpLeft"){h(t,r,s);l=0;c=0;d=e(".nivo-slice",t);if(o==="sliceUpLeft"){d=e(".nivo-slice",t)._reverse()}d.each(function(){var n=e(this);n.css({bottom:"0px"});if(c===r.slices-1){setTimeout(function(){n.animate({opacity:"1.0"},r.animSpeed,"",function(){t.trigger("nivo:animFinished")})},100+l)}else{setTimeout(function(){n.animate({opacity:"1.0"},r.animSpeed)},100+l)}l+=50;c++})}else if(o==="sliceUpDown"||o==="sliceUpDownRight"||o==="sliceUpDownLeft"){h(t,r,s);l=0;c=0;var b=0;d=e(".nivo-slice",t);if(o==="sliceUpDownLeft"){d=e(".nivo-slice",t)._reverse()}d.each(function(){var n=e(this);if(c===0){n.css("top","0px");c++}else{n.css("bottom","0px");c=0}if(b===r.slices-1){setTimeout(function(){n.animate({opacity:"1.0"},r.animSpeed,"",function(){t.trigger("nivo:animFinished")})},100+l)}else{setTimeout(function(){n.animate({opacity:"1.0"},r.animSpeed)},100+l)}l+=50;b++})}else if(o==="fold"){h(t,r,s);l=0;c=0;e(".nivo-slice",t).each(function(){var n=e(this);var i=n.width();n.css({top:"0px",width:"0px"});if(c===r.slices-1){setTimeout(function(){n.animate({width:i,opacity:"1.0"},r.animSpeed,"",function(){t.trigger("nivo:animFinished")})},100+l)}else{setTimeout(function(){n.animate({width:i,opacity:"1.0"},r.animSpeed)},100+l)}l+=50;c++})}else if(o==="fade"){h(t,r,s);m=e(".nivo-slice:first",t);m.css({width:t.width()+"px"});m.animate({opacity:"1.0"},r.animSpeed*2,"",function(){t.trigger("nivo:animFinished")})}else if(o==="slideInRight"){h(t,r,s);m=e(".nivo-slice:first",t);m.css({width:"0px",opacity:"1"});m.animate({width:t.width()+"px"},r.animSpeed*2,"",function(){t.trigger("nivo:animFinished")})}else if(o==="slideInLeft"){h(t,r,s);m=e(".nivo-slice:first",t);m.css({width:"0px",opacity:"1",left:"",right:"0px"});m.animate({width:t.width()+"px"},r.animSpeed*2,"",function(){m.css({left:"0px",right:""});t.trigger("nivo:animFinished")})}else if(o==="boxRandom"){p(t,r,s);g=r.boxCols*r.boxRows;c=0;l=0;y=v(e(".nivo-box",t));y.each(function(){var n=e(this);if(c===g-1){setTimeout(function(){n.animate({opacity:"1"},r.animSpeed,"",function(){t.trigger("nivo:animFinished")})},100+l)}else{setTimeout(function(){n.animate({opacity:"1"},r.animSpeed)},100+l)}l+=20;c++})}else if(o==="boxRain"||o==="boxRainReverse"||o==="boxRainGrow"||o==="boxRainGrowReverse"){p(t,r,s);g=r.boxCols*r.boxRows;c=0;l=0;var w=0;var E=0;var S=[];S[w]=[];y=e(".nivo-box",t);if(o==="boxRainReverse"||o==="boxRainGrowReverse"){y=e(".nivo-box",t)._reverse()}y.each(function(){S[w][E]=e(this);E++;if(E===r.boxCols){w++;E=0;S[w]=[]}});for(var x=0;x=0&&T0){if(r.startSlide>=i.totalSlides){r.startSlide=i.totalSlides-1}i.currentSlide=r.startSlide}i.currentImage=e(o[i.currentSlide]);if(!i.currentImage.is("img")){i.currentImage=i.currentImage.find("img:first")}i.currentImage.is("a")&&i.currentImage.show();var u=e("
").addClass("nivo-main-image");u.attr("src",i.currentImage.attr("src")).show().appendTo(s);e(window).resize(function(){s.children("img").width(s.width());u.attr("src",i.currentImage.attr("src")).stop().height("auto");e(".nivo-slice, .nivo-box").remove()});var a=e("",{"class":"nivo-caption"});s.append(a);var f=function(t){var n=e(".nivo-caption",s);if(i.currentImage.attr("title")!=""&&i.currentImage.attr("title")!=undefined){var r=i.currentImage.attr("title");if(r.substr(0,1)=="#")r=e(r).html();if(n.is(":visible")){setTimeout(function(){n.html(r)},t.animSpeed)}else{n.html(r).stop().fadeIn(t.animSpeed)}}else{n.stop().fadeOut(t.animSpeed)}};f(r);var l=0;if(!r.manualAdvance&&o.length>1){l=setInterval(function(){v(s,o,r,false)},r.pauseTime)}if(r.directionNav){s.append('").on("click","a.nivo-prevNav",function(){if(i.running){return false}clearInterval(l);l="";i.currentSlide-=2;v(s,o,r,"prev")}).on("click","a.nivo-nextNav",function(){if(i.running){return false}clearInterval(l);l="";v(s,o,r,"next")})}if(r.controlNav){i.controlNavEl=e('');s.after(i.controlNavEl);for(var c=0;c
')}}else{i.controlNavEl.append(''+(c+1)+"")}}e("a:eq("+i.currentSlide+")",i.controlNavEl).addClass("active");e("a",i.controlNavEl).bind("click",function(){if(i.running||e(this).hasClass("active"))return false;clearInterval(l);l="";u.attr("src",i.currentImage.attr("src"));i.currentSlide=e(this).attr("rel")-1;v(s,o,r,"control")})}if(r.pauseOnHover){s.hover(function(){i.paused=true;clearInterval(l);l=""},function(){i.paused=false;if(l===""&&!r.manualAdvance){l=setInterval(function(){v(s,o,r,false)},r.pauseTime)}})}s.bind("nivo:animFinished",function(){u.attr("src",i.currentImage.attr("src"));i.running=false;e(o).each(function(){if(e(this).is("a")){e(this).hide()}});if(e(o[i.currentSlide]).is("a")){e(o[i.currentSlide]).show()}if(l===""&&!i.paused&&!r.manualAdvance){l=setInterval(function(){v(slider,o,r,false)},r.pauseTime)}r.afterChange.call(this)});var p=function(t,n,r){var i=e(r.currentImage).parent();if(i.is("a")){i.show()}e('img[src="'+r.currentImage.attr("src")+'"]',t).not(".nivo-main-image,.nivo-control img").width(t.width()).css("visibility","hidden").show();var s=e('img[src="'+r.currentImage.attr("src")+'"]',t).not(".nivo-main-image,.nivo-control img").parent().is("a")?e('img[src="'+r.currentImage.attr("src")+'"]',t).not(".nivo-main-image,.nivo-control img").parent().height():e('img[src="'+r.currentImage.attr("src")+'"]',t).not(".nivo-main-image,.nivo-control img").height();for(var o=0;o
').css({left:a*o+"px",width:t.width()-a*o+"px",height:s+"px",opacity:"0",overflow:"hidden"}))}else{t.append(e('
').css({left:a*o+"px",width:a+"px",height:s+"px",opacity:"0",overflow:"hidden"}))}}e(".nivo-slice",t).height(s);u.stop().animate({height:e(r.currentImage).height()},n.animSpeed)};var d=function(t,n,r){if(e(r.currentImage).parent().is("a"))e(r.currentImage).parent().show();e('img[src="'+r.currentImage.attr("src")+'"]',t).not(".nivo-main-image,.nivo-control img").width(t.width()).css("visibility","hidden").show();var i=Math.round(t.width()/n.boxCols),s=Math.round(e('img[src="'+r.currentImage.attr("src")+'"]',t).not(".nivo-main-image,.nivo-control img").height()/n.boxRows);for(var o=0;o
').css({opacity:0,left:i*a+"px",top:s*o+"px",width:t.width()-i*a+"px"}));e('.nivo-box[name="'+a+'"]',t).height(e('.nivo-box[name="'+a+'"] img',t).height()+"px")}else{t.append(e('').css({opacity:0,left:i*a+"px",top:s*o+"px",width:i+"px"}));e('.nivo-box[name="'+a+'"]',t).height(e('.nivo-box[name="'+a+'"] img',t).height()+"px")}}}u.stop().animate({height:e(r.currentImage).height()},n.animSpeed)};var v=function(t,n,r,i){var s=t.data("nivo:vars");if(s&&s.currentSlide===s.totalSlides-1){r.lastSlide.call(this)}if((!s||s.stop)&&!i){return false}r.beforeChange.call(this);if(!i){u.attr("src",s.currentImage.attr("src"))}else{if(i==="prev"){u.attr("src",s.currentImage.attr("src"))}if(i==="next"){u.attr("src",s.currentImage.attr("src"))}}s.currentSlide++;if(s.currentSlide===s.totalSlides){s.currentSlide=0;r.slideshowEnd.call(this)}if(s.currentSlide<0){s.currentSlide=s.totalSlides-1}if(e(n[s.currentSlide]).is("img")){s.currentImage=e(n[s.currentSlide])}else{s.currentImage=e(n[s.currentSlide]).find("img:first")}if(r.controlNav){e("a",s.controlNavEl).removeClass("active");e("a:eq("+s.currentSlide+")",s.controlNavEl).addClass("active")}f(r);e(".nivo-slice",t).remove();e(".nivo-box",t).remove();var o=r.effect,a="";if(r.effect==="random"){a=new Array("sliceDownRight","sliceDownLeft","sliceUpRight","sliceUpLeft","sliceUpDown","sliceUpDownLeft","fold","fade","boxRandom","boxRain","boxRainReverse","boxRainGrow","boxRainGrowReverse");o=a[Math.floor(Math.random()*(a.length+1))];if(o===undefined){o="fade"}}if(r.effect.indexOf(",")!==-1){a=r.effect.split(",");o=a[Math.floor(Math.random()*a.length)];if(o===undefined){o="fade"}}if(s.currentImage.attr("data-transition")){o=s.currentImage.attr("data-transition")}s.running=true;var l=0,c=0,h="",v="",g="";var y=e(".nivo-slice:first",t);if(o==="sliceDown"||o==="sliceDownRight"||o==="sliceDownLeft"){p(t,r,s);l=0;c=0;h=e(".nivo-slice",t);if(o==="sliceDownLeft"){h=e(".nivo-slice",t)._reverse()}h.each(function(){var n=e(this);n.css({top:0});if(c===r.slices-1){setTimeout(function(){n.animate({opacity:1},r.animSpeed,"",function(){t.trigger("nivo:animFinished")})},100+l)}else{setTimeout(function(){n.animate({opacity:1},r.animSpeed)},100+l)}l+=50;c++})}else if(o==="sliceUp"||o==="sliceUpRight"||o==="sliceUpLeft"){p(t,r,s);l=0;c=0;h=e(".nivo-slice",t);if(o==="sliceUpLeft"){h=e(".nivo-slice",t)._reverse()}h.each(function(){var n=e(this);n.css({bottom:0});if(c===r.slices-1){setTimeout(function(){n.animate({opacity:1},r.animSpeed,"",function(){t.trigger("nivo:animFinished")})},100+l)}else{setTimeout(function(){n.animate({opacity:1},r.animSpeed)},100+l)}l+=50;c++})}else if(o==="sliceUpDown"||o==="sliceUpDownRight"||o==="sliceUpDownLeft"){p(t,r,s);l=0;c=0;var b=0;h=e(".nivo-slice",t);if(o==="sliceUpDownLeft"){h=e(".nivo-slice",t)._reverse()}h.each(function(){var n=e(this);if(c===0){n.css(top,0);c++}else{n.css(bottom,0);c=0}if(b===r.slices-1){setTimeout(function(){n.animate({opacity:1},r.animSpeed,"",function(){t.trigger("nivo:animFinished")})},100+l)}else{setTimeout(function(){n.animate({opacity:1},r.animSpeed)},100+l)}l+=50;b++})}else if(o==="fold"){p(t,r,s);l=0;c=0;e(".nivo-slice",t).each(function(){var n=e(this),i=n.width();n.css({top:0,width:0});if(c===r.slices-1){setTimeout(function(){n.animate({width:i,opacity:1},r.animSpeed,"",function(){t.trigger("nivo:animFinished")})},100+l)}else{setTimeout(function(){n.animate({width:i,opacity:1},r.animSpeed)},100+l)}l+=50;c++})}else if(o==="fade"){p(t,r,s);y.css({width:t.width()}).animate({opacity:1},r.animSpeed*2,"",function(){t.trigger("nivo:animFinished")})}else if(o==="slideInRight"){p(t,r,s);y.css({width:0,opacity:1}).animate({width:t.width()},r.animSpeed*2,"",function(){t.trigger("nivo:animFinished")})}else if(o==="slideInLeft"){p(t,r,s);y.css({width:0,opacity:1,left:"",right:0}).animate({width:t.width()},r.animSpeed*2,"",function(){y.css({left:0,right:""});t.trigger("nivo:animFinished")})}else if(o==="boxRandom"){d(t,r,s);v=r.boxCols*r.boxRows;c=0;l=0;g=m(e(".nivo-box",t));g.each(function(){var n=e(this);if(c===v-1){setTimeout(function(){n.animate({opacity:1},r.animSpeed,"",function(){t.trigger("nivo:animFinished")})},100+l)}else{setTimeout(function(){n.animate({opacity:1},r.animSpeed)},100+l)}l+=20;c++})}else if(o==="boxRain"||o==="boxRainReverse"||o==="boxRainGrow"||o==="boxRainGrowReverse"){d(t,r,s);v=r.boxCols*r.boxRows;c=0;l=0;var w=0,E=0,S=[];S[w]=[];g=e(".nivo-box",t);if(o==="boxRainReverse"||o==="boxRainGrowReverse"){g=e(".nivo-box",t)._reverse()}g.each(function(){S[w][E]=e(this);E++;if(E===r.boxCols){w++;E=0;S[w]=[]}});for(var x=0;x=0&&T