From 541c1c3aa299129c966114943b09de3349859d02 Mon Sep 17 00:00:00 2001 From: Jason Busby Date: Mon, 16 Jan 2012 03:53:06 +0000 Subject: [PATCH 01/19] Removed repeat code Removed unneeded jQuery selector --- jquery.nivo.slider.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/jquery.nivo.slider.js b/jquery.nivo.slider.js index d42f05c..e708f2a 100644 --- a/jquery.nivo.slider.js +++ b/jquery.nivo.slider.js @@ -391,7 +391,7 @@ var timeBuff = 0; var i = 0; var slices = $('.nivo-slice', slider); - if(currentEffect == 'sliceDownLeft') slices = $('.nivo-slice', slider)._reverse(); + if(currentEffect == 'sliceDownLeft') slices = slices._reverse(); slices.each(function(){ var slice = $(this); @@ -414,7 +414,7 @@ var timeBuff = 0; var i = 0; var slices = $('.nivo-slice', slider); - if(currentEffect == 'sliceUpLeft') slices = $('.nivo-slice', slider)._reverse(); + if(currentEffect == 'sliceUpLeft') slices = slices._reverse(); slices.each(function(){ var slice = $(this); @@ -438,7 +438,7 @@ var i = 0; var v = 0; var slices = $('.nivo-slice', slider); - if(currentEffect == 'sliceUpDownLeft') slices = $('.nivo-slice', slider)._reverse(); + if(currentEffect == 'sliceUpDownLeft') slices = slices._reverse(); slices.each(function(){ var slice = $(this); @@ -566,10 +566,10 @@ box2Darr[rowIndex] = new Array(); var boxes = $('.nivo-box', slider); if(currentEffect == 'boxRainReverse' || currentEffect == 'boxRainGrowReverse'){ - boxes = $('.nivo-box', slider)._reverse(); + boxes = boxes._reverse(); } boxes.each(function(){ - box2Darr[rowIndex][colIndex] = $(this); + box2Darr[rowIndex][colIndex] = this; colIndex++; if(colIndex == settings.boxCols){ rowIndex++; From 6ce2d839806e9592e4c34da9bff8ea43d6912730 Mon Sep 17 00:00:00 2001 From: Jason Busby Date: Fri, 20 Jan 2012 02:18:18 +0000 Subject: [PATCH 02/19] Replaced most instance of jQuery's each method in place of default JS loops Replaced selector filters with chained filters Reworked slices/boxes creation functions to cache HTML and append as a whole Added many cache variables --- jquery.nivo.slider.js | 1243 ++++++++++++++++++++++------------------- 1 file changed, 671 insertions(+), 572 deletions(-) diff --git a/jquery.nivo.slider.js b/jquery.nivo.slider.js index e708f2a..8a1c014 100644 --- a/jquery.nivo.slider.js +++ b/jquery.nivo.slider.js @@ -6,323 +6,402 @@ * Free to use and abuse under the MIT license. * http://www.opensource.org/licenses/mit-license.php * - * March 2010 + * January 2012 */ -(function($) { +(function($){ - var NivoSlider = function(element, options){ + var NivoSlider = function(element, options) + { //Defaults are below var settings = $.extend({}, $.fn.nivoSlider.defaults, options); - //Useful variables. Play carefully. - var vars = { - currentSlide: 0, - currentImage: '', - totalSlides: 0, - running: false, - paused: false, - stop: false - }; - - //Get this slider - var slider = $(element); - slider.data('nivo:vars', vars); - slider.css('position','relative'); - slider.addClass('nivoSlider'); - - //Find our slider children - var kids = slider.children(); - kids.each(function() { - var child = $(this); - var link = ''; - if(!child.is('img')){ - if(child.is('a')){ - child.addClass('nivo-imageLink'); - link = child; - } - child = child.find('img:first'); - } - //Get img width & height - var childWidth = child.width(); - if(childWidth == 0) childWidth = child.attr('width'); - var childHeight = child.height(); - if(childHeight == 0) childHeight = child.attr('height'); - //Resize the slider - if(childWidth > slider.width()){ - slider.width(childWidth); - } - if(childHeight > slider.height()){ - slider.height(childHeight); - } - if(link != ''){ - link.css('display','none'); - } - child.css('display','none'); - 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; - 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'); - } - - //Show initial link - if($(kids[vars.currentSlide]).is('a')){ - $(kids[vars.currentSlide]).css('display','block'); - } - - //Set first background - slider.css('background','url("'+ vars.currentImage.attr('src') +'") no-repeat'); - - //Create caption - slider.append( - $('

').css({ display:'none', opacity:settings.captionOpacity }) - ); - - // Cross browser default caption opacity - $('.nivo-caption', slider).css('opacity', 0); - + //Useful variables. Play carefully. + var vars = { + currentSlide: 0, + currentImage: '', + totalSlides: 0, + running: false, + paused: false, + stop: false + }; + + //Get this slider + var slider = $(element); + slider.data('nivo:vars', vars); + slider.css('position','relative'); + slider.addClass('nivoSlider'); + + //Find our slider children + var kids = slider.children(), + kidsCount = kids.length, + kidsIndex = 0, + child, + childWidth = 0, + childHeight = 0, + link = ''; + + do{ + child = $(kids[kidsIndex]); + + if(!child.is('img')){ + if(child.is('a')){ + child.addClass('nivo-imageLink'); + link = child; + } + child = child.find('img').eq(0); + } + + //Get img width & height + childWidth = child.width(), + childHeight = child.height(); + + if(childWidth === 0) childWidth = child.attr('width'); + if(childHeight === 0) childHeight = child.attr('height'); + + //Resize the slider + if(childWidth > slider.width()){ + slider.width(childWidth); + } + if(childHeight > slider.height()){ + slider.height(childHeight); + } + + if(link != ''){ + link.css('display','none'); + } + child.css('display','none'); + + ++vars.totalSlides; + } + while(++kidsIndex < kidsCount); + + //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; + } + vars.currentSlide = settings.startSlide; + } + + var el = $(kids[vars.currentSlide]); + + //Get initial image + if(el.is('img')){ + vars.currentImage = el; + } else { + vars.currentImage = el.find('img').eq(0); + } + + //Show initial link + if(el.is('a')){ + el.css('display','block'); + } + + //Set first background + slider.css('background', 'url("'+ vars.currentImage.attr('src') +'") no-repeat'); + + //Create caption + slider.append( + $('

').css({ display: 'none', opacity: settings.captionOpacity }) + ); + + // Cross browser default caption opacity + $('.nivo-caption', slider).css('opacity', 0); + // Process caption function var processCaption = function(settings){ - 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(); + var nivoCaption = $('.nivo-caption', slider), + title = (vars.currentImage.attr('title')) ? vars.currentImage.attr('title') : ''; + + if(title){ + if(title.substr(0,1) == '#') title = $(title).html(); if(nivoCaption.css('opacity') != 0){ nivoCaption.find('p').stop().fadeTo(settings.animSpeed, 0, function(){ - $(this).html(title); - $(this).stop().fadeTo(settings.animSpeed, 1); + $(this).html(title).stop().fadeTo(settings.animSpeed, 1); }); } else { nivoCaption.find('p').html(title); - } + } nivoCaption.stop().fadeTo(settings.animSpeed, settings.captionOpacity); } else { nivoCaption.stop().fadeTo(settings.animSpeed, 0); } } - - //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); - } - - //Add Direction nav - if(settings.directionNav){ - slider.append(''); - - //Hide Direction nav - if(settings.directionNavHide){ - $('.nivo-directionNav', slider).hide(); - slider.hover(function(){ - $('.nivo-directionNav', slider).show(); - }, function(){ - $('.nivo-directionNav', slider).hide(); - }); - } - - $('a.nivo-prevNav', slider).live('click', function(){ - if(vars.running) return false; - clearInterval(timer); - timer = ''; - vars.currentSlide -= 2; - nivoRun(slider, kids, settings, 'prev'); - }); - - $('a.nivo-nextNav', slider).live('click', function(){ - if(vars.running) return false; - clearInterval(timer); - timer = ''; - nivoRun(slider, kids, settings, 'next'); - }); - } - - //Add Control nav - if(settings.controlNav){ - var nivoControl = $('
'); - slider.append(nivoControl); - for(var i = 0; i < kids.length; i++){ - if(settings.controlNavThumbs){ - var child = kids.eq(i); - if(!child.is('img')){ - child = child.find('img:first'); - } - if (settings.controlNavThumbsFromRel) { - nivoControl.append(''); - } else { - nivoControl.append(''); - } - } else { - nivoControl.append(''+ (i + 1) +''); - } - - } - //Set initial active link - $('.nivo-controlNav a:eq('+ vars.currentSlide +')', slider).addClass('active'); - - $('.nivo-controlNav a', slider).live('click', function(){ - if(vars.running) return false; - if($(this).hasClass('active')) return false; - clearInterval(timer); - timer = ''; - slider.css('background','url("'+ vars.currentImage.attr('src') +'") no-repeat'); - vars.currentSlide = $(this).attr('rel') - 1; - nivoRun(slider, kids, settings, 'control'); - }); - } - - //Keyboard Navigation - if(settings.keyboardNav){ - $(window).keypress(function(event){ - //Left - if(event.keyCode == '37'){ - if(vars.running) return false; - clearInterval(timer); - timer = ''; - vars.currentSlide-=2; - nivoRun(slider, kids, settings, 'prev'); - } - //Right - if(event.keyCode == '39'){ - if(vars.running) return false; - clearInterval(timer); - timer = ''; - nivoRun(slider, kids, settings, 'next'); - } - }); - } - - //For pauseOnHover setting - if(settings.pauseOnHover){ - slider.hover(function(){ - vars.paused = true; - clearInterval(timer); - timer = ''; - }, function(){ - vars.paused = false; - //Restart the timer - if(timer == '' && !settings.manualAdvance){ - timer = setInterval(function(){ nivoRun(slider, kids, settings, false); }, settings.pauseTime); - } - }); - } - - //Event when Animation finishes - slider.bind('nivo:animFinished', function(){ - vars.running = false; - //Hide child links - $(kids).each(function(){ - if($(this).is('a')){ - $(this).css('display','none'); - } - }); - //Show current link - if($(kids[vars.currentSlide]).is('a')){ - $(kids[vars.currentSlide]).css('display','block'); - } - //Restart the timer - if(timer == '' && !vars.paused && !settings.manualAdvance){ - timer = setInterval(function(){ nivoRun(slider, kids, settings, false); }, settings.pauseTime); - } - //Trigger the afterChange callback - settings.afterChange.call(this); - }); - - // Add slices for slice animations - var createSlices = function(slider, settings, vars){ - 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', width:(slider.width()-(sliceWidth*i))+'px', - height:'0px', - opacity:'0', - background: 'url("'+ vars.currentImage.attr('src') +'") no-repeat -'+ ((sliceWidth + (i * sliceWidth)) - sliceWidth) +'px 0%' - }) - ); + + //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); + } + + //Add Direction nav + if(settings.directionNav){ + slider.append(''); + + //Hide Direction nav + if(settings.directionNavHide){ + $('.nivo-directionNav', slider).hide(); + + slider.hover(function(){ + $('.nivo-directionNav', slider).show(); + }, function(){ + $('.nivo-directionNav', slider).hide(); + }); + } + + $('a.nivo-prevNav', slider).live('click', function(){ + if(vars.running){ + return false; + } + + clearInterval(timer); + timer = ''; + vars.currentSlide -= 2; + nivoRun(slider, kids, settings, 'prev'); + }); + + $('a.nivo-nextNav', slider).live('click', function(){ + if(vars.running){ + return false; + } + + clearInterval(timer); + timer = ''; + nivoRun(slider, kids, settings, 'next'); + }); + } + + //Add Control nav + if(settings.controlNav){ + var nivoControl = $('
'), + slide, + controlHTML = '', + i = 0; + + slider.append(nivoControl); + + do{ + if(settings.controlNavThumbs){ + slide = kids.eq(i); + + if(!slide.is('img')){ + slide = slide.find('img').eq(0); + } + + if (settings.controlNavThumbsFromRel) { + controlHTML = ''; + } else { + controlHTML = ''; + } } else { - slider.append( - $('
').css({ - left:(sliceWidth*i)+'px', width:sliceWidth+'px', - height:'0px', - opacity:'0', - background: 'url("'+ vars.currentImage.attr('src') +'") no-repeat -'+ ((sliceWidth + (i * sliceWidth)) - sliceWidth) +'px 0%' - }) - ); + controlHTML = i + 1; + } + + nivoControl.append(''+ controlHTML +''); + } + while(++i < kids.length); + + //Set initial active link + $('.nivo-controlNav a', slider).eq(vars.currentSlide).addClass('active'); + + $('.nivo-controlNav a', slider).live('click', function(){ + var anchor = $(this); + + if(vars.running || anchor.hasClass('active')){ + return false; + } + + clearInterval(timer); + timer = ''; + slider.css('background','url("'+ vars.currentImage.attr('src') +'") no-repeat'); + vars.currentSlide = anchor.attr('rel') - 1; + nivoRun(slider, kids, settings, 'control'); + }); + } + + //Keyboard Navigation + if(settings.keyboardNav){ + $(window).keypress(function(event){ + //Left + if(event.keyCode == '37'){ + if(vars.running) return false; + clearInterval(timer); + timer = ''; + vars.currentSlide-=2; + nivoRun(slider, kids, settings, 'prev'); + } + //Right + if(event.keyCode == '39'){ + if(vars.running) return false; + clearInterval(timer); + timer = ''; + nivoRun(slider, kids, settings, 'next'); + } + }); + } + + //For pauseOnHover setting + if(settings.pauseOnHover){ + slider.hover(function(){ + vars.paused = true; + clearInterval(timer); + timer = null; + }, function(){ + vars.paused = false; + //Restart the timer + if(timer === null && !settings.manualAdvance){ + timer = setInterval(function(){ nivoRun(slider, kids, settings, false); }, settings.pauseTime); } + }); + } + + //Event when Animation finishes + slider.bind('nivo:animFinished', function(){ + vars.running = false; + + var link, + i = kids.length, + el = $(kids[vars.currentSlide]); + + //Hide child links + while(--i + 1){ + link = $(kids[i]); + + if(link.is('a')){ + link.css('display','none'); + } + } + + //Show current link + if(el.is('a')){ + el.css('display','block'); + } + + //Restart the timer + if(timer == '' && !vars.paused && !settings.manualAdvance){ + timer = setInterval(function(){ nivoRun(slider, kids, settings, false); }, settings.pauseTime); } - } - + + //Trigger the afterChange callback + settings.afterChange.call(this); + }); + + // Add slices for slice animations + var createSlices = function(){ + var sliderImg = vars.currentImage.attr('src'), + sliderWidth = slider.width(), + slices = 0, + slicesHTML = document.createDocumentFragment(), + sliceWidth, + offset; + + var css = { + background: '', + left: '', + width: '', + height: '0px', + opacity: 0 + }; + + do{ + sliceWidth = Math.round(sliderWidth / settings.slices); + offset = sliceWidth * slices; + + css.left = offset +'px'; + css.background = 'url("'+ sliderImg +'") no-repeat -'+ ((sliceWidth + offset) - sliceWidth) +'px 0%'; + css.width = sliceWidth +'px'; + + // fix up uneven spacing + if(slices == settings.slices - 1){ + css.width = (sliderWidth - offset) +'px'; + } + + // add slice to fragment - use jQuery to add css + slicesHTML.appendChild($('
').css(css)[0]); + } + while(++slices < settings.slices); + + // insert slices as a whole + slider.append(slicesHTML); + }; + // Add boxes for box animations - var createBoxes = function(slider, settings, vars){ - var boxWidth = Math.round(slider.width()/settings.boxCols); - var boxHeight = Math.round(slider.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({ - opacity:0, - left:(boxWidth*cols)+'px', - top:(boxHeight*rows)+'px', - width:(slider.width()-(boxWidth*cols))+'px', - height:boxHeight+'px', - background: 'url("'+ vars.currentImage.attr('src') +'") no-repeat -'+ ((boxWidth + (cols * boxWidth)) - boxWidth) +'px -'+ ((boxHeight + (rows * boxHeight)) - boxHeight) +'px' - }) - ); - } else { - slider.append( - $('
').css({ - opacity:0, - left:(boxWidth*cols)+'px', - top:(boxHeight*rows)+'px', - width:boxWidth+'px', - height:boxHeight+'px', - background: 'url("'+ vars.currentImage.attr('src') +'") no-repeat -'+ ((boxWidth + (cols * boxWidth)) - boxWidth) +'px -'+ ((boxHeight + (rows * boxHeight)) - boxHeight) +'px' - }) - ); + var createBoxes = function(){ + var sliderWidth = slider.width(), + boxWidth = Math.round(sliderWidth / settings.boxCols), + boxHeight = Math.round(slider.height() / settings.boxRows), + boxesHTML = document.createDocumentFragment(), + offsetLeft = 0, + rows = 0, + cols = 0; + + var css = { + background: 'url("'+ vars.currentImage.attr('src') +'") no-repeat', + backgroundPosition: '', + left: '', + top: '', + width: '', + height: boxHeight +'px', + opacity: 0 + }; + + do{ + // row specific styles + css.top = (boxHeight * rows) +'px'; + css.width = boxWidth +'px'; + + do{ + offsetLeft = boxWidth * cols; + + // column specific styles + css.left = (boxWidth * cols) +'px'; + css.backgroundPosition = '-'+ ((boxWidth + offsetLeft) - boxWidth) +'px -'+ ((boxHeight + (rows * boxHeight)) - boxHeight) +'px'; + + // fix up uneven spacing + if(cols === settings.boxCols - 1){ + css.width = (sliderWidth - offsetLeft) +'px'; } + + // add box to fragment - use jQuery to add css + boxesHTML.appendChild($('
').css(css)[0]); } + while(++cols < settings.boxCols); + + // reset columns + cols = 0; } - } + while(++rows < settings.boxRows); - // Private run method + // insert boxes as a whole + slider.append(boxesHTML); + }; + + // Private run method 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)){ + + //Trigger the lastSlide callback + if(vars && (vars.currentSlide == vars.totalSlides - 1)){ settings.lastSlide.call(this); } - - // Stop + + // Stop if((!vars || vars.stop) && !nudge) return false; - + //Trigger the beforeChange callback settings.beforeChange.call(this); - + //Set current background before change if(!nudge){ slider.css('background','url("'+ vars.currentImage.attr('src') +'") no-repeat'); @@ -335,330 +414,350 @@ } } vars.currentSlide++; - //Trigger the slideshowEnd callback - if(vars.currentSlide == vars.totalSlides){ + //Trigger the slideshowEnd callback + if(vars.currentSlide == vars.totalSlides){ vars.currentSlide = 0; settings.slideshowEnd.call(this); } if(vars.currentSlide < 0) vars.currentSlide = (vars.totalSlides - 1); + + var currentElement = $(kids[vars.currentSlide]); //Set vars.currentImage - if($(kids[vars.currentSlide]).is('img')){ - vars.currentImage = $(kids[vars.currentSlide]); - } else { - vars.currentImage = $(kids[vars.currentSlide]).find('img:first'); - } - + vars.currentImage = (currentElement.is('img')) ? currentElement : currentElement.find('img').eq(0); + //Set active links if(settings.controlNav){ - $('.nivo-controlNav a', slider).removeClass('active'); - $('.nivo-controlNav a:eq('+ vars.currentSlide +')', slider).addClass('active'); + $('.nivo-controlNav a', slider).removeClass('active').eq(vars.currentSlide).addClass('active'); } - + //Process caption 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; + //Generate random effect - if(settings.effect == 'random'){ - var anims = new Array('sliceDownRight','sliceDownLeft','sliceUpRight','sliceUpLeft','sliceUpDown','sliceUpDownLeft','fold','fade', - 'boxRandom','boxRain','boxRainReverse','boxRainGrow','boxRainGrowReverse'); - currentEffect = anims[Math.floor(Math.random()*(anims.length + 1))]; - if(currentEffect == undefined) currentEffect = 'fade'; + if(settings.effect === 'random'){ + var anims = ['sliceDownRight','sliceDownLeft','sliceUpRight','sliceUpLeft','sliceUpDown','sliceUpDownLeft','fold','fade', + 'boxRandom','boxRain','boxRainReverse','boxRainGrow','boxRainGrowReverse']; + + 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){ + var anims = settings.effect.split(','); + + currentEffect = anims[Math.floor(Math.random() * anims.length)]; + + if(currentEffect == undefined){ + currentEffect = 'fade'; + } } - - //Run random effect from specified set (eg: effect:'fold,fade') - if(settings.effect.indexOf(',') != -1){ - var anims = settings.effect.split(','); - currentEffect = anims[Math.floor(Math.random()*(anims.length))]; - 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'); - } - + + //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; - if(currentEffect == 'sliceDown' || currentEffect == 'sliceDownRight' || currentEffect == 'sliceDownLeft'){ - createSlices(slider, settings, vars); - var timeBuff = 0; - var i = 0; - var slices = $('.nivo-slice', slider); - if(currentEffect == 'sliceDownLeft') slices = slices._reverse(); - - slices.each(function(){ - var slice = $(this); - slice.css({ 'top': '0px' }); - if(i == settings.slices-1){ - setTimeout(function(){ - slice.animate({ height:'100%', opacity:'1.0' }, settings.animSpeed, '', function(){ slider.trigger('nivo:animFinished'); }); - }, (100 + timeBuff)); - } else { - setTimeout(function(){ - slice.animate({ height:'100%', opacity:'1.0' }, settings.animSpeed); - }, (100 + timeBuff)); + + var timedAnimate = function(el, css, speed, buff, end){ + setTimeout(function(){ + el.animate(css, (!speed) ? settings.animSpeed : speed, '', (end) ? function(){ slider.trigger('nivo:animFinished') } : null); + }, 100 + buff) + } + + switch(currentEffect){ + case 'sliceDown': + case 'sliceDownRight': + case 'sliceDownLeft': + createSlices(slider, settings, vars); + + var timeBuff = 0, + slices = $('.nivo-slice', slider), + sliceIndex = 0, + slice; + + if(currentEffect === 'sliceDownLeft'){ + slices = slices._reverse(); } - timeBuff += 50; - i++; - }); - } - else if(currentEffect == 'sliceUp' || currentEffect == 'sliceUpRight' || currentEffect == 'sliceUpLeft'){ - createSlices(slider, settings, vars); - var timeBuff = 0; - var i = 0; - var slices = $('.nivo-slice', slider); - if(currentEffect == 'sliceUpLeft') slices = slices._reverse(); - - slices.each(function(){ - var slice = $(this); - slice.css({ 'bottom': '0px' }); - if(i == settings.slices-1){ - setTimeout(function(){ - slice.animate({ height:'100%', opacity:'1.0' }, settings.animSpeed, '', function(){ slider.trigger('nivo:animFinished'); }); - }, (100 + timeBuff)); - } else { - setTimeout(function(){ - slice.animate({ height:'100%', opacity:'1.0' }, settings.animSpeed); - }, (100 + timeBuff)); + + do{ + slice = $(slices[sliceIndex]); + + slice.css({ 'top': '0px' }); + + timedAnimate(slice, { height: '100%', opacity: 1 }, null, timeBuff, (sliceIndex === settings.slices - 1) ? true : false); + + timeBuff += 50; } - timeBuff += 50; - i++; - }); - } - else if(currentEffect == 'sliceUpDown' || currentEffect == 'sliceUpDownRight' || currentEffect == 'sliceUpDownLeft'){ - createSlices(slider, settings, vars); - var timeBuff = 0; - var i = 0; - var v = 0; - var slices = $('.nivo-slice', slider); - if(currentEffect == 'sliceUpDownLeft') slices = slices._reverse(); - - slices.each(function(){ - var slice = $(this); - if(i == 0){ - slice.css('top','0px'); - i++; - } else { - slice.css('bottom','0px'); - i = 0; + while(++sliceIndex < settings.slices); + break; + + case 'sliceUp': + case 'sliceUpRight': + case 'sliceUpLeft': + createSlices(slider, settings, vars); + + var timeBuff = 0, + slices = $('.nivo-slice', slider), + sliceIndex = 0, + slice; + + if(currentEffect === 'sliceUpLeft'){ + slices = slices._reverse(); } - - if(v == settings.slices-1){ - setTimeout(function(){ - slice.animate({ height:'100%', opacity:'1.0' }, settings.animSpeed, '', function(){ slider.trigger('nivo:animFinished'); }); - }, (100 + timeBuff)); - } else { - setTimeout(function(){ - slice.animate({ height:'100%', opacity:'1.0' }, settings.animSpeed); - }, (100 + timeBuff)); + + do{ + slice = $(slices[sliceIndex]); + + slice.css({ 'bottom': '0px' }); + + timedAnimate(slice, { height: '100%', opacity: 1 }, null, timeBuff, (sliceIndex === settings.slices - 1) ? true : false); + + timeBuff += 50; } - timeBuff += 50; - v++; - }); - } - else if(currentEffect == 'fold'){ - createSlices(slider, settings, vars); - var timeBuff = 0; - var i = 0; - - $('.nivo-slice', slider).each(function(){ - var slice = $(this); - var origWidth = slice.width(); - slice.css({ top:'0px', height:'100%', width:'0px' }); - if(i == settings.slices-1){ - setTimeout(function(){ - slice.animate({ width:origWidth, opacity:'1.0' }, settings.animSpeed, '', function(){ slider.trigger('nivo:animFinished'); }); - }, (100 + timeBuff)); - } else { - setTimeout(function(){ - slice.animate({ width:origWidth, opacity:'1.0' }, settings.animSpeed); - }, (100 + timeBuff)); + while(++sliceIndex < settings.slices); + break; + + case 'sliceUpDown': + case 'sliceUpDownRight': + case 'sliceUpDownLeft': + createSlices(slider, settings, vars); + + var timeBuff = 0, + top = 0, + slices = $('.nivo-slice', slider), + sliceIndex = 0, + slice; + + if(currentEffect === 'sliceUpDownLeft'){ + slices = slices._reverse(); } - timeBuff += 50; - i++; - }); - } - else if(currentEffect == 'fade'){ - createSlices(slider, settings, vars); - - var firstSlice = $('.nivo-slice:first', slider); - firstSlice.css({ - 'height': '100%', - 'width': slider.width() + 'px' - }); - - firstSlice.animate({ opacity:'1.0' }, (settings.animSpeed*2), '', function(){ slider.trigger('nivo:animFinished'); }); - } - else if(currentEffect == 'slideInRight'){ - createSlices(slider, settings, vars); - - var firstSlice = $('.nivo-slice:first', slider); - firstSlice.css({ - 'height': '100%', - 'width': '0px', - 'opacity': '1' - }); - - firstSlice.animate({ width: slider.width() + 'px' }, (settings.animSpeed*2), '', function(){ slider.trigger('nivo:animFinished'); }); - } - else if(currentEffect == 'slideInLeft'){ - createSlices(slider, settings, vars); - - var firstSlice = $('.nivo-slice:first', slider); - firstSlice.css({ - 'height': '100%', - 'width': '0px', - 'opacity': '1', - 'left': '', - 'right': '0px' - }); - - firstSlice.animate({ width: slider.width() + 'px' }, (settings.animSpeed*2), '', function(){ - // Reset positioning - firstSlice.css({ - 'left': '0px', - 'right': '' - }); - slider.trigger('nivo:animFinished'); - }); - } - else if(currentEffect == 'boxRandom'){ - createBoxes(slider, settings, vars); - - var totalBoxes = settings.boxCols * settings.boxRows; - var i = 0; - var timeBuff = 0; - - var boxes = shuffle($('.nivo-box', slider)); - boxes.each(function(){ - var box = $(this); - if(i == totalBoxes-1){ - setTimeout(function(){ - box.animate({ opacity:'1' }, settings.animSpeed, '', function(){ slider.trigger('nivo:animFinished'); }); - }, (100 + timeBuff)); - } else { - setTimeout(function(){ - box.animate({ opacity:'1' }, settings.animSpeed); - }, (100 + timeBuff)); + + do{ + slice = $(slices[sliceIndex]); + + if(top){ + slice.css('top', '0px'); + } else { + slice.css('bottom', '0px'); + } + // flip bool + top = !top; + + timedAnimate(slice, { height: '100%', opacity: 1 }, null, timeBuff, (sliceIndex === settings.slices - 1) ? true : false); + + timeBuff += 50; } - timeBuff += 20; - i++; - }); - } - else if(currentEffect == 'boxRain' || currentEffect == 'boxRainReverse' || currentEffect == 'boxRainGrow' || currentEffect == 'boxRainGrowReverse'){ - createBoxes(slider, settings, vars); - - var totalBoxes = settings.boxCols * settings.boxRows; - var i = 0; - var timeBuff = 0; - - // Split boxes into 2D array - var rowIndex = 0; - var colIndex = 0; - var box2Darr = new Array(); - box2Darr[rowIndex] = new Array(); - var boxes = $('.nivo-box', slider); - if(currentEffect == 'boxRainReverse' || currentEffect == 'boxRainGrowReverse'){ - boxes = boxes._reverse(); - } - boxes.each(function(){ - box2Darr[rowIndex][colIndex] = this; - colIndex++; - if(colIndex == settings.boxCols){ - rowIndex++; - colIndex = 0; - box2Darr[rowIndex] = new Array(); + while(++sliceIndex < settings.slices); + break; + + case 'fold': + createSlices(slider, settings, vars); + + var timeBuff = 0, + slices = $('.nivo-slice', slider), + sliceIndex = 0, + slice, + sliceWidth = 0; + + do{ + slice = $(slices[sliceIndex]); + sliceWidth = slice.width(); + + slice.css({ top: '0px', height: '100%', width: '0px' }); + + timedAnimate(slice, { width: sliceWidth +'px', opacity: 1 }, null, timeBuff, (sliceIndex === settings.slices - 1) ? true : false); + + timeBuff += 50; } - }); - - // 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 - 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(); - 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'); }); - }, (100 + time)); - } else { - setTimeout(function(){ - box.animate({ opacity:'1', width:w, height:h }, settings.animSpeed/1.3); - }, (100 + time)); + while(++sliceIndex < settings.slices); + break; + + case 'fade': + createSlices(slider, settings, vars); + + var firstSlice = $('.nivo-slice', slider).eq(0); + + firstSlice + .css({ height: '100%', width: slider.width() +'px' }) + + .animate({ opacity: 1 }, (settings.animSpeed * 2), '', function(){ + slider.trigger('nivo:animFinished'); + }); + break; + + case 'slideInRight': + createSlices(slider, settings, vars); + + var firstSlice = $('.nivo-slice', slider).eq(0); + + firstSlice + .css({ height: '100%', width: '0px', opacity: 1}) + + .animate({ width: slider.width() +'px' }, (settings.animSpeed * 2), '', function(){ + slider.trigger('nivo:animFinished'); + }); + break; + + case 'slideInLeft': + createSlices(slider, settings, vars); + + var firstSlice = $('.nivo-slice', slider).eq(0); + + firstSlice + .css({ height: '100%', width: '0px', opacity: 1, left: '', right: '0px' }) + + .animate({ width: slider.width() +'px' }, (settings.animSpeed * 2), '', function(){ + // Reset positioning + firstSlice.css({ left: '0px', right: '' }); + slider.trigger('nivo:animFinished'); + }); + break; + + case 'boxRandom': + createBoxes(slider, settings, vars); + + var totalBoxes = settings.boxCols * settings.boxRows, + timeBuff = 0, + boxes = shuffle($('.nivo-box', slider)), + boxIndex = 0, + box; + + do{ + box = $(boxes[boxIndex]); + + timedAnimate(box, { opacity: 1 }, null, timeBuff, (boxIndex === totalBoxes - 1) ? true : false); + + timeBuff += 20; + } + while(++boxIndex < totalBoxes); + break; + + case 'boxRain': + case 'boxRainReverse': + case 'boxRainGrow': + case 'boxRainGrowReverse': + createBoxes(slider, settings, vars); + + var totalBoxes = settings.boxCols * settings.boxRows, + timeBuff = 0, + box2Darr = new Array(), + rowIndex = 0, + colIndex = 0, + boxes = $('.nivo-box', slider), + boxIndex = 0; + + if(currentEffect == 'boxRainReverse' || currentEffect == 'boxRainGrowReverse'){ + boxes = boxes._reverse(); + } + + // Split boxes into 2D array + box2Darr[rowIndex] = new Array(); + + do{ + box2Darr[rowIndex][colIndex] = boxes[boxIndex]; + ++colIndex; + + if(colIndex === settings.boxCols){ + ++rowIndex; + box2Darr[rowIndex] = new Array(); + + // reset column + colIndex = 0; + } + } + while(++boxIndex < totalBoxes); + + var cols = 0, + rows = 0, + curCol = 0, + i = 0, + box, + boxWidth = 0, + boxHeight = 0; + + // Run animation + do{ + curCol = cols; + + do{ + ++i; + + if(curCol >= 0 && curCol < settings.boxCols){ + box = $(box2Darr[rows][curCol]); + boxWidth = box.width(); + boxHeight = box.height(); + + if(currentEffect == 'boxRainGrow' || currentEffect == 'boxRainGrowReverse'){ + box.width(0).height(0); } - })(rows, prevCol, timeBuff, i, totalBoxes); - i++; + + timedAnimate(box, { width: boxWidth, height: boxHeight, opacity: 1}, settings.animSpeed / 1.3, timeBuff, (i === totalBoxes) ? true : false); + } + + --curCol; } - prevCol--; + while(++rows < settings.boxRows); + + // reset rows + rows = 0; + + timeBuff += 100; } - timeBuff += 100; - } + while(++cols < (settings.boxCols * 2)); + break; } } - + // Shuffle an array var shuffle = function(arr){ for(var j, x, i = arr.length; i; j = parseInt(Math.random() * i), 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 - this.stop = function(){ - if(!$(element).data('nivo:vars').stop){ - $(element).data('nivo:vars').stop = true; - trace('Stop Slider'); - } - } - - this.start = function(){ - if($(element).data('nivo:vars').stop){ - $(element).data('nivo:vars').stop = 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'); - // Pass options to plugin constructor - var nivoslider = new NivoSlider(this, options); - // Store plugin object in this element's data - element.data('nivoslider', nivoslider); - }); + // Start / Stop + this.stop = function(){ + if(!$(element).data('nivo:vars').stop){ + $(element).data('nivo:vars').stop = true; + } + } + + this.start = function(){ + if($(element).data('nivo:vars').stop){ + $(element).data('nivo:vars').stop = false; + } + } + + //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'); + } + // 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', @@ -672,7 +771,7 @@ directionNavHide: true, controlNav: true, controlNavThumbs: false, - controlNavThumbsFromRel: false, + controlNavThumbsFromRel: false, controlNavThumbsSearch: '.jpg', controlNavThumbsReplace: '_thumb.jpg', keyboardNav: true, @@ -685,10 +784,10 @@ beforeChange: function(){}, afterChange: function(){}, slideshowEnd: function(){}, - lastSlide: function(){}, - afterLoad: function(){} + lastSlide: function(){}, + afterLoad: function(){} }; $.fn._reverse = [].reverse; - + })(jQuery); \ No newline at end of file From 159dc0485b508d873efa701ef49bda49bfd74ce0 Mon Sep 17 00:00:00 2001 From: Jason Busby Date: Fri, 20 Jan 2012 02:22:10 +0000 Subject: [PATCH 03/19] Minified version using advanced Google Closure Compiler (8029 bytes) --- jquery.nivo.slider.pack.js | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/jquery.nivo.slider.pack.js b/jquery.nivo.slider.pack.js index 7bb2356..51026b4 100644 --- a/jquery.nivo.slider.pack.js +++ b/jquery.nivo.slider.pack.js @@ -6,7 +6,21 @@ * Free to use and abuse under the MIT license. * http://www.opensource.org/licenses/mit-license.php * - * March 2010 + * January 2012 */ - -(function(a){var b=function(b,c){var d=a.extend({},a.fn.nivoSlider.defaults,c);var e={currentSlide:0,currentImage:"",totalSlides:0,running:false,paused:false,stop:false};var f=a(b);f.data("nivo:vars",e);f.css("position","relative");f.addClass("nivoSlider");var g=f.children();g.each(function(){var b=a(this);var c="";if(!b.is("img")){if(b.is("a")){b.addClass("nivo-imageLink");c=b}b=b.find("img:first")}var d=b.width();if(d==0)d=b.attr("width");var g=b.height();if(g==0)g=b.attr("height");if(d>f.width()){f.width(d)}if(g>f.height()){f.height(g)}if(c!=""){c.css("display","none")}b.css("display","none");e.totalSlides++});if(d.randomStart){d.startSlide=Math.floor(Math.random()*e.totalSlides)}if(d.startSlide>0){if(d.startSlide>=e.totalSlides)d.startSlide=e.totalSlides-1;e.currentSlide=d.startSlide}if(a(g[e.currentSlide]).is("img")){e.currentImage=a(g[e.currentSlide])}else{e.currentImage=a(g[e.currentSlide]).find("img:first")}if(a(g[e.currentSlide]).is("a")){a(g[e.currentSlide]).css("display","block")}f.css("background",'url("'+e.currentImage.attr("src")+'") no-repeat');f.append(a('

').css({display:"none",opacity:d.captionOpacity}));a(".nivo-caption",f).css("opacity",0);var h=function(b){var c=a(".nivo-caption",f);if(e.currentImage.attr("title")!=""&&e.currentImage.attr("title")!=undefined){var d=e.currentImage.attr("title");if(d.substr(0,1)=="#")d=a(d).html();if(c.css("opacity")!=0){c.find("p").stop().fadeTo(b.animSpeed,0,function(){a(this).html(d);a(this).stop().fadeTo(b.animSpeed,1)})}else{c.find("p").html(d)}c.stop().fadeTo(b.animSpeed,b.captionOpacity)}else{c.stop().fadeTo(b.animSpeed,0)}};h(d);var i=0;if(!d.manualAdvance&&g.length>1){i=setInterval(function(){o(f,g,d,false)},d.pauseTime)}if(d.directionNav){f.append('");if(d.directionNavHide){a(".nivo-directionNav",f).hide();f.hover(function(){a(".nivo-directionNav",f).show()},function(){a(".nivo-directionNav",f).hide()})}a("a.nivo-prevNav",f).live("click",function(){if(e.running)return false;clearInterval(i);i="";e.currentSlide-=2;o(f,g,d,"prev")});a("a.nivo-nextNav",f).live("click",function(){if(e.running)return false;clearInterval(i);i="";o(f,g,d,"next")})}if(d.controlNav){var j=a('
');f.append(j);for(var k=0;k')}else{j.append('')}}else{j.append(''+(k+1)+"")}}a(".nivo-controlNav a:eq("+e.currentSlide+")",f).addClass("active");a(".nivo-controlNav a",f).live("click",function(){if(e.running)return false;if(a(this).hasClass("active"))return false;clearInterval(i);i="";f.css("background",'url("'+e.currentImage.attr("src")+'") no-repeat');e.currentSlide=a(this).attr("rel")-1;o(f,g,d,"control")})}if(d.keyboardNav){a(window).keypress(function(a){if(a.keyCode=="37"){if(e.running)return false;clearInterval(i);i="";e.currentSlide-=2;o(f,g,d,"prev")}if(a.keyCode=="39"){if(e.running)return false;clearInterval(i);i="";o(f,g,d,"next")}})}if(d.pauseOnHover){f.hover(function(){e.paused=true;clearInterval(i);i=""},function(){e.paused=false;if(i==""&&!d.manualAdvance){i=setInterval(function(){o(f,g,d,false)},d.pauseTime)}})}f.bind("nivo:animFinished",function(){e.running=false;a(g).each(function(){if(a(this).is("a")){a(this).css("display","none")}});if(a(g[e.currentSlide]).is("a")){a(g[e.currentSlide]).css("display","block")}if(i==""&&!e.paused&&!d.manualAdvance){i=setInterval(function(){o(f,g,d,false)},d.pauseTime)}d.afterChange.call(this)});var m=function(b,c,d){for(var e=0;e').css({left:f*e+"px",width:b.width()-f*e+"px",height:"0px",opacity:"0",background:'url("'+d.currentImage.attr("src")+'") no-repeat -'+(f+e*f-f)+"px 0%"}))}else{b.append(a('
').css({left:f*e+"px",width:f+"px",height:"0px",opacity:"0",background:'url("'+d.currentImage.attr("src")+'") no-repeat -'+(f+e*f-f)+"px 0%"}))}}};var n=function(b,c,d){var e=Math.round(b.width()/c.boxCols);var f=Math.round(b.height()/c.boxRows);for(var g=0;g').css({opacity:0,left:e*h+"px",top:f*g+"px",width:b.width()-e*h+"px",height:f+"px",background:'url("'+d.currentImage.attr("src")+'") no-repeat -'+(e+h*e-e)+"px -"+(f+g*f-f)+"px"}))}else{b.append(a('
').css({opacity:0,left:e*h+"px",top:f*g+"px",width:e+"px",height:f+"px",background:'url("'+d.currentImage.attr("src")+'") no-repeat -'+(e+h*e-e)+"px -"+(f+g*f-f)+"px"}))}}}};var o=function(b,c,d,e){var f=b.data("nivo:vars");if(f&&f.currentSlide==f.totalSlides-1){d.lastSlide.call(this)}if((!f||f.stop)&&!e)return false;d.beforeChange.call(this);if(!e){b.css("background",'url("'+f.currentImage.attr("src")+'") no-repeat')}else{if(e=="prev"){b.css("background",'url("'+f.currentImage.attr("src")+'") no-repeat')}if(e=="next"){b.css("background",'url("'+f.currentImage.attr("src")+'") no-repeat')}}f.currentSlide++;if(f.currentSlide==f.totalSlides){f.currentSlide=0;d.slideshowEnd.call(this)}if(f.currentSlide<0)f.currentSlide=f.totalSlides-1;if(a(c[f.currentSlide]).is("img")){f.currentImage=a(c[f.currentSlide])}else{f.currentImage=a(c[f.currentSlide]).find("img:first")}if(d.controlNav){a(".nivo-controlNav a",b).removeClass("active");a(".nivo-controlNav a:eq("+f.currentSlide+")",b).addClass("active")}h(d);a(".nivo-slice",b).remove();a(".nivo-box",b).remove();var g=d.effect;if(d.effect=="random"){var i=new Array("sliceDownRight","sliceDownLeft","sliceUpRight","sliceUpLeft","sliceUpDown","sliceUpDownLeft","fold","fade","boxRandom","boxRain","boxRainReverse","boxRainGrow","boxRainGrowReverse");g=i[Math.floor(Math.random()*(i.length+1))];if(g==undefined)g="fade"}if(d.effect.indexOf(",")!=-1){var i=d.effect.split(",");g=i[Math.floor(Math.random()*i.length)];if(g==undefined)g="fade"}if(f.currentImage.attr("data-transition")){g=f.currentImage.attr("data-transition")}f.running=true;if(g=="sliceDown"||g=="sliceDownRight"||g=="sliceDownLeft"){m(b,d,f);var j=0;var k=0;var l=a(".nivo-slice",b);if(g=="sliceDownLeft")l=a(".nivo-slice",b)._reverse();l.each(function(){var c=a(this);c.css({top:"0px"});if(k==d.slices-1){setTimeout(function(){c.animate({height:"100%",opacity:"1.0"},d.animSpeed,"",function(){b.trigger("nivo:animFinished")})},100+j)}else{setTimeout(function(){c.animate({height:"100%",opacity:"1.0"},d.animSpeed)},100+j)}j+=50;k++})}else if(g=="sliceUp"||g=="sliceUpRight"||g=="sliceUpLeft"){m(b,d,f);var j=0;var k=0;var l=a(".nivo-slice",b);if(g=="sliceUpLeft")l=a(".nivo-slice",b)._reverse();l.each(function(){var c=a(this);c.css({bottom:"0px"});if(k==d.slices-1){setTimeout(function(){c.animate({height:"100%",opacity:"1.0"},d.animSpeed,"",function(){b.trigger("nivo:animFinished")})},100+j)}else{setTimeout(function(){c.animate({height:"100%",opacity:"1.0"},d.animSpeed)},100+j)}j+=50;k++})}else if(g=="sliceUpDown"||g=="sliceUpDownRight"||g=="sliceUpDownLeft"){m(b,d,f);var j=0;var k=0;var o=0;var l=a(".nivo-slice",b);if(g=="sliceUpDownLeft")l=a(".nivo-slice",b)._reverse();l.each(function(){var c=a(this);if(k==0){c.css("top","0px");k++}else{c.css("bottom","0px");k=0}if(o==d.slices-1){setTimeout(function(){c.animate({height:"100%",opacity:"1.0"},d.animSpeed,"",function(){b.trigger("nivo:animFinished")})},100+j)}else{setTimeout(function(){c.animate({height:"100%",opacity:"1.0"},d.animSpeed)},100+j)}j+=50;o++})}else if(g=="fold"){m(b,d,f);var j=0;var k=0;a(".nivo-slice",b).each(function(){var c=a(this);var e=c.width();c.css({top:"0px",height:"100%",width:"0px"});if(k==d.slices-1){setTimeout(function(){c.animate({width:e,opacity:"1.0"},d.animSpeed,"",function(){b.trigger("nivo:animFinished")})},100+j)}else{setTimeout(function(){c.animate({width:e,opacity:"1.0"},d.animSpeed)},100+j)}j+=50;k++})}else if(g=="fade"){m(b,d,f);var q=a(".nivo-slice:first",b);q.css({height:"100%",width:b.width()+"px"});q.animate({opacity:"1.0"},d.animSpeed*2,"",function(){b.trigger("nivo:animFinished")})}else if(g=="slideInRight"){m(b,d,f);var q=a(".nivo-slice:first",b);q.css({height:"100%",width:"0px",opacity:"1"});q.animate({width:b.width()+"px"},d.animSpeed*2,"",function(){b.trigger("nivo:animFinished")})}else if(g=="slideInLeft"){m(b,d,f);var q=a(".nivo-slice:first",b);q.css({height:"100%",width:"0px",opacity:"1",left:"",right:"0px"});q.animate({width:b.width()+"px"},d.animSpeed*2,"",function(){q.css({left:"0px",right:""});b.trigger("nivo:animFinished")})}else if(g=="boxRandom"){n(b,d,f);var r=d.boxCols*d.boxRows;var k=0;var j=0;var s=p(a(".nivo-box",b));s.each(function(){var c=a(this);if(k==r-1){setTimeout(function(){c.animate({opacity:"1"},d.animSpeed,"",function(){b.trigger("nivo:animFinished")})},100+j)}else{setTimeout(function(){c.animate({opacity:"1"},d.animSpeed)},100+j)}j+=20;k++})}else if(g=="boxRain"||g=="boxRainReverse"||g=="boxRainGrow"||g=="boxRainGrowReverse"){n(b,d,f);var r=d.boxCols*d.boxRows;var k=0;var j=0;var t=0;var u=0;var v=new Array;v[t]=new Array;var s=a(".nivo-box",b);if(g=="boxRainReverse"||g=="boxRainGrowReverse"){s=a(".nivo-box",b)._reverse()}s.each(function(){v[t][u]=a(this);u++;if(u==d.boxCols){t++;u=0;v[t]=new Array}});for(var w=0;w=0&&x=0&&m').css(i)[0])}while(++l').css(j)[0])}while(++ec.width()&&c.width(u),v>c.height()&&c.height(v),x!=""&&x.css("display","none"),h.css("display","none"),++f.g;while(++p0){if(a.i>=f.g)a.i=f.g-1;f.a=a.i}m=b(i[f.a]);f.b=m.is("img")?m:m.find("img").eq(0);m.is("a")&&m.css("display","block");c.css("background",'url("'+f.b.attr("src")+'") no-repeat');c.append(b('

').css({display:"none",opacity:a.n}));b(".nivo-caption",c).css("opacity",0);y(a);var j=0;!a.l&&i.length>1&&(j=setInterval(function(){n(c,i,a,!1)},a.m));a.v&&(c.append('"),a.w&&(b(".nivo-directionNav",c).hide(),c.hover(function(){b(".nivo-directionNav",c).show()},function(){b(".nivo-directionNav",c).hide()})),b("a.nivo-prevNav",c).live("click",function(){if(f.f)return!1;clearInterval(j);j="";f.a-=2;n(c,i,a,"prev")}),b("a.nivo-nextNav",c).live("click",function(){if(f.f)return!1;clearInterval(j);j="";n(c,i,a,"next")}));if(a.o){m=b('
');h="";p=0;c.append(m);do a.q?(h=i.eq(p),h.is("img")||(h=h.find("img").eq(0)),h=a.r? +'':''):h=p+1,m.append(''+h+"");while(++p Date: Fri, 20 Jan 2012 03:15:55 +0000 Subject: [PATCH 04/19] Added default case to animation switch --- jquery.nivo.slider.js | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/jquery.nivo.slider.js b/jquery.nivo.slider.js index 8a1c014..05684ca 100644 --- a/jquery.nivo.slider.js +++ b/jquery.nivo.slider.js @@ -447,20 +447,12 @@ 'boxRandom','boxRain','boxRainReverse','boxRainGrow','boxRainGrowReverse']; 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){ + else if(settings.effect.indexOf(',') !== -1){ var anims = settings.effect.split(','); currentEffect = anims[Math.floor(Math.random() * anims.length)]; - - if(currentEffect == undefined){ - currentEffect = 'fade'; - } } //Custom transition as defined by "data-transition" attribute @@ -585,6 +577,7 @@ while(++sliceIndex < settings.slices); break; + default: case 'fade': createSlices(slider, settings, vars); From 14eea846d0c3d5ba8b7c364816c94d5ee7731773 Mon Sep 17 00:00:00 2001 From: Jason Busby Date: Fri, 20 Jan 2012 03:20:37 +0000 Subject: [PATCH 05/19] New minified version --- jquery.nivo.slider.pack.js | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/jquery.nivo.slider.pack.js b/jquery.nivo.slider.pack.js index 51026b4..d311c28 100644 --- a/jquery.nivo.slider.pack.js +++ b/jquery.nivo.slider.pack.js @@ -8,19 +8,19 @@ * * January 2012 */ -(function(b){var q=null;function s(){return function(){}}function A(o,t){function w(b){for(var d,e,g=b.length;g;d=parseInt(Math.random()*g),e=b[--g],b[g]=b[d],b[d]=e);return b}function n(k,d,e,g){var a=k.data("nivo:vars");if(a&&!a.stop||g){g?(g=="prev"&&k.css("background",'url("'+a.b.attr("src")+'") no-repeat'),g=="next"&&k.css("background",'url("'+a.b.attr("src")+'") no-repeat')):k.css("background",'url("'+a.b.attr("src")+'") no-repeat');a.a++;if(a.a==a.g)a.a=0;if(a.a<0)a.a=a.g-1;d=b(d[a.a]);a.b=d.is("img")?d:d.find("img").eq(0);e.o&&b(".nivo-controlNav a", -k).removeClass("active").eq(a.a).addClass("active");y(e);b(".nivo-slice",k).remove();b(".nivo-box",k).remove();g=e.k;e.k==="random"&&(d=["sliceDownRight","sliceDownLeft","sliceUpRight","sliceUpLeft","sliceUpDown","sliceUpDownLeft","fold","fade","boxRandom","boxRain","boxRainReverse","boxRainGrow","boxRainGrowReverse"],g=d[Math.floor(Math.random()*(d.length-1))],g===void 0&&(g="fade"));e.k.indexOf(",")!==-1&&(d=e.k.split(","),g=d[Math.floor(Math.random()*d.length)],g==void 0&&(g="fade"));a.b.attr("data-transition")&& -(g=a.b.attr("data-transition"));a.f=!0;a=function(a,b,c,d,f){setTimeout(function(){a.animate(b,!c?e.d:c,"",f?function(){k.trigger("nivo:animFinished")}:q)},100+d)};switch(g){case "sliceDown":case "sliceDownRight":case "sliceDownLeft":r();var d=0,c=b(".nivo-slice",k),l=0;g==="sliceDownLeft"&&(c=c.j());do g=b(c[l]),g.css({top:"0px"}),a(g,{height:"100%",opacity:1},q,d,l===e.c-1?!0:!1),d+=50;while(++l=0&&m').css(i)[0])}while(++l').css(j)[0])}while(++ec.width()&&c.width(u),v>c.height()&&c.height(v),x!=""&&x.css("display","none"),h.css("display","none"),++f.g;while(++p0){if(a.i>=f.g)a.i=f.g-1;f.a=a.i}m=b(i[f.a]);f.b=m.is("img")?m:m.find("img").eq(0);m.is("a")&&m.css("display","block");c.css("background",'url("'+f.b.attr("src")+'") no-repeat');c.append(b('

').css({display:"none",opacity:a.n}));b(".nivo-caption",c).css("opacity",0);y(a);var j=0;!a.l&&i.length>1&&(j=setInterval(function(){n(c,i,a,!1)},a.m));a.v&&(c.append('"),a.w&&(b(".nivo-directionNav",c).hide(),c.hover(function(){b(".nivo-directionNav",c).show()},function(){b(".nivo-directionNav",c).hide()})),b("a.nivo-prevNav",c).live("click",function(){if(f.f)return!1;clearInterval(j);j="";f.a-=2;n(c,i,a,"prev")}),b("a.nivo-nextNav",c).live("click",function(){if(f.f)return!1;clearInterval(j);j="";n(c,i,a,"next")}));if(a.o){m=b('
');h="";p=0;c.append(m);do a.q?(h=i.eq(p),h.is("img")||(h=h.find("img").eq(0)),h=a.r? -'':''):h=p+1,m.append(''+h+"");while(++p=0&&m').css(l)[0])}while(++k').css(k)[0])}while(++eb.width()&&b.width(u),v>b.height()&&b.height(v),x!=""&&x.css("display","none"),g.css("display","none"),++f.g;while(++p0){if(a.i>=f.g)a.i=f.g-1;f.a=a.i}m=c(i[f.a]);f.b=m.is("img")?m:m.find("img").eq(0);m.is("a")&&m.css("display","block");b.css("background",'url("'+f.b.attr("src")+'") no-repeat');b.append(c('

').css({display:"none",opacity:a.n}));c(".nivo-caption",b).css("opacity",0);y(a);var j=0;!a.l&&i.length>1&&(j=setInterval(function(){n(b,i,a,!1)},a.m));a.v&&(b.append('"),a.w&&(c(".nivo-directionNav",b).hide(),b.hover(function(){c(".nivo-directionNav",b).show()},function(){c(".nivo-directionNav",b).hide()})),c("a.nivo-prevNav",b).live("click",function(){if(f.f)return!1;clearInterval(j);j="";f.a-=2;n(b,i,a,"prev")}),c("a.nivo-nextNav",b).live("click",function(){if(f.f)return!1;clearInterval(j);j="";n(b,i,a,"next")}));if(a.o){m=c('
');g="";p=0;b.append(m);do a.q?(g=i.eq(p),g.is("img")||(g=g.find("img").eq(0)),g=a.r? +'':''):g=p+1,m.append(''+g+"");while(++p Date: Fri, 20 Jan 2012 03:47:27 +0000 Subject: [PATCH 06/19] Updated kids while --- jquery.nivo.slider.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/jquery.nivo.slider.js b/jquery.nivo.slider.js index 05684ca..db16c7c 100644 --- a/jquery.nivo.slider.js +++ b/jquery.nivo.slider.js @@ -34,14 +34,14 @@ //Find our slider children var kids = slider.children(), - kidsCount = kids.length, - kidsIndex = 0, + kidsIndex = kids.length, child, childWidth = 0, childHeight = 0, - link = ''; + link = null; - do{ + //Set up some stuff + while(--kidsIndex + 1){ child = $(kids[kidsIndex]); if(!child.is('img')){ @@ -67,14 +67,13 @@ slider.height(childHeight); } - if(link != ''){ + if(link){ link.css('display','none'); } child.css('display','none'); ++vars.totalSlides; } - while(++kidsIndex < kidsCount); //If randomStart if(settings.randomStart){ From 02bb3d172df575a50868fcaba3021bac5201b1c3 Mon Sep 17 00:00:00 2001 From: Jason Busby Date: Sat, 21 Jan 2012 02:27:13 +0000 Subject: [PATCH 07/19] Added cached elements object - also improves readability Improved some loops --- jquery.nivo.slider.js | 445 +++++++++++++++++++++++------------------- 1 file changed, 248 insertions(+), 197 deletions(-) diff --git a/jquery.nivo.slider.js b/jquery.nivo.slider.js index db16c7c..a5179e4 100644 --- a/jquery.nivo.slider.js +++ b/jquery.nivo.slider.js @@ -5,72 +5,70 @@ * Copyright 2011, Gilbert Pellegrom * Free to use and abuse under the MIT license. * http://www.opensource.org/licenses/mit-license.php - * + * * January 2012 */ (function($){ - var NivoSlider = function(element, options) + var NivoSlider = function(element, options) { //Defaults are below var settings = $.extend({}, $.fn.nivoSlider.defaults, options); //Useful variables. Play carefully. var vars = { - currentSlide: 0, - currentImage: '', + currentSlideIndex: 0, + currentImage: {}, totalSlides: 0, running: false, paused: false, stop: false }; + // element cache + var el = {}; + //Get this slider - var slider = $(element); - slider.data('nivo:vars', vars); - slider.css('position','relative'); - slider.addClass('nivoSlider'); + el.slider = $(element); + el.slider.data('nivo:vars', vars); + el.slider.css('position','relative'); + el.slider.addClass('nivoSlider'); //Find our slider children - var kids = slider.children(), - kidsIndex = kids.length, - child, - childWidth = 0, - childHeight = 0, - link = null; - - //Set up some stuff - while(--kidsIndex + 1){ - child = $(kids[kidsIndex]); - - if(!child.is('img')){ - if(child.is('a')){ - child.addClass('nivo-imageLink'); - link = child; + el.slides = el.slider.children(); + + var slide, + slidesIndex = el.slides.length, + slideWidth = 0, + slideHeight = 0; + + while(--slidesIndex + 1){ + slide = $(el.slides[slidesIndex]); + + if(!slide.is('img')){ + if(slide.is('a')){ + slide.addClass('nivo-imageLink'); } - child = child.find('img').eq(0); + slide = slide.find('img').eq(0); } //Get img width & height - childWidth = child.width(), - childHeight = child.height(); + slideWidth = slide.width(), + slideHeight = slide.height(); - if(childWidth === 0) childWidth = child.attr('width'); - if(childHeight === 0) childHeight = child.attr('height'); + if(slideWidth === 0) slideWidth = slide.attr('width'); + if(slideHeight === 0) slideHeight = slide.attr('height'); //Resize the slider - if(childWidth > slider.width()){ - slider.width(childWidth); + if(slideWidth > el.slider.width()){ + el.slider.width(slideWidth); } - if(childHeight > slider.height()){ - slider.height(childHeight); + if(slideHeight > el.slider.height()){ + el.slider.height(slideHeight); } - if(link){ - link.css('display','none'); - } - child.css('display','none'); + slide.css('display','none'); ++vars.totalSlides; } @@ -85,196 +83,234 @@ if(settings.startSlide >= vars.totalSlides){ settings.startSlide = vars.totalSlides - 1; } - vars.currentSlide = settings.startSlide; + vars.currentSlideIndex = settings.startSlide; } - var el = $(kids[vars.currentSlide]); + // add caption elements to element object + el.currentSlide = $(el.slides[vars.currentSlideIndex]); //Get initial image - if(el.is('img')){ - vars.currentImage = el; + if(el.currentSlide.is('img')){ + vars.currentImage.url = el.currentSlide.attr('src'); + vars.currentImage.title = el.currentSlide.attr('title'); } else { - vars.currentImage = el.find('img').eq(0); + var img = el.currentSlide.find('img').eq(0); + vars.currentImage.url = img.attr('src'); + vars.currentImage.title = img.attr('title'); } //Show initial link - if(el.is('a')){ - el.css('display','block'); + if(el.currentSlide.is('a')){ + el.currentSlide.css('display','block'); } //Set first background - slider.css('background', 'url("'+ vars.currentImage.attr('src') +'") no-repeat'); + el.slider + .css('background', 'url("'+ vars.currentImage.url +'") no-repeat') + //Create caption + .append( + $('

').css({ display: 'none', opacity: settings.captionOpacity }) + ); - //Create caption - slider.append( - $('

').css({ display: 'none', opacity: settings.captionOpacity }) - ); + // add caption elements to element object + el.sliderCaption = $('.nivo-caption', el.slider); + el.sliderCaptionP = el.sliderCaption.find('p'); // Cross browser default caption opacity - $('.nivo-caption', slider).css('opacity', 0); + el.sliderCaption.css('opacity', 0); // Process caption function - var processCaption = function(settings){ - var nivoCaption = $('.nivo-caption', slider), - title = (vars.currentImage.attr('title')) ? vars.currentImage.attr('title') : ''; + var processCaption = function(){ + var title = (vars.currentImage.title) ? vars.currentImage.title : null; if(title){ - if(title.substr(0,1) == '#') title = $(title).html(); + if(title.substr(0,1) == '#'){ + title = $(title).html(); + } - if(nivoCaption.css('opacity') != 0){ - nivoCaption.find('p').stop().fadeTo(settings.animSpeed, 0, function(){ - $(this).html(title).stop().fadeTo(settings.animSpeed, 1); + if(el.sliderCaption.css('opacity') != 0){ + el.sliderCaptionP.stop().fadeTo(settings.animSpeed, 0, function(){ + el.sliderCaptionP.html(title).stop().fadeTo(settings.animSpeed, 1); }); } else { - nivoCaption.find('p').html(title); + el.sliderCaptionP.html(title); } - nivoCaption.stop().fadeTo(settings.animSpeed, settings.captionOpacity); - } else { - nivoCaption.stop().fadeTo(settings.animSpeed, 0); } + + el.sliderCaption.stop().fadeTo(settings.animSpeed, (title) ? settings.captionOpacity : 0); } - //Process initial caption - processCaption(settings); + //Process initial caption + processCaption(); //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); + if(!settings.manualAdvance && vars.totalSlides > 1){ + timer = setInterval(function(){ nivoRun(false); }, settings.pauseTime); + } else { + // "oh dear!" + return false; } //Add Direction nav if(settings.directionNav){ - slider.append(''); + + // insert direction controls + el.slider.append(''); + + // add direction nav element to element object + el.sliderDirectionNav = $('.nivo-directionNav', el.slider); //Hide Direction nav if(settings.directionNavHide){ - $('.nivo-directionNav', slider).hide(); - - slider.hover(function(){ - $('.nivo-directionNav', slider).show(); - }, function(){ - $('.nivo-directionNav', slider).hide(); - }); + el.sliderDirectionNav.hide(); + + el.slider.hover( + function(){ + el.sliderDirectionNav.show(); + }, + function(){ + el.sliderDirectionNav.hide(); + } + ); } - $('a.nivo-prevNav', slider).live('click', function(){ - if(vars.running){ - return false; - } + el.sliderDirectionNav + .children() + .click( + function(){ + var dir = $(this).data('dir'); + dir = (dir) ? dir : 'next'; - clearInterval(timer); - timer = ''; - vars.currentSlide -= 2; - nivoRun(slider, kids, settings, 'prev'); - }); + if(vars.running){ + return false; + } - $('a.nivo-nextNav', slider).live('click', function(){ - if(vars.running){ - return false; - } + clearInterval(timer); + timer = null; - clearInterval(timer); - timer = ''; - nivoRun(slider, kids, settings, 'next'); - }); + if (dir === 'prev'){ + vars.currentSlideIndex -= 2; + } + nivoRun(dir); + } + ); } //Add Control nav if(settings.controlNav){ - var nivoControl = $('
'), - slide, + var slide, controlHTML = '', - i = 0; + controlHTMLContent = '', + i = el.slides.length; - slider.append(nivoControl); - - do{ + while(--i + 1){ if(settings.controlNavThumbs){ - slide = kids.eq(i); + slide = $(el.slides[i]); if(!slide.is('img')){ slide = slide.find('img').eq(0); } if (settings.controlNavThumbsFromRel) { - controlHTML = ''; + controlHTMLContent = ''; } else { - controlHTML = ''; + controlHTMLContent = ''; } } else { - controlHTML = i + 1; + controlHTMLContent = i + 1; } - nivoControl.append(''+ controlHTML +''); + controlHTML = ''+ controlHTMLContent +'' + controlHTML; } - while(++i < kids.length); + + // append control HTML as a whole + el.slider.append('
'+ controlHTML +'
'); + + // add control nav to elements object + el.sliderControlNav = $('.nivo-controlNav', el.slider); + el.sliderControlNavLinks = el.sliderControlNav.find('a'); //Set initial active link - $('.nivo-controlNav a', slider).eq(vars.currentSlide).addClass('active'); + el.sliderControlNavLinks + .click( + function(){ + var anchor = $(this); + + if(vars.running || anchor.hasClass('active')){ + return false; + } - $('.nivo-controlNav a', slider).live('click', function(){ - var anchor = $(this); + clearInterval(timer); + timer = null; - if(vars.running || anchor.hasClass('active')){ - return false; - } + el.slider.css('background', 'url("'+ vars.currentImage.url +'") no-repeat'); - clearInterval(timer); - timer = ''; - slider.css('background','url("'+ vars.currentImage.attr('src') +'") no-repeat'); - vars.currentSlide = anchor.attr('rel') - 1; - nivoRun(slider, kids, settings, 'control'); - }); + vars.currentSlideIndex = anchor.data('slide') - 1; + nivoRun('control'); + } + ) + .eq(vars.currentSlideIndex) + .addClass('active'); } //Keyboard Navigation if(settings.keyboardNav){ - $(window).keypress(function(event){ + $(document).keypress(function(e){ //Left - if(event.keyCode == '37'){ - if(vars.running) return false; + if(e.keyCode == '37'){ + if(vars.running){ + return false; + } + clearInterval(timer); - timer = ''; - vars.currentSlide-=2; - nivoRun(slider, kids, settings, 'prev'); + timer = null; + vars.currentSlideIndex -= 2; + nivoRun('prev'); } //Right - if(event.keyCode == '39'){ - if(vars.running) return false; + else if(e.keyCode == '39'){ + if(vars.running){ + return false; + } + clearInterval(timer); - timer = ''; - nivoRun(slider, kids, settings, 'next'); + timer = null; + nivoRun('next'); } }); } //For pauseOnHover setting if(settings.pauseOnHover){ - slider.hover(function(){ - vars.paused = true; - clearInterval(timer); - timer = null; - }, function(){ - vars.paused = false; - //Restart the timer - if(timer === null && !settings.manualAdvance){ - timer = setInterval(function(){ nivoRun(slider, kids, settings, false); }, settings.pauseTime); + el.slider.hover( + function(){ + vars.paused = true; + + clearInterval(timer); + timer = null; + }, + function(){ + vars.paused = false; + + //Restart the timer + if(timer === null && !settings.manualAdvance){ + timer = setInterval(function(){ nivoRun(false); }, settings.pauseTime); + } } - }); + ); } //Event when Animation finishes - slider.bind('nivo:animFinished', function(){ + el.slider.bind('nivo:animFinished', function(){ vars.running = false; var link, - i = kids.length, - el = $(kids[vars.currentSlide]); + i = el.slides.length; //Hide child links while(--i + 1){ - link = $(kids[i]); + link = $(el.slides[i]); if(link.is('a')){ link.css('display','none'); @@ -282,13 +318,13 @@ } //Show current link - if(el.is('a')){ - el.css('display','block'); + if(el.currentSlide.is('a')){ + el.currentSlide.css('display','block'); } //Restart the timer if(timer == '' && !vars.paused && !settings.manualAdvance){ - timer = setInterval(function(){ nivoRun(slider, kids, settings, false); }, settings.pauseTime); + timer = setInterval(function(){ nivoRun(false); }, settings.pauseTime); } //Trigger the afterChange callback @@ -297,8 +333,8 @@ // Add slices for slice animations var createSlices = function(){ - var sliderImg = vars.currentImage.attr('src'), - sliderWidth = slider.width(), + var sliderImg = vars.currentImage.url, + sliderWidth = el.slider.width(), slices = 0, slicesHTML = document.createDocumentFragment(), sliceWidth, @@ -331,21 +367,21 @@ while(++slices < settings.slices); // insert slices as a whole - slider.append(slicesHTML); + el.slider.append(slicesHTML); }; // Add boxes for box animations var createBoxes = function(){ - var sliderWidth = slider.width(), + var sliderWidth = el.slider.width(), boxWidth = Math.round(sliderWidth / settings.boxCols), - boxHeight = Math.round(slider.height() / settings.boxRows), + boxHeight = Math.round(el.slider.height() / settings.boxRows), boxesHTML = document.createDocumentFragment(), offsetLeft = 0, rows = 0, cols = 0; var css = { - background: 'url("'+ vars.currentImage.attr('src') +'") no-repeat', + background: 'url("'+ vars.currentImage.url +'") no-repeat', backgroundPosition: '', left: '', top: '', @@ -382,16 +418,16 @@ while(++rows < settings.boxRows); // insert boxes as a whole - slider.append(boxesHTML); + el.slider.append(boxesHTML); }; // Private run method - var nivoRun = function(slider, kids, settings, nudge){ + var nivoRun = function(nudge){ //Get our vars - var vars = slider.data('nivo:vars'); + var vars = el.slider.data('nivo:vars'); //Trigger the lastSlide callback - if(vars && (vars.currentSlide == vars.totalSlides - 1)){ + if(vars && (vars.currentSlideIndex == vars.totalSlides - 1)){ settings.lastSlide.call(this); } @@ -403,40 +439,52 @@ //Set current background before change if(!nudge){ - slider.css('background','url("'+ vars.currentImage.attr('src') +'") no-repeat'); + el.slider.css('background','url("'+ vars.currentImage.url +'") no-repeat'); } else { if(nudge == 'prev'){ - slider.css('background','url("'+ vars.currentImage.attr('src') +'") no-repeat'); + el.slider.css('background','url("'+ vars.currentImage.url +'") no-repeat'); } if(nudge == 'next'){ - slider.css('background','url("'+ vars.currentImage.attr('src') +'") no-repeat'); + el.slider.css('background','url("'+ vars.currentImage.url +'") no-repeat'); } } - vars.currentSlide++; + + // increment current slide + ++vars.currentSlideIndex; + //Trigger the slideshowEnd callback - if(vars.currentSlide == vars.totalSlides){ - vars.currentSlide = 0; + if(vars.currentSlideIndex == vars.totalSlides){ + vars.currentSlideIndex = 0; settings.slideshowEnd.call(this); } - if(vars.currentSlide < 0) vars.currentSlide = (vars.totalSlides - 1); + else if(vars.currentSlideIndex < 0){ + vars.currentSlideIndex = (vars.totalSlides - 1); + } + + // update current slide element + el.currentSlide = $(el.slides[vars.currentSlideIndex]); + el.currentSlide = (el.currentSlide.is('img')) ? el.currentSlide : el.currentSlide.find('img').eq(0); - var currentElement = $(kids[vars.currentSlide]); //Set vars.currentImage - vars.currentImage = (currentElement.is('img')) ? currentElement : currentElement.find('img').eq(0); + vars.currentImage = { + url: el.currentSlide.attr('src'), + title: el.currentSlide.attr('title'), + transition: el.currentSlide.data('transition') + } //Set active links if(settings.controlNav){ - $('.nivo-controlNav a', slider).removeClass('active').eq(vars.currentSlide).addClass('active'); + el.sliderControlNavLinks.removeClass('active').eq(vars.currentSlideIndex).addClass('active'); } //Process caption - processCaption(settings); + processCaption(); // Remove any slices from last transition - $('.nivo-slice', slider).remove(); + $('.nivo-slice', el.slider).remove(); // Remove any boxes from last transition - $('.nivo-box', slider).remove(); + $('.nivo-box', el.slider).remove(); var currentEffect = settings.effect; @@ -447,24 +495,25 @@ currentEffect = anims[Math.floor(Math.random() * (anims.length - 1))]; } + //Run random effect from specified set (eg: effect:'fold,fade') - else if(settings.effect.indexOf(',') !== -1){ + if(settings.effect.indexOf(',') !== -1){ var anims = settings.effect.split(','); currentEffect = anims[Math.floor(Math.random() * anims.length)]; } //Custom transition as defined by "data-transition" attribute - if(vars.currentImage.attr('data-transition')){ - currentEffect = vars.currentImage.attr('data-transition'); + if(vars.currentImage.transition){ + currentEffect = vars.currentImage.transition; } //Run effects vars.running = true; - var timedAnimate = function(el, css, speed, buff, end){ + var timedAnimate = function(element, css, speed, buff, end){ setTimeout(function(){ - el.animate(css, (!speed) ? settings.animSpeed : speed, '', (end) ? function(){ slider.trigger('nivo:animFinished') } : null); + element.animate(css, (!speed) ? settings.animSpeed : speed, '', (end) ? function(){ el.slider.trigger('nivo:animFinished'); _log((end) ? 'the end' : ''); } : null); }, 100 + buff) } @@ -472,10 +521,10 @@ case 'sliceDown': case 'sliceDownRight': case 'sliceDownLeft': - createSlices(slider, settings, vars); + createSlices(); var timeBuff = 0, - slices = $('.nivo-slice', slider), + slices = $('.nivo-slice', el.slider), sliceIndex = 0, slice; @@ -498,10 +547,10 @@ case 'sliceUp': case 'sliceUpRight': case 'sliceUpLeft': - createSlices(slider, settings, vars); + createSlices(); var timeBuff = 0, - slices = $('.nivo-slice', slider), + slices = $('.nivo-slice', el.slider), sliceIndex = 0, slice; @@ -524,11 +573,11 @@ case 'sliceUpDown': case 'sliceUpDownRight': case 'sliceUpDownLeft': - createSlices(slider, settings, vars); + createSlices(); var timeBuff = 0, top = 0, - slices = $('.nivo-slice', slider), + slices = $('.nivo-slice', el.slider), sliceIndex = 0, slice; @@ -555,10 +604,10 @@ break; case 'fold': - createSlices(slider, settings, vars); + createSlices(); var timeBuff = 0, - slices = $('.nivo-slice', slider), + slices = $('.nivo-slice', el.slider), sliceIndex = 0, slice, sliceWidth = 0; @@ -578,52 +627,52 @@ default: case 'fade': - createSlices(slider, settings, vars); + createSlices(); - var firstSlice = $('.nivo-slice', slider).eq(0); + var firstSlice = $('.nivo-slice', el.slider).eq(0); firstSlice - .css({ height: '100%', width: slider.width() +'px' }) + .css({ height: '100%', width: el.slider.width() +'px' }) .animate({ opacity: 1 }, (settings.animSpeed * 2), '', function(){ - slider.trigger('nivo:animFinished'); + el.slider.trigger('nivo:animFinished'); }); break; case 'slideInRight': - createSlices(slider, settings, vars); + createSlices(); - var firstSlice = $('.nivo-slice', slider).eq(0); + var firstSlice = $('.nivo-slice', el.slider).eq(0); firstSlice .css({ height: '100%', width: '0px', opacity: 1}) - .animate({ width: slider.width() +'px' }, (settings.animSpeed * 2), '', function(){ - slider.trigger('nivo:animFinished'); + .animate({ width: el.slider.width() +'px' }, (settings.animSpeed * 2), '', function(){ + el.slider.trigger('nivo:animFinished'); }); break; case 'slideInLeft': - createSlices(slider, settings, vars); + createSlices(); - var firstSlice = $('.nivo-slice', slider).eq(0); + var firstSlice = $('.nivo-slice', el.slider).eq(0); firstSlice .css({ height: '100%', width: '0px', opacity: 1, left: '', right: '0px' }) - .animate({ width: slider.width() +'px' }, (settings.animSpeed * 2), '', function(){ + .animate({ width: el.slider.width() +'px' }, (settings.animSpeed * 2), '', function(){ // Reset positioning firstSlice.css({ left: '0px', right: '' }); - slider.trigger('nivo:animFinished'); + el.slider.trigger('nivo:animFinished'); }); break; case 'boxRandom': - createBoxes(slider, settings, vars); + createBoxes(); var totalBoxes = settings.boxCols * settings.boxRows, timeBuff = 0, - boxes = shuffle($('.nivo-box', slider)), + boxes = shuffle($('.nivo-box', el.slider)), boxIndex = 0, box; @@ -641,14 +690,14 @@ case 'boxRainReverse': case 'boxRainGrow': case 'boxRainGrowReverse': - createBoxes(slider, settings, vars); + createBoxes(); var totalBoxes = settings.boxCols * settings.boxRows, timeBuff = 0, box2Darr = new Array(), rowIndex = 0, colIndex = 0, - boxes = $('.nivo-box', slider), + boxes = $('.nivo-box', el.slider), boxIndex = 0; if(currentEffect == 'boxRainReverse' || currentEffect == 'boxRainGrowReverse'){ @@ -721,14 +770,14 @@ // Start / Stop this.stop = function(){ - if(!$(element).data('nivo:vars').stop){ - $(element).data('nivo:vars').stop = true; + if(!el.slider.data('nivo:vars').stop){ + el.slider.data('nivo:vars').stop = true; } } this.start = function(){ - if($(element).data('nivo:vars').stop){ - $(element).data('nivo:vars').stop = false; + if(el.slider.data('nivo:vars').stop){ + el.slider.data('nivo:vars').stop = false; } } @@ -737,6 +786,7 @@ return this; }; + $.fn.nivoSlider = function(options){ return this.each(function(key, value){ var element = $(this); @@ -750,6 +800,7 @@ element.data('nivoslider', nivoslider); }); }; + //Default settings $.fn.nivoSlider.defaults = { effect: 'random', @@ -779,7 +830,7 @@ lastSlide: function(){}, afterLoad: function(){} }; - + $.fn._reverse = [].reverse; })(jQuery); \ No newline at end of file From 6bc3c46de42779599c32df88aa25483f15ef3a64 Mon Sep 17 00:00:00 2001 From: Jason Busby Date: Sat, 21 Jan 2012 02:33:32 +0000 Subject: [PATCH 08/19] Added support for Webkit keyboard arrow keys. Fixed boxRain effect incrementing in the wrong place causing the trigger to fire many times. --- jquery.nivo.slider.js | 12 ++++++------ jquery.nivo.slider.pack.js | 28 ++++++++++++++-------------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/jquery.nivo.slider.js b/jquery.nivo.slider.js index a5179e4..9f83f41 100644 --- a/jquery.nivo.slider.js +++ b/jquery.nivo.slider.js @@ -256,9 +256,11 @@ //Keyboard Navigation if(settings.keyboardNav){ - $(document).keypress(function(e){ + $(document).keydown(function(e){ + var code = (e.keyCode) ? e.keyCode : e.which; + //Left - if(e.keyCode == '37'){ + if(code === 37 || code === 63234){ if(vars.running){ return false; } @@ -269,7 +271,7 @@ nivoRun('prev'); } //Right - else if(e.keyCode == '39'){ + else if(code === 39 || code === 63235){ if(vars.running){ return false; } @@ -734,8 +736,6 @@ curCol = cols; do{ - ++i; - if(curCol >= 0 && curCol < settings.boxCols){ box = $(box2Darr[rows][curCol]); boxWidth = box.width(); @@ -745,7 +745,7 @@ box.width(0).height(0); } - timedAnimate(box, { width: boxWidth, height: boxHeight, opacity: 1}, settings.animSpeed / 1.3, timeBuff, (i === totalBoxes) ? true : false); + timedAnimate(box, { width: boxWidth, height: boxHeight, opacity: 1}, settings.animSpeed / 1.3, timeBuff, (++i === totalBoxes) ? true : false); } --curCol; diff --git a/jquery.nivo.slider.pack.js b/jquery.nivo.slider.pack.js index d311c28..6f37fa5 100644 --- a/jquery.nivo.slider.pack.js +++ b/jquery.nivo.slider.pack.js @@ -8,19 +8,19 @@ * * January 2012 */ -(function(c){var q=null;function s(){return function(){}}function A(o,t){function w(c){for(var d,e,a=c.length;a;d=parseInt(Math.random()*a),e=c[--a],c[a]=c[d],c[d]=e);return c}function n(a,d,e,b){var h=a.data("nivo:vars");if(h&&!h.stop||b){b?(b=="prev"&&a.css("background",'url("'+h.b.attr("src")+'") no-repeat'),b=="next"&&a.css("background",'url("'+h.b.attr("src")+'") no-repeat')):a.css("background",'url("'+h.b.attr("src")+'") no-repeat');h.a++;if(h.a==h.g)h.a=0;if(h.a<0)h.a=h.g-1;d=c(d[h.a]);h.b=d.is("img")?d:d.find("img").eq(0);e.o&&c(".nivo-controlNav a", -a).removeClass("active").eq(h.a).addClass("active");y(e);c(".nivo-slice",a).remove();c(".nivo-box",a).remove();b=e.k;e.k==="random"?(d=["sliceDownRight","sliceDownLeft","sliceUpRight","sliceUpLeft","sliceUpDown","sliceUpDownLeft","fold","fade","boxRandom","boxRain","boxRainReverse","boxRainGrow","boxRainGrowReverse"],b=d[Math.floor(Math.random()*(d.length-1))]):e.k.indexOf(",")!==-1&&(d=e.k.split(","),b=d[Math.floor(Math.random()*d.length)]);h.b.attr("data-transition")&&(b=h.b.attr("data-transition")); +(function(c,q){function s(){return function(){}}function z(p,t){function v(c){for(var d,e,a=c.length;a;d=parseInt(Math.random()*a),e=c[--a],c[a]=c[d],c[d]=e);return c}function o(a,d,e,b){var h=a.data("nivo:vars");if(h&&!h.stop||b){b?(b=="prev"&&a.css("background",'url("'+h.b.attr("src")+'") no-repeat'),b=="next"&&a.css("background",'url("'+h.b.attr("src")+'") no-repeat')):a.css("background",'url("'+h.b.attr("src")+'") no-repeat');h.a++;if(h.a==h.g)h.a=0;if(h.a<0)h.a=h.g-1;d=c(d[h.a]);h.b=d.is("img")?d:d.find("img").eq(0);e.o&&c(".nivo-controlNav a", +a).removeClass("active").eq(h.a).addClass("active");x(e);c(".nivo-slice",a).remove();c(".nivo-box",a).remove();b=e.k;e.k==="random"?(d=["sliceDownRight","sliceDownLeft","sliceUpRight","sliceUpLeft","sliceUpDown","sliceUpDownLeft","fold","fade","boxRandom","boxRain","boxRainReverse","boxRainGrow","boxRainGrowReverse"],b=d[Math.floor(Math.random()*(d.length-1))]):e.k.indexOf(",")!==-1&&(d=e.k.split(","),b=d[Math.floor(Math.random()*d.length)]);h.b.attr("data-transition")&&(b=h.b.attr("data-transition")); h.f=!0;h=function(b,c,d,f,h){setTimeout(function(){b.animate(c,!d?e.d:d,"",h?function(){a.trigger("nivo:animFinished")}:q)},100+f)};switch(b){case "sliceDown":case "sliceDownRight":case "sliceDownLeft":r();var d=0,f=c(".nivo-slice",a),k=0;b==="sliceDownLeft"&&(f=f.j());do b=c(f[k]),b.css({top:"0px"}),h(b,{height:"100%",opacity:1},q,d,k===e.c-1?!0:!1),d+=50;while(++k=0&&m').css(l)[0])}while(++k').css(k)[0])}while(++eb.width()&&b.width(u),v>b.height()&&b.height(v),x!=""&&x.css("display","none"),g.css("display","none"),++f.g;while(++p0){if(a.i>=f.g)a.i=f.g-1;f.a=a.i}m=c(i[f.a]);f.b=m.is("img")?m:m.find("img").eq(0);m.is("a")&&m.css("display","block");b.css("background",'url("'+f.b.attr("src")+'") no-repeat');b.append(c('

').css({display:"none",opacity:a.n}));c(".nivo-caption",b).css("opacity",0);y(a);var j=0;!a.l&&i.length>1&&(j=setInterval(function(){n(b,i,a,!1)},a.m));a.v&&(b.append('"),a.w&&(c(".nivo-directionNav",b).hide(),b.hover(function(){c(".nivo-directionNav",b).show()},function(){c(".nivo-directionNav",b).hide()})),c("a.nivo-prevNav",b).live("click",function(){if(f.f)return!1;clearInterval(j);j="";f.a-=2;n(b,i,a,"prev")}),c("a.nivo-nextNav",b).live("click",function(){if(f.f)return!1;clearInterval(j);j="";n(b,i,a,"next")}));if(a.o){m=c('
');g="";p=0;b.append(m);do a.q?(g=i.eq(p),g.is("img")||(g=g.find("img").eq(0)),g=a.r? -'':''):g=p+1,m.append(''+g+"");while(++p=0&&i').css(l)[0])}while(++k').css(k)[0])}while(++eb.width()&&b.width(i),u>b.height()&&b.height(u),w&&w.css("display","none"),g.css("display","none"),++f.g;if(a.D)a.i=Math.floor(Math.random()*f.g);if(a.i>0){if(a.i>= +f.g)a.i=f.g-1;f.a=a.i}n=c(m[f.a]);f.b=n.is("img")?n:n.find("img").eq(0);n.is("a")&&n.css("display","block");b.css("background",'url("'+f.b.attr("src")+'") no-repeat');b.append(c('

').css({display:"none",opacity:a.n}));c(".nivo-caption",b).css("opacity",0);x(a);var j=0;!a.l&&m.length>1&&(j=setInterval(function(){o(b,m,a,!1)},a.m));a.v&&(b.append('"),a.w&& +(c(".nivo-directionNav",b).hide(),b.hover(function(){c(".nivo-directionNav",b).show()},function(){c(".nivo-directionNav",b).hide()})),c("a.nivo-prevNav",b).live("click",function(){if(f.f)return!1;clearInterval(j);j="";f.a-=2;o(b,m,a,"prev")}),c("a.nivo-nextNav",b).live("click",function(){if(f.f)return!1;clearInterval(j);j="";o(b,m,a,"next")}));if(a.o){n=c('
');i="";g=0;b.append(n);do a.q?(i=m.eq(g),i.is("img")||(i=i.find("img").eq(0)),i=a.r?'':''):i=g+1,n.append(''+i+"");while(++g Date: Sat, 21 Jan 2012 02:47:52 +0000 Subject: [PATCH 09/19] Repacked Removed spaces in the head comment Removed console log --- jquery.nivo.slider.js | 22 ++++++++--------- jquery.nivo.slider.pack.js | 49 +++++++++++++++++++------------------- 2 files changed, 35 insertions(+), 36 deletions(-) diff --git a/jquery.nivo.slider.js b/jquery.nivo.slider.js index 9f83f41..b86cd18 100644 --- a/jquery.nivo.slider.js +++ b/jquery.nivo.slider.js @@ -1,13 +1,13 @@ -/* - * jQuery Nivo Slider v2.7.1 - * http://nivo.dev7studios.com - * - * Copyright 2011, Gilbert Pellegrom - * Free to use and abuse under the MIT license. - * http://www.opensource.org/licenses/mit-license.php - * - * January 2012 - */ +/** +* jQuery Nivo Slider v2.7.1 +* http://nivo.dev7studios.com +* +* Copyright 2011, Gilbert Pellegrom +* Free to use and abuse under the MIT license. +* http://www.opensource.org/licenses/mit-license.php +* +* January 2012 +*/ (function($){ @@ -515,7 +515,7 @@ var timedAnimate = function(element, css, speed, buff, end){ setTimeout(function(){ - element.animate(css, (!speed) ? settings.animSpeed : speed, '', (end) ? function(){ el.slider.trigger('nivo:animFinished'); _log((end) ? 'the end' : ''); } : null); + element.animate(css, (!speed) ? settings.animSpeed : speed, '', (end) ? function(){ el.slider.trigger('nivo:animFinished'); } : null); }, 100 + buff) } diff --git a/jquery.nivo.slider.pack.js b/jquery.nivo.slider.pack.js index 6f37fa5..75cf47f 100644 --- a/jquery.nivo.slider.pack.js +++ b/jquery.nivo.slider.pack.js @@ -1,26 +1,25 @@ /* - * jQuery Nivo Slider v2.7.1 - * http://nivo.dev7studios.com - * - * Copyright 2011, Gilbert Pellegrom - * Free to use and abuse under the MIT license. - * http://www.opensource.org/licenses/mit-license.php - * - * January 2012 - */ -(function(c,q){function s(){return function(){}}function z(p,t){function v(c){for(var d,e,a=c.length;a;d=parseInt(Math.random()*a),e=c[--a],c[a]=c[d],c[d]=e);return c}function o(a,d,e,b){var h=a.data("nivo:vars");if(h&&!h.stop||b){b?(b=="prev"&&a.css("background",'url("'+h.b.attr("src")+'") no-repeat'),b=="next"&&a.css("background",'url("'+h.b.attr("src")+'") no-repeat')):a.css("background",'url("'+h.b.attr("src")+'") no-repeat');h.a++;if(h.a==h.g)h.a=0;if(h.a<0)h.a=h.g-1;d=c(d[h.a]);h.b=d.is("img")?d:d.find("img").eq(0);e.o&&c(".nivo-controlNav a", -a).removeClass("active").eq(h.a).addClass("active");x(e);c(".nivo-slice",a).remove();c(".nivo-box",a).remove();b=e.k;e.k==="random"?(d=["sliceDownRight","sliceDownLeft","sliceUpRight","sliceUpLeft","sliceUpDown","sliceUpDownLeft","fold","fade","boxRandom","boxRain","boxRainReverse","boxRainGrow","boxRainGrowReverse"],b=d[Math.floor(Math.random()*(d.length-1))]):e.k.indexOf(",")!==-1&&(d=e.k.split(","),b=d[Math.floor(Math.random()*d.length)]);h.b.attr("data-transition")&&(b=h.b.attr("data-transition")); -h.f=!0;h=function(b,c,d,f,h){setTimeout(function(){b.animate(c,!d?e.d:d,"",h?function(){a.trigger("nivo:animFinished")}:q)},100+f)};switch(b){case "sliceDown":case "sliceDownRight":case "sliceDownLeft":r();var d=0,f=c(".nivo-slice",a),k=0;b==="sliceDownLeft"&&(f=f.j());do b=c(f[k]),b.css({top:"0px"}),h(b,{height:"100%",opacity:1},q,d,k===e.c-1?!0:!1),d+=50;while(++k=0&&i').css(l)[0])}while(++k').css(k)[0])}while(++eb.width()&&b.width(i),u>b.height()&&b.height(u),w&&w.css("display","none"),g.css("display","none"),++f.g;if(a.D)a.i=Math.floor(Math.random()*f.g);if(a.i>0){if(a.i>= -f.g)a.i=f.g-1;f.a=a.i}n=c(m[f.a]);f.b=n.is("img")?n:n.find("img").eq(0);n.is("a")&&n.css("display","block");b.css("background",'url("'+f.b.attr("src")+'") no-repeat');b.append(c('

').css({display:"none",opacity:a.n}));c(".nivo-caption",b).css("opacity",0);x(a);var j=0;!a.l&&m.length>1&&(j=setInterval(function(){o(b,m,a,!1)},a.m));a.v&&(b.append('"),a.w&& -(c(".nivo-directionNav",b).hide(),b.hover(function(){c(".nivo-directionNav",b).show()},function(){c(".nivo-directionNav",b).hide()})),c("a.nivo-prevNav",b).live("click",function(){if(f.f)return!1;clearInterval(j);j="";f.a-=2;o(b,m,a,"prev")}),c("a.nivo-nextNav",b).live("click",function(){if(f.f)return!1;clearInterval(j);j="";o(b,m,a,"next")}));if(a.o){n=c('
');i="";g=0;b.append(n);do a.q?(i=m.eq(g),i.is("img")||(i=i.find("img").eq(0)),i=a.r?'':''):i=g+1,n.append(''+i+"");while(++g=0&&o').css(i)[0])}while(++g').css(m)[0])}while(++ga.a.width()&&a.a.width(i),t>a.a.height()&&a.a.height(t),e.css("display","none"),++c.i;if(b.M)b.l=Math.floor(Math.random()*c.i);if(b.l>0){if(b.l>=c.i)b.l= +c.i-1;c.d=b.l}a.c=f(a.h[c.d]);a.c.is("img")?(c.b.url=a.c.attr("src"),c.b.title=a.c.attr("title")):(e=a.c.find("img").eq(0),c.b.url=e.attr("src"),c.b.title=e.attr("title"));a.c.is("a")&&a.c.css("display","block");a.a.css("background",'url("'+c.b.url+'") no-repeat').append(f('

').css({display:"none",opacity:b.t}));a.o=f(".nivo-caption",a.a);a.s=a.o.find("p");a.o.css("opacity",0);w();var g=0;if(!b.q&&c.i>1)g=setInterval(function(){m(!1)},b.r);else return!1;if(b.G)a.a.append('"),a.p=f(".nivo-directionNav",a.a),b.H&&(a.p.hide(),a.a.hover(function(){a.p.show()},function(){a.p.hide()})),a.p.children().click(function(){var a=f(this).data("dir"),a=a?a:"next";if(c.j)return!1;clearInterval(g);g=n;a==="prev"&&(c.d-=2);m(a)});if(b.u){e=p="";for(i=a.h.length;--i+1;)b.A?(e=f(a.h[i]),e.is("img")||(e=e.find("img").eq(0)),e=b.B?'':''): +e=i+1,p=''+e+""+p;a.a.append('
'+p+"
");a.N=f(".nivo-controlNav",a.a);a.w=a.N.find("a");a.w.click(function(){var b=f(this);if(c.j||b.hasClass("active"))return!1;clearInterval(g);g=n;a.a.css("background",'url("'+c.b.url+'") no-repeat');c.d=b.data("slide")-1;m("control")}).eq(c.d).addClass("active")}b.I&&f(document).keydown(function(a){a=a.keyCode?a.keyCode:a.which;if(a===37||a===63234){if(c.j)return!1;clearInterval(g); +g=n;c.d-=2;m("prev")}else if(a===39||a===63235){if(c.j)return!1;clearInterval(g);g=n;m("next")}});b.K&&a.a.hover(function(){c.paused=!0;clearInterval(g);g=n},function(){c.paused=!1;g===n&&!b.q&&(g=setInterval(function(){m(!1)},b.r))});a.a.bind("nivo:animFinished",function(){c.j=!1;for(var d,e=a.h.length;--e+1;)d=f(a.h[e]),d.is("a")&&d.css("display","none");a.c.is("a")&&a.c.css("display","block");g==""&&!c.paused&&!b.q&&(g=setInterval(function(){m(!1)},b.r))});this.stop=function(){if(!a.a.data("nivo:vars").stop)a.a.data("nivo:vars").stop= +!0};this.start=function(){if(a.a.data("nivo:vars").stop)a.a.data("nivo:vars").stop=!1};return this}f.fn.nivoSlider=function(u){return this.each(function(){var q=f(this);if(q.data("nivoslider"))return q.data("nivoslider");var v=new y(this,u);q.data("nivoslider",v)})};f.fn.nivoSlider.F={n:"random",e:15,g:8,k:4,f:500,r:3E3,l:0,G:!0,H:!0,u:!0,A:!1,B:!1,D:".jpg",C:"_thumb.jpg",I:!0,K:!0,q:!1,t:0.8,L:"Prev",J:"Next",M:!1,Q:s(),O:s(),S:s(),R:s(),P:s()};f.fn.m=[].reverse})(jQuery,null); \ No newline at end of file From 6068be07e7e2ab3eccba0d0695a34dc77c10c36f Mon Sep 17 00:00:00 2001 From: Jason Busby Date: Sat, 21 Jan 2012 03:32:24 +0000 Subject: [PATCH 10/19] Fixed manual advance mess up --- jquery.nivo.slider.js | 8 +++++--- jquery.nivo.slider.pack.js | 32 ++++++++++++++++---------------- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/jquery.nivo.slider.js b/jquery.nivo.slider.js index b86cd18..41f65ff 100644 --- a/jquery.nivo.slider.js +++ b/jquery.nivo.slider.js @@ -145,8 +145,10 @@ //In the words of Super Mario "let's a go!" var timer = 0; - if(!settings.manualAdvance && vars.totalSlides > 1){ - timer = setInterval(function(){ nivoRun(false); }, settings.pauseTime); + if (vars.totalSlides > 1){ + if(!settings.manualAdvance){ + timer = setInterval(function(){ nivoRun(false); }, settings.pauseTime); + } } else { // "oh dear!" return false; @@ -258,7 +260,7 @@ if(settings.keyboardNav){ $(document).keydown(function(e){ var code = (e.keyCode) ? e.keyCode : e.which; - + //Left if(code === 37 || code === 63234){ if(vars.running){ diff --git a/jquery.nivo.slider.pack.js b/jquery.nivo.slider.pack.js index 75cf47f..88a5c5f 100644 --- a/jquery.nivo.slider.pack.js +++ b/jquery.nivo.slider.pack.js @@ -1,4 +1,4 @@ -/* +/** * jQuery Nivo Slider v2.7.1 * http://nivo.dev7studios.com * @@ -8,18 +8,18 @@ * * January 2012 */ -(function(f,n){function s(){return function(){}}function y(u,q){function v(a){for(var b,f,c=a.length;c;b=parseInt(Math.random()*c),f=a[--c],a[c]=a[b],a[b]=f);return a}function m(d){var h=a.a.data("nivo:vars");if(h&&!h.stop||d){d?(d=="prev"&&a.a.css("background",'url("'+h.b.url+'") no-repeat'),d=="next"&&a.a.css("background",'url("'+h.b.url+'") no-repeat')):a.a.css("background",'url("'+h.b.url+'") no-repeat');++h.d;if(h.d==h.i)h.d=0;else if(h.d<0)h.d=h.i-1;a.c=f(a.h[h.d]);a.c=a.c.is("img")?a.c:a.c.find("img").eq(0);h.b={url:a.c.attr("src"), -title:a.c.attr("title"),z:a.c.data("transition")};b.u&&a.w.removeClass("active").eq(h.d).addClass("active");w();f(".nivo-slice",a.a).remove();f(".nivo-box",a.a).remove();var c=b.n;b.n==="random"&&(d=["sliceDownRight","sliceDownLeft","sliceUpRight","sliceUpLeft","sliceUpDown","sliceUpDownLeft","fold","fade","boxRandom","boxRain","boxRainReverse","boxRainGrow","boxRainGrowReverse"],c=d[Math.floor(Math.random()*(d.length-1))]);b.n.indexOf(",")!==-1&&(d=b.n.split(","),c=d[Math.floor(Math.random()*d.length)]); -if(h.b.z)c=h.b.z;h.j=!0;h=function(d,c,f,h,e){setTimeout(function(){d.animate(c,!f?b.f:f,"",e?function(){a.a.trigger("nivo:animFinished")}:n)},100+h)};switch(c){case "sliceDown":case "sliceDownRight":case "sliceDownLeft":r();var d=0,l=f(".nivo-slice",a.a),j=0;c==="sliceDownLeft"&&(l=l.m());do c=f(l[j]),c.css({top:"0px"}),h(c,{height:"100%",opacity:1},n,d,j===b.e-1?!0:!1),d+=50;while(++j=0&&o').css(i)[0])}while(++g').css(m)[0])}while(++ga.a.width()&&a.a.width(i),t>a.a.height()&&a.a.height(t),e.css("display","none"),++c.i;if(b.M)b.l=Math.floor(Math.random()*c.i);if(b.l>0){if(b.l>=c.i)b.l= -c.i-1;c.d=b.l}a.c=f(a.h[c.d]);a.c.is("img")?(c.b.url=a.c.attr("src"),c.b.title=a.c.attr("title")):(e=a.c.find("img").eq(0),c.b.url=e.attr("src"),c.b.title=e.attr("title"));a.c.is("a")&&a.c.css("display","block");a.a.css("background",'url("'+c.b.url+'") no-repeat').append(f('

').css({display:"none",opacity:b.t}));a.o=f(".nivo-caption",a.a);a.s=a.o.find("p");a.o.css("opacity",0);w();var g=0;if(!b.q&&c.i>1)g=setInterval(function(){m(!1)},b.r);else return!1;if(b.G)a.a.append('"),a.p=f(".nivo-directionNav",a.a),b.H&&(a.p.hide(),a.a.hover(function(){a.p.show()},function(){a.p.hide()})),a.p.children().click(function(){var a=f(this).data("dir"),a=a?a:"next";if(c.j)return!1;clearInterval(g);g=n;a==="prev"&&(c.d-=2);m(a)});if(b.u){e=p="";for(i=a.h.length;--i+1;)b.A?(e=f(a.h[i]),e.is("img")||(e=e.find("img").eq(0)),e=b.B?'':''): -e=i+1,p=''+e+""+p;a.a.append('
'+p+"
");a.N=f(".nivo-controlNav",a.a);a.w=a.N.find("a");a.w.click(function(){var b=f(this);if(c.j||b.hasClass("active"))return!1;clearInterval(g);g=n;a.a.css("background",'url("'+c.b.url+'") no-repeat');c.d=b.data("slide")-1;m("control")}).eq(c.d).addClass("active")}b.I&&f(document).keydown(function(a){a=a.keyCode?a.keyCode:a.which;if(a===37||a===63234){if(c.j)return!1;clearInterval(g); -g=n;c.d-=2;m("prev")}else if(a===39||a===63235){if(c.j)return!1;clearInterval(g);g=n;m("next")}});b.K&&a.a.hover(function(){c.paused=!0;clearInterval(g);g=n},function(){c.paused=!1;g===n&&!b.q&&(g=setInterval(function(){m(!1)},b.r))});a.a.bind("nivo:animFinished",function(){c.j=!1;for(var d,e=a.h.length;--e+1;)d=f(a.h[e]),d.is("a")&&d.css("display","none");a.c.is("a")&&a.c.css("display","block");g==""&&!c.paused&&!b.q&&(g=setInterval(function(){m(!1)},b.r))});this.stop=function(){if(!a.a.data("nivo:vars").stop)a.a.data("nivo:vars").stop= -!0};this.start=function(){if(a.a.data("nivo:vars").stop)a.a.data("nivo:vars").stop=!1};return this}f.fn.nivoSlider=function(u){return this.each(function(){var q=f(this);if(q.data("nivoslider"))return q.data("nivoslider");var v=new y(this,u);q.data("nivoslider",v)})};f.fn.nivoSlider.F={n:"random",e:15,g:8,k:4,f:500,r:3E3,l:0,G:!0,H:!0,u:!0,A:!1,B:!1,D:".jpg",C:"_thumb.jpg",I:!0,K:!0,q:!1,t:0.8,L:"Prev",J:"Next",M:!1,Q:s(),O:s(),S:s(),R:s(),P:s()};f.fn.m=[].reverse})(jQuery,null); \ No newline at end of file +(function(e){var n=null;function s(){return function(){}}function y(u,q){function v(a){for(var b,e,c=a.length;c;b=parseInt(Math.random()*c),e=a[--c],a[c]=a[b],a[b]=e);return a}function m(d){var h=a.a.data("nivo:vars");if(h&&!h.stop||d){d?(d=="prev"&&a.a.css("background",'url("'+h.b.url+'") no-repeat'),d=="next"&&a.a.css("background",'url("'+h.b.url+'") no-repeat')):a.a.css("background",'url("'+h.b.url+'") no-repeat');++h.d;if(h.d==h.i)h.d=0;else if(h.d<0)h.d=h.i-1;a.c=e(a.h[h.d]);a.c=a.c.is("img")?a.c:a.c.find("img").eq(0);h.b={url:a.c.attr("src"), +title:a.c.attr("title"),z:a.c.data("transition")};b.u&&a.w.removeClass("active").eq(h.d).addClass("active");w();e(".nivo-slice",a.a).remove();e(".nivo-box",a.a).remove();var c=b.n;b.n==="random"&&(d=["sliceDownRight","sliceDownLeft","sliceUpRight","sliceUpLeft","sliceUpDown","sliceUpDownLeft","fold","fade","boxRandom","boxRain","boxRainReverse","boxRainGrow","boxRainGrowReverse"],c=d[Math.floor(Math.random()*(d.length-1))]);b.n.indexOf(",")!==-1&&(d=b.n.split(","),c=d[Math.floor(Math.random()*d.length)]); +if(h.b.z)c=h.b.z;h.j=!0;h=function(d,c,e,h,f){setTimeout(function(){d.animate(c,!e?b.f:e,"",f?function(){a.a.trigger("nivo:animFinished")}:n)},100+h)};switch(c){case "sliceDown":case "sliceDownRight":case "sliceDownLeft":r();var d=0,l=e(".nivo-slice",a.a),j=0;c==="sliceDownLeft"&&(l=l.m());do c=e(l[j]),c.css({top:"0px"}),h(c,{height:"100%",opacity:1},n,d,j===b.e-1?!0:!1),d+=50;while(++j=0&&o').css(i)[0])}while(++g').css(m)[0])}while(++ga.a.width()&&a.a.width(i),t>a.a.height()&&a.a.height(t),f.css("display","none"),++c.i;if(b.M)b.l=Math.floor(Math.random()*c.i);if(b.l>0){if(b.l>=c.i)b.l=c.i-1;c.d=b.l}a.c=e(a.h[c.d]); +a.c.is("img")?(c.b.url=a.c.attr("src"),c.b.title=a.c.attr("title")):(f=a.c.find("img").eq(0),c.b.url=f.attr("src"),c.b.title=f.attr("title"));a.c.is("a")&&a.c.css("display","block");a.a.css("background",'url("'+c.b.url+'") no-repeat').append(e('

').css({display:"none",opacity:b.t}));a.o=e(".nivo-caption",a.a);a.s=a.o.find("p");a.o.css("opacity",0);w();var g=0;if(c.i>1)b.q||(g=setInterval(function(){m(!1)},b.r));else return!1;if(b.G)a.a.append('"),a.p=e(".nivo-directionNav",a.a),b.H&&(a.p.hide(),a.a.hover(function(){a.p.show()},function(){a.p.hide()})),a.p.children().click(function(){var a=e(this).data("dir"),a=a?a:"next";if(c.j)return!1;clearInterval(g);g=n;a==="prev"&&(c.d-=2);m(a)});if(b.u){f=p="";for(i=a.h.length;--i+1;)b.A?(f=e(a.h[i]),f.is("img")||(f=f.find("img").eq(0)),f=b.B?'':''): +f=i+1,p=''+f+""+p;a.a.append('
'+p+"
");a.N=e(".nivo-controlNav",a.a);a.w=a.N.find("a");a.w.click(function(){var b=e(this);if(c.j||b.hasClass("active"))return!1;clearInterval(g);g=n;a.a.css("background",'url("'+c.b.url+'") no-repeat');c.d=b.data("slide")-1;m("control")}).eq(c.d).addClass("active")}b.I&&e(document).keydown(function(a){a=a.keyCode?a.keyCode:a.which;if(a===37||a===63234){if(c.j)return!1;clearInterval(g); +g=n;c.d-=2;m("prev")}else if(a===39||a===63235){if(c.j)return!1;clearInterval(g);g=n;m("next")}});b.K&&a.a.hover(function(){c.paused=!0;clearInterval(g);g=n},function(){c.paused=!1;g===n&&!b.q&&(g=setInterval(function(){m(!1)},b.r))});a.a.bind("nivo:animFinished",function(){c.j=!1;for(var d,f=a.h.length;--f+1;)d=e(a.h[f]),d.is("a")&&d.css("display","none");a.c.is("a")&&a.c.css("display","block");g==""&&!c.paused&&!b.q&&(g=setInterval(function(){m(!1)},b.r))});this.stop=function(){if(!a.a.data("nivo:vars").stop)a.a.data("nivo:vars").stop= +!0};this.start=function(){if(a.a.data("nivo:vars").stop)a.a.data("nivo:vars").stop=!1};return this}e.fn.nivoSlider=function(u){return this.each(function(){var q=e(this);if(q.data("nivoslider"))return q.data("nivoslider");var v=new y(this,u);q.data("nivoslider",v)})};e.fn.nivoSlider.F={n:"random",e:15,g:8,k:4,f:500,r:3E3,l:0,G:!0,H:!0,u:!0,A:!1,B:!1,D:".jpg",C:"_thumb.jpg",I:!0,K:!0,q:!1,t:0.8,L:"Prev",J:"Next",M:!1,Q:s(),O:s(),S:s(),R:s(),P:s()};e.fn.m=[].reverse})(jQuery); \ No newline at end of file From 8734c6b6b641f080a31a7b945e9f7b8723eaa51e Mon Sep 17 00:00:00 2001 From: Jason Busby Date: Sat, 21 Jan 2012 17:30:32 +0000 Subject: [PATCH 11/19] Added slideIn effect which slides left or right depending on the nudge type Combined 'slideInLeft' & 'slideInRight' effects Added previousSlideIndex var Fixed 'slideInLeft' effect Improved 'boxRain' loop Repacked Added official Mario quote --- jquery.nivo.slider.js | 76 +++++++++++++++++++++++++------------- jquery.nivo.slider.pack.js | 30 +++++++-------- 2 files changed, 65 insertions(+), 41 deletions(-) diff --git a/jquery.nivo.slider.js b/jquery.nivo.slider.js index 41f65ff..ac4079f 100644 --- a/jquery.nivo.slider.js +++ b/jquery.nivo.slider.js @@ -18,6 +18,7 @@ //Useful variables. Play carefully. var vars = { + previousSlideIndex: 0, currentSlideIndex: 0, currentImage: {}, totalSlides: 0, @@ -86,7 +87,7 @@ vars.currentSlideIndex = settings.startSlide; } - // add caption elements to element object + // add current slide element to element object el.currentSlide = $(el.slides[vars.currentSlideIndex]); //Get initial image @@ -147,10 +148,15 @@ var timer = 0; if (vars.totalSlides > 1){ if(!settings.manualAdvance){ - timer = setInterval(function(){ nivoRun(false); }, settings.pauseTime); + timer = setInterval(function(){ + // store previous index + vars.previousSlideIndex = vars.currentSlideIndex; + + nivoRun(false); + }, settings.pauseTime); } } else { - // "oh dear!" + // "oops. I meant to do that." return false; } @@ -191,6 +197,9 @@ clearInterval(timer); timer = null; + // store previous index + vars.previousSlideIndex = vars.currentSlideIndex; + if (dir === 'prev'){ vars.currentSlideIndex -= 2; } @@ -248,6 +257,9 @@ el.slider.css('background', 'url("'+ vars.currentImage.url +'") no-repeat'); + // store previous index + vars.previousSlideIndex = vars.currentSlideIndex; + vars.currentSlideIndex = anchor.data('slide') - 1; nivoRun('control'); } @@ -261,6 +273,9 @@ $(document).keydown(function(e){ var code = (e.keyCode) ? e.keyCode : e.which; + // store previous index + vars.previousSlideIndex = vars.currentSlideIndex; + //Left if(code === 37 || code === 63234){ if(vars.running){ @@ -299,7 +314,12 @@ //Restart the timer if(timer === null && !settings.manualAdvance){ - timer = setInterval(function(){ nivoRun(false); }, settings.pauseTime); + timer = setInterval(function(){ + // store previous index + vars.previousSlideIndex = vars.currentSlideIndex; + + nivoRun(false); + }, settings.pauseTime); } } ); @@ -327,7 +347,7 @@ } //Restart the timer - if(timer == '' && !vars.paused && !settings.manualAdvance){ + if(timer === null && !vars.paused && !settings.manualAdvance){ timer = setInterval(function(){ nivoRun(false); }, settings.pauseTime); } @@ -458,11 +478,13 @@ //Trigger the slideshowEnd callback if(vars.currentSlideIndex == vars.totalSlides){ + vars.previousSlideIndex = vars.totalSlides - 1; vars.currentSlideIndex = 0; settings.slideshowEnd.call(this); } else if(vars.currentSlideIndex < 0){ - vars.currentSlideIndex = (vars.totalSlides - 1); + vars.previousSlideIndex = 0; + vars.currentSlideIndex = vars.totalSlides - 1; } // update current slide element @@ -499,9 +521,8 @@ currentEffect = anims[Math.floor(Math.random() * (anims.length - 1))]; } - //Run random effect from specified set (eg: effect:'fold,fade') - if(settings.effect.indexOf(',') !== -1){ + else if(settings.effect.indexOf(',') !== -1){ var anims = settings.effect.split(','); currentEffect = anims[Math.floor(Math.random() * anims.length)]; @@ -643,30 +664,31 @@ }); break; + case 'slideIn': + case 'slideInLeft': case 'slideInRight': createSlices(); - var firstSlice = $('.nivo-slice', el.slider).eq(0); - - firstSlice - .css({ height: '100%', width: '0px', opacity: 1}) + var sliderWidth = el.slider.width(), + firstSlice = $('.nivo-slice', el.slider).eq(0), + slideInLeft = (currentEffect === 'slideInLeft' || (currentEffect === 'slideIn' && vars.currentSlideIndex > vars.previousSlideIndex)) ? true : false; - .animate({ width: el.slider.width() +'px' }, (settings.animSpeed * 2), '', function(){ - el.slider.trigger('nivo:animFinished'); - }); - break; + var css = { + left: '', + right: sliderWidth +'px', + width: sliderWidth +'px', + height: '100%', + opacity: 1 + }; - case 'slideInLeft': - createSlices(); - - var firstSlice = $('.nivo-slice', el.slider).eq(0); + if (slideInLeft){ + css.right = -sliderWidth +'px'; + } firstSlice - .css({ height: '100%', width: '0px', opacity: 1, left: '', right: '0px' }) + .css(css) - .animate({ width: el.slider.width() +'px' }, (settings.animSpeed * 2), '', function(){ - // Reset positioning - firstSlice.css({ left: '0px', right: '' }); + .animate({ right: '0px' }, (settings.animSpeed * 2), '', function(){ el.slider.trigger('nivo:animFinished'); }); break; @@ -702,7 +724,8 @@ rowIndex = 0, colIndex = 0, boxes = $('.nivo-box', el.slider), - boxIndex = 0; + boxIndex = 0, + i = totalBoxes; if(currentEffect == 'boxRainReverse' || currentEffect == 'boxRainGrowReverse'){ boxes = boxes._reverse(); @@ -714,6 +737,7 @@ do{ box2Darr[rowIndex][colIndex] = boxes[boxIndex]; ++colIndex; + ++boxIndex; if(colIndex === settings.boxCols){ ++rowIndex; @@ -723,7 +747,7 @@ colIndex = 0; } } - while(++boxIndex < totalBoxes); + while(--i); var cols = 0, rows = 0, diff --git a/jquery.nivo.slider.pack.js b/jquery.nivo.slider.pack.js index 88a5c5f..4cbbdd8 100644 --- a/jquery.nivo.slider.pack.js +++ b/jquery.nivo.slider.pack.js @@ -8,18 +8,18 @@ * * January 2012 */ -(function(e){var n=null;function s(){return function(){}}function y(u,q){function v(a){for(var b,e,c=a.length;c;b=parseInt(Math.random()*c),e=a[--c],a[c]=a[b],a[b]=e);return a}function m(d){var h=a.a.data("nivo:vars");if(h&&!h.stop||d){d?(d=="prev"&&a.a.css("background",'url("'+h.b.url+'") no-repeat'),d=="next"&&a.a.css("background",'url("'+h.b.url+'") no-repeat')):a.a.css("background",'url("'+h.b.url+'") no-repeat');++h.d;if(h.d==h.i)h.d=0;else if(h.d<0)h.d=h.i-1;a.c=e(a.h[h.d]);a.c=a.c.is("img")?a.c:a.c.find("img").eq(0);h.b={url:a.c.attr("src"), -title:a.c.attr("title"),z:a.c.data("transition")};b.u&&a.w.removeClass("active").eq(h.d).addClass("active");w();e(".nivo-slice",a.a).remove();e(".nivo-box",a.a).remove();var c=b.n;b.n==="random"&&(d=["sliceDownRight","sliceDownLeft","sliceUpRight","sliceUpLeft","sliceUpDown","sliceUpDownLeft","fold","fade","boxRandom","boxRain","boxRainReverse","boxRainGrow","boxRainGrowReverse"],c=d[Math.floor(Math.random()*(d.length-1))]);b.n.indexOf(",")!==-1&&(d=b.n.split(","),c=d[Math.floor(Math.random()*d.length)]); -if(h.b.z)c=h.b.z;h.j=!0;h=function(d,c,e,h,f){setTimeout(function(){d.animate(c,!e?b.f:e,"",f?function(){a.a.trigger("nivo:animFinished")}:n)},100+h)};switch(c){case "sliceDown":case "sliceDownRight":case "sliceDownLeft":r();var d=0,l=e(".nivo-slice",a.a),j=0;c==="sliceDownLeft"&&(l=l.m());do c=e(l[j]),c.css({top:"0px"}),h(c,{height:"100%",opacity:1},n,d,j===b.e-1?!0:!1),d+=50;while(++j=0&&o').css(i)[0])}while(++g').css(m)[0])}while(++ga.a.width()&&a.a.width(i),t>a.a.height()&&a.a.height(t),f.css("display","none"),++c.i;if(b.M)b.l=Math.floor(Math.random()*c.i);if(b.l>0){if(b.l>=c.i)b.l=c.i-1;c.d=b.l}a.c=e(a.h[c.d]); -a.c.is("img")?(c.b.url=a.c.attr("src"),c.b.title=a.c.attr("title")):(f=a.c.find("img").eq(0),c.b.url=f.attr("src"),c.b.title=f.attr("title"));a.c.is("a")&&a.c.css("display","block");a.a.css("background",'url("'+c.b.url+'") no-repeat').append(e('

').css({display:"none",opacity:b.t}));a.o=e(".nivo-caption",a.a);a.s=a.o.find("p");a.o.css("opacity",0);w();var g=0;if(c.i>1)b.q||(g=setInterval(function(){m(!1)},b.r));else return!1;if(b.G)a.a.append('"),a.p=e(".nivo-directionNav",a.a),b.H&&(a.p.hide(),a.a.hover(function(){a.p.show()},function(){a.p.hide()})),a.p.children().click(function(){var a=e(this).data("dir"),a=a?a:"next";if(c.j)return!1;clearInterval(g);g=n;a==="prev"&&(c.d-=2);m(a)});if(b.u){f=p="";for(i=a.h.length;--i+1;)b.A?(f=e(a.h[i]),f.is("img")||(f=f.find("img").eq(0)),f=b.B?'':''): -f=i+1,p=''+f+""+p;a.a.append('
'+p+"
");a.N=e(".nivo-controlNav",a.a);a.w=a.N.find("a");a.w.click(function(){var b=e(this);if(c.j||b.hasClass("active"))return!1;clearInterval(g);g=n;a.a.css("background",'url("'+c.b.url+'") no-repeat');c.d=b.data("slide")-1;m("control")}).eq(c.d).addClass("active")}b.I&&e(document).keydown(function(a){a=a.keyCode?a.keyCode:a.which;if(a===37||a===63234){if(c.j)return!1;clearInterval(g); -g=n;c.d-=2;m("prev")}else if(a===39||a===63235){if(c.j)return!1;clearInterval(g);g=n;m("next")}});b.K&&a.a.hover(function(){c.paused=!0;clearInterval(g);g=n},function(){c.paused=!1;g===n&&!b.q&&(g=setInterval(function(){m(!1)},b.r))});a.a.bind("nivo:animFinished",function(){c.j=!1;for(var d,f=a.h.length;--f+1;)d=e(a.h[f]),d.is("a")&&d.css("display","none");a.c.is("a")&&a.c.css("display","block");g==""&&!c.paused&&!b.q&&(g=setInterval(function(){m(!1)},b.r))});this.stop=function(){if(!a.a.data("nivo:vars").stop)a.a.data("nivo:vars").stop= -!0};this.start=function(){if(a.a.data("nivo:vars").stop)a.a.data("nivo:vars").stop=!1};return this}e.fn.nivoSlider=function(u){return this.each(function(){var q=e(this);if(q.data("nivoslider"))return q.data("nivoslider");var v=new y(this,u);q.data("nivoslider",v)})};e.fn.nivoSlider.F={n:"random",e:15,g:8,k:4,f:500,r:3E3,l:0,G:!0,H:!0,u:!0,A:!1,B:!1,D:".jpg",C:"_thumb.jpg",I:!0,K:!0,q:!1,t:0.8,L:"Prev",J:"Next",M:!1,Q:s(),O:s(),S:s(),R:s(),P:s()};e.fn.m=[].reverse})(jQuery); \ No newline at end of file +(function(g){var m=null;function r(){return function(){}}function y(u,s){function v(a){for(var b,e,g=a.length;g;b=parseInt(Math.random()*g),e=a[--g],a[g]=a[b],a[b]=e);return a}function o(c){var d=a.a.data("nivo:vars");if(d&&!d.stop||c){c?(c=="prev"&&a.a.css("background",'url("'+d.c.url+'") no-repeat'),c=="next"&&a.a.css("background",'url("'+d.c.url+'") no-repeat')):a.a.css("background",'url("'+d.c.url+'") no-repeat');++d.b;if(d.b==d.i)d.g=d.i-1,d.b=0;else if(d.b<0)d.g=0,d.b=d.i-1;a.d=g(a.h[d.b]);a.d=a.d.is("img")?a.d:a.d.find("img").eq(0); +d.c={url:a.d.attr("src"),title:a.d.attr("title"),A:a.d.data("transition")};b.v&&a.z.removeClass("active").eq(d.b).addClass("active");w();g(".nivo-slice",a.a).remove();g(".nivo-box",a.a).remove();c=b.o;b.o==="random"?(c=["sliceDownRight","sliceDownLeft","sliceUpRight","sliceUpLeft","sliceUpDown","sliceUpDownLeft","fold","fade","boxRandom","boxRain","boxRainReverse","boxRainGrow","boxRainGrowReverse"],c=c[Math.floor(Math.random()*(c.length-1))]):b.o.indexOf(",")!==-1&&(c=b.o.split(","),c=c[Math.floor(Math.random()* +c.length)]);if(d.c.A)c=d.c.A;d.k=!0;var e=function(c,e,d,g,f){setTimeout(function(){c.animate(e,!d?b.j:d,"",f?function(){a.a.trigger("nivo:animFinished")}:m)},100+g)};switch(c){case "sliceDown":case "sliceDownRight":case "sliceDownLeft":q();var d=0,k=g(".nivo-slice",a.a),i=0;c==="sliceDownLeft"&&(k=k.n());do c=g(k[i]),c.css({top:"0px"}),e(c,{height:"100%",opacity:1},m,d,i===b.e-1?!0:!1),d+=50;while(++id.g)i.right= +-k+"px";e.css(i).animate({right:"0px"},b.j*2,"",function(){a.a.trigger("nivo:animFinished")});break;case "boxRandom":x();var k=b.f*b.l,d=0,n=v(g(".nivo-box",a.a)),l=0,h;do h=g(n[l]),e(h,{opacity:1},m,d,l===k-1?!0:!1),d+=20;while(++l=0&&j').css(l)[0])}while(++j').css(n)[0])}while(++fa.a.width()&&a.a.width(j),t>a.a.height()&&a.a.height(t),f.css("display","none"),++e.i;if(b.N)b.m=Math.floor(Math.random()*e.i);if(b.m>0){if(b.m>=e.i)b.m=e.i-1;e.b=b.m}a.d=g(a.h[e.b]);a.d.is("img")?(e.c.url=a.d.attr("src"),e.c.title=a.d.attr("title")):(f=a.d.find("img").eq(0), +e.c.url=f.attr("src"),e.c.title=f.attr("title"));a.d.is("a")&&a.d.css("display","block");a.a.css("background",'url("'+e.c.url+'") no-repeat').append(g('

').css({display:"none",opacity:b.u}));a.p=g(".nivo-caption",a.a);a.t=a.p.find("p");a.p.css("opacity",0);w();var h=0;if(e.i>1)b.r||(h=setInterval(function(){e.g=e.b;o(!1)},b.s));else return!1;if(b.H)a.a.append('"),a.q=g(".nivo-directionNav",a.a),b.I&&(a.q.hide(),a.a.hover(function(){a.q.show()},function(){a.q.hide()})),a.q.children().click(function(){var a=g(this).data("dir"),a=a?a:"next";if(e.k)return!1;clearInterval(h);h=m;e.g=e.b;a==="prev"&&(e.b-=2);o(a)});if(b.v){f=p="";for(j=a.h.length;--j+1;)b.B?(f=g(a.h[j]),f.is("img")||(f=f.find("img").eq(0)),f=b.C?'':''):f=j+1,p=''+f+""+p;a.a.append('
'+p+"
");a.O=g(".nivo-controlNav",a.a);a.z=a.O.find("a");a.z.click(function(){var c=g(this);if(e.k||c.hasClass("active"))return!1;clearInterval(h);h=m;a.a.css("background",'url("'+e.c.url+'") no-repeat');e.g=e.b;e.b=c.data("slide")-1;o("control")}).eq(e.b).addClass("active")}b.J&&g(document).keydown(function(a){a=a.keyCode?a.keyCode:a.which;e.g=e.b;if(a===37||a===63234){if(e.k)return!1;clearInterval(h);h=m;e.b-=2;o("prev")}else if(a=== +39||a===63235){if(e.k)return!1;clearInterval(h);h=m;o("next")}});b.L&&a.a.hover(function(){e.paused=!0;clearInterval(h);h=m},function(){e.paused=!1;h===m&&!b.r&&(h=setInterval(function(){e.g=e.b;o(!1)},b.s))});a.a.bind("nivo:animFinished",function(){e.k=!1;for(var c,d=a.h.length;--d+1;)c=g(a.h[d]),c.is("a")&&c.css("display","none");a.d.is("a")&&a.d.css("display","block");h===m&&!e.paused&&!b.r&&(h=setInterval(function(){o(!1)},b.s))});this.stop=function(){if(!a.a.data("nivo:vars").stop)a.a.data("nivo:vars").stop= +!0};this.start=function(){if(a.a.data("nivo:vars").stop)a.a.data("nivo:vars").stop=!1};return this}g.fn.nivoSlider=function(u){return this.each(function(){var s=g(this);if(s.data("nivoslider"))return s.data("nivoslider");var v=new y(this,u);s.data("nivoslider",v)})};g.fn.nivoSlider.G={o:"random",e:15,f:8,l:4,j:500,s:3E3,m:0,H:!0,I:!0,v:!0,B:!1,C:!1,F:".jpg",D:"_thumb.jpg",J:!0,L:!0,r:!1,u:0.8,M:"Prev",K:"Next",N:!1,R:r(),P:r(),T:r(),S:r(),Q:r()};g.fn.n=[].reverse})(jQuery); \ No newline at end of file From 1e7d7fe98d3691347de4a623c7970148ff5c524c Mon Sep 17 00:00:00 2001 From: Jason Busby Date: Sat, 21 Jan 2012 18:55:39 +0000 Subject: [PATCH 12/19] Reworked 'slideInLeft' animation css --- jquery.nivo.slider.js | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/jquery.nivo.slider.js b/jquery.nivo.slider.js index ac4079f..79728ef 100644 --- a/jquery.nivo.slider.js +++ b/jquery.nivo.slider.js @@ -368,7 +368,7 @@ background: '', left: '', width: '', - height: '0px', + height: '0', opacity: 0 }; @@ -560,7 +560,7 @@ do{ slice = $(slices[sliceIndex]); - slice.css({ 'top': '0px' }); + slice.css({ 'top': '0' }); timedAnimate(slice, { height: '100%', opacity: 1 }, null, timeBuff, (sliceIndex === settings.slices - 1) ? true : false); @@ -586,7 +586,7 @@ do{ slice = $(slices[sliceIndex]); - slice.css({ 'bottom': '0px' }); + slice.css({ 'bottom': '0' }); timedAnimate(slice, { height: '100%', opacity: 1 }, null, timeBuff, (sliceIndex === settings.slices - 1) ? true : false); @@ -614,9 +614,9 @@ slice = $(slices[sliceIndex]); if(top){ - slice.css('top', '0px'); + slice.css('top', '0'); } else { - slice.css('bottom', '0px'); + slice.css('bottom', '0'); } // flip bool top = !top; @@ -641,7 +641,7 @@ slice = $(slices[sliceIndex]); sliceWidth = slice.width(); - slice.css({ top: '0px', height: '100%', width: '0px' }); + slice.css({ top: '0', height: '100%', width: '0' }); timedAnimate(slice, { width: sliceWidth +'px', opacity: 1 }, null, timeBuff, (sliceIndex === settings.slices - 1) ? true : false); @@ -669,26 +669,22 @@ case 'slideInRight': createSlices(); - var sliderWidth = el.slider.width(), - firstSlice = $('.nivo-slice', el.slider).eq(0), - slideInLeft = (currentEffect === 'slideInLeft' || (currentEffect === 'slideIn' && vars.currentSlideIndex > vars.previousSlideIndex)) ? true : false; + var firstSlice = $('.nivo-slice', el.slider).eq(0), + slideInLeft = (currentEffect === 'slideInLeft' || (currentEffect === 'slideIn' && vars.currentSlideIndex < vars.previousSlideIndex)) ? true : false; var css = { - left: '', - right: sliderWidth +'px', - width: sliderWidth +'px', + backgroundPosition: (slideInLeft) ? '100% 0' : '0 0', + left: (slideInLeft) ? '0' : '', + right: (slideInLeft) ? '' : '0', + width: '0', height: '100%', opacity: 1 }; - if (slideInLeft){ - css.right = -sliderWidth +'px'; - } - firstSlice .css(css) - .animate({ right: '0px' }, (settings.animSpeed * 2), '', function(){ + .animate({ width: el.slider.width() }, (settings.animSpeed * 2), '', function(){ el.slider.trigger('nivo:animFinished'); }); break; From b096465801c82ab179d5c2431bfddabc3514aab4 Mon Sep 17 00:00:00 2001 From: Jason Busby Date: Thu, 26 Jan 2012 02:01:43 +0000 Subject: [PATCH 13/19] Added cycle, cycleLeft & cycleRight effect (aka sliding) Added overflow hidden to CSS nivoSlider class for cycle effect Added slice limit attribute to createSlices function Repacked --- jquery.nivo.slider.js | 260 +++++++++++++++++++++++-------------- jquery.nivo.slider.pack.js | 32 ++--- nivo-slider.css | 1 + 3 files changed, 180 insertions(+), 113 deletions(-) diff --git a/jquery.nivo.slider.js b/jquery.nivo.slider.js index 79728ef..b661745 100644 --- a/jquery.nivo.slider.js +++ b/jquery.nivo.slider.js @@ -81,9 +81,12 @@ //Set startSlide if(settings.startSlide > 0){ + // limit startslide at total slides count if(settings.startSlide >= vars.totalSlides){ settings.startSlide = vars.totalSlides - 1; } + + vars.previousSlideIndex = settings.startSlide - 1; vars.currentSlideIndex = settings.startSlide; } @@ -92,12 +95,16 @@ //Get initial image if(el.currentSlide.is('img')){ - vars.currentImage.url = el.currentSlide.attr('src'); - vars.currentImage.title = el.currentSlide.attr('title'); + vars.currentImage = { + url: el.currentSlide.attr('src'), + title: el.currentSlide.attr('title') + }; } else { - var img = el.currentSlide.find('img').eq(0); - vars.currentImage.url = img.attr('src'); - vars.currentImage.title = img.attr('title'); + vars.currentImage = el.currentSlide.find('img').eq(0); + vars.currentImage = { + url: vars.currentImage.attr('src'), + title: vars.currentImage.attr('title') + }; } //Show initial link @@ -122,7 +129,7 @@ // Process caption function var processCaption = function(){ - var title = (vars.currentImage.title) ? vars.currentImage.title : null; + var title = vars.currentImage.title || null; if(title){ if(title.substr(0,1) == '#'){ @@ -144,21 +151,17 @@ //Process initial caption processCaption(); - //In the words of Super Mario "let's a go!" - var timer = 0; - if (vars.totalSlides > 1){ - if(!settings.manualAdvance){ - timer = setInterval(function(){ - // store previous index - vars.previousSlideIndex = vars.currentSlideIndex; - - nivoRun(false); - }, settings.pauseTime); - } - } else { - // "oops. I meant to do that." + // we need more than one slide! + if(vars.totalSlides < 2){ return false; } + + var timer = null; + + //In the words of Super Mario "let's a go!" + if(!settings.manualAdvance){ + timer = setInterval(function(){ nivoRun(false); }, settings.pauseTime); + } //Add Direction nav if(settings.directionNav){ @@ -187,8 +190,7 @@ .children() .click( function(){ - var dir = $(this).data('dir'); - dir = (dir) ? dir : 'next'; + var dir = $(this).data('dir') || 'next'; if(vars.running){ return false; @@ -197,10 +199,8 @@ clearInterval(timer); timer = null; - // store previous index - vars.previousSlideIndex = vars.currentSlideIndex; - if (dir === 'prev'){ + vars.previousSlideIndex -= 1; vars.currentSlideIndex -= 2; } nivoRun(dir); @@ -257,9 +257,6 @@ el.slider.css('background', 'url("'+ vars.currentImage.url +'") no-repeat'); - // store previous index - vars.previousSlideIndex = vars.currentSlideIndex; - vars.currentSlideIndex = anchor.data('slide') - 1; nivoRun('control'); } @@ -271,30 +268,22 @@ //Keyboard Navigation if(settings.keyboardNav){ $(document).keydown(function(e){ - var code = (e.keyCode) ? e.keyCode : e.which; + var code = e.keyCode || e.which; + + if(vars.running){ + return false; + } - // store previous index - vars.previousSlideIndex = vars.currentSlideIndex; + clearInterval(timer); + timer = null; //Left if(code === 37 || code === 63234){ - if(vars.running){ - return false; - } - - clearInterval(timer); - timer = null; vars.currentSlideIndex -= 2; nivoRun('prev'); } //Right else if(code === 39 || code === 63235){ - if(vars.running){ - return false; - } - - clearInterval(timer); - timer = null; nivoRun('next'); } }); @@ -314,12 +303,7 @@ //Restart the timer if(timer === null && !settings.manualAdvance){ - timer = setInterval(function(){ - // store previous index - vars.previousSlideIndex = vars.currentSlideIndex; - - nivoRun(false); - }, settings.pauseTime); + timer = setInterval(function(){ nivoRun(false); }, settings.pauseTime); } } ); @@ -356,10 +340,11 @@ }); // Add slices for slice animations - var createSlices = function(){ + var createSlices = function(slices){ var sliderImg = vars.currentImage.url, sliderWidth = el.slider.width(), - slices = 0, + i = 0, + sliceLimit = slices || settings.slices, slicesHTML = document.createDocumentFragment(), sliceWidth, offset; @@ -373,22 +358,22 @@ }; do{ - sliceWidth = Math.round(sliderWidth / settings.slices); - offset = sliceWidth * slices; + sliceWidth = Math.round(sliderWidth / sliceLimit); + offset = sliceWidth * i; css.left = offset +'px'; css.background = 'url("'+ sliderImg +'") no-repeat -'+ ((sliceWidth + offset) - sliceWidth) +'px 0%'; css.width = sliceWidth +'px'; // fix up uneven spacing - if(slices == settings.slices - 1){ + if(i === sliceLimit - 1){ css.width = (sliderWidth - offset) +'px'; } // add slice to fragment - use jQuery to add css slicesHTML.appendChild($('
').css(css)[0]); } - while(++slices < settings.slices); + while(++i < sliceLimit); // insert slices as a whole el.slider.append(slicesHTML); @@ -401,8 +386,8 @@ boxHeight = Math.round(el.slider.height() / settings.boxRows), boxesHTML = document.createDocumentFragment(), offsetLeft = 0, - rows = 0, - cols = 0; + row = 0, + col = 0; var css = { background: 'url("'+ vars.currentImage.url +'") no-repeat', @@ -416,30 +401,30 @@ do{ // row specific styles - css.top = (boxHeight * rows) +'px'; + css.top = (boxHeight * row) +'px'; css.width = boxWidth +'px'; do{ - offsetLeft = boxWidth * cols; + offsetLeft = boxWidth * col; // column specific styles - css.left = (boxWidth * cols) +'px'; - css.backgroundPosition = '-'+ ((boxWidth + offsetLeft) - boxWidth) +'px -'+ ((boxHeight + (rows * boxHeight)) - boxHeight) +'px'; + css.left = offsetLeft +'px'; + css.backgroundPosition = '-'+ ((boxWidth + offsetLeft) - boxWidth) +'px -'+ ((boxHeight + (row * boxHeight)) - boxHeight) +'px'; // fix up uneven spacing - if(cols === settings.boxCols - 1){ + if(col === settings.boxCols - 1){ css.width = (sliderWidth - offsetLeft) +'px'; } // add box to fragment - use jQuery to add css boxesHTML.appendChild($('
').css(css)[0]); } - while(++cols < settings.boxCols); + while(++col < settings.boxCols); // reset columns - cols = 0; + col = 0; } - while(++rows < settings.boxRows); + while(++row < settings.boxRows); // insert boxes as a whole el.slider.append(boxesHTML); @@ -456,47 +441,53 @@ } // Stop - if((!vars || vars.stop) && !nudge) return false; + if((!vars || vars.stop) && !nudge){ + return false; + } //Trigger the beforeChange callback settings.beforeChange.call(this); //Set current background before change - if(!nudge){ - el.slider.css('background','url("'+ vars.currentImage.url +'") no-repeat'); - } else { - if(nudge == 'prev'){ - el.slider.css('background','url("'+ vars.currentImage.url +'") no-repeat'); - } - if(nudge == 'next'){ - el.slider.css('background','url("'+ vars.currentImage.url +'") no-repeat'); - } - } + el.slider.css('background','url("'+ vars.currentImage.url +'") no-repeat'); + + // previous index is stored at the end of this function - // increment current slide + // increment current index ++vars.currentSlideIndex; - //Trigger the slideshowEnd callback - if(vars.currentSlideIndex == vars.totalSlides){ + if(vars.currentSlideIndex >= vars.totalSlides){ vars.previousSlideIndex = vars.totalSlides - 1; vars.currentSlideIndex = 0; + + //Trigger the slideshowEnd callback settings.slideshowEnd.call(this); } + else if(vars.currentSlideIndex === 0){ + vars.previousSlideIndex = vars.totalSlides - 1; + } else if(vars.currentSlideIndex < 0){ - vars.previousSlideIndex = 0; vars.currentSlideIndex = vars.totalSlides - 1; + vars.previousSlideIndex = vars.totalSlides - 2; } + // update previous slide element + el.previousSlide = el.currentSlide; + // update current slide element el.currentSlide = $(el.slides[vars.currentSlideIndex]); el.currentSlide = (el.currentSlide.is('img')) ? el.currentSlide : el.currentSlide.find('img').eq(0); - //Set vars.currentImage + //Set slide images + vars.previousImage = { + url: el.previousSlide.attr('src') + }; + vars.currentImage = { url: el.currentSlide.attr('src'), title: el.currentSlide.attr('title'), transition: el.currentSlide.data('transition') - } + }; //Set active links if(settings.controlNav){ @@ -508,16 +499,15 @@ // Remove any slices from last transition $('.nivo-slice', el.slider).remove(); - // Remove any boxes from last transition $('.nivo-box', el.slider).remove(); - var currentEffect = settings.effect; + var currentEffect = settings.effect || 'fade'; //Generate random effect if(settings.effect === 'random'){ var anims = ['sliceDownRight','sliceDownLeft','sliceUpRight','sliceUpLeft','sliceUpDown','sliceUpDownLeft','fold','fade', - 'boxRandom','boxRain','boxRainReverse','boxRainGrow','boxRainGrowReverse']; + 'cycle', 'boxRandom','boxRain','boxRainReverse','boxRainGrow','boxRainGrowReverse']; currentEffect = anims[Math.floor(Math.random() * (anims.length - 1))]; } @@ -538,7 +528,7 @@ var timedAnimate = function(element, css, speed, buff, end){ setTimeout(function(){ - element.animate(css, (!speed) ? settings.animSpeed : speed, '', (end) ? function(){ el.slider.trigger('nivo:animFinished'); } : null); + element.animate(css, (speed || settings.animSpeed), '', (end && function(){ el.slider.trigger('nivo:animFinished'); })); }, 100 + buff) } @@ -652,39 +642,110 @@ default: case 'fade': - createSlices(); + createSlices(1); - var firstSlice = $('.nivo-slice', el.slider).eq(0); + var slice = $('.nivo-slice', el.slider); - firstSlice - .css({ height: '100%', width: el.slider.width() +'px' }) + slice + .css({ width: el.slider.width() +'px', height: '100%' }) .animate({ opacity: 1 }, (settings.animSpeed * 2), '', function(){ el.slider.trigger('nivo:animFinished'); }); break; - case 'slideIn': + case 'cycle': + case 'cycleLeft': + case 'cycleRight': + createSlices(1); + + var sliderWidth = el.slider.width(), + slice = $('.nivo-slice', el.slider), + cycleLeft = (currentEffect === 'cycleLeft' || (currentEffect === 'cycle' && (nudge === 'prev' || (nudge === 'control' && vars.currentSlideIndex < vars.previousSlideIndex)))) ? true : false, + css1, css2, + sliceHTML = document.createDocumentFragment(); + + css1 = { + position: 'absolute', + right: (cycleLeft) ? '0' : sliderWidth +'px', + background: 'url("'+ vars.previousImage.url +'")', + width: sliderWidth +'px', + height: '100%' + }; + + css2 = { + position: 'absolute', + right: (cycleLeft) ? sliderWidth +'px' : '0', + backgroundImage: 'url("'+ vars.currentImage.url +'")', + width: sliderWidth +'px', + height: '100%' + }; + + sliceHTML.appendChild($('
').css(css1)[0]); + sliceHTML.appendChild($('
').css(css2)[0]); + slice.html(sliceHTML); + + var css = { + left: (cycleLeft) ? -sliderWidth +'px' : '0', + width: (sliderWidth * 2) +'px', + height: '100%', + opacity: 1 + }; + + slice + .css(css) + + .animate({ left: ((cycleLeft) ? '0' : -sliderWidth +'px') }, (settings.animSpeed * 2), '', function(){ + el.slider.trigger('nivo:animFinished'); + }); + break; + + case 'slideInHorizontal': case 'slideInLeft': case 'slideInRight': - createSlices(); + createSlices(1); - var firstSlice = $('.nivo-slice', el.slider).eq(0), - slideInLeft = (currentEffect === 'slideInLeft' || (currentEffect === 'slideIn' && vars.currentSlideIndex < vars.previousSlideIndex)) ? true : false; + var slice = $('.nivo-slice', el.slider), + slideInLeft = (currentEffect === 'slideInLeft' || (currentEffect === 'slideInHorizontal' && (nudge === 'prev' || (nudge === 'control' && vars.currentSlideIndex < vars.previousSlideIndex)))) ? true : false; var css = { - backgroundPosition: (slideInLeft) ? '100% 0' : '0 0', left: (slideInLeft) ? '0' : '', right: (slideInLeft) ? '' : '0', + backgroundPosition: (slideInLeft) ? '100% 0' : '0 0', width: '0', height: '100%', opacity: 1 }; - firstSlice + slice + .css(css) + + .animate({ width: '100%' }, (settings.animSpeed * 2), '', function(){ + el.slider.trigger('nivo:animFinished'); + }); + break; + + case 'slideInVertical': + case 'slideInTop': + case 'slideInBottom': + createSlices(1); + + var slice = $('.nivo-slice', el.slider), + slideInTop = (currentEffect === 'slideInTop' || (currentEffect === 'slideInVertical' && (nudge === 'prev' || (nudge === 'control' && vars.currentSlideIndex > vars.previousSlideIndex)))) ? true : false; + + var css = { + top: (slideInTop) ? '0' : '', + bottom: (slideInTop) ? '' : '0', + backgroundPosition: (slideInTop) ? '0 100%' : '0 0', + width: '100%', + height: '0', + opacity: 1 + }; + + slice .css(css) - .animate({ width: el.slider.width() }, (settings.animSpeed * 2), '', function(){ + .animate({ height: '100%' }, (settings.animSpeed * 2), '', function(){ el.slider.trigger('nivo:animFinished'); }); break; @@ -782,6 +843,9 @@ while(++cols < (settings.boxCols * 2)); break; } + + // save current index as previous index + vars.previousSlideIndex = vars.currentSlideIndex; } // Shuffle an array @@ -795,13 +859,13 @@ if(!el.slider.data('nivo:vars').stop){ el.slider.data('nivo:vars').stop = true; } - } + }; this.start = function(){ if(el.slider.data('nivo:vars').stop){ el.slider.data('nivo:vars').stop = false; } - } + }; //Trigger the afterLoad callback settings.afterLoad.call(this); diff --git a/jquery.nivo.slider.pack.js b/jquery.nivo.slider.pack.js index 4cbbdd8..45e9f74 100644 --- a/jquery.nivo.slider.pack.js +++ b/jquery.nivo.slider.pack.js @@ -8,18 +8,20 @@ * * January 2012 */ -(function(g){var m=null;function r(){return function(){}}function y(u,s){function v(a){for(var b,e,g=a.length;g;b=parseInt(Math.random()*g),e=a[--g],a[g]=a[b],a[b]=e);return a}function o(c){var d=a.a.data("nivo:vars");if(d&&!d.stop||c){c?(c=="prev"&&a.a.css("background",'url("'+d.c.url+'") no-repeat'),c=="next"&&a.a.css("background",'url("'+d.c.url+'") no-repeat')):a.a.css("background",'url("'+d.c.url+'") no-repeat');++d.b;if(d.b==d.i)d.g=d.i-1,d.b=0;else if(d.b<0)d.g=0,d.b=d.i-1;a.d=g(a.h[d.b]);a.d=a.d.is("img")?a.d:a.d.find("img").eq(0); -d.c={url:a.d.attr("src"),title:a.d.attr("title"),A:a.d.data("transition")};b.v&&a.z.removeClass("active").eq(d.b).addClass("active");w();g(".nivo-slice",a.a).remove();g(".nivo-box",a.a).remove();c=b.o;b.o==="random"?(c=["sliceDownRight","sliceDownLeft","sliceUpRight","sliceUpLeft","sliceUpDown","sliceUpDownLeft","fold","fade","boxRandom","boxRain","boxRainReverse","boxRainGrow","boxRainGrowReverse"],c=c[Math.floor(Math.random()*(c.length-1))]):b.o.indexOf(",")!==-1&&(c=b.o.split(","),c=c[Math.floor(Math.random()* -c.length)]);if(d.c.A)c=d.c.A;d.k=!0;var e=function(c,e,d,g,f){setTimeout(function(){c.animate(e,!d?b.j:d,"",f?function(){a.a.trigger("nivo:animFinished")}:m)},100+g)};switch(c){case "sliceDown":case "sliceDownRight":case "sliceDownLeft":q();var d=0,k=g(".nivo-slice",a.a),i=0;c==="sliceDownLeft"&&(k=k.n());do c=g(k[i]),c.css({top:"0px"}),e(c,{height:"100%",opacity:1},m,d,i===b.e-1?!0:!1),d+=50;while(++id.g)i.right= --k+"px";e.css(i).animate({right:"0px"},b.j*2,"",function(){a.a.trigger("nivo:animFinished")});break;case "boxRandom":x();var k=b.f*b.l,d=0,n=v(g(".nivo-box",a.a)),l=0,h;do h=g(n[l]),e(h,{opacity:1},m,d,l===k-1?!0:!1),d+=20;while(++l=0&&j').css(l)[0])}while(++j').css(n)[0])}while(++fa.a.width()&&a.a.width(j),t>a.a.height()&&a.a.height(t),f.css("display","none"),++e.i;if(b.N)b.m=Math.floor(Math.random()*e.i);if(b.m>0){if(b.m>=e.i)b.m=e.i-1;e.b=b.m}a.d=g(a.h[e.b]);a.d.is("img")?(e.c.url=a.d.attr("src"),e.c.title=a.d.attr("title")):(f=a.d.find("img").eq(0), -e.c.url=f.attr("src"),e.c.title=f.attr("title"));a.d.is("a")&&a.d.css("display","block");a.a.css("background",'url("'+e.c.url+'") no-repeat').append(g('

').css({display:"none",opacity:b.u}));a.p=g(".nivo-caption",a.a);a.t=a.p.find("p");a.p.css("opacity",0);w();var h=0;if(e.i>1)b.r||(h=setInterval(function(){e.g=e.b;o(!1)},b.s));else return!1;if(b.H)a.a.append('"),a.q=g(".nivo-directionNav",a.a),b.I&&(a.q.hide(),a.a.hover(function(){a.q.show()},function(){a.q.hide()})),a.q.children().click(function(){var a=g(this).data("dir"),a=a?a:"next";if(e.k)return!1;clearInterval(h);h=m;e.g=e.b;a==="prev"&&(e.b-=2);o(a)});if(b.v){f=p="";for(j=a.h.length;--j+1;)b.B?(f=g(a.h[j]),f.is("img")||(f=f.find("img").eq(0)),f=b.C?'':''):f=j+1,p=''+f+""+p;a.a.append('
'+p+"
");a.O=g(".nivo-controlNav",a.a);a.z=a.O.find("a");a.z.click(function(){var c=g(this);if(e.k||c.hasClass("active"))return!1;clearInterval(h);h=m;a.a.css("background",'url("'+e.c.url+'") no-repeat');e.g=e.b;e.b=c.data("slide")-1;o("control")}).eq(e.b).addClass("active")}b.J&&g(document).keydown(function(a){a=a.keyCode?a.keyCode:a.which;e.g=e.b;if(a===37||a===63234){if(e.k)return!1;clearInterval(h);h=m;e.b-=2;o("prev")}else if(a=== -39||a===63235){if(e.k)return!1;clearInterval(h);h=m;o("next")}});b.L&&a.a.hover(function(){e.paused=!0;clearInterval(h);h=m},function(){e.paused=!1;h===m&&!b.r&&(h=setInterval(function(){e.g=e.b;o(!1)},b.s))});a.a.bind("nivo:animFinished",function(){e.k=!1;for(var c,d=a.h.length;--d+1;)c=g(a.h[d]),c.is("a")&&c.css("display","none");a.d.is("a")&&a.d.css("display","block");h===m&&!e.paused&&!b.r&&(h=setInterval(function(){o(!1)},b.s))});this.stop=function(){if(!a.a.data("nivo:vars").stop)a.a.data("nivo:vars").stop= -!0};this.start=function(){if(a.a.data("nivo:vars").stop)a.a.data("nivo:vars").stop=!1};return this}g.fn.nivoSlider=function(u){return this.each(function(){var s=g(this);if(s.data("nivoslider"))return s.data("nivoslider");var v=new y(this,u);s.data("nivoslider",v)})};g.fn.nivoSlider.G={o:"random",e:15,f:8,l:4,j:500,s:3E3,m:0,H:!0,I:!0,v:!0,B:!1,C:!1,F:".jpg",D:"_thumb.jpg",J:!0,L:!0,r:!1,u:0.8,M:"Prev",K:"Next",N:!1,R:r(),P:r(),T:r(),S:r(),Q:r()};g.fn.n=[].reverse})(jQuery); \ No newline at end of file +(function(e){var o=null;function s(){return function(){}}function z(v,t){function w(a){for(var b,d,e=a.length;e;b=parseInt(Math.random()*e),d=a[--e],a[e]=a[b],a[b]=d);return a}function p(c){var g=a.a.data("nivo:vars");if(g&&!g.stop||c){a.a.css("background",'url("'+g.d.url+'") no-repeat');++g.b;if(g.b>=g.e)g.g=g.e-1,g.b=0;else if(g.b===0)g.g=g.e-1;else if(g.b<0)g.b=g.e-1,g.g=g.e-2;a.O=a.c;a.c=e(a.j[g.b]);a.c=a.c.is("img")?a.c:a.c.find("img").eq(0);g.N={url:a.O.attr("src")};g.d={url:a.c.attr("src"),title:a.c.attr("title"),A:a.c.data("transition")}; +b.v&&a.z.removeClass("active").eq(g.b).addClass("active");x();e(".nivo-slice",a.a).remove();e(".nivo-box",a.a).remove();var d=b.o||"fade";b.o==="random"?(d=["sliceDownRight","sliceDownLeft","sliceUpRight","sliceUpLeft","sliceUpDown","sliceUpDownLeft","fold","fade","cycle","boxRandom","boxRain","boxRainReverse","boxRainGrow","boxRainGrowReverse"],d=d[Math.floor(Math.random()*(d.length-1))]):b.o.indexOf(",")!==-1&&(d=b.o.split(","),d=d[Math.floor(Math.random()*d.length)]);if(g.d.A)d=g.d.A;g.m=!0;var f= +function(c,d,e,f,g){setTimeout(function(){c.animate(d,e||b.f,"",g&&function(){a.a.trigger("nivo:animFinished")})},100+f)};switch(d){case "sliceDown":case "sliceDownRight":case "sliceDownLeft":r();var c=0,k=e(".nivo-slice",a.a),j=0,h;d==="sliceDownLeft"&&(k=k.n());do h=e(k[j]),h.css({top:"0"}),f(h,{height:"100%",opacity:1},o,c,j===b.h-1?!0:!1),c+=50;while(++j").css(c)[0]);j.appendChild(e("
").css(k)[0]);h.html(j);c={left:d?-f+"px":"0",width:f*2+"px",height:"100%",opacity:1};h.css(c).animate({left:d?"0":-f+"px"},b.f*2,"",function(){a.a.trigger("nivo:animFinished")});break;case "slideInHorizontal":case "slideInLeft":case "slideInRight":r(1);h=e(".nivo-slice",a.a);d=d=== +"slideInLeft"||d==="slideInHorizontal"&&(c==="prev"||c==="control"&&g.bg.g)?!0:!1;c={top:d?"0":"",bottom:d?"":"0",backgroundPosition:d? +"0 100%":"0 0",width:"100%",height:"0",opacity:1};h.css(c).animate({height:"100%"},b.f*2,"",function(){a.a.trigger("nivo:animFinished")});break;case "boxRandom":y();h=b.i*b.l;var c=0,i=w(e(".nivo-box",a.a)),m=0;do l=e(i[m]),f(l,{opacity:1},o,c,m===h-1?!0:!1),c+=20;while(++m=0&&n').css(l)[0])}while(++h').css(l)[0])}while(++ia.a.width()&&a.a.width(n),u>a.a.height()&&a.a.height(u),i.css("display","none"),++f.e;if(b.P)b.k=Math.floor(Math.random()*f.e);if(b.k>0){if(b.k>=f.e)b.k=f.e-1;f.g=b.k-1;f.b=b.k}a.c=e(a.j[f.b]);a.c.is("img")?f.d={url:a.c.attr("src"),title:a.c.attr("title")}: +(f.d=a.c.find("img").eq(0),f.d={url:f.d.attr("src"),title:f.d.attr("title")});a.c.is("a")&&a.c.css("display","block");a.a.css("background",'url("'+f.d.url+'") no-repeat').append(e('

').css({display:"none",opacity:b.u}));a.p=e(".nivo-caption",a.a);a.t=a.p.find("p");a.p.css("opacity",0);x();if(f.e<2)return!1;var m=o;b.r||(m=setInterval(function(){p(!1)},b.s));if(b.H)a.a.append('"),a.q=e(".nivo-directionNav",a.a),b.I&&(a.q.hide(),a.a.hover(function(){a.q.show()},function(){a.q.hide()})),a.q.children().click(function(){var a=e(this).data("dir")||"next";if(f.m)return!1;clearInterval(m);m=o;a==="prev"&&(f.g-=1,f.b-=2);p(a)});if(b.v){i=q="";for(n=a.j.length;--n+1;)b.B?(i=e(a.j[n]),i.is("img")||(i=i.find("img").eq(0)),i=b.C?'':''):i=n+1,q=''+i+""+q;a.a.append('
'+q+"
");a.Q=e(".nivo-controlNav",a.a);a.z=a.Q.find("a");a.z.click(function(){var c=e(this);if(f.m||c.hasClass("active"))return!1;clearInterval(m);m=o;a.a.css("background",'url("'+f.d.url+'") no-repeat');f.b=c.data("slide")-1;p("control")}).eq(f.b).addClass("active")}b.J&&e(document).keydown(function(a){a=a.keyCode||a.which;if(f.m)return!1;clearInterval(m);m=o;a===37||a===63234?(f.b-=2,p("prev")):(a===39||a===63235)&&p("next")});b.L&& +a.a.hover(function(){f.paused=!0;clearInterval(m);m=o},function(){f.paused=!1;m===o&&!b.r&&(m=setInterval(function(){p(!1)},b.s))});a.a.bind("nivo:animFinished",function(){f.m=!1;for(var c,g=a.j.length;--g+1;)c=e(a.j[g]),c.is("a")&&c.css("display","none");a.c.is("a")&&a.c.css("display","block");m===o&&!f.paused&&!b.r&&(m=setInterval(function(){p(!1)},b.s))});this.stop=function(){if(!a.a.data("nivo:vars").stop)a.a.data("nivo:vars").stop=!0};this.start=function(){if(a.a.data("nivo:vars").stop)a.a.data("nivo:vars").stop= +!1};return this}e.fn.nivoSlider=function(v){return this.each(function(){var t=e(this);if(t.data("nivoslider"))return t.data("nivoslider");var w=new z(this,v);t.data("nivoslider",w)})};e.fn.nivoSlider.G={o:"random",h:15,i:8,l:4,f:500,s:3E3,k:0,H:!0,I:!0,v:!0,B:!1,C:!1,F:".jpg",D:"_thumb.jpg",J:!0,L:!0,r:!1,u:0.8,M:"Prev",K:"Next",P:!1,T:s(),R:s(),V:s(),U:s(),S:s()};e.fn.n=[].reverse})(jQuery); \ No newline at end of file diff --git a/nivo-slider.css b/nivo-slider.css index 4fd76ea..e4228fb 100644 --- a/nivo-slider.css +++ b/nivo-slider.css @@ -13,6 +13,7 @@ /* The Nivo Slider styles */ .nivoSlider { position:relative; + overflow:hidden; } .nivoSlider img { position:absolute; From 9a22de43403d26380241e7b9c012f39a99e0c6d3 Mon Sep 17 00:00:00 2001 From: Jason Busby Date: Thu, 26 Jan 2012 02:56:35 +0000 Subject: [PATCH 14/19] Removed redundant code (oops!) Repacked --- jquery.nivo.slider.js | 26 ++++++++++---------------- jquery.nivo.slider.pack.js | 34 +++++++++++++++++----------------- 2 files changed, 27 insertions(+), 33 deletions(-) diff --git a/jquery.nivo.slider.js b/jquery.nivo.slider.js index b661745..25f551b 100644 --- a/jquery.nivo.slider.js +++ b/jquery.nivo.slider.js @@ -85,7 +85,7 @@ if(settings.startSlide >= vars.totalSlides){ settings.startSlide = vars.totalSlides - 1; } - + vars.previousSlideIndex = settings.startSlide - 1; vars.currentSlideIndex = settings.startSlide; } @@ -155,7 +155,7 @@ if(vars.totalSlides < 2){ return false; } - + var timer = null; //In the words of Super Mario "let's a go!" @@ -200,7 +200,6 @@ timer = null; if (dir === 'prev'){ - vars.previousSlideIndex -= 1; vars.currentSlideIndex -= 2; } nivoRun(dir); @@ -269,7 +268,7 @@ if(settings.keyboardNav){ $(document).keydown(function(e){ var code = e.keyCode || e.which; - + if(vars.running){ return false; } @@ -457,23 +456,18 @@ ++vars.currentSlideIndex; if(vars.currentSlideIndex >= vars.totalSlides){ - vars.previousSlideIndex = vars.totalSlides - 1; vars.currentSlideIndex = 0; //Trigger the slideshowEnd callback settings.slideshowEnd.call(this); } - else if(vars.currentSlideIndex === 0){ - vars.previousSlideIndex = vars.totalSlides - 1; - } else if(vars.currentSlideIndex < 0){ vars.currentSlideIndex = vars.totalSlides - 1; - vars.previousSlideIndex = vars.totalSlides - 2; } // update previous slide element el.previousSlide = el.currentSlide; - + // update current slide element el.currentSlide = $(el.slides[vars.currentSlideIndex]); el.currentSlide = (el.currentSlide.is('img')) ? el.currentSlide : el.currentSlide.find('img').eq(0); @@ -507,7 +501,7 @@ //Generate random effect if(settings.effect === 'random'){ var anims = ['sliceDownRight','sliceDownLeft','sliceUpRight','sliceUpLeft','sliceUpDown','sliceUpDownLeft','fold','fade', - 'cycle', 'boxRandom','boxRain','boxRainReverse','boxRainGrow','boxRainGrowReverse']; + 'cycle','boxRandom','boxRain','boxRainReverse','boxRainGrow','boxRainGrowReverse']; currentEffect = anims[Math.floor(Math.random() * (anims.length - 1))]; } @@ -672,7 +666,7 @@ width: sliderWidth +'px', height: '100%' }; - + css2 = { position: 'absolute', right: (cycleLeft) ? sliderWidth +'px' : '0', @@ -680,11 +674,11 @@ width: sliderWidth +'px', height: '100%' }; - + sliceHTML.appendChild($('
').css(css1)[0]); sliceHTML.appendChild($('
').css(css2)[0]); slice.html(sliceHTML); - + var css = { left: (cycleLeft) ? -sliderWidth +'px' : '0', width: (sliderWidth * 2) +'px', @@ -724,7 +718,7 @@ el.slider.trigger('nivo:animFinished'); }); break; - + case 'slideInVertical': case 'slideInTop': case 'slideInBottom': @@ -843,7 +837,7 @@ while(++cols < (settings.boxCols * 2)); break; } - + // save current index as previous index vars.previousSlideIndex = vars.currentSlideIndex; } diff --git a/jquery.nivo.slider.pack.js b/jquery.nivo.slider.pack.js index 45e9f74..55a38e4 100644 --- a/jquery.nivo.slider.pack.js +++ b/jquery.nivo.slider.pack.js @@ -8,20 +8,20 @@ * * January 2012 */ -(function(e){var o=null;function s(){return function(){}}function z(v,t){function w(a){for(var b,d,e=a.length;e;b=parseInt(Math.random()*e),d=a[--e],a[e]=a[b],a[b]=d);return a}function p(c){var g=a.a.data("nivo:vars");if(g&&!g.stop||c){a.a.css("background",'url("'+g.d.url+'") no-repeat');++g.b;if(g.b>=g.e)g.g=g.e-1,g.b=0;else if(g.b===0)g.g=g.e-1;else if(g.b<0)g.b=g.e-1,g.g=g.e-2;a.O=a.c;a.c=e(a.j[g.b]);a.c=a.c.is("img")?a.c:a.c.find("img").eq(0);g.N={url:a.O.attr("src")};g.d={url:a.c.attr("src"),title:a.c.attr("title"),A:a.c.data("transition")}; -b.v&&a.z.removeClass("active").eq(g.b).addClass("active");x();e(".nivo-slice",a.a).remove();e(".nivo-box",a.a).remove();var d=b.o||"fade";b.o==="random"?(d=["sliceDownRight","sliceDownLeft","sliceUpRight","sliceUpLeft","sliceUpDown","sliceUpDownLeft","fold","fade","cycle","boxRandom","boxRain","boxRainReverse","boxRainGrow","boxRainGrowReverse"],d=d[Math.floor(Math.random()*(d.length-1))]):b.o.indexOf(",")!==-1&&(d=b.o.split(","),d=d[Math.floor(Math.random()*d.length)]);if(g.d.A)d=g.d.A;g.m=!0;var f= -function(c,d,e,f,g){setTimeout(function(){c.animate(d,e||b.f,"",g&&function(){a.a.trigger("nivo:animFinished")})},100+f)};switch(d){case "sliceDown":case "sliceDownRight":case "sliceDownLeft":r();var c=0,k=e(".nivo-slice",a.a),j=0,h;d==="sliceDownLeft"&&(k=k.n());do h=e(k[j]),h.css({top:"0"}),f(h,{height:"100%",opacity:1},o,c,j===b.h-1?!0:!1),c+=50;while(++j").css(c)[0]);j.appendChild(e("
").css(k)[0]);h.html(j);c={left:d?-f+"px":"0",width:f*2+"px",height:"100%",opacity:1};h.css(c).animate({left:d?"0":-f+"px"},b.f*2,"",function(){a.a.trigger("nivo:animFinished")});break;case "slideInHorizontal":case "slideInLeft":case "slideInRight":r(1);h=e(".nivo-slice",a.a);d=d=== -"slideInLeft"||d==="slideInHorizontal"&&(c==="prev"||c==="control"&&g.bg.g)?!0:!1;c={top:d?"0":"",bottom:d?"":"0",backgroundPosition:d? -"0 100%":"0 0",width:"100%",height:"0",opacity:1};h.css(c).animate({height:"100%"},b.f*2,"",function(){a.a.trigger("nivo:animFinished")});break;case "boxRandom":y();h=b.i*b.l;var c=0,i=w(e(".nivo-box",a.a)),m=0;do l=e(i[m]),f(l,{opacity:1},o,c,m===h-1?!0:!1),c+=20;while(++m=0&&n').css(l)[0])}while(++h').css(l)[0])}while(++ia.a.width()&&a.a.width(n),u>a.a.height()&&a.a.height(u),i.css("display","none"),++f.e;if(b.P)b.k=Math.floor(Math.random()*f.e);if(b.k>0){if(b.k>=f.e)b.k=f.e-1;f.g=b.k-1;f.b=b.k}a.c=e(a.j[f.b]);a.c.is("img")?f.d={url:a.c.attr("src"),title:a.c.attr("title")}: -(f.d=a.c.find("img").eq(0),f.d={url:f.d.attr("src"),title:f.d.attr("title")});a.c.is("a")&&a.c.css("display","block");a.a.css("background",'url("'+f.d.url+'") no-repeat').append(e('

').css({display:"none",opacity:b.u}));a.p=e(".nivo-caption",a.a);a.t=a.p.find("p");a.p.css("opacity",0);x();if(f.e<2)return!1;var m=o;b.r||(m=setInterval(function(){p(!1)},b.s));if(b.H)a.a.append('"),a.q=e(".nivo-directionNav",a.a),b.I&&(a.q.hide(),a.a.hover(function(){a.q.show()},function(){a.q.hide()})),a.q.children().click(function(){var a=e(this).data("dir")||"next";if(f.m)return!1;clearInterval(m);m=o;a==="prev"&&(f.g-=1,f.b-=2);p(a)});if(b.v){i=q="";for(n=a.j.length;--n+1;)b.B?(i=e(a.j[n]),i.is("img")||(i=i.find("img").eq(0)),i=b.C?'':''):i=n+1,q=''+i+""+q;a.a.append('
'+q+"
");a.Q=e(".nivo-controlNav",a.a);a.z=a.Q.find("a");a.z.click(function(){var c=e(this);if(f.m||c.hasClass("active"))return!1;clearInterval(m);m=o;a.a.css("background",'url("'+f.d.url+'") no-repeat');f.b=c.data("slide")-1;p("control")}).eq(f.b).addClass("active")}b.J&&e(document).keydown(function(a){a=a.keyCode||a.which;if(f.m)return!1;clearInterval(m);m=o;a===37||a===63234?(f.b-=2,p("prev")):(a===39||a===63235)&&p("next")});b.L&& -a.a.hover(function(){f.paused=!0;clearInterval(m);m=o},function(){f.paused=!1;m===o&&!b.r&&(m=setInterval(function(){p(!1)},b.s))});a.a.bind("nivo:animFinished",function(){f.m=!1;for(var c,g=a.j.length;--g+1;)c=e(a.j[g]),c.is("a")&&c.css("display","none");a.c.is("a")&&a.c.css("display","block");m===o&&!f.paused&&!b.r&&(m=setInterval(function(){p(!1)},b.s))});this.stop=function(){if(!a.a.data("nivo:vars").stop)a.a.data("nivo:vars").stop=!0};this.start=function(){if(a.a.data("nivo:vars").stop)a.a.data("nivo:vars").stop= -!1};return this}e.fn.nivoSlider=function(v){return this.each(function(){var t=e(this);if(t.data("nivoslider"))return t.data("nivoslider");var w=new z(this,v);t.data("nivoslider",w)})};e.fn.nivoSlider.G={o:"random",h:15,i:8,l:4,f:500,s:3E3,k:0,H:!0,I:!0,v:!0,B:!1,C:!1,F:".jpg",D:"_thumb.jpg",J:!0,L:!0,r:!1,u:0.8,M:"Prev",K:"Next",P:!1,T:s(),R:s(),V:s(),U:s(),S:s()};e.fn.n=[].reverse})(jQuery); \ No newline at end of file +(function(e){var o=null;function s(){return function(){}}function z(v,t){function w(a){for(var b,d,e=a.length;e;b=parseInt(Math.random()*e),d=a[--e],a[e]=a[b],a[b]=d);return a}function p(c){var i=a.a.data("nivo:vars");if(i&&!i.stop||c){a.a.css("background",'url("'+i.d.url+'") no-repeat');++i.c;if(i.c>=i.i)i.c=0;else if(i.c<0)i.c=i.i-1;a.O=a.b;a.b=e(a.h[i.c]);a.b=a.b.is("img")?a.b:a.b.find("img").eq(0);i.N={url:a.O.attr("src")};i.d={url:a.b.attr("src"),title:a.b.attr("title"),A:a.b.data("transition")};b.v&&a.z.removeClass("active").eq(i.c).addClass("active"); +x();e(".nivo-slice",a.a).remove();e(".nivo-box",a.a).remove();var d=b.o||"fade";b.o==="random"?(d=["sliceDownRight","sliceDownLeft","sliceUpRight","sliceUpLeft","sliceUpDown","sliceUpDownLeft","fold","fade","cycle","boxRandom","boxRain","boxRainReverse","boxRainGrow","boxRainGrowReverse"],d=d[Math.floor(Math.random()*(d.length-1))]):b.o.indexOf(",")!==-1&&(d=b.o.split(","),d=d[Math.floor(Math.random()*d.length)]);if(i.d.A)d=i.d.A;i.m=!0;var f=function(c,d,e,f,g){setTimeout(function(){c.animate(d, +e||b.e,"",g&&function(){a.a.trigger("nivo:animFinished")})},100+f)};switch(d){case "sliceDown":case "sliceDownRight":case "sliceDownLeft":r();var c=0,k=e(".nivo-slice",a.a),j=0,g;d==="sliceDownLeft"&&(k=k.n());do g=e(k[j]),g.css({top:"0"}),f(g,{height:"100%",opacity:1},o,c,j===b.f-1?!0:!1),c+=50;while(++j").css(c)[0]);j.appendChild(e("
").css(k)[0]);g.html(j);c={left:d?-f+"px":"0",width:f*2+"px",height:"100%",opacity:1};g.css(c).animate({left:d?"0":-f+"px"},b.e*2,"",function(){a.a.trigger("nivo:animFinished")});break;case "slideInHorizontal":case "slideInLeft":case "slideInRight":r(1);g=e(".nivo-slice",a.a);d=d==="slideInLeft"||d==="slideInHorizontal"&&(c==="prev"||c==="control"&& +i.ci.l)?!0:!1;c={top:d?"0":"",bottom:d?"":"0",backgroundPosition:d?"0 100%":"0 0",width:"100%",height:"0",opacity:1};g.css(c).animate({height:"100%"}, +b.e*2,"",function(){a.a.trigger("nivo:animFinished")});break;case "boxRandom":y();g=b.g*b.k;var c=0,h=w(e(".nivo-box",a.a)),m=0;do l=e(h[m]),f(l,{opacity:1},o,c,m===g-1?!0:!1),c+=20;while(++m= +0&&n').css(l)[0])}while(++g').css(l)[0])}while(++ha.a.width()&&a.a.width(n),u>a.a.height()&&a.a.height(u),h.css("display","none"),++f.i;if(b.P)b.j=Math.floor(Math.random()*f.i);if(b.j>0){if(b.j>=f.i)b.j=f.i-1;f.l=b.j-1;f.c=b.j}a.b=e(a.h[f.c]);a.b.is("img")?f.d={url:a.b.attr("src"),title:a.b.attr("title")}:(f.d=a.b.find("img").eq(0),f.d={url:f.d.attr("src"), +title:f.d.attr("title")});a.b.is("a")&&a.b.css("display","block");a.a.css("background",'url("'+f.d.url+'") no-repeat').append(e('

').css({display:"none",opacity:b.u}));a.p=e(".nivo-caption",a.a);a.t=a.p.find("p");a.p.css("opacity",0);x();if(f.i<2)return!1;var m=o;b.r||(m=setInterval(function(){p(!1)},b.s));if(b.H)a.a.append('"), +a.q=e(".nivo-directionNav",a.a),b.I&&(a.q.hide(),a.a.hover(function(){a.q.show()},function(){a.q.hide()})),a.q.children().click(function(){var a=e(this).data("dir")||"next";if(f.m)return!1;clearInterval(m);m=o;a==="prev"&&(f.c-=2);p(a)});if(b.v){h=q="";for(n=a.h.length;--n+1;)b.B?(h=e(a.h[n]),h.is("img")||(h=h.find("img").eq(0)),h=b.C?'':''):h=n+1,q=''+h+""+q; +a.a.append('
'+q+"
");a.Q=e(".nivo-controlNav",a.a);a.z=a.Q.find("a");a.z.click(function(){var c=e(this);if(f.m||c.hasClass("active"))return!1;clearInterval(m);m=o;a.a.css("background",'url("'+f.d.url+'") no-repeat');f.c=c.data("slide")-1;p("control")}).eq(f.c).addClass("active")}b.J&&e(document).keydown(function(a){a=a.keyCode||a.which;if(f.m)return!1;clearInterval(m);m=o;a===37||a===63234?(f.c-=2,p("prev")):(a===39||a===63235)&&p("next")});b.L&&a.a.hover(function(){f.paused= +!0;clearInterval(m);m=o},function(){f.paused=!1;m===o&&!b.r&&(m=setInterval(function(){p(!1)},b.s))});a.a.bind("nivo:animFinished",function(){f.m=!1;for(var c,h=a.h.length;--h+1;)c=e(a.h[h]),c.is("a")&&c.css("display","none");a.b.is("a")&&a.b.css("display","block");m===o&&!f.paused&&!b.r&&(m=setInterval(function(){p(!1)},b.s))});this.stop=function(){if(!a.a.data("nivo:vars").stop)a.a.data("nivo:vars").stop=!0};this.start=function(){if(a.a.data("nivo:vars").stop)a.a.data("nivo:vars").stop=!1};return this} +e.fn.nivoSlider=function(v){return this.each(function(){var t=e(this);if(t.data("nivoslider"))return t.data("nivoslider");var w=new z(this,v);t.data("nivoslider",w)})};e.fn.nivoSlider.G={o:"random",f:15,g:8,k:4,e:500,s:3E3,j:0,H:!0,I:!0,v:!0,B:!1,C:!1,F:".jpg",D:"_thumb.jpg",J:!0,L:!0,r:!1,u:0.8,M:"Prev",K:"Next",P:!1,T:s(),R:s(),V:s(),U:s(),S:s()};e.fn.n=[].reverse})(jQuery); \ No newline at end of file From d478bf7d2e9a746480bdd935dbbdab648657c445 Mon Sep 17 00:00:00 2001 From: Jason Busby Date: Thu, 26 Jan 2012 20:14:36 +0000 Subject: [PATCH 15/19] Fixed slide links not displaying. Changed slide link removal time to beginning of animation. Repacked. --- jquery.nivo.slider.js | 72 +++++++++++++++----------------------- jquery.nivo.slider.pack.js | 34 +++++++++--------- 2 files changed, 46 insertions(+), 60 deletions(-) diff --git a/jquery.nivo.slider.js b/jquery.nivo.slider.js index 25f551b..932cc23 100644 --- a/jquery.nivo.slider.js +++ b/jquery.nivo.slider.js @@ -11,7 +11,7 @@ (function($){ - var NivoSlider = function(element, options) + var NivoSlider = function(element, options) { //Defaults are below var settings = $.extend({}, $.fn.nivoSlider.defaults, options); @@ -38,6 +38,7 @@ //Find our slider children el.slides = el.slider.children(); + el.linkSlides = el.slider.children('a') || false; var slide, slidesIndex = el.slides.length, @@ -48,9 +49,6 @@ slide = $(el.slides[slidesIndex]); if(!slide.is('img')){ - if(slide.is('a')){ - slide.addClass('nivo-imageLink'); - } slide = slide.find('img').eq(0); } @@ -74,6 +72,11 @@ ++vars.totalSlides; } + // attach class to anchors + if(el.linkSlides){ + el.linkSlides.addClass('nivo-imageLink'); + } + //If randomStart if(settings.randomStart){ settings.startSlide = Math.floor(Math.random() * vars.totalSlides); @@ -94,18 +97,11 @@ el.currentSlide = $(el.slides[vars.currentSlideIndex]); //Get initial image - if(el.currentSlide.is('img')){ - vars.currentImage = { - url: el.currentSlide.attr('src'), - title: el.currentSlide.attr('title') - }; - } else { - vars.currentImage = el.currentSlide.find('img').eq(0); - vars.currentImage = { - url: vars.currentImage.attr('src'), - title: vars.currentImage.attr('title') - }; - } + vars.currentImage = (el.currentSlide.is('img')) ? el.currentSlide : el.currentSlide.find('img').eq(0); + vars.currentImage = { + url: vars.currentImage.attr('src'), + title: vars.currentImage.attr('title') + }; //Show initial link if(el.currentSlide.is('a')){ @@ -312,18 +308,6 @@ el.slider.bind('nivo:animFinished', function(){ vars.running = false; - var link, - i = el.slides.length; - - //Hide child links - while(--i + 1){ - link = $(el.slides[i]); - - if(link.is('a')){ - link.css('display','none'); - } - } - //Show current link if(el.currentSlide.is('a')){ el.currentSlide.css('display','block'); @@ -340,15 +324,14 @@ // Add slices for slice animations var createSlices = function(slices){ - var sliderImg = vars.currentImage.url, - sliderWidth = el.slider.width(), + var sliderWidth = el.slider.width(), i = 0, sliceLimit = slices || settings.slices, slicesHTML = document.createDocumentFragment(), sliceWidth, offset; - var css = { + var css = { background: '', left: '', width: '', @@ -361,7 +344,7 @@ offset = sliceWidth * i; css.left = offset +'px'; - css.background = 'url("'+ sliderImg +'") no-repeat -'+ ((sliceWidth + offset) - sliceWidth) +'px 0%'; + css.background = 'url("'+ vars.currentImage.url +'") no-repeat -'+ ((sliceWidth + offset) - sliceWidth) +'px 0%'; css.width = sliceWidth +'px'; // fix up uneven spacing @@ -470,17 +453,15 @@ // update current slide element el.currentSlide = $(el.slides[vars.currentSlideIndex]); - el.currentSlide = (el.currentSlide.is('img')) ? el.currentSlide : el.currentSlide.find('img').eq(0); //Set slide images - vars.previousImage = { - url: el.previousSlide.attr('src') - }; + vars.previousImage = vars.currentImage; + vars.currentImage = (el.currentSlide.is('img')) ? el.currentSlide : el.currentSlide.find('img').eq(0); vars.currentImage = { - url: el.currentSlide.attr('src'), - title: el.currentSlide.attr('title'), - transition: el.currentSlide.data('transition') + url: vars.currentImage.attr('src'), + title: vars.currentImage.attr('title'), + transition: vars.currentImage.data('transition') }; //Set active links @@ -488,6 +469,11 @@ el.sliderControlNavLinks.removeClass('active').eq(vars.currentSlideIndex).addClass('active'); } + // hide links + if(el.linkSlides){ + el.linkSlides.css('display','none'); + } + //Process caption processCaption(); @@ -663,14 +649,14 @@ position: 'absolute', right: (cycleLeft) ? '0' : sliderWidth +'px', background: 'url("'+ vars.previousImage.url +'")', - width: sliderWidth +'px', - height: '100%' - }; + width: sliderWidth +'px', + height: '100%' + }; css2 = { position: 'absolute', right: (cycleLeft) ? sliderWidth +'px' : '0', - backgroundImage: 'url("'+ vars.currentImage.url +'")', + background: 'url("'+ vars.currentImage.url +'")', width: sliderWidth +'px', height: '100%' }; diff --git a/jquery.nivo.slider.pack.js b/jquery.nivo.slider.pack.js index 55a38e4..8585179 100644 --- a/jquery.nivo.slider.pack.js +++ b/jquery.nivo.slider.pack.js @@ -8,20 +8,20 @@ * * January 2012 */ -(function(e){var o=null;function s(){return function(){}}function z(v,t){function w(a){for(var b,d,e=a.length;e;b=parseInt(Math.random()*e),d=a[--e],a[e]=a[b],a[b]=d);return a}function p(c){var i=a.a.data("nivo:vars");if(i&&!i.stop||c){a.a.css("background",'url("'+i.d.url+'") no-repeat');++i.c;if(i.c>=i.i)i.c=0;else if(i.c<0)i.c=i.i-1;a.O=a.b;a.b=e(a.h[i.c]);a.b=a.b.is("img")?a.b:a.b.find("img").eq(0);i.N={url:a.O.attr("src")};i.d={url:a.b.attr("src"),title:a.b.attr("title"),A:a.b.data("transition")};b.v&&a.z.removeClass("active").eq(i.c).addClass("active"); -x();e(".nivo-slice",a.a).remove();e(".nivo-box",a.a).remove();var d=b.o||"fade";b.o==="random"?(d=["sliceDownRight","sliceDownLeft","sliceUpRight","sliceUpLeft","sliceUpDown","sliceUpDownLeft","fold","fade","cycle","boxRandom","boxRain","boxRainReverse","boxRainGrow","boxRainGrowReverse"],d=d[Math.floor(Math.random()*(d.length-1))]):b.o.indexOf(",")!==-1&&(d=b.o.split(","),d=d[Math.floor(Math.random()*d.length)]);if(i.d.A)d=i.d.A;i.m=!0;var f=function(c,d,e,f,g){setTimeout(function(){c.animate(d, -e||b.e,"",g&&function(){a.a.trigger("nivo:animFinished")})},100+f)};switch(d){case "sliceDown":case "sliceDownRight":case "sliceDownLeft":r();var c=0,k=e(".nivo-slice",a.a),j=0,g;d==="sliceDownLeft"&&(k=k.n());do g=e(k[j]),g.css({top:"0"}),f(g,{height:"100%",opacity:1},o,c,j===b.f-1?!0:!1),c+=50;while(++j").css(c)[0]);j.appendChild(e("
").css(k)[0]);g.html(j);c={left:d?-f+"px":"0",width:f*2+"px",height:"100%",opacity:1};g.css(c).animate({left:d?"0":-f+"px"},b.e*2,"",function(){a.a.trigger("nivo:animFinished")});break;case "slideInHorizontal":case "slideInLeft":case "slideInRight":r(1);g=e(".nivo-slice",a.a);d=d==="slideInLeft"||d==="slideInHorizontal"&&(c==="prev"||c==="control"&& -i.ci.l)?!0:!1;c={top:d?"0":"",bottom:d?"":"0",backgroundPosition:d?"0 100%":"0 0",width:"100%",height:"0",opacity:1};g.css(c).animate({height:"100%"}, -b.e*2,"",function(){a.a.trigger("nivo:animFinished")});break;case "boxRandom":y();g=b.g*b.k;var c=0,h=w(e(".nivo-box",a.a)),m=0;do l=e(h[m]),f(l,{opacity:1},o,c,m===g-1?!0:!1),c+=20;while(++m= -0&&n').css(l)[0])}while(++g').css(l)[0])}while(++ha.a.width()&&a.a.width(n),u>a.a.height()&&a.a.height(u),h.css("display","none"),++f.i;if(b.P)b.j=Math.floor(Math.random()*f.i);if(b.j>0){if(b.j>=f.i)b.j=f.i-1;f.l=b.j-1;f.c=b.j}a.b=e(a.h[f.c]);a.b.is("img")?f.d={url:a.b.attr("src"),title:a.b.attr("title")}:(f.d=a.b.find("img").eq(0),f.d={url:f.d.attr("src"), -title:f.d.attr("title")});a.b.is("a")&&a.b.css("display","block");a.a.css("background",'url("'+f.d.url+'") no-repeat').append(e('

').css({display:"none",opacity:b.u}));a.p=e(".nivo-caption",a.a);a.t=a.p.find("p");a.p.css("opacity",0);x();if(f.i<2)return!1;var m=o;b.r||(m=setInterval(function(){p(!1)},b.s));if(b.H)a.a.append('"), -a.q=e(".nivo-directionNav",a.a),b.I&&(a.q.hide(),a.a.hover(function(){a.q.show()},function(){a.q.hide()})),a.q.children().click(function(){var a=e(this).data("dir")||"next";if(f.m)return!1;clearInterval(m);m=o;a==="prev"&&(f.c-=2);p(a)});if(b.v){h=q="";for(n=a.h.length;--n+1;)b.B?(h=e(a.h[n]),h.is("img")||(h=h.find("img").eq(0)),h=b.C?'':''):h=n+1,q=''+h+""+q; -a.a.append('
'+q+"
");a.Q=e(".nivo-controlNav",a.a);a.z=a.Q.find("a");a.z.click(function(){var c=e(this);if(f.m||c.hasClass("active"))return!1;clearInterval(m);m=o;a.a.css("background",'url("'+f.d.url+'") no-repeat');f.c=c.data("slide")-1;p("control")}).eq(f.c).addClass("active")}b.J&&e(document).keydown(function(a){a=a.keyCode||a.which;if(f.m)return!1;clearInterval(m);m=o;a===37||a===63234?(f.c-=2,p("prev")):(a===39||a===63235)&&p("next")});b.L&&a.a.hover(function(){f.paused= -!0;clearInterval(m);m=o},function(){f.paused=!1;m===o&&!b.r&&(m=setInterval(function(){p(!1)},b.s))});a.a.bind("nivo:animFinished",function(){f.m=!1;for(var c,h=a.h.length;--h+1;)c=e(a.h[h]),c.is("a")&&c.css("display","none");a.b.is("a")&&a.b.css("display","block");m===o&&!f.paused&&!b.r&&(m=setInterval(function(){p(!1)},b.s))});this.stop=function(){if(!a.a.data("nivo:vars").stop)a.a.data("nivo:vars").stop=!0};this.start=function(){if(a.a.data("nivo:vars").stop)a.a.data("nivo:vars").stop=!1};return this} -e.fn.nivoSlider=function(v){return this.each(function(){var t=e(this);if(t.data("nivoslider"))return t.data("nivoslider");var w=new z(this,v);t.data("nivoslider",w)})};e.fn.nivoSlider.G={o:"random",f:15,g:8,k:4,e:500,s:3E3,j:0,H:!0,I:!0,v:!0,B:!1,C:!1,F:".jpg",D:"_thumb.jpg",J:!0,L:!0,r:!1,u:0.8,M:"Prev",K:"Next",P:!1,T:s(),R:s(),V:s(),U:s(),S:s()};e.fn.n=[].reverse})(jQuery); \ No newline at end of file +(function(e){var o=null;function s(){return function(){}}function z(v,t){function w(a){for(var b,c,e=a.length;e;b=parseInt(Math.random()*e),c=a[--e],a[e]=a[b],a[b]=c);return a}function p(d){var g=a.a.data("nivo:vars");if(g&&!g.stop||d){a.a.css("background",'url("'+g.b.url+'") no-repeat');++g.c;if(g.c>=g.h)g.c=0;else if(g.c<0)g.c=g.h-1;a.V=a.d;a.d=e(a.i[g.c]);g.O=g.b;g.b=a.d.is("img")?a.d:a.d.find("img").eq(0);g.b={url:g.b.attr("src"),title:g.b.attr("title"),B:g.b.data("transition")};b.w&&a.A.removeClass("active").eq(g.c).addClass("active");a.p&& +a.p.css("display","none");x();e(".nivo-slice",a.a).remove();e(".nivo-box",a.a).remove();var c=b.o||"fade";b.o==="random"?(c=["sliceDownRight","sliceDownLeft","sliceUpRight","sliceUpLeft","sliceUpDown","sliceUpDownLeft","fold","fade","cycle","boxRandom","boxRain","boxRainReverse","boxRainGrow","boxRainGrowReverse"],c=c[Math.floor(Math.random()*(c.length-1))]):b.o.indexOf(",")!==-1&&(c=b.o.split(","),c=c[Math.floor(Math.random()*c.length)]);if(g.b.B)c=g.b.B;g.m=!0;var f=function(d,c,e,f,g){setTimeout(function(){d.animate(c, +e||b.e,"",g&&function(){a.a.trigger("nivo:animFinished")})},100+f)};switch(c){case "sliceDown":case "sliceDownRight":case "sliceDownLeft":r();var d=0,l=e(".nivo-slice",a.a),k=0,h;c==="sliceDownLeft"&&(l=l.n());do h=e(l[k]),h.css({top:"0"}),f(h,{height:"100%",opacity:1},o,d,k===b.f-1?!0:!1),d+=50;while(++k").css(d)[0]);k.appendChild(e("
").css(l)[0]);h.html(k);d={left:c?-f+"px":"0",width:f*2+"px",height:"100%",opacity:1};h.css(d).animate({left:c?"0":-f+"px"},b.e*2,"",function(){a.a.trigger("nivo:animFinished")});break;case "slideInHorizontal":case "slideInLeft":case "slideInRight":r(1);h=e(".nivo-slice",a.a);c=c==="slideInLeft"||c==="slideInHorizontal"&&(d==="prev"||d==="control"&&g.c< +g.l)?!0:!1;d={left:c?"0":"",right:c?"":"0",backgroundPosition:c?"100% 0":"0 0",width:"0",height:"100%",opacity:1};h.css(d).animate({width:"100%"},b.e*2,"",function(){a.a.trigger("nivo:animFinished")});break;case "slideInVertical":case "slideInTop":case "slideInBottom":r(1);h=e(".nivo-slice",a.a);c=c==="slideInTop"||c==="slideInVertical"&&(d==="prev"||d==="control"&&g.c>g.l)?!0:!1;d={top:c?"0":"",bottom:c?"":"0",backgroundPosition:c?"0 100%":"0 0",width:"100%",height:"0",opacity:1};h.css(d).animate({height:"100%"}, +b.e*2,"",function(){a.a.trigger("nivo:animFinished")});break;case "boxRandom":y();h=b.g*b.k;var d=0,j=w(e(".nivo-box",a.a)),i=0;do n=e(j[i]),f(n,{opacity:1},o,d,i===h-1?!0:!1),d+=20;while(++i= +0&&m').css(i)[0])}while(++h').css(h)[0])}while(++ca.a.width()&&a.a.width(m),u>a.a.height()&&a.a.height(u),j.css("display","none"),++f.h;a.p&&a.p.addClass("nivo-imageLink");if(b.P)b.j=Math.floor(Math.random()*f.h);if(b.j>0){if(b.j>=f.h)b.j=f.h-1;f.l=b.j-1;f.c=b.j}a.d=e(a.i[f.c]);f.b=a.d.is("img")?a.d:a.d.find("img").eq(0);f.b={url:f.b.attr("src"),title:f.b.attr("title")};a.d.is("a")&& +a.d.css("display","block");a.a.css("background",'url("'+f.b.url+'") no-repeat').append(e('

').css({display:"none",opacity:b.v}));a.q=e(".nivo-caption",a.a);a.u=a.q.find("p");a.q.css("opacity",0);x();if(f.h<2)return!1;var i=o;b.s||(i=setInterval(function(){p(!1)},b.t));if(b.I)a.a.append('"),a.r=e(".nivo-directionNav",a.a),b.J&& +(a.r.hide(),a.a.hover(function(){a.r.show()},function(){a.r.hide()})),a.r.children().click(function(){var a=e(this).data("dir")||"next";if(f.m)return!1;clearInterval(i);i=o;a==="prev"&&(f.c-=2);p(a)});if(b.w){j=q="";for(m=a.i.length;--m+1;)b.C?(j=e(a.i[m]),j.is("img")||(j=j.find("img").eq(0)),j=b.D?'':''):j=m+1,q=''+j+""+q;a.a.append('
'+ +q+"
");a.Q=e(".nivo-controlNav",a.a);a.A=a.Q.find("a");a.A.click(function(){var b=e(this);if(f.m||b.hasClass("active"))return!1;clearInterval(i);i=o;a.a.css("background",'url("'+f.b.url+'") no-repeat');f.c=b.data("slide")-1;p("control")}).eq(f.c).addClass("active")}b.K&&e(document).keydown(function(a){a=a.keyCode||a.which;if(f.m)return!1;clearInterval(i);i=o;a===37||a===63234?(f.c-=2,p("prev")):(a===39||a===63235)&&p("next")});b.M&&a.a.hover(function(){f.paused=!0;clearInterval(i);i=o},function(){f.paused= +!1;i===o&&!b.s&&(i=setInterval(function(){p(!1)},b.t))});a.a.bind("nivo:animFinished",function(){f.m=!1;a.d.is("a")&&a.d.css("display","block");i===o&&!f.paused&&!b.s&&(i=setInterval(function(){p(!1)},b.t))});this.stop=function(){if(!a.a.data("nivo:vars").stop)a.a.data("nivo:vars").stop=!0};this.start=function(){if(a.a.data("nivo:vars").stop)a.a.data("nivo:vars").stop=!1};return this}e.fn.nivoSlider=function(v){return this.each(function(){var t=e(this);if(t.data("nivoslider"))return t.data("nivoslider");var w= +new z(this,v);t.data("nivoslider",w)})};e.fn.nivoSlider.H={o:"random",f:15,g:8,k:4,e:500,t:3E3,j:0,I:!0,J:!0,w:!0,C:!1,D:!1,G:".jpg",F:"_thumb.jpg",K:!0,M:!0,s:!1,v:0.8,N:"Prev",L:"Next",P:!1,T:s(),R:s(),W:s(),U:s(),S:s()};e.fn.n=[].reverse})(jQuery); \ No newline at end of file From 3b12fd542c2b8d6a67d0aff4098dd122c440a633 Mon Sep 17 00:00:00 2001 From: Jason Busby Date: Fri, 27 Jan 2012 05:12:15 +0000 Subject: [PATCH 16/19] Options passed in during initialization now function correctly. Repacked. --- jquery.nivo.slider.js | 160 +++++++++++++++++++++++-------------- jquery.nivo.slider.pack.js | 36 +++++---- 2 files changed, 117 insertions(+), 79 deletions(-) diff --git a/jquery.nivo.slider.js b/jquery.nivo.slider.js index 932cc23..aa52e1f 100644 --- a/jquery.nivo.slider.js +++ b/jquery.nivo.slider.js @@ -13,10 +13,46 @@ var NivoSlider = function(element, options) { - //Defaults are below + // Defaults are below var settings = $.extend({}, $.fn.nivoSlider.defaults, options); - //Useful variables. Play carefully. + /* + * All settings must be mapped here. This keeps them public when compiled. + * ( Remove this if you're not going to compile me! ) + */ + settings = { + effect: settings['effect'], + slices: settings['slices'], + boxCols: settings['boxCols'], + boxRows: settings['boxRows'], + animSpeed: settings['animSpeed'], + pauseTime: settings['pauseTime'], + startSlide: settings['startSlide'], + directionNav: settings['directionNav'], + directionNavHide: settings['directionNavHide'], + controlNav: settings['controlNav'], + controlNavThumbs: settings['controlNavThumbs'], + controlNavThumbsFromRel: settings['controlNavThumbsFromRel'], + controlNavThumbsSearch: settings['controlNavThumbsSearch'], + controlNavThumbsReplace: settings['controlNavThumbsReplace'], + keyboardNav: settings['keyboardNav'], + pauseOnHover: settings['pauseOnHover'], + manualAdvance: settings['manualAdvance'], + captionOpacity: settings['captionOpacity'], + prevText: settings['prevText'], + nextText: settings['nextText'], + randomStart: settings['randomStart'], + beforeChange: settings['beforeChange'], + afterChange: settings['afterChange'], + slideshowEnd: settings['slideshowEnd'], + lastSlide: settings['lastSlide'], + afterLoad: settings['afterLoad'] + }; + /* + * Mapping end. + */ + + // Useful variables. Play carefully. var vars = { previousSlideIndex: 0, currentSlideIndex: 0, @@ -30,13 +66,13 @@ // element cache var el = {}; - //Get this slider + // Get this slider el.slider = $(element); el.slider.data('nivo:vars', vars); el.slider.css('position','relative'); el.slider.addClass('nivoSlider'); - //Find our slider children + // Find our slider children el.slides = el.slider.children(); el.linkSlides = el.slider.children('a') || false; @@ -52,14 +88,14 @@ slide = slide.find('img').eq(0); } - //Get img width & height + // Get img width & height slideWidth = slide.width(), slideHeight = slide.height(); if(slideWidth === 0) slideWidth = slide.attr('width'); if(slideHeight === 0) slideHeight = slide.attr('height'); - //Resize the slider + // Resize the slider if(slideWidth > el.slider.width()){ el.slider.width(slideWidth); } @@ -77,12 +113,12 @@ el.linkSlides.addClass('nivo-imageLink'); } - //If randomStart + // If randomStart if(settings.randomStart){ settings.startSlide = Math.floor(Math.random() * vars.totalSlides); } - //Set startSlide + // Set startSlide if(settings.startSlide > 0){ // limit startslide at total slides count if(settings.startSlide >= vars.totalSlides){ @@ -96,22 +132,22 @@ // add current slide element to element object el.currentSlide = $(el.slides[vars.currentSlideIndex]); - //Get initial image + // Get initial image vars.currentImage = (el.currentSlide.is('img')) ? el.currentSlide : el.currentSlide.find('img').eq(0); vars.currentImage = { url: vars.currentImage.attr('src'), title: vars.currentImage.attr('title') }; - //Show initial link + // Show initial link if(el.currentSlide.is('a')){ el.currentSlide.css('display','block'); } - //Set first background + // Set first background el.slider .css('background', 'url("'+ vars.currentImage.url +'") no-repeat') - //Create caption + // Create caption .append( $('

').css({ display: 'none', opacity: settings.captionOpacity }) ); @@ -144,7 +180,7 @@ el.sliderCaption.stop().fadeTo(settings.animSpeed, (title) ? settings.captionOpacity : 0); } - //Process initial caption + // Process initial caption processCaption(); // we need more than one slide! @@ -154,12 +190,12 @@ var timer = null; - //In the words of Super Mario "let's a go!" + // In the words of Super Mario "let's a go!" if(!settings.manualAdvance){ timer = setInterval(function(){ nivoRun(false); }, settings.pauseTime); } - //Add Direction nav + // Add Direction nav if(settings.directionNav){ // insert direction controls @@ -168,7 +204,7 @@ // add direction nav element to element object el.sliderDirectionNav = $('.nivo-directionNav', el.slider); - //Hide Direction nav + // Hide Direction nav if(settings.directionNavHide){ el.sliderDirectionNav.hide(); @@ -203,7 +239,7 @@ ); } - //Add Control nav + // Add Control nav if(settings.controlNav){ var slide, controlHTML = '', @@ -237,7 +273,7 @@ el.sliderControlNav = $('.nivo-controlNav', el.slider); el.sliderControlNavLinks = el.sliderControlNav.find('a'); - //Set initial active link + // Set initial active link el.sliderControlNavLinks .click( function(){ @@ -260,7 +296,7 @@ .addClass('active'); } - //Keyboard Navigation + // Keyboard Navigation if(settings.keyboardNav){ $(document).keydown(function(e){ var code = e.keyCode || e.which; @@ -284,7 +320,7 @@ }); } - //For pauseOnHover setting + // For pauseOnHover setting if(settings.pauseOnHover){ el.slider.hover( function(){ @@ -296,7 +332,7 @@ function(){ vars.paused = false; - //Restart the timer + // Restart the timer if(timer === null && !settings.manualAdvance){ timer = setInterval(function(){ nivoRun(false); }, settings.pauseTime); } @@ -304,21 +340,21 @@ ); } - //Event when Animation finishes + // Event when Animation finishes el.slider.bind('nivo:animFinished', function(){ vars.running = false; - //Show current link + // Show current link if(el.currentSlide.is('a')){ el.currentSlide.css('display','block'); } - //Restart the timer + // Restart the timer if(timer === null && !vars.paused && !settings.manualAdvance){ timer = setInterval(function(){ nivoRun(false); }, settings.pauseTime); } - //Trigger the afterChange callback + // Trigger the afterChange callback settings.afterChange.call(this); }); @@ -417,7 +453,7 @@ //Get our vars var vars = el.slider.data('nivo:vars'); - //Trigger the lastSlide callback + // Trigger the lastSlide callback if(vars && (vars.currentSlideIndex == vars.totalSlides - 1)){ settings.lastSlide.call(this); } @@ -427,10 +463,10 @@ return false; } - //Trigger the beforeChange callback + // Trigger the beforeChange callback settings.beforeChange.call(this); - //Set current background before change + // Set current background before change el.slider.css('background','url("'+ vars.currentImage.url +'") no-repeat'); // previous index is stored at the end of this function @@ -464,7 +500,7 @@ transition: vars.currentImage.data('transition') }; - //Set active links + // Set active links if(settings.controlNav){ el.sliderControlNavLinks.removeClass('active').eq(vars.currentSlideIndex).addClass('active'); } @@ -474,7 +510,7 @@ el.linkSlides.css('display','none'); } - //Process caption + // Process caption processCaption(); // Remove any slices from last transition @@ -484,26 +520,26 @@ var currentEffect = settings.effect || 'fade'; - //Generate random effect + // Generate random effect if(settings.effect === 'random'){ var anims = ['sliceDownRight','sliceDownLeft','sliceUpRight','sliceUpLeft','sliceUpDown','sliceUpDownLeft','fold','fade', 'cycle','boxRandom','boxRain','boxRainReverse','boxRainGrow','boxRainGrowReverse']; currentEffect = anims[Math.floor(Math.random() * (anims.length - 1))]; } - //Run random effect from specified set (eg: effect:'fold,fade') + // Run random effect from specified set (eg: effect:'fold,fade') else if(settings.effect.indexOf(',') !== -1){ var anims = settings.effect.split(','); currentEffect = anims[Math.floor(Math.random() * anims.length)]; } - //Custom transition as defined by "data-transition" attribute + // Custom transition as defined by "data-transition" attribute if(vars.currentImage.transition){ currentEffect = vars.currentImage.transition; } - //Run effects + // Run effects vars.running = true; var timedAnimate = function(element, css, speed, buff, end){ @@ -847,7 +883,7 @@ } }; - //Trigger the afterLoad callback + // Trigger the afterLoad callback settings.afterLoad.call(this); return this; @@ -867,34 +903,34 @@ }); }; - //Default settings + // Default settings $.fn.nivoSlider.defaults = { - effect: 'random', - slices: 15, - boxCols: 8, - boxRows: 4, - animSpeed: 500, - pauseTime: 3000, - startSlide: 0, - directionNav: true, - directionNavHide: true, - controlNav: true, - controlNavThumbs: false, - controlNavThumbsFromRel: false, - controlNavThumbsSearch: '.jpg', - controlNavThumbsReplace: '_thumb.jpg', - keyboardNav: true, - pauseOnHover: true, - manualAdvance: false, - captionOpacity: 0.8, - prevText: 'Prev', - nextText: 'Next', - randomStart: false, - beforeChange: function(){}, - afterChange: function(){}, - slideshowEnd: function(){}, - lastSlide: function(){}, - afterLoad: function(){} + 'effect': 'random', + 'slices': 15, + 'boxCols': 8, + 'boxRows': 4, + 'animSpeed': 500, + 'pauseTime': 3000, + 'startSlide': 0, + 'directionNav': true, + 'directionNavHide': true, + 'controlNav': true, + 'controlNavThumbs': false, + 'controlNavThumbsFromRel': false, + 'controlNavThumbsSearch': '.jpg', + 'controlNavThumbsReplace': '_thumb.jpg', + 'keyboardNav': true, + 'pauseOnHover': true, + 'manualAdvance': false, + 'captionOpacity': 0.8, + 'prevText': 'Prev', + 'nextText': 'Next', + 'randomStart': false, + 'beforeChange': function(){}, + 'afterChange': function(){}, + 'slideshowEnd': function(){}, + 'lastSlide': function(){}, + 'afterLoad': function(){} }; $.fn._reverse = [].reverse; diff --git a/jquery.nivo.slider.pack.js b/jquery.nivo.slider.pack.js index 8585179..f800bc6 100644 --- a/jquery.nivo.slider.pack.js +++ b/jquery.nivo.slider.pack.js @@ -8,20 +8,22 @@ * * January 2012 */ -(function(e){var o=null;function s(){return function(){}}function z(v,t){function w(a){for(var b,c,e=a.length;e;b=parseInt(Math.random()*e),c=a[--e],a[e]=a[b],a[b]=c);return a}function p(d){var g=a.a.data("nivo:vars");if(g&&!g.stop||d){a.a.css("background",'url("'+g.b.url+'") no-repeat');++g.c;if(g.c>=g.h)g.c=0;else if(g.c<0)g.c=g.h-1;a.V=a.d;a.d=e(a.i[g.c]);g.O=g.b;g.b=a.d.is("img")?a.d:a.d.find("img").eq(0);g.b={url:g.b.attr("src"),title:g.b.attr("title"),B:g.b.data("transition")};b.w&&a.A.removeClass("active").eq(g.c).addClass("active");a.p&& -a.p.css("display","none");x();e(".nivo-slice",a.a).remove();e(".nivo-box",a.a).remove();var c=b.o||"fade";b.o==="random"?(c=["sliceDownRight","sliceDownLeft","sliceUpRight","sliceUpLeft","sliceUpDown","sliceUpDownLeft","fold","fade","cycle","boxRandom","boxRain","boxRainReverse","boxRainGrow","boxRainGrowReverse"],c=c[Math.floor(Math.random()*(c.length-1))]):b.o.indexOf(",")!==-1&&(c=b.o.split(","),c=c[Math.floor(Math.random()*c.length)]);if(g.b.B)c=g.b.B;g.m=!0;var f=function(d,c,e,f,g){setTimeout(function(){d.animate(c, -e||b.e,"",g&&function(){a.a.trigger("nivo:animFinished")})},100+f)};switch(c){case "sliceDown":case "sliceDownRight":case "sliceDownLeft":r();var d=0,l=e(".nivo-slice",a.a),k=0,h;c==="sliceDownLeft"&&(l=l.n());do h=e(l[k]),h.css({top:"0"}),f(h,{height:"100%",opacity:1},o,d,k===b.f-1?!0:!1),d+=50;while(++k").css(d)[0]);k.appendChild(e("
").css(l)[0]);h.html(k);d={left:c?-f+"px":"0",width:f*2+"px",height:"100%",opacity:1};h.css(d).animate({left:c?"0":-f+"px"},b.e*2,"",function(){a.a.trigger("nivo:animFinished")});break;case "slideInHorizontal":case "slideInLeft":case "slideInRight":r(1);h=e(".nivo-slice",a.a);c=c==="slideInLeft"||c==="slideInHorizontal"&&(d==="prev"||d==="control"&&g.c< -g.l)?!0:!1;d={left:c?"0":"",right:c?"":"0",backgroundPosition:c?"100% 0":"0 0",width:"0",height:"100%",opacity:1};h.css(d).animate({width:"100%"},b.e*2,"",function(){a.a.trigger("nivo:animFinished")});break;case "slideInVertical":case "slideInTop":case "slideInBottom":r(1);h=e(".nivo-slice",a.a);c=c==="slideInTop"||c==="slideInVertical"&&(d==="prev"||d==="control"&&g.c>g.l)?!0:!1;d={top:c?"0":"",bottom:c?"":"0",backgroundPosition:c?"0 100%":"0 0",width:"100%",height:"0",opacity:1};h.css(d).animate({height:"100%"}, -b.e*2,"",function(){a.a.trigger("nivo:animFinished")});break;case "boxRandom":y();h=b.g*b.k;var d=0,j=w(e(".nivo-box",a.a)),i=0;do n=e(j[i]),f(n,{opacity:1},o,d,i===h-1?!0:!1),d+=20;while(++i= -0&&m').css(i)[0])}while(++h').css(h)[0])}while(++ca.a.width()&&a.a.width(m),u>a.a.height()&&a.a.height(u),j.css("display","none"),++f.h;a.p&&a.p.addClass("nivo-imageLink");if(b.P)b.j=Math.floor(Math.random()*f.h);if(b.j>0){if(b.j>=f.h)b.j=f.h-1;f.l=b.j-1;f.c=b.j}a.d=e(a.i[f.c]);f.b=a.d.is("img")?a.d:a.d.find("img").eq(0);f.b={url:f.b.attr("src"),title:f.b.attr("title")};a.d.is("a")&& -a.d.css("display","block");a.a.css("background",'url("'+f.b.url+'") no-repeat').append(e('

').css({display:"none",opacity:b.v}));a.q=e(".nivo-caption",a.a);a.u=a.q.find("p");a.q.css("opacity",0);x();if(f.h<2)return!1;var i=o;b.s||(i=setInterval(function(){p(!1)},b.t));if(b.I)a.a.append('"),a.r=e(".nivo-directionNav",a.a),b.J&& -(a.r.hide(),a.a.hover(function(){a.r.show()},function(){a.r.hide()})),a.r.children().click(function(){var a=e(this).data("dir")||"next";if(f.m)return!1;clearInterval(i);i=o;a==="prev"&&(f.c-=2);p(a)});if(b.w){j=q="";for(m=a.i.length;--m+1;)b.C?(j=e(a.i[m]),j.is("img")||(j=j.find("img").eq(0)),j=b.D?'':''):j=m+1,q=''+j+""+q;a.a.append('
'+ -q+"
");a.Q=e(".nivo-controlNav",a.a);a.A=a.Q.find("a");a.A.click(function(){var b=e(this);if(f.m||b.hasClass("active"))return!1;clearInterval(i);i=o;a.a.css("background",'url("'+f.b.url+'") no-repeat');f.c=b.data("slide")-1;p("control")}).eq(f.c).addClass("active")}b.K&&e(document).keydown(function(a){a=a.keyCode||a.which;if(f.m)return!1;clearInterval(i);i=o;a===37||a===63234?(f.c-=2,p("prev")):(a===39||a===63235)&&p("next")});b.M&&a.a.hover(function(){f.paused=!0;clearInterval(i);i=o},function(){f.paused= -!1;i===o&&!b.s&&(i=setInterval(function(){p(!1)},b.t))});a.a.bind("nivo:animFinished",function(){f.m=!1;a.d.is("a")&&a.d.css("display","block");i===o&&!f.paused&&!b.s&&(i=setInterval(function(){p(!1)},b.t))});this.stop=function(){if(!a.a.data("nivo:vars").stop)a.a.data("nivo:vars").stop=!0};this.start=function(){if(a.a.data("nivo:vars").stop)a.a.data("nivo:vars").stop=!1};return this}e.fn.nivoSlider=function(v){return this.each(function(){var t=e(this);if(t.data("nivoslider"))return t.data("nivoslider");var w= -new z(this,v);t.data("nivoslider",w)})};e.fn.nivoSlider.H={o:"random",f:15,g:8,k:4,e:500,t:3E3,j:0,I:!0,J:!0,w:!0,C:!1,D:!1,G:".jpg",F:"_thumb.jpg",K:!0,M:!0,s:!1,v:0.8,N:"Prev",L:"Next",P:!1,T:s(),R:s(),W:s(),U:s(),S:s()};e.fn.n=[].reverse})(jQuery); \ No newline at end of file +(function(e){var o=null;function s(){return function(){}}function z(v,t){function w(a){for(var b,c,e=a.length;e;b=parseInt(Math.random()*e),c=a[--e],a[e]=a[b],a[b]=c);return a}function p(d){var g=a.a.data("nivo:vars");g&&g.c==g.h-1&&b.O.call(this);if(g&&!g.stop||d){b.F.call(this);a.a.css("background",'url("'+g.b.url+'") no-repeat');++g.c;if(g.c>=g.h)g.c=0,b.V.call(this);else if(g.c<0)g.c=g.h-1;a.W=a.d;a.d=e(a.i[g.c]);g.S=g.b;g.b=a.d.is("img")?a.d:a.d.find("img").eq(0);g.b={url:g.b.attr("src"),title:g.b.attr("title"),B:g.b.data("transition")}; +b.w&&a.A.removeClass("active").eq(g.c).addClass("active");a.p&&a.p.css("display","none");x();e(".nivo-slice",a.a).remove();e(".nivo-box",a.a).remove();var c=b.o||"fade";b.o==="random"?(c=["sliceDownRight","sliceDownLeft","sliceUpRight","sliceUpLeft","sliceUpDown","sliceUpDownLeft","fold","fade","cycle","boxRandom","boxRain","boxRainReverse","boxRainGrow","boxRainGrowReverse"],c=c[Math.floor(Math.random()*(c.length-1))]):b.o.indexOf(",")!==-1&&(c=b.o.split(","),c=c[Math.floor(Math.random()*c.length)]); +if(g.b.B)c=g.b.B;g.m=!0;var f=function(d,c,e,f,g){setTimeout(function(){d.animate(c,e||b.e,"",g&&function(){a.a.trigger("nivo:animFinished")})},100+f)};switch(c){case "sliceDown":case "sliceDownRight":case "sliceDownLeft":r();var d=0,l=e(".nivo-slice",a.a),k=0,h;c==="sliceDownLeft"&&(l=l.n());do h=e(l[k]),h.css({top:"0"}),f(h,{height:"100%",opacity:1},o,d,k===b.f-1?!0:!1),d+=50;while(++k").css(d)[0]);k.appendChild(e("
").css(l)[0]);h.html(k);d={left:c?-f+"px":"0",width:f*2+"px",height:"100%",opacity:1};h.css(d).animate({left:c?"0":-f+"px"},b.e*2,"",function(){a.a.trigger("nivo:animFinished")});break;case "slideInHorizontal":case "slideInLeft":case "slideInRight":r(1);h=e(".nivo-slice",a.a);c=c==="slideInLeft"|| +c==="slideInHorizontal"&&(d==="prev"||d==="control"&&g.cg.l)?!0:!1;d={top:c?"0":"",bottom:c?"":"0",backgroundPosition:c?"0 100%": +"0 0",width:"100%",height:"0",opacity:1};h.css(d).animate({height:"100%"},b.e*2,"",function(){a.a.trigger("nivo:animFinished")});break;case "boxRandom":y();h=b.g*b.k;var d=0,j=w(e(".nivo-box",a.a)),i=0;do n=e(j[i]),f(n,{opacity:1},o,d,i===h-1?!0:!1),d+=20;while(++i=0&&m').css(i)[0])}while(++h').css(h)[0])}while(++ca.a.width()&&a.a.width(m),u>a.a.height()&&a.a.height(u),j.css("display","none"),++f.h;a.p&&a.p.addClass("nivo-imageLink");if(b.T)b.j=Math.floor(Math.random()*f.h);if(b.j>0){if(b.j>=f.h)b.j=f.h-1;f.l=b.j-1;f.c=b.j}a.d=e(a.i[f.c]);f.b=a.d.is("img")?a.d:a.d.find("img").eq(0);f.b={url:f.b.attr("src"),title:f.b.attr("title")};a.d.is("a")&& +a.d.css("display","block");a.a.css("background",'url("'+f.b.url+'") no-repeat').append(e('

').css({display:"none",opacity:b.v}));a.q=e(".nivo-caption",a.a);a.u=a.q.find("p");a.q.css("opacity",0);x();if(f.h<2)return!1;var i=o;b.s||(i=setInterval(function(){p(!1)},b.t));if(b.L)a.a.append('"),a.r=e(".nivo-directionNav",a.a),b.M&& +(a.r.hide(),a.a.hover(function(){a.r.show()},function(){a.r.hide()})),a.r.children().click(function(){var a=e(this).data("dir")||"next";if(f.m)return!1;clearInterval(i);i=o;a==="prev"&&(f.c-=2);p(a)});if(b.w){j=q="";for(m=a.i.length;--m+1;)b.G?(j=e(a.i[m]),j.is("img")||(j=j.find("img").eq(0)),j=b.H?'':''):j=m+1,q=''+j+""+q;a.a.append('
'+ +q+"
");a.U=e(".nivo-controlNav",a.a);a.A=a.U.find("a");a.A.click(function(){var b=e(this);if(f.m||b.hasClass("active"))return!1;clearInterval(i);i=o;a.a.css("background",'url("'+f.b.url+'") no-repeat');f.c=b.data("slide")-1;p("control")}).eq(f.c).addClass("active")}b.N&&e(document).keydown(function(a){a=a.keyCode||a.which;if(f.m)return!1;clearInterval(i);i=o;a===37||a===63234?(f.c-=2,p("prev")):(a===39||a===63235)&&p("next")});b.Q&&a.a.hover(function(){f.paused=!0;clearInterval(i);i=o},function(){f.paused= +!1;i===o&&!b.s&&(i=setInterval(function(){p(!1)},b.t))});a.a.bind("nivo:animFinished",function(){f.m=!1;a.d.is("a")&&a.d.css("display","block");i===o&&!f.paused&&!b.s&&(i=setInterval(function(){p(!1)},b.t));b.C.call(this)});this.stop=function(){if(!a.a.data("nivo:vars").stop)a.a.data("nivo:vars").stop=!0};this.start=function(){if(a.a.data("nivo:vars").stop)a.a.data("nivo:vars").stop=!1};b.D.call(this);return this}e.fn.nivoSlider=function(v){return this.each(function(){var t=e(this);if(t.data("nivoslider"))return t.data("nivoslider"); +var w=new z(this,v);t.data("nivoslider",w)})};e.fn.nivoSlider.K={effect:"random",slices:15,boxCols:8,boxRows:4,animSpeed:500,pauseTime:3E3,startSlide:0,directionNav:!0,directionNavHide:!0,controlNav:!0,controlNavThumbs:!1,controlNavThumbsFromRel:!1,controlNavThumbsSearch:".jpg",controlNavThumbsReplace:"_thumb.jpg",keyboardNav:!0,pauseOnHover:!0,manualAdvance:!1,captionOpacity:0.8,prevText:"Prev",nextText:"Next",randomStart:!1,beforeChange:s(),afterChange:s(),slideshowEnd:s(),lastSlide:s(),afterLoad:s()};e.fn.n= +[].reverse})(jQuery); \ No newline at end of file From b5dcc5f76c87d9eb418c013f54a395f7e735c514 Mon Sep 17 00:00:00 2001 From: Jason Busby Date: Mon, 7 May 2012 18:56:00 +0100 Subject: [PATCH 17/19] Updated readme with new features Added jQuery externs file for use when packing with Google Closure Compiler advanced. --- README | 1 - README.markdown | 8 + jquery-1.6.externs.js | 1989 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 1997 insertions(+), 1 deletion(-) delete mode 100644 README create mode 100644 README.markdown create mode 100644 jquery-1.6.externs.js diff --git a/README b/README deleted file mode 100644 index 2e5185c..0000000 --- a/README +++ /dev/null @@ -1 +0,0 @@ -Nivo Slider is "The Most Awesome jQuery Image Slider". See http://nivo.dev7studios.com for more info. \ No newline at end of file diff --git a/README.markdown b/README.markdown new file mode 100644 index 0000000..80bec70 --- /dev/null +++ b/README.markdown @@ -0,0 +1,8 @@ +>Nivo Slider is "The Most Awesome jQuery Image Slider". See http://nivo.dev7studios.com for more info. + +## New Features +- New cycle, cycleLeft and cycleRigt effects, aka sliding. "cycle" moves depending on slide direction. +- New slideIn effect animates depending on slide direction. +- Supports Webkit keyboard arrow keys. +- Improved code which is less dependant on jQuery. +- Packed with Google Closure Compiler Advanced using jquery externs file. Comes out at the same size of the original but with more features! \ No newline at end of file diff --git a/jquery-1.6.externs.js b/jquery-1.6.externs.js new file mode 100644 index 0000000..6b67de5 --- /dev/null +++ b/jquery-1.6.externs.js @@ -0,0 +1,1989 @@ +/* + * Copyright 2011 The Closure Compiler Authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @fileoverview Externs for jQuery 1.6.1 + * + * Note that some functions use different return types depending on the number + * of parameters passed in. In these cases, you may need to annotate the type + * of the result in your code, so the JSCompiler understands which type you're + * expecting. For example: + * var elt = /** @type {Element} * / (foo.get(0)); + * + * @see http://api.jquery.com/ + * @externs + */ + +/** @typedef {(Window|Document|Element|Array.|string|jQuery| + * NodeList)} */ +var jQuerySelector; + +/** + * @constructor + * @param {(jQuerySelector|Element|Array.|Object|jQuery|string| + * function())=} arg1 + * @param {(Element|jQuery|Document| + * Object.)=} arg2 + * @return {jQuery} + */ +function jQuery(arg1, arg2) {}; + +/** + * @constructor + * @extends {jQuery} + * @param {(jQuerySelector|Element|Array.|Object|jQuery|string| + * function())} arg1 + * @param {(Element|jQuery|Document| + * Object.)=} arg2 + * @return {jQuery} + */ +function $(arg1, arg2) {}; + +/** + * @param {string} key + * @param {string} value + * @param {object} options + * @return {string} + */ +jQuery.cookie = function(key, value, options) {}; + +/** + * @param {(jQuerySelector|Array.|string)} arg1 + * @param {Element=} context + * @return {jQuery} + * @nosideeffects + */ +jQuery.prototype.add = function(arg1, context) {}; + +/** + * @param {(string|function(number,String))} arg1 + * @return {jQuery} + */ +jQuery.prototype.addClass = function(arg1) {}; + +/** + * @param {(string|Element|jQuery|function(number))} arg1 + * @param {(string|Element|Array.|jQuery)=} content + * @return {jQuery} + */ +jQuery.prototype.after = function(arg1, content) {}; + +/** + * @param {(string|Object.)} arg1 + * @param {Object.=} settings + * @return {jQuery.jqXHR} + */ +jQuery.ajax = function(arg1, settings) {}; + +/** + * @param {(string|Object.)} arg1 + * @param {Object.=} settings + * @return {jQuery.jqXHR} + */ +$.ajax = function(arg1, settings) {}; + +/** + * @param {function(jQuery.event,XMLHttpRequest,Object.)} handler + * @return {jQuery} + */ +jQuery.prototype.ajaxComplete = function(handler) {}; + +/** + * @param {function(jQuery.event,jQuery.jqXHR,Object.,*)} handler + * @return {jQuery} + */ +jQuery.prototype.ajaxError = function(handler) {}; + +/** + * @param {(string| + * function(Object.,Object.,jQuery.jqXHR))} dataTypes + * @param {function(Object.,Object.,jQuery.jqXHR)=} handler + * @return {undefined} + */ +jQuery.ajaxPrefilter = function(dataTypes, handler) {}; + +/** + * @param {(string| + * function(Object.,Object.,jQuery.jqXHR))} dataTypes + * @param {function(Object.,Object.,jQuery.jqXHR)=} handler + * @return {undefined} + */ +$.ajaxPrefilter = function(dataTypes, handler) {}; + +/** + * @param {function(jQuery.event,jQuery.jqXHR,Object.)} handler + * @return {jQuery} + */ +jQuery.prototype.ajaxSend = function(handler) {}; + +/** @param {Object.} options */ +jQuery.ajaxSetup = function(options) {}; + +/** @param {Object.} options */ +$.ajaxSetup = function(options) {}; + +/** + * @param {function()} handler + * @return {jQuery} + */ +jQuery.prototype.ajaxStart = function(handler) {}; + +/** + * @param {function()} handler + * @return {jQuery} + */ +jQuery.prototype.ajaxStop = function(handler) {}; + +/** + * @param {function(jQuery.event,XMLHttpRequest,Object.)} handler + * @return {jQuery} + */ +jQuery.prototype.ajaxSuccess = function(handler) {}; + +/** + * @return {jQuery} + * @nosideeffects + */ +jQuery.prototype.andSelf = function() {}; + +/** + * @param {Object.} properties + * @param {(string|number|function()|Object.)=} arg2 + * @param {(string|function())=} easing + * @param {function()=} complete + * @return {jQuery} + */ +jQuery.prototype.animate = function(properties, arg2, easing, complete) {}; + +/** + * @param {(string|Element|jQuery|function(number,string))} arg1 + * @param {(string|Element|Array.|jQuery)=} content + * @return {jQuery} + */ +jQuery.prototype.append = function(arg1, content) {}; + +/** + * @param {(jQuerySelector|Element|jQuery)} target + * @return {jQuery} + */ +jQuery.prototype.appendTo = function(target) {}; + +/** + * @param {(string|Object.)} arg1 + * @param {(string|number|function(number,string))=} arg2 + * @return {(string|jQuery)} + */ +jQuery.prototype.attr = function(arg1, arg2) {}; + +/** + * @param {(string|Element|jQuery|function())} arg1 + * @param {(string|Element|Array.|jQuery)=} content + * @return {jQuery} + */ +jQuery.prototype.before = function(arg1, content) {}; + +/** + * @param {(string|Object.)} arg1 + * @param {(Object.|function(jQuery.event)|boolean)=} eventData + * @param {(function(jQuery.event)|boolean)=} arg3 + * @return {jQuery} + */ +jQuery.prototype.bind = function(arg1, eventData, arg3) {}; + +/** + * @param {(function(jQuery.event)|Object.)=} arg1 + * @param {function(jQuery.event)=} handler + * @return {jQuery} + */ +jQuery.prototype.blur = function(arg1, handler) {}; + +/** @type {boolean} */ +jQuery.boxModel; + +/** @type {boolean} */ +$.boxModel; + +/** @type {jQuery.browser_} */ +jQuery.browser; + +/** @type {jQuery.browser_} */ +$.browser; + +/** + * This type is used interally to define the jQuery.browser subtype + * @constructor + * @private + */ +jQuery.browser_ = function() {}; + +/** + * @type {boolean} + * @const + */ +jQuery.browser_.prototype.mozilla; + +/** + * @type {boolean} + * @const + */ +jQuery.browser_.prototype.msie; + +/** + * @type {boolean} + * @const + */ +jQuery.browser_.prototype.opera; + +/** + * @type {boolean} + * @const + * @deprecated + */ +jQuery.browser_.prototype.safari; + +/** + * @type {string} + * @const + */ +jQuery.browser_.prototype.version; + +/** + * @type {boolean} + * @const + */ +jQuery.browser_.prototype.webkit; + +/** + * @param {(function(jQuery.event)|Object.)=} arg1 + * @param {function(jQuery.event)=} handler + * @return {jQuery} + */ +jQuery.prototype.change = function(arg1, handler) {}; + +/** + * @param {jQuerySelector=} selector + * @return {jQuery} + * @nosideeffects + */ +jQuery.prototype.children = function(selector) {}; + +/** + * @param {string=} queueName + * @return {jQuery} + */ +jQuery.prototype.clearQueue = function(queueName) {}; + +/** + * @param {(function(jQuery.event)|Object.)=} arg1 + * @param {function(jQuery.event)=} handler + * @return {jQuery} + */ +jQuery.prototype.click = function(arg1, handler) {}; + +/** + * @param {boolean=} withDataAndEvents + * @param {boolean=} deepWithDataAndEvents + * @return {jQuery} + * @suppress {checkTypes} http://code.google.com/p/closure-compiler/issues/detail?id=583 + */ +jQuery.prototype.clone = function(withDataAndEvents, deepWithDataAndEvents) {}; + +/** + * @param {(jQuerySelector|jQuery|Element|string|Array.)} arg1 + * @param {Element=} context + * @return {(jQuery|Array.)} + * @nosideeffects + */ +jQuery.prototype.closest = function(arg1, context) {}; + +/** + * @param {Element} container + * @param {Element} contained + * @return {boolean} + */ +jQuery.contains = function(container, contained) {}; + +/** + * @param {Element} container + * @param {Element} contained + * @return {boolean} + */ +$.contains = function(container, contained) {}; + +/** + * @return {jQuery} + * @nosideeffects + */ +jQuery.prototype.contents = function() {}; + +/** @type {Element} */ +jQuery.prototype.context; + +/** + * @param {(string|Object.)} arg1 + * @param {(string|number|function(number,*))=} arg2 + * @return {(string|jQuery)} + */ +jQuery.prototype.css = function(arg1, arg2) {}; + +/** @type {Object.} */ +jQuery.cssHooks; + +/** @type {Object.} */ +$.cssHooks; + +/** + * @param {Element} elem + * @param {string=} key + * @param {*=} value + * @return {*} + */ +jQuery.data = function(elem, key, value) {}; + +/** + * @param {(string|Object.)=} arg1 + * @param {*=} value + * @return {*} + */ +jQuery.prototype.data = function(arg1, value) {}; + +/** + * @param {Element} elem + * @param {string=} key + * @param {*=} value + * @return {*} + */ +$.data = function(elem, key, value) {}; + +/** + * @param {(function(jQuery.event)|Object.)=} arg1 + * @param {function(jQuery.event)=} handler + * @return {jQuery} + */ +jQuery.prototype.dblclick = function(arg1, handler) {}; + +/** + * @constructor + * @param {function()=} opt_fn + * @see http://api.jquery.com/category/deferred-object/ + */ +jQuery.deferred = function(opt_fn) {}; + +/** + * @constructor + * @extends {jQuery.deferred} + * @param {function()=} opt_fn + * @return {jQuery.Deferred} + */ +jQuery.Deferred = function(opt_fn) {}; + +/** + * @constructor + * @extends {jQuery.deferred} + * @param {function()=} opt_fn + * @see http://api.jquery.com/category/deferred-object/ + */ +$.deferred = function(opt_fn) {}; + +/** + * @constructor + * @extends {jQuery.deferred} + * @param {function()=} opt_fn + * @return {jQuery.Deferred} + */ +$.Deferred = function(opt_fn) {}; + +/** + * @param {function()} alwaysCallbacks + * @return {jQuery.deferred} + */ +jQuery.deferred.prototype.always = function(alwaysCallbacks) {}; + +/** + * @param {function()} doneCallbacks + * @param {function()=} doneCallbacks2 + * @return {jQuery.deferred} + */ +jQuery.deferred.prototype.done = function(doneCallbacks, doneCallbacks2) {}; + +/** + * @param {function()} failCallbacks + * @param {function()=} failCallbacks2 + * @return {jQuery.deferred} + */ +jQuery.deferred.prototype.fail = function(failCallbacks, failCallbacks2) {}; + +/** + * @return {boolean} + * @nosideeffects + */ +jQuery.deferred.prototype.isRejected = function() {}; + +/** + * @return {boolean} + * @nosideeffects + */ +jQuery.deferred.prototype.isResolved = function() {}; + +/** + * @param {function()=} doneFilter + * @param {function()=} failFilter + * @return {jQuery.Promise} + */ +jQuery.deferred.prototype.pipe = function(doneFilter, failFilter) {}; + +/** + * @param {Object=} target + * @return {jQuery.Promise} + */ +jQuery.deferred.prototype.promise = function(target) {}; + +/** + * @param {...*} var_args + * @return {jQuery.deferred} + */ +jQuery.deferred.prototype.reject = function(var_args) {}; + +/** + * @param {Object} context + * @param {Array.<*>=} args + * @return {jQuery.deferred} + */ +jQuery.deferred.prototype.rejectWith = function(context, args) {}; + +/** + * @param {...*} var_args + * @return {jQuery.deferred} + */ +jQuery.deferred.prototype.resolve = function(var_args) {}; + +/** + * @param {Object} context + * @param {Array.<*>=} args + * @return {jQuery.deferred} + */ +jQuery.deferred.prototype.resolveWith = function(context, args) {}; + +/** + * @param {function()} doneCallbacks + * @param {function()} failCallbacks + * @return {jQuery.deferred} + */ +jQuery.deferred.prototype.then = function(doneCallbacks, failCallbacks) {}; + +/** + * @param {number} duration + * @param {string=} queueName + * @return {jQuery} + */ +jQuery.prototype.delay = function(duration, queueName) {}; + +/** + * @param {string} selector + * @param {(string|Object.)} arg2 + * @param {(function()|Object.)=} arg3 + * @param {function()=} handler + * @return {jQuery} + */ +jQuery.prototype.delegate = function(selector, arg2, arg3, handler) {}; + +/** + * @param {Element} elem + * @param {string=} queueName + * @return {jQuery} + */ +jQuery.dequeue = function(elem, queueName) {}; + +/** + * @param {string=} queueName + * @return {jQuery} + */ +jQuery.prototype.dequeue = function(queueName) {}; + +/** + * @param {Element} elem + * @param {string=} queueName + * @return {jQuery} + */ +$.dequeue = function(elem, queueName) {}; + +/** + * @param {jQuerySelector=} selector + * @return {jQuery} + */ +jQuery.prototype.detach = function(selector) {}; + +/** + * @param {(string|Object.)=} arg1 + * @param {string=} handler + * @return {jQuery} + */ +jQuery.prototype.die = function(arg1, handler) {}; + +/** + * @param {Object} collection + * @param {function(number,*)} callback + * @return {Object} + */ +jQuery.each = function(collection, callback) {}; + +/** + * @param {function(number,Element)} fnc + * @return {jQuery} + */ +jQuery.prototype.each = function(fnc) {}; + +/** + * @param {Object} collection + * @param {function(number,*)} callback + * @return {Object} + */ +$.each = function(collection, callback) {}; + +/** @return {jQuery} */ +jQuery.prototype.empty = function() {}; + +/** + * @return {jQuery} + * @nosideeffects + */ +jQuery.prototype.end = function() {}; + +/** + * @param {number} arg1 + * @return {jQuery} + * @nosideeffects + */ +jQuery.prototype.eq = function(arg1) {}; + +/** @param {string} message */ +jQuery.error = function(message) {}; + +/** + * @param {(function(jQuery.event)|Object.)} arg1 + * @param {function(jQuery.event)=} handler + * @return {jQuery} + */ +jQuery.prototype.error = function(arg1, handler) {}; + +/** @param {string} message */ +$.error = function(message) {}; + +/** + * @constructor + * @param {string} eventType + */ +jQuery.event = function(eventType) {}; + +/** + * @constructor + * @extends {jQuery.event} + * @param {string} eventType + * @return {jQuery.Event} + */ +jQuery.Event = function(eventType) {}; + +/** + * @constructor + * @extends {jQuery.event} + * @param {string} eventType + */ +$.event = function(eventType) {}; + +/** + * @constructor + * @extends {jQuery.event} + * @param {string} eventType + * @return {$.Event} + */ +$.Event = function(eventType) {}; + +/** @type {Element} */ +jQuery.event.prototype.currentTarget; + +/** @type {*} */ +jQuery.event.prototype.data; + +/** + * @return {boolean} + * @nosideeffects + */ +jQuery.event.prototype.isDefaultPrevented = function() {}; + +/** + * @return {boolean} + * @nosideeffects + */ +jQuery.event.prototype.isImmediatePropagationStopped = function() {}; + +/** + * @return {boolean} + * @nosideeffects + */ +jQuery.event.prototype.isPropagationStopped = function() {}; + +/** @type {string} */ +jQuery.event.prototype.namespace; + +/** @type {Event} */ +jQuery.event.prototype.originalEvent; + +/** @type {number} */ +jQuery.event.prototype.pageX; + +/** @type {number} */ +jQuery.event.prototype.pageY; + +/** @return {undefined} */ +jQuery.event.prototype.preventDefault = function() {}; + +/** @type {Object.} */ +jQuery.event.prototype.props; + +/** @type {Element} */ +jQuery.event.prototype.relatedTarget; + +/** @type {*} */ +jQuery.event.prototype.result; + +/** @return {undefined} */ +jQuery.event.prototype.stopImmediatePropagation = function() {}; + +/** @return {undefined} */ +jQuery.event.prototype.stopPropagation = function() {}; + +/** @type {Element} */ +jQuery.event.prototype.target; + +/** @type {number} */ +jQuery.event.prototype.timeStamp; + +/** @type {string} */ +jQuery.event.prototype.type; + +/** @type {number} */ +jQuery.event.prototype.which; + +/** + * @param {(Object|boolean)} arg1 + * @param {...*} var_args + * @return {Object} + */ +jQuery.extend = function(arg1, var_args) {}; + +/** + * @param {(Object|boolean)} arg1 + * @param {...*} var_args + * @return {Object} + */ +jQuery.prototype.extend = function(arg1, var_args) {}; + +/** + * @param {(Object|boolean)} arg1 + * @param {...*} var_args + * @return {Object} + */ +$.extend = function(arg1, var_args) {}; + +/** + * @param {(string|number|function())=} duration + * @param {(function()|string)=} arg2 + * @param {function()=} callback + * @return {jQuery} + */ +jQuery.prototype.fadeIn = function(duration, arg2, callback) {}; + +/** + * @param {(string|number|function())=} duration + * @param {(function()|string)=} arg2 + * @param {function()=} callback + * @return {jQuery} + */ +jQuery.prototype.fadeOut = function(duration, arg2, callback) {}; + +/** + * @param {(string|number)} duration + * @param {number} opacity + * @param {(function()|string)=} arg3 + * @param {function()=} callback + * @return {jQuery} + */ +jQuery.prototype.fadeTo = function(duration, opacity, arg3, callback) {}; + +/** + * @param {(string|number|function())=} duration + * @param {(string|function())=} easing + * @param {function()=} callback + * @return {jQuery} + */ +jQuery.prototype.fadeToggle = function(duration, easing, callback) {}; + +/** + * @param {(jQuerySelector|function(number)|Element|jQuery)} arg1 + * @return {jQuery} + */ +jQuery.prototype.filter = function(arg1) {}; + +/** + * @param {(jQuerySelector|jQuery|Element)} arg1 + * @return {jQuery} + * @nosideeffects + */ +jQuery.prototype.find = function(arg1) {}; + +/** + * @return {jQuery} + * @nosideeffects + */ +jQuery.prototype.first = function() {}; + +/** @see http://docs.jquery.com/Plugins/Authoring */ +jQuery.fn; + +/** @see http://docs.jquery.com/Plugins/Authoring */ +$.fn; + +/** + * @param {(function(jQuery.event)|Object.)=} arg1 + * @param {function(jQuery.event)=} handler + * @return {jQuery} + */ +jQuery.prototype.focus = function(arg1, handler) {}; + +/** + * @param {(function(jQuery.event)|Object.)} arg1 + * @param {function(jQuery.event)=} handler + * @return {jQuery} + */ +jQuery.prototype.focusin = function(arg1, handler) {}; + +/** + * @param {(function(jQuery.event)|Object.)} arg1 + * @param {function(jQuery.event)=} handler + * @return {jQuery} + */ +jQuery.prototype.focusout = function(arg1, handler) {}; + +/** @const */ +jQuery.fx = {}; + +/** @const */ +$.fx = {}; + +/** @type {number} */ +jQuery.fx.interval; + +/** @type {number} */ +$.fx.interval; + +/** @type {boolean} */ +jQuery.fx.off; + +/** @type {boolean} */ +$.fx.off; + +/** + * @param {string} url + * @param {(Object.|string| + * function(string,string,jQuery.jqXHR))=} data + * @param {(function(string,string,jQuery.jqXHR)|string)=} success + * @param {string=} dataType + * @return {jQuery.jqXHR} + */ +jQuery.get = function(url, data, success, dataType) {}; + +/** + * @param {number=} index + * @return {(Element|Array.)} + * @nosideeffects + */ +jQuery.prototype.get = function(index) {}; + +/** + * @param {string} url + * @param {(Object.|string| + * function(string,string,jQuery.jqXHR))=} data + * @param {(function(string,string,jQuery.jqXHR)|string)=} success + * @param {string=} dataType + * @return {jQuery.jqXHR} + */ +$.get = function(url, data, success, dataType) {}; + +/** + * @param {string} url + * @param {(Object.|function(string,string,jQuery.jqXHR))=} data + * @param {function(string,string,jQuery.jqXHR)=} success + * @return {jQuery.jqXHR} + */ +jQuery.getJSON = function(url, data, success) {}; + +/** + * @param {string} url + * @param {(Object.|function(string,string,jQuery.jqXHR))=} data + * @param {function(string,string,jQuery.jqXHR)=} success + * @return {jQuery.jqXHR} + */ +$.getJSON = function(url, data, success) {}; + +/** + * @param {string} url + * @param {function(string,string)=} success + * @return {XMLHttpRequest} + */ +jQuery.getScript = function(url, success) {}; + +/** + * @param {string} url + * @param {function(string,string)=} success + * @return {XMLHttpRequest} + */ +$.getScript = function(url, success) {}; + +/** @param {string} code */ +jQuery.globalEval = function(code) {}; + +/** @param {string} code */ +$.globalEval = function(code) {}; + +/** + * @param {Array.<*>} arr + * @param {function(*,number)} fnc + * @param {boolean=} invert + * @return {Array.<*>} + */ +jQuery.grep = function(arr, fnc, invert) {}; + +/** + * @param {Array.<*>} arr + * @param {function(*,number)} fnc + * @param {boolean=} invert + * @return {Array.<*>} + */ +$.grep = function(arr, fnc, invert) {}; + +/** + * @param {(string|Element)} arg1 + * @return {jQuery} + * @nosideeffects + */ +jQuery.prototype.has = function(arg1) {}; + +/** + * @param {string} className + * @return {boolean} + * @nosideeffects + */ +jQuery.prototype.hasClass = function(className) {}; + +/** + * @param {Element} elem + * @return {boolean} + * @nosideeffects + */ +jQuery.hasData = function(elem) {}; + +/** + * @param {Element} elem + * @return {boolean} + * @nosideeffects + */ +$.hasData = function(elem) {}; + +/** + * @param {(string|number|function(number,number))=} arg1 + * @return {(number|jQuery)} + */ +jQuery.prototype.height = function(arg1) {}; + +/** + * @param {(string|number|function())=} duration + * @param {(function()|string)=} arg2 + * @param {function()=} callback + * @return {jQuery} + */ +jQuery.prototype.hide = function(duration, arg2, callback) {}; + +/** + * @param {boolean} hold + * @return {boolean} + */ +jQuery.holdReady = function(hold) {}; + +/** + * @param {boolean} hold + * @return {boolean} + */ +$.holdReady = function(hold) {}; + +/** + * @param {function(jQuery.event)} arg1 + * @param {function(jQuery.event)=} handlerOut + * @return {jQuery} + */ +jQuery.prototype.hover = function(arg1, handlerOut) {}; + +/** + * @param {(string|function(number,string))=} arg1 + * @return {(string|jQuery)} + */ +jQuery.prototype.html = function(arg1) {}; + +/** + * @param {*} value + * @param {Array.<*>} arr + * @return {number} + * @nosideeffects + */ +jQuery.inArray = function(value, arr) {}; + +/** + * @param {*} value + * @param {Array.<*>} arr + * @return {number} + * @nosideeffects + */ +$.inArray = function(value, arr) {}; + +/** + * @param {(jQuerySelector|Element|jQuery)=} arg1 + * @return {number} + */ +jQuery.prototype.index = function(arg1) {}; + +/** + * @return {number} + * @nosideeffects + */ +jQuery.prototype.innerHeight = function() {}; + +/** + * @return {number} + * @nosideeffects + */ +jQuery.prototype.innerWidth = function() {}; + +/** + * @param {(jQuerySelector|Element|jQuery)} target + * @return {jQuery} + */ +jQuery.prototype.insertAfter = function(target) {}; + +/** + * @param {(jQuerySelector|Element|jQuery)} target + * @return {jQuery} + */ +jQuery.prototype.insertBefore = function(target) {}; + +/** + * @param {(jQuerySelector|function(number)|jQuery|Element)} arg1 + * @return {boolean} + */ +jQuery.prototype.is = function(arg1) {}; + +/** + * @param {*} obj + * @return {boolean} + * @nosideeffects + */ +jQuery.isArray = function(obj) {}; + +/** + * @param {*} obj + * @return {boolean} + * @nosideeffects + */ +$.isArray = function(obj) {}; + +/** + * @param {Object} obj + * @return {boolean} + * @nosideeffects + */ +jQuery.isEmptyObject = function(obj) {}; + +/** + * @param {Object} obj + * @return {boolean} + * @nosideeffects + */ +$.isEmptyObject = function(obj) {}; + +/** + * @param {*} obj + * @return {boolean} + * @nosideeffects + */ +jQuery.isFunction = function(obj) {}; + +/** + * @param {*} obj + * @return {boolean} + * @nosideeffects + */ +$.isFunction = function(obj) {}; + +/** + * @param {Object} obj + * @return {boolean} + * @nosideeffects + */ +jQuery.isPlainObject = function(obj) {}; + +/** + * @param {Object} obj + * @return {boolean} + * @nosideeffects + */ +$.isPlainObject = function(obj) {}; + +/** + * @param {*} obj + * @return {boolean} + * @nosideeffects + */ +jQuery.isWindow = function(obj) {}; + +/** + * @param {*} obj + * @return {boolean} + * @nosideeffects + */ +$.isWindow = function(obj) {}; + +/** + * @param {Element} node + * @return {boolean} + * @nosideeffects + */ +jQuery.isXMLDoc = function(node) {}; + +/** + * @param {Element} node + * @return {boolean} + * @nosideeffects + */ +$.isXMLDoc = function(node) {}; + +/** @type {string} */ +jQuery.prototype.jquery; + +/** + * @constructor + * @extends {XMLHttpRequest} + * @implements {jQuery.Promise} + * @private + * @see http://api.jquery.com/jQuery.ajax/#jqXHR + */ +jQuery.jqXHR = function () {}; + +/** + * @param {function()} callback + * @return {jQuery.jqXHR} +*/ +jQuery.jqXHR.prototype.complete = function (callback) {}; + +/** + * @override + * @param {function()} doneCallbacks + * @return {jQuery.Promise} + */ +jQuery.jqXHR.prototype.done = function(doneCallbacks) {}; + +/** + * @param {function()} callback + * @return {jQuery.jqXHR} +*/ +jQuery.jqXHR.prototype.error = function (callback) {}; + +/** + * @override + * @param {function()} failCallbacks + * @return {jQuery.Promise} + */ +jQuery.jqXHR.prototype.fail = function(failCallbacks) {}; + +/** + * @override + * @return {boolean} + * @nosideeffects + */ +jQuery.jqXHR.prototype.isRejected = function() {}; + +/** + * @override + * @return {boolean} + * @nosideeffects + */ +jQuery.jqXHR.prototype.isResolved = function() {}; + +/** + * @override + * @deprecated + */ +jQuery.jqXHR.prototype.onreadystatechange = function (callback) {}; + +/** + * @param {function()} callback + * @return {jQuery.jqXHR} +*/ +jQuery.jqXHR.prototype.success = function (callback) {}; + +/** + * @override + * @param {function()} doneCallbacks + * @param {function()} failCallbacks + * @return {jQuery.Promise} + */ +jQuery.jqXHR.prototype.then = function(doneCallbacks, failCallbacks) {}; + +/** + * @param {(function(jQuery.event)|Object.)=} arg1 + * @param {function(jQuery.event)=} handler + * @return {jQuery} + */ +jQuery.prototype.keydown = function(arg1, handler) {}; + +/** + * @param {(function(jQuery.event)|Object.)=} arg1 + * @param {function(jQuery.event)=} handler + * @return {jQuery} + */ +jQuery.prototype.keypress = function(arg1, handler) {}; + +/** + * @param {(function(jQuery.event)|Object.)=} arg1 + * @param {function(jQuery.event)=} handler + * @return {jQuery} + */ +jQuery.prototype.keyup = function(arg1, handler) {}; + +/** + * @return {jQuery} + * @nosideeffects + */ +jQuery.prototype.last = function() {}; + +/** @type {number} */ +jQuery.prototype.length; + +/** + * @param {(string|Object.)} arg1 + * @param {(function()|Object.)=} arg2 + * @param {function()=} handler + * @return {jQuery} + */ +jQuery.prototype.live = function(arg1, arg2, handler) {}; + +/** + * @param {(function(jQuery.event)|Object.|string)} arg1 + * @param {(function(jQuery.event)|Object.|string)=} arg2 + * @param {function(string,string,XMLHttpRequest)=} complete + * @return {jQuery} + */ +jQuery.prototype.load = function(arg1, arg2, complete) {}; + +/** + * @param {*} obj + * @return {Array.<*>} + */ +jQuery.makeArray = function(obj) {}; + +/** + * @param {*} obj + * @return {Array.<*>} + */ +$.makeArray = function(obj) {}; + +/** + * @param {(Array.<*>|Object.)} arg1 + * @param {(function(*,number)|function(*,(string|number)))} callback + * @return {Array.<*>} + */ +jQuery.map = function(arg1, callback) {}; + +/** + * @param {function(number,Element)} callback + * @return {jQuery} + */ +jQuery.prototype.map = function(callback) {}; + +/** + * @param {(Array.<*>|Object.)} arg1 + * @param {(function(*,number)|function(*,(string|number)))} callback + * @return {Array.<*>} + */ +$.map = function(arg1, callback) {}; + +/** + * @param {Array.<*>} first + * @param {Array.<*>} second + * @return {Array.<*>} + */ +jQuery.merge = function(first, second) {}; + +/** + * @param {Array.<*>} first + * @param {Array.<*>} second + * @return {Array.<*>} + */ +$.merge = function(first, second) {}; + +/** + * @param {(function(jQuery.event)|Object.)=} arg1 + * @param {function(jQuery.event)=} handler + * @return {jQuery} + */ +jQuery.prototype.mousedown = function(arg1, handler) {}; + +/** + * @param {(function(jQuery.event)|Object.)=} arg1 + * @param {function(jQuery.event)=} handler + * @return {jQuery} + */ +jQuery.prototype.mouseenter = function(arg1, handler) {}; + +/** + * @param {(function(jQuery.event)|Object.)=} arg1 + * @param {function(jQuery.event)=} handler + * @return {jQuery} + */ +jQuery.prototype.mouseleave = function(arg1, handler) {}; + +/** + * @param {(function(jQuery.event)|Object.)=} arg1 + * @param {function(jQuery.event)=} handler + * @return {jQuery} + */ +jQuery.prototype.mousemove = function(arg1, handler) {}; + +/** + * @param {(function(jQuery.event)|Object.)=} arg1 + * @param {function(jQuery.event)=} handler + * @return {jQuery} + */ +jQuery.prototype.mouseout = function(arg1, handler) {}; + +/** + * @param {(function(jQuery.event)|Object.)=} arg1 + * @param {function(jQuery.event)=} handler + * @return {jQuery} + */ +jQuery.prototype.mouseover = function(arg1, handler) {}; + +/** + * @param {(function(jQuery.event)|Object.)=} arg1 + * @param {function(jQuery.event)=} handler + * @return {jQuery} + */ +jQuery.prototype.mouseup = function(arg1, handler) {}; + +/** + * @param {jQuerySelector=} selector + * @return {jQuery} + * @nosideeffects + */ +jQuery.prototype.next = function(selector) {}; + +/** + * @param {string=} selector + * @return {jQuery} + * @nosideeffects + */ +jQuery.prototype.nextAll = function(selector) {}; + +/** + * @param {jQuerySelector=} selector + * @return {jQuery} + * @nosideeffects + */ +jQuery.prototype.nextUntil = function(selector) {}; + +/** + * @param {boolean=} removeAll + * @return {Object} + */ +jQuery.noConflict = function(removeAll) {}; + +/** + * @param {boolean=} removeAll + * @return {Object} + */ +$.noConflict = function(removeAll) {}; + +/** + * @return {function()} + * @nosideeffects + */ +jQuery.noop = function() {}; + +/** + * @return {function()} + * @nosideeffects + */ +$.noop = function() {}; + +/** + * @param {(jQuerySelector|Array.|function(number))} arg1 + * @return {jQuery} + */ +jQuery.prototype.not = function(arg1) {}; + +/** + * @return {number} + * @nosideeffects + */ +jQuery.now = function() {}; + +/** + * @return {number} + * @nosideeffects + */ +$.now = function() {}; + +/** + * @param {({left:number,top:number}| + * function(number,{top:number,left:number}))=} arg1 + * @return {({left:number,top:number}|jQuery)} + */ +jQuery.prototype.offset = function(arg1) {}; + +/** + * @return {jQuery} + * @nosideeffects + */ +jQuery.prototype.offsetParent = function() {}; + +/** + * @param {string} eventType + * @param {(Object.|function(jQuery.event))} eventData + * @param {function(jQuery.event)=} handler + * @return {jQuery} + */ +jQuery.prototype.one = function(eventType, eventData, handler) {}; + +/** + * @param {boolean=} includeMargin + * @return {number} + * @nosideeffects + */ +jQuery.prototype.outerHeight = function(includeMargin) {}; + +/** + * @param {boolean=} includeMargin + * @return {number} + * @nosideeffects + */ +jQuery.prototype.outerWidth = function(includeMargin) {}; + +/** + * @param {(Object.|Array.>)} obj + * @param {boolean=} traditional + * @return {string} + */ +jQuery.param = function(obj, traditional) {}; + +/** + * @param {(Object.|Array.>)} obj + * @param {boolean=} traditional + * @return {string} + */ +$.param = function(obj, traditional) {}; + +/** + * @param {jQuerySelector=} selector + * @return {jQuery} + * @nosideeffects + */ +jQuery.prototype.parent = function(selector) {}; + +/** + * @param {jQuerySelector=} selector + * @return {jQuery} + * @nosideeffects + */ +jQuery.prototype.parents = function(selector) {}; + +/** + * @param {jQuerySelector=} selector + * @return {jQuery} + * @nosideeffects + */ +jQuery.prototype.parentsUntil = function(selector) {}; + +/** + * @param {string} json + * @return {Object.} + */ +jQuery.parseJSON = function(json) {}; + +/** + * @param {string} json + * @return {Object.} + */ +$.parseJSON = function(json) {}; + +/** + * @param {string} data + * @return {Document} + */ +jQuery.parseXML = function(data) {}; + +/** + * @param {string} data + * @return {Document} + */ +$.parseXML = function(data) {}; + +/** + * @return {{left:number,top:number}} + * @nosideeffects + */ +jQuery.prototype.position = function() {}; + +/** + * @param {string} url + * @param {(Object.|string| + * function(string,string,jQuery.jqXHR))=} data + * @param {(function(string,string,jQuery.jqXHR)|string)=} success + * @param {string=} dataType + * @return {jQuery.jqXHR} + */ +jQuery.post = function(url, data, success, dataType) {}; + +/** + * @param {string} url + * @param {(Object.|string| + * function(string,string,jQuery.jqXHR))=} data + * @param {(function(string,string,jQuery.jqXHR)|string)=} success + * @param {string=} dataType + * @return {jQuery.jqXHR} + */ +$.post = function(url, data, success, dataType) {}; + +/** + * @param {(string|Element|jQuery|function(number,string))} arg1 + * @param {(string|Element|jQuery)=} content + * @return {jQuery} + */ +jQuery.prototype.prepend = function(arg1, content) {}; + +/** + * @param {(jQuerySelector|Element|jQuery)} target + * @return {jQuery} + */ +jQuery.prototype.prependTo = function(target) {}; + +/** + * @param {jQuerySelector=} selector + * @return {jQuery} + * @nosideeffects + */ +jQuery.prototype.prev = function(selector) {}; + +/** + * @param {jQuerySelector=} selector + * @return {jQuery} + * @nosideeffects + */ +jQuery.prototype.prevAll = function(selector) {}; + +/** + * @param {jQuerySelector=} selector + * @return {jQuery} + * @nosideeffects + */ +jQuery.prototype.prevUntil = function(selector) {}; + +/** + * @param {(string|Object)=} type + * @param {Object=} target + * @return {jQuery.Promise} + */ +jQuery.prototype.promise = function(type, target) {}; + +/** + * @interface + * @private + * @see http://api.jquery.com/Types/#Promise + */ +jQuery.Promise = function () {}; + +/** + * @param {function()} doneCallbacks + * @return {jQuery.Promise} + */ +jQuery.Promise.prototype.done = function(doneCallbacks) {}; + +/** + * @param {function()} failCallbacks + * @return {jQuery.Promise} + */ +jQuery.Promise.prototype.fail = function(failCallbacks) {}; + +/** + * @return {boolean} + * @nosideeffects + */ +jQuery.Promise.prototype.isRejected = function() {}; + +/** + * @return {boolean} + * @nosideeffects + */ +jQuery.Promise.prototype.isResolved = function() {}; + +/** + * @param {function()} doneCallbacks + * @param {function()} failCallbacks + * @return {jQuery.Promise} + */ +jQuery.Promise.prototype.then = function(doneCallbacks, failCallbacks) {}; + +/** + * @param {(string|Object.)} arg1 + * @param {(string|number|boolean|function(number,String))=} arg2 + * @return {(string|jQuery)} + */ +jQuery.prototype.prop = function(arg1, arg2) {}; + +/** + * @param {(function()|Object)} arg1 + * @param {(Object|string)} arg2 + * @return {function()} + */ +jQuery.proxy = function(arg1, arg2) {}; + +/** + * @param {(function()|Object)} arg1 + * @param {(Object|string)} arg2 + * @return {function()} + */ +$.proxy = function(arg1, arg2) {}; + +/** + * @param {Array.} elements + * @param {string=} name + * @param {Array.<*>=} args + * @return {jQuery} + */ +jQuery.prototype.pushStack = function(elements, name, args) {}; + +/** + * @param {(string|Array.|function(function()))=} queueName + * @param {(Array.|function(function()))=} arg2 + * @return {(Array.|jQuery)} + */ +jQuery.prototype.queue = function(queueName, arg2) {}; + +/** + * @param {Element} elem + * @param {string=} queueName + * @param {(Array.|function())=} arg3 + * @return {(Array.|jQuery)} + */ +jQuery.queue = function(elem, queueName, arg3) {}; + +/** + * @param {Element} elem + * @param {string=} queueName + * @param {(Array.|function())=} arg3 + * @return {(Array.|jQuery)} + */ +$.queue = function(elem, queueName, arg3) {}; + +/** + * @param {function()} handler + * @return {jQuery} + */ +jQuery.prototype.ready = function(handler) {}; + +/** + * @param {string=} selector + * @return {jQuery} + */ +jQuery.prototype.remove = function(selector) {}; + +/** + * @param {string} attributeName + * @return {jQuery} + */ +jQuery.prototype.removeAttr = function(attributeName) {}; + +/** + * @param {(string|function(number,string))=} arg1 + * @return {jQuery} + */ +jQuery.prototype.removeClass = function(arg1) {}; + +/** + * @param {string=} name + * @return {jQuery} + */ +jQuery.prototype.removeData = function(name) {}; + +/** + * @param {Element} elem + * @param {string=} name + * @return {jQuery} + */ +jQuery.removeData = function(elem, name) {}; + +/** + * @param {Element} elem + * @param {string=} name + * @return {jQuery} + */ +$.removeData = function(elem, name) {}; + +/** + * @param {string} propertyName + * @param {(string|number|boolean)} value + * @return {jQuery} + */ +jQuery.prototype.removeProp = function(propertyName, value) {}; + +/** + * @param {jQuerySelector} target + * @return {jQuery} + */ +jQuery.prototype.replaceAll = function(target) {}; + +/** + * @param {(string|Element|jQuery|function())} arg1 + * @return {jQuery} + */ +jQuery.prototype.replaceWith = function(arg1) {}; + +/** + * @param {(function(jQuery.event)|Object.)=} arg1 + * @param {function(jQuery.event)=} handler + * @return {jQuery} + */ +jQuery.prototype.resize = function(arg1, handler) {}; + +/** + * @param {(function(jQuery.event)|Object.)=} arg1 + * @param {function(jQuery.event)=} handler + * @return {jQuery} + */ +jQuery.prototype.scroll = function(arg1, handler) {}; + +/** + * @param {number=} value + * @return {(number|jQuery)} + */ +jQuery.prototype.scrollLeft = function(value) {}; + +/** + * @param {number=} value + * @return {(number|jQuery)} + */ +jQuery.prototype.scrollTop = function(value) {}; + +/** + * @param {(function(jQuery.event)|Object.)=} arg1 + * @param {function(jQuery.event)=} handler + * @return {jQuery} + */ +jQuery.prototype.select = function(arg1, handler) {}; + +/** + * @return {string} + * @nosideeffects + */ +jQuery.prototype.serialize = function() {}; + +/** + * @return {Array.>} + * @nosideeffects + */ +jQuery.prototype.serializeArray = function() {}; + +/** + * @param {(string|number|function())=} duration + * @param {(function()|string)=} arg2 + * @param {function()=} callback + * @return {jQuery} + */ +jQuery.prototype.show = function(duration, arg2, callback) {}; + +/** + * @param {jQuerySelector=} selector + * @return {jQuery} + * @nosideeffects + */ +jQuery.prototype.siblings = function(selector) {}; + +/** + * @return {number} + * @nosideeffects + */ +jQuery.prototype.size = function() {}; + +/** + * @param {number} start + * @param {number=} end + * @return {jQuery} + * @nosideeffects + */ +jQuery.prototype.slice = function(start, end) {}; + +/** + * @param {(string|number|function())=} duration + * @param {(function()|string)=} arg2 + * @param {function()=} callback + * @return {jQuery} + */ +jQuery.prototype.slideDown = function(duration, arg2, callback) {}; + +/** + * @param {(string|number|function())=} duration + * @param {(function()|string)=} arg2 + * @param {function()=} callback + * @return {jQuery} + */ +jQuery.prototype.slideToggle = function(duration, arg2, callback) {}; + +/** + * @param {(string|number|function())=} duration + * @param {(function()|string)=} arg2 + * @param {function()=} callback + * @return {jQuery} + */ +jQuery.prototype.slideUp = function(duration, arg2, callback) {}; + +/** + * @param {boolean=} clearQueue + * @param {boolean=} jumpToEnd + * @return {jQuery} + */ +jQuery.prototype.stop = function(clearQueue, jumpToEnd) {}; + +/** + * @return {jQuery} + * @nosideeffects + */ +jQuery.sub = function() {}; + +/** + * @return {jQuery} + * @nosideeffects + */ +$.sub = function() {}; + +/** + * @param {(function(jQuery.event)|Object.)=} arg1 + * @param {function(jQuery.event)=} handler + * @return {jQuery} + */ +jQuery.prototype.submit = function(arg1, handler) {}; + +/** @type {jQuery.support_} */ +jQuery.support; + +/** @type {jQuery.support_} */ +$.support; + +/** + * This type is used interally to define the jQuery.support subtype + * @constructor + * @private + */ +jQuery.support_ = function() {}; + +/** @type {boolean} */ +jQuery.support_.prototype.boxModel; + +/** @type {boolean} */ +jQuery.support_.prototype.changeBubbles; + +/** @type {boolean} */ +jQuery.support_.prototype.cssFloat; + +/** @type {boolean} */ +jQuery.support_.prototype.hrefNormalized; + +/** @type {boolean} */ +jQuery.support_.prototype.htmlSerialize; + +/** @type {boolean} */ +jQuery.support_.prototype.leadingWhitespace; + +/** @type {boolean} */ +jQuery.support_.prototype.noCloneEvent; + +/** @type {boolean} */ +jQuery.support_.prototype.opacity; + +/** @type {boolean} */ +jQuery.support_.prototype.scriptEval; + +/** @type {boolean} */ +jQuery.support_.prototype.style; + +/** @type {boolean} */ +jQuery.support_.prototype.submitBubbles; + +/** @type {boolean} */ +jQuery.support_.prototype.tbody; + +/** + * @param {(string|function(number,string))=} arg1 + * @return {(string|jQuery)} + */ +jQuery.prototype.text = function(arg1) {}; + +/** + * @return {Array.} + * @nosideeffects + */ +jQuery.prototype.toArray = function() {}; + +/** + * @param {(function(jQuery.event)|string|number|function()|boolean)=} arg1 + * @param {(function(jQuery.event)|function()|string)=} arg2 + * @param {(function(jQuery.event)|function())=} arg3 + * @return {jQuery} + */ +jQuery.prototype.toggle = function(arg1, arg2, arg3) {}; + +/** + * @param {(string|function(number,string))} arg1 + * @param {boolean=} flag + * @return {jQuery} + */ +jQuery.prototype.toggleClass = function(arg1, flag) {}; + +/** + * @param {(string|jQuery.event)} arg1 + * @param {Object=} extraParameters + * @return {jQuery} + */ +jQuery.prototype.trigger = function(arg1, extraParameters) {}; + +/** + * @param {string} eventType + * @param {Array.<*>} extraParameters + * @return {*} + */ +jQuery.prototype.triggerHandler = function(eventType, extraParameters) {}; + +/** + * @param {string} str + * @return {string} + * @nosideeffects + */ +jQuery.trim = function(str) {}; + +/** + * @param {string} str + * @return {string} + * @nosideeffects + */ +$.trim = function(str) {}; + +/** + * @param {*} obj + * @return {string} + * @nosideeffects + */ +jQuery.type = function(obj) {}; + +/** + * @param {*} obj + * @return {string} + * @nosideeffects + */ +$.type = function(obj) {}; + +/** + * @param {(string|function(jQuery.event)|jQuery.event)=} arg1 + * @param {(function(jQuery.event)|boolean)=} arg2 + * @return {jQuery} + */ +jQuery.prototype.unbind = function(arg1, arg2) {}; + +/** + * @param {string=} arg1 + * @param {(string|Object.)=} arg2 + * @param {function()=} handler + * @return {jQuery} + */ +jQuery.prototype.undelegate = function(arg1, arg2, handler) {}; + +/** + * @param {Array.} arr + * @return {Array.} + */ +jQuery.unique = function(arr) {}; + +/** + * @param {Array.} arr + * @return {Array.} + */ +$.unique = function(arr) {}; + +/** + * @param {(function(jQuery.event)|Object.)} arg1 + * @param {function(jQuery.event)=} handler + * @return {jQuery} + */ +jQuery.prototype.unload = function(arg1, handler) {}; + +/** @return {jQuery} */ +jQuery.prototype.unwrap = function() {}; + +/** + * @param {(string|function(number,*))=} arg1 + * @return {(string|number|Array.|jQuery)} + */ +jQuery.prototype.val = function(arg1) {}; + +/** + * @param {jQuery.deferred} deferreds + * @return {jQuery.Promise} + */ +jQuery.when = function(deferreds) {}; + +/** + * @param {jQuery.deferred} deferreds + * @return {jQuery.Promise} + */ +$.when = function(deferreds) {}; + +/** + * @param {(string|number|function(number,number))=} arg1 + * @return {(number|jQuery)} + */ +jQuery.prototype.width = function(arg1) {}; + +/** + * @param {(string|jQuerySelector|Element|jQuery|function(number))} arg1 + * @return {jQuery} + */ +jQuery.prototype.wrap = function(arg1) {}; + +/** + * @param {(string|jQuerySelector|Element|jQuery)} wrappingElement + * @return {jQuery} + */ +jQuery.prototype.wrapAll = function(wrappingElement) {}; + +/** + * @param {(string|function())} arg1 + * @return {jQuery} + */ +jQuery.prototype.wrapInner = function(arg1) {}; From 651b8ac34398a37adef07a312e87341404ae01e8 Mon Sep 17 00:00:00 2001 From: Jason Busby Date: Mon, 7 May 2012 19:08:30 +0100 Subject: [PATCH 18/19] Added braces to prevent lint errors. Improved readme --- README.markdown | 8 ++++---- jquery.nivo.slider.js | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.markdown b/README.markdown index 80bec70..b28a58a 100644 --- a/README.markdown +++ b/README.markdown @@ -1,8 +1,8 @@ >Nivo Slider is "The Most Awesome jQuery Image Slider". See http://nivo.dev7studios.com for more info. -## New Features -- New cycle, cycleLeft and cycleRigt effects, aka sliding. "cycle" moves depending on slide direction. -- New slideIn effect animates depending on slide direction. +## Branch Features +- New 'cycle', 'cycleLeft' and 'cycleRigt' effects, aka sliding. 'cycle' moves depending on slide direction. +- New 'slideIn' effect animates depending on slide direction. - Supports Webkit keyboard arrow keys. - Improved code which is less dependant on jQuery. -- Packed with Google Closure Compiler Advanced using jquery externs file. Comes out at the same size of the original but with more features! \ No newline at end of file +- Packed with Google Closure Compiler Advanced using jquery externs file. Comes out smaller at a size of the original but with more features! \ No newline at end of file diff --git a/jquery.nivo.slider.js b/jquery.nivo.slider.js index aa52e1f..c0b4340 100644 --- a/jquery.nivo.slider.js +++ b/jquery.nivo.slider.js @@ -866,7 +866,7 @@ // Shuffle an array var shuffle = function(arr){ - for(var j, x, i = arr.length; i; j = parseInt(Math.random() * i), x = arr[--i], arr[i] = arr[j], arr[j] = x); + for(var j, x, i = arr.length; i; j = parseInt(Math.random() * i), x = arr[--i], arr[i] = arr[j], arr[j] = x){}; return arr; } From b3b9ccd726eeb8fde9269720226d1ae0a18e6cef Mon Sep 17 00:00:00 2001 From: Jason Busby Date: Mon, 7 May 2012 19:12:05 +0100 Subject: [PATCH 19/19] Improved readme --- README.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.markdown b/README.markdown index b28a58a..68982ff 100644 --- a/README.markdown +++ b/README.markdown @@ -1,8 +1,8 @@ >Nivo Slider is "The Most Awesome jQuery Image Slider". See http://nivo.dev7studios.com for more info. ## Branch Features -- New 'cycle', 'cycleLeft' and 'cycleRigt' effects, aka sliding. 'cycle' moves depending on slide direction. +- New 'cycle', 'cycleLeft' and 'cycleRigt' effects, aka sliding. 'cycle' animates depending on slide direction. - New 'slideIn' effect animates depending on slide direction. - Supports Webkit keyboard arrow keys. - Improved code which is less dependant on jQuery. -- Packed with Google Closure Compiler Advanced using jquery externs file. Comes out smaller at a size of the original but with more features! \ No newline at end of file +- Packed with Google Closure Compiler Advanced using jquery externs file. Smaller size than the original but with more features! \ No newline at end of file