From 556910e59432295376b44bee393e79724a3723ce Mon Sep 17 00:00:00 2001 From: thydzik Date: Fri, 23 Nov 2012 09:00:26 +0800 Subject: [PATCH 1/4] Update README --- README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README b/README index 2e5185c..8d4d9d0 100644 --- a/README +++ b/README @@ -1 +1 @@ -Nivo Slider is "The Most Awesome jQuery Image Slider". See http://nivo.dev7studios.com for more info. \ No newline at end of file +Lazy Load v2 \ No newline at end of file From 23427f8bb31fffafd14a8ceb920ec71db848d241 Mon Sep 17 00:00:00 2001 From: thydzik Date: Fri, 23 Nov 2012 09:02:24 +0800 Subject: [PATCH 2/4] Update jquery.nivo.slider.js --- jquery.nivo.slider.js | 148 ++++++++++++++++++++++++++++++++---------- 1 file changed, 114 insertions(+), 34 deletions(-) diff --git a/jquery.nivo.slider.js b/jquery.nivo.slider.js index 8c290b2..4f65389 100644 --- a/jquery.nivo.slider.js +++ b/jquery.nivo.slider.js @@ -5,6 +5,12 @@ * Copyright 2012, Dev7studios * Free to use and abuse under the MIT license. * http://www.opensource.org/licenses/mit-license.php + * + * Copyright 2012, Lee Powers, Gilbert Pellegrom + * Free to use and abuse under the MIT license. + * http://www.opensource.org/licenses/mit-license.php + * + * Code updates from jQuery Lazy Nivo Slider 1.0 */ (function($) { @@ -49,39 +55,84 @@ child.css('display','none'); vars.totalSlides++; }); - - // If randomStart - if(settings.randomStart){ - settings.startSlide = Math.floor(Math.random() * vars.totalSlides); + + // START ADDED + // Parse image source from an element. + // Checks in data-src, then in src + var parse_src = function(elem) { + return elem.data('src') || elem.attr('src'); } - // Set startSlide - if(settings.startSlide > 0){ - if(settings.startSlide >= vars.totalSlides) { settings.startSlide = vars.totalSlides - 1; } - vars.currentSlide = settings.startSlide; + // Parse out the image URL string at the given child index. + // Does no bounds checking! + var parse_image = function(idx) { + if($(kids[idx]).is('img')) { + return $(kids[idx]); + } else { + return $(kids[idx]).find('img:first'); + } } + // Preload the image in the kids collection at the given step from the current slide + var preload_image = function(step) { + + var nxt = vars.currentSlide + step; + if (nxt >= kids.length) nxt = 0 + else if (nxt < 0) nxt = 0; + var img = parse_image(nxt); + img.attr('src', img.data('src')); + } + // END ADDED + // 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 - var sliderImg = $(''); - sliderImg.attr('src', vars.currentImage.attr('src')).show(); + //preload_image(0); //the first image is a src image + var sliderImg = $(''); + //sliderImg.attr('src', vars.currentImage.attr('src')).show(); + sliderImg.attr('src', parse_src(vars.currentImage)).show();//ADDED slider.append(sliderImg); + + // 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; + } + + preload_image(1); + + //START ADDED + // Preload second image to transition into. + // Given the first image some time to load! + //if (!settings.manualAdvance && kids.length > 1) { + // setTimeout(function() { + // preload_image(1); + // //}, Math.max(1000, settings.pauseTime - 1000)); + // //}, settings.pauseTime / 2); + // }, 0); + //} + //END ADDED // Detect Window Resize $(window).resize(function() { slider.children('img').width(slider.width()); - sliderImg.attr('src', vars.currentImage.attr('src')); + //sliderImg.attr('src', vars.currentImage.attr('src')); + sliderImg.attr('src', parse_src(vars.currentImage)); //ADDED sliderImg.stop().height('auto'); $('.nivo-slice').remove(); $('.nivo-box').remove(); @@ -164,7 +215,8 @@ if($(this).hasClass('active')) return false; clearInterval(timer); timer = ''; - sliderImg.attr('src', vars.currentImage.attr('src')); + //sliderImg.attr('src', vars.currentImage.attr('src')); + sliderImg.attr('src', parse_src(vars.currentImage)); //ADDED vars.currentSlide = $(this).attr('rel') - 1; nivoRun(slider, kids, settings, 'control'); }); @@ -187,7 +239,9 @@ // Event when Animation finishes slider.bind('nivo:animFinished', function(){ - sliderImg.attr('src', vars.currentImage.attr('src')); + //sliderImg.attr('src', vars.currentImage.attr('src')); + sliderImg.attr('src', parse_src(vars.currentImage)); //ADDED + vars.running = false; // Hide child links $(kids).each(function(){ @@ -200,9 +254,21 @@ $(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); + //REMOVED + //if(timer === '' && !vars.paused && !settings.manualAdvance){ + // timer = setInterval(function(){ nivoRun(slider, kids, settings, false); }, settings.pauseTime); + //} + //START ADDED + if(!vars.paused && !settings.manualAdvance){ + // Preload the next image (when found) + preload_image(1); + // Restart the timer + if (timer == '' ) { + timer = setInterval(function(){ nivoRun(slider, kids, settings, false); }, settings.pauseTime); + } } + //END ADDED + // Trigger the afterChange callback settings.afterChange.call(this); }); @@ -210,15 +276,17 @@ // Add slices for slice animations var createSlices = function(slider, settings, vars) { if($(vars.currentImage).parent().is('a')) $(vars.currentImage).parent().css('display','block'); - $('img[src="'+ vars.currentImage.attr('src') +'"]', slider).not('.nivo-main-image,.nivo-control img').width(slider.width()).css('visibility', 'hidden').show(); - var sliceHeight = ($('img[src="'+ vars.currentImage.attr('src') +'"]', slider).not('.nivo-main-image,.nivo-control img').parent().is('a')) ? $('img[src="'+ vars.currentImage.attr('src') +'"]', slider).not('.nivo-main-image,.nivo-control img').parent().height() : $('img[src="'+ vars.currentImage.attr('src') +'"]', slider).not('.nivo-main-image,.nivo-control img').height(); - + //$('img[src="'+ vars.currentImage.attr('src') +'"]', slider).not('.nivo-main-image,.nivo-control img').width(slider.width()).css('visibility', 'hidden').show(); + $('img[src="'+ parse_src(vars.currentImage) +'"]', slider).not('.nivo-main-image,.nivo-control img').width(slider.width()).css('visibility', 'hidden').show(); //ADDED + //var sliceHeight = ($('img[src="'+ vars.currentImage.attr('src') +'"]', slider).not('.nivo-main-image,.nivo-control img').parent().is('a')) ? $('img[src="'+ vars.currentImage.attr('src') +'"]', slider).not('.nivo-main-image,.nivo-control img').parent().height() : $('img[src="'+ vars.currentImage.attr('src') +'"]', slider).not('.nivo-main-image,.nivo-control img').height(); + var sliceHeight = ($('img[src="'+ parse_src(vars.currentImage) +'"]', slider).not('.nivo-main-image,.nivo-control img').parent().is('a')) ? $('img[src="'+ parse_src(vars.currentImage) +'"]', slider).not('.nivo-main-image,.nivo-control img').parent().height() : $('img[src="'+ parse_src(vars.currentImage) +'"]', slider).not('.nivo-main-image,.nivo-control img').height(); //ADDED for(var i = 0; i < settings.slices; i++){ var sliceWidth = Math.round(slider.width()/settings.slices); if(i === settings.slices-1){ slider.append( - $('
').css({ + //$('
').css({ + $('
').css({ //ADDED left:(sliceWidth*i)+'px', width:(slider.width()-(sliceWidth*i))+'px', height:sliceHeight+'px', @@ -228,7 +296,8 @@ ); } else { slider.append( - $('
').css({ + //$('
').css({ + $('
').css({ //ADDED left:(sliceWidth*i)+'px', width:sliceWidth+'px', height:sliceHeight+'px', @@ -248,16 +317,19 @@ // Add boxes for box animations var createBoxes = function(slider, settings, vars){ if($(vars.currentImage).parent().is('a')) $(vars.currentImage).parent().css('display','block'); - $('img[src="'+ vars.currentImage.attr('src') +'"]', slider).not('.nivo-main-image,.nivo-control img').width(slider.width()).css('visibility', 'hidden').show(); + //$('img[src="'+ vars.currentImage.attr('src') +'"]', slider).not('.nivo-main-image,.nivo-control img').width(slider.width()).css('visibility', 'hidden').show(); + $('img[src="'+ parse_src(vars.currentImage) +'"]', slider).not('.nivo-main-image,.nivo-control img').width(slider.width()).css('visibility', 'hidden').show(); //ADDED var boxWidth = Math.round(slider.width()/settings.boxCols), - boxHeight = Math.round($('img[src="'+ vars.currentImage.attr('src') +'"]', slider).not('.nivo-main-image,.nivo-control img').height() / settings.boxRows); + //boxHeight = Math.round($('img[src="'+ vars.currentImage.attr('src') +'"]', slider).not('.nivo-main-image,.nivo-control img').height() / settings.boxRows); + boxHeight = Math.round($('img[src="'+ parse_src(vars.currentImage) +'"]', slider).not('.nivo-main-image,.nivo-control img').height() / settings.boxRows); //ADDED for(var rows = 0; rows < settings.boxRows; rows++){ for(var cols = 0; cols < settings.boxCols; cols++){ if(cols === settings.boxCols-1){ slider.append( - $('
').css({ + //$('
').css({ + $('
').css({ //ADDED opacity:0, left:(boxWidth*cols)+'px', top:(boxHeight*rows)+'px', @@ -268,7 +340,8 @@ $('.nivo-box[name="'+ cols +'"]', slider).height($('.nivo-box[name="'+ cols +'"] img', slider).height()+'px'); } else { slider.append( - $('
').css({ + //$('
').css({ + $('
').css({ //ADDED opacity:0, left:(boxWidth*cols)+'px', top:(boxHeight*rows)+'px', @@ -303,13 +376,16 @@ // Set current background before change if(!nudge){ - sliderImg.attr('src', vars.currentImage.attr('src')); + //sliderImg.attr('src', vars.currentImage.attr('src')); + sliderImg.attr('src', parse_src(vars.currentImage)); //ADDED } else { if(nudge === 'prev'){ - sliderImg.attr('src', vars.currentImage.attr('src')); + //sliderImg.attr('src', vars.currentImage.attr('src')); + sliderImg.attr('src', parse_src(vars.currentImage)); //ADDED } if(nudge === 'next'){ - sliderImg.attr('src', vars.currentImage.attr('src')); + //sliderImg.attr('src', vars.currentImage.attr('src')); + sliderImg.attr('src', parse_src(vars.currentImage)); //ADDED } } @@ -321,11 +397,15 @@ } if(vars.currentSlide < 0) { vars.currentSlide = (vars.totalSlides - 1); } // Set vars.currentImage - if($(kids[vars.currentSlide]).is('img')){ - vars.currentImage = $(kids[vars.currentSlide]); - } else { - vars.currentImage = $(kids[vars.currentSlide]).find('img:first'); - } + //REMOVED + //if($(kids[vars.currentSlide]).is('img')){ + // vars.currentImage = $(kids[vars.currentSlide]); + //} else { + // vars.currentImage = $(kids[vars.currentSlide]).find('img:first'); + //} + //START ADDED + vars.currentImage = parse_image(vars.currentSlide); + //END ADDED // Set active links if(settings.controlNav){ @@ -643,7 +723,7 @@ pauseTime: 3000, startSlide: 0, directionNav: true, - controlNav: true, + controlNav: false, controlNavThumbs: false, pauseOnHover: true, manualAdvance: false, From 8f47a995d518defe90bfa645e06cc67c96e93aa3 Mon Sep 17 00:00:00 2001 From: Travis Hydzik Date: Fri, 23 Nov 2012 09:07:30 +0800 Subject: [PATCH 3/4] Update jquery.nivo.slider.pack.js --- jquery.nivo.slider.pack.js | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/jquery.nivo.slider.pack.js b/jquery.nivo.slider.pack.js index 929c77b..640fec0 100644 --- a/jquery.nivo.slider.pack.js +++ b/jquery.nivo.slider.pack.js @@ -1,10 +1 @@ -/* - * jQuery Nivo Slider v3.1 - * http://nivo.dev7studios.com - * - * Copyright 2012, Dev7studios - * Free to use and abuse under the MIT license. - * http://www.opensource.org/licenses/mit-license.php - */ - -(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,controlNavEl:false};var f=a(b);f.data("nivo:vars",e).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=d===0?b.attr("width"):b.width(),f=f===0?b.attr("height"):b.height();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")}var h=a('');h.attr("src",e.currentImage.attr("src")).show();f.append(h);a(window).resize(function(){f.children("img").width(f.width());h.attr("src",e.currentImage.attr("src"));h.stop().height("auto");a(".nivo-slice").remove();a(".nivo-box").remove()});f.append(a('
'));var i=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("display")=="block"){setTimeout(function(){c.html(d)},b.animSpeed)}else{c.html(d);c.stop().fadeIn(b.animSpeed)}}else{c.stop().fadeOut(b.animSpeed)}};i(d);var j=0;if(!d.manualAdvance&&g.length>1){j=setInterval(function(){o(f,g,d,false)},d.pauseTime)}if(d.directionNav){f.append('");a("a.nivo-prevNav",f).live("click",function(){if(e.running){return false}clearInterval(j);j="";e.currentSlide-=2;o(f,g,d,"prev")});a("a.nivo-nextNav",f).live("click",function(){if(e.running){return false}clearInterval(j);j="";o(f,g,d,"next")})}if(d.controlNav){e.controlNavEl=a('
');f.after(e.controlNavEl);for(var k=0;k')}else{e.controlNavEl.append(''+(k+1)+"")}}a("a:eq("+e.currentSlide+")",e.controlNavEl).addClass("active");a("a",e.controlNavEl).bind("click",function(){if(e.running)return false;if(a(this).hasClass("active"))return false;clearInterval(j);j="";h.attr("src",e.currentImage.attr("src"));e.currentSlide=a(this).attr("rel")-1;o(f,g,d,"control")})}if(d.pauseOnHover){f.hover(function(){e.paused=true;clearInterval(j);j=""},function(){e.paused=false;if(j===""&&!d.manualAdvance){j=setInterval(function(){o(f,g,d,false)},d.pauseTime)}})}f.bind("nivo:animFinished",function(){h.attr("src",e.currentImage.attr("src"));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(j===""&&!e.paused&&!d.manualAdvance){j=setInterval(function(){o(f,g,d,false)},d.pauseTime)}d.afterChange.call(this)});var m=function(b,c,d){if(a(d.currentImage).parent().is("a"))a(d.currentImage).parent().css("display","block");a('img[src="'+d.currentImage.attr("src")+'"]',b).not(".nivo-main-image,.nivo-control img").width(b.width()).css("visibility","hidden").show();var e=a('img[src="'+d.currentImage.attr("src")+'"]',b).not(".nivo-main-image,.nivo-control img").parent().is("a")?a('img[src="'+d.currentImage.attr("src")+'"]',b).not(".nivo-main-image,.nivo-control img").parent().height():a('img[src="'+d.currentImage.attr("src")+'"]',b).not(".nivo-main-image,.nivo-control img").height();for(var f=0;f').css({left:g*f+"px",width:b.width()-g*f+"px",height:e+"px",opacity:"0",overflow:"hidden"}))}else{b.append(a('
').css({left:g*f+"px",width:g+"px",height:e+"px",opacity:"0",overflow:"hidden"}))}}a(".nivo-slice",b).height(e);h.stop().animate({height:a(d.currentImage).height()},c.animSpeed)};var n=function(b,c,d){if(a(d.currentImage).parent().is("a"))a(d.currentImage).parent().css("display","block");a('img[src="'+d.currentImage.attr("src")+'"]',b).not(".nivo-main-image,.nivo-control img").width(b.width()).css("visibility","hidden").show();var e=Math.round(b.width()/c.boxCols),f=Math.round(a('img[src="'+d.currentImage.attr("src")+'"]',b).not(".nivo-main-image,.nivo-control img").height()/c.boxRows);for(var g=0;g').css({opacity:0,left:e*i+"px",top:f*g+"px",width:b.width()-e*i+"px"}));a('.nivo-box[name="'+i+'"]',b).height(a('.nivo-box[name="'+i+'"] img',b).height()+"px")}else{b.append(a('
').css({opacity:0,left:e*i+"px",top:f*g+"px",width:e+"px"}));a('.nivo-box[name="'+i+'"]',b).height(a('.nivo-box[name="'+i+'"] img',b).height()+"px")}}}h.stop().animate({height:a(d.currentImage).height()},c.animSpeed)};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){h.attr("src",f.currentImage.attr("src"))}else{if(e==="prev"){h.attr("src",f.currentImage.attr("src"))}if(e==="next"){h.attr("src",f.currentImage.attr("src"))}}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("a",f.controlNavEl).removeClass("active");a("a:eq("+f.currentSlide+")",f.controlNavEl).addClass("active")}i(d);a(".nivo-slice",b).remove();a(".nivo-box",b).remove();var g=d.effect,j="";if(d.effect==="random"){j=new Array("sliceDownRight","sliceDownLeft","sliceUpRight","sliceUpLeft","sliceUpDown","sliceUpDownLeft","fold","fade","boxRandom","boxRain","boxRainReverse","boxRainGrow","boxRainGrowReverse");g=j[Math.floor(Math.random()*(j.length+1))];if(g===undefined){g="fade"}}if(d.effect.indexOf(",")!==-1){j=d.effect.split(",");g=j[Math.floor(Math.random()*j.length)];if(g===undefined){g="fade"}}if(f.currentImage.attr("data-transition")){g=f.currentImage.attr("data-transition")}f.running=true;var k=0,l=0,o="",q="",r="",s="";if(g==="sliceDown"||g==="sliceDownRight"||g==="sliceDownLeft"){m(b,d,f);k=0;l=0;o=a(".nivo-slice",b);if(g==="sliceDownLeft"){o=a(".nivo-slice",b)._reverse()}o.each(function(){var c=a(this);c.css({top:"0px"});if(l===d.slices-1){setTimeout(function(){c.animate({opacity:"1.0"},d.animSpeed,"",function(){b.trigger("nivo:animFinished")})},100+k)}else{setTimeout(function(){c.animate({opacity:"1.0"},d.animSpeed)},100+k)}k+=50;l++})}else if(g==="sliceUp"||g==="sliceUpRight"||g==="sliceUpLeft"){m(b,d,f);k=0;l=0;o=a(".nivo-slice",b);if(g==="sliceUpLeft"){o=a(".nivo-slice",b)._reverse()}o.each(function(){var c=a(this);c.css({bottom:"0px"});if(l===d.slices-1){setTimeout(function(){c.animate({opacity:"1.0"},d.animSpeed,"",function(){b.trigger("nivo:animFinished")})},100+k)}else{setTimeout(function(){c.animate({opacity:"1.0"},d.animSpeed)},100+k)}k+=50;l++})}else if(g==="sliceUpDown"||g==="sliceUpDownRight"||g==="sliceUpDownLeft"){m(b,d,f);k=0;l=0;var t=0;o=a(".nivo-slice",b);if(g==="sliceUpDownLeft"){o=a(".nivo-slice",b)._reverse()}o.each(function(){var c=a(this);if(l===0){c.css("top","0px");l++}else{c.css("bottom","0px");l=0}if(t===d.slices-1){setTimeout(function(){c.animate({opacity:"1.0"},d.animSpeed,"",function(){b.trigger("nivo:animFinished")})},100+k)}else{setTimeout(function(){c.animate({opacity:"1.0"},d.animSpeed)},100+k)}k+=50;t++})}else if(g==="fold"){m(b,d,f);k=0;l=0;a(".nivo-slice",b).each(function(){var c=a(this);var e=c.width();c.css({top:"0px",width:"0px"});if(l===d.slices-1){setTimeout(function(){c.animate({width:e,opacity:"1.0"},d.animSpeed,"",function(){b.trigger("nivo:animFinished")})},100+k)}else{setTimeout(function(){c.animate({width:e,opacity:"1.0"},d.animSpeed)},100+k)}k+=50;l++})}else if(g==="fade"){m(b,d,f);q=a(".nivo-slice:first",b);q.css({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);q=a(".nivo-slice:first",b);q.css({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);q=a(".nivo-slice:first",b);q.css({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);r=d.boxCols*d.boxRows;l=0;k=0;s=p(a(".nivo-box",b));s.each(function(){var c=a(this);if(l===r-1){setTimeout(function(){c.animate({opacity:"1"},d.animSpeed,"",function(){b.trigger("nivo:animFinished")})},100+k)}else{setTimeout(function(){c.animate({opacity:"1"},d.animSpeed)},100+k)}k+=20;l++})}else if(g==="boxRain"||g==="boxRainReverse"||g==="boxRainGrow"||g==="boxRainGrowReverse"){n(b,d,f);r=d.boxCols*d.boxRows;l=0;k=0;var u=0;var v=0;var w=[];w[u]=[];s=a(".nivo-box",b);if(g==="boxRainReverse"||g==="boxRainGrowReverse"){s=a(".nivo-box",b)._reverse()}s.each(function(){w[u][v]=a(this);v++;if(v===d.boxCols){u++;v=0;w[u]=[]}});for(var x=0;x=0&&y=o.length){w=0}else{if(w<0){w=0}}var i=n(w);i.attr("src",i.data("src"))};if(b(o[m.currentSlide]).is("img")){m.currentImage=b(o[m.currentSlide])}else{m.currentImage=b(o[m.currentSlide]).find("img:first")}if(b(o[m.currentSlide]).is("a")){b(o[m.currentSlide]).css("display","block")}var t=b('');t.attr("src",g(m.currentImage)).show();p.append(t);if(v.randomStart){v.startSlide=Math.floor(Math.random()*m.totalSlides)}if(v.startSlide>0){if(v.startSlide>=m.totalSlides){v.startSlide=m.totalSlides-1}m.currentSlide=v.startSlide}l(1);b(window).resize(function(){p.children("img").width(p.width());t.attr("src",g(m.currentImage));t.stop().height("auto");b(".nivo-slice").remove();b(".nivo-box").remove()});p.append(b('
'));var k=function(i){var x=b(".nivo-caption",p);if(m.currentImage.attr("title")!=""&&m.currentImage.attr("title")!=undefined){var w=m.currentImage.attr("title");if(w.substr(0,1)=="#"){w=b(w).html()}if(x.css("display")=="block"){setTimeout(function(){x.html(w)},i.animSpeed)}else{x.html(w);x.stop().fadeIn(i.animSpeed)}}else{x.stop().fadeOut(i.animSpeed)}};k(v);var j=0;if(!v.manualAdvance&&o.length>1){j=setInterval(function(){h(p,o,v,false)},v.pauseTime)}if(v.directionNav){p.append('");b("a.nivo-prevNav",p).live("click",function(){if(m.running){return false}clearInterval(j);j="";m.currentSlide-=2;h(p,o,v,"prev")});b("a.nivo-nextNav",p).live("click",function(){if(m.running){return false}clearInterval(j);j="";h(p,o,v,"next")})}if(v.controlNav){m.controlNavEl=b('
');p.after(m.controlNavEl);for(var s=0;s')}}else{m.controlNavEl.append(''+(s+1)+"")}}b("a:eq("+m.currentSlide+")",m.controlNavEl).addClass("active");b("a",m.controlNavEl).bind("click",function(){if(m.running){return false}if(b(this).hasClass("active")){return false}clearInterval(j);j="";t.attr("src",g(m.currentImage));m.currentSlide=b(this).attr("rel")-1;h(p,o,v,"control")})}if(v.pauseOnHover){p.hover(function(){m.paused=true;clearInterval(j);j=""},function(){m.paused=false;if(j===""&&!v.manualAdvance){j=setInterval(function(){h(p,o,v,false)},v.pauseTime)}})}p.bind("nivo:animFinished",function(){t.attr("src",g(m.currentImage));m.running=false;b(o).each(function(){if(b(this).is("a")){b(this).css("display","none")}});if(b(o[m.currentSlide]).is("a")){b(o[m.currentSlide]).css("display","block")}if(!m.paused&&!v.manualAdvance){l(1);if(j==""){j=setInterval(function(){h(p,o,v,false)},v.pauseTime)}}v.afterChange.call(this)});var u=function(y,x,B){if(b(B.currentImage).parent().is("a")){b(B.currentImage).parent().css("display","block")}b('img[src="'+g(B.currentImage)+'"]',y).not(".nivo-main-image,.nivo-control img").width(y.width()).css("visibility","hidden").show();var z=(b('img[src="'+g(B.currentImage)+'"]',y).not(".nivo-main-image,.nivo-control img").parent().is("a"))?b('img[src="'+g(B.currentImage)+'"]',y).not(".nivo-main-image,.nivo-control img").parent().height():b('img[src="'+g(B.currentImage)+'"]',y).not(".nivo-main-image,.nivo-control img").height();for(var w=0;w').css({left:(A*w)+"px",width:(y.width()-(A*w))+"px",height:z+"px",opacity:"0",overflow:"hidden"}))}else{y.append(b('
').css({left:(A*w)+"px",width:A+"px",height:z+"px",opacity:"0",overflow:"hidden"}))}}b(".nivo-slice",y).height(z);t.stop().animate({height:b(B.currentImage).height()},x.animSpeed)};var q=function(x,i,A){if(b(A.currentImage).parent().is("a")){b(A.currentImage).parent().css("display","block")}b('img[src="'+g(A.currentImage)+'"]',x).not(".nivo-main-image,.nivo-control img").width(x.width()).css("visibility","hidden").show();var w=Math.round(x.width()/i.boxCols),B=Math.round(b('img[src="'+g(A.currentImage)+'"]',x).not(".nivo-main-image,.nivo-control img").height()/i.boxRows);for(var y=0;y').css({opacity:0,left:(w*z)+"px",top:(B*y)+"px",width:(x.width()-(w*z))+"px"}));b('.nivo-box[name="'+z+'"]',x).height(b('.nivo-box[name="'+z+'"] img',x).height()+"px")}else{x.append(b('
').css({opacity:0,left:(w*z)+"px",top:(B*y)+"px",width:w+"px"}));b('.nivo-box[name="'+z+'"]',x).height(b('.nivo-box[name="'+z+'"] img',x).height()+"px")}}}t.stop().animate({height:b(A.currentImage).height()},i.animSpeed)};var h=function(K,J,N,G){var I=K.data("nivo:vars");if(I&&(I.currentSlide===I.totalSlides-1)){N.lastSlide.call(this)}if((!I||I.stop)&&!G){return false}N.beforeChange.call(this);if(!G){t.attr("src",g(I.currentImage))}else{if(G==="prev"){t.attr("src",g(I.currentImage))}if(G==="next"){t.attr("src",g(I.currentImage))}}I.currentSlide++;if(I.currentSlide===I.totalSlides){I.currentSlide=0;N.slideshowEnd.call(this)}if(I.currentSlide<0){I.currentSlide=(I.totalSlides-1)}I.currentImage=n(I.currentSlide);if(N.controlNav){b("a",I.controlNavEl).removeClass("active");b("a:eq("+I.currentSlide+")",I.controlNavEl).addClass("active")}k(N);b(".nivo-slice",K).remove();b(".nivo-box",K).remove();var x=N.effect,P="";if(N.effect==="random"){P=new Array("sliceDownRight","sliceDownLeft","sliceUpRight","sliceUpLeft","sliceUpDown","sliceUpDownLeft","fold","fade","boxRandom","boxRain","boxRainReverse","boxRainGrow","boxRainGrowReverse");x=P[Math.floor(Math.random()*(P.length+1))];if(x===undefined){x="fade"}}if(N.effect.indexOf(",")!==-1){P=N.effect.split(",");x=P[Math.floor(Math.random()*(P.length))];if(x===undefined){x="fade"}}if(I.currentImage.attr("data-transition")){x=I.currentImage.attr("data-transition")}I.running=true;var O=0,L=0,w="",C="",M="",z="";if(x==="sliceDown"||x==="sliceDownRight"||x==="sliceDownLeft"){u(K,N,I);O=0;L=0;w=b(".nivo-slice",K);if(x==="sliceDownLeft"){w=b(".nivo-slice",K)._reverse()}w.each(function(){var i=b(this);i.css({top:"0px"});if(L===N.slices-1){setTimeout(function(){i.animate({opacity:"1.0"},N.animSpeed,"",function(){K.trigger("nivo:animFinished")})},(100+O))}else{setTimeout(function(){i.animate({opacity:"1.0"},N.animSpeed)},(100+O))}O+=50;L++})}else{if(x==="sliceUp"||x==="sliceUpRight"||x==="sliceUpLeft"){u(K,N,I);O=0;L=0;w=b(".nivo-slice",K);if(x==="sliceUpLeft"){w=b(".nivo-slice",K)._reverse()}w.each(function(){var i=b(this);i.css({bottom:"0px"});if(L===N.slices-1){setTimeout(function(){i.animate({opacity:"1.0"},N.animSpeed,"",function(){K.trigger("nivo:animFinished")})},(100+O))}else{setTimeout(function(){i.animate({opacity:"1.0"},N.animSpeed)},(100+O))}O+=50;L++})}else{if(x==="sliceUpDown"||x==="sliceUpDownRight"||x==="sliceUpDownLeft"){u(K,N,I);O=0;L=0;var E=0;w=b(".nivo-slice",K);if(x==="sliceUpDownLeft"){w=b(".nivo-slice",K)._reverse()}w.each(function(){var i=b(this);if(L===0){i.css("top","0px");L++}else{i.css("bottom","0px");L=0}if(E===N.slices-1){setTimeout(function(){i.animate({opacity:"1.0"},N.animSpeed,"",function(){K.trigger("nivo:animFinished")})},(100+O))}else{setTimeout(function(){i.animate({opacity:"1.0"},N.animSpeed)},(100+O))}O+=50;E++})}else{if(x==="fold"){u(K,N,I);O=0;L=0;b(".nivo-slice",K).each(function(){var i=b(this);var Q=i.width();i.css({top:"0px",width:"0px"});if(L===N.slices-1){setTimeout(function(){i.animate({width:Q,opacity:"1.0"},N.animSpeed,"",function(){K.trigger("nivo:animFinished")})},(100+O))}else{setTimeout(function(){i.animate({width:Q,opacity:"1.0"},N.animSpeed)},(100+O))}O+=50;L++})}else{if(x==="fade"){u(K,N,I);C=b(".nivo-slice:first",K);C.css({width:K.width()+"px"});C.animate({opacity:"1.0"},(N.animSpeed*2),"",function(){K.trigger("nivo:animFinished")})}else{if(x==="slideInRight"){u(K,N,I);C=b(".nivo-slice:first",K);C.css({width:"0px",opacity:"1"});C.animate({width:K.width()+"px"},(N.animSpeed*2),"",function(){K.trigger("nivo:animFinished")})}else{if(x==="slideInLeft"){u(K,N,I);C=b(".nivo-slice:first",K);C.css({width:"0px",opacity:"1",left:"",right:"0px"});C.animate({width:K.width()+"px"},(N.animSpeed*2),"",function(){C.css({left:"0px",right:""});K.trigger("nivo:animFinished")})}else{if(x==="boxRandom"){q(K,N,I);M=N.boxCols*N.boxRows;L=0;O=0;z=e(b(".nivo-box",K));z.each(function(){var i=b(this);if(L===M-1){setTimeout(function(){i.animate({opacity:"1"},N.animSpeed,"",function(){K.trigger("nivo:animFinished")})},(100+O))}else{setTimeout(function(){i.animate({opacity:"1"},N.animSpeed)},(100+O))}O+=20;L++})}else{if(x==="boxRain"||x==="boxRainReverse"||x==="boxRainGrow"||x==="boxRainGrowReverse"){q(K,N,I);M=N.boxCols*N.boxRows;L=0;O=0;var B=0;var H=0;var F=[];F[B]=[];z=b(".nivo-box",K);if(x==="boxRainReverse"||x==="boxRainGrowReverse"){z=b(".nivo-box",K)._reverse()}z.each(function(){F[B][H]=b(this);H++;if(H===N.boxCols){B++;H=0;F[B]=[]}});for(var D=0;D<(N.boxCols*2);D++){var y=D;for(var A=0;A=0&&y Date: Fri, 23 Nov 2012 09:10:59 +0800 Subject: [PATCH 4/4] Update jquery.nivo.slider.js --- jquery.nivo.slider.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery.nivo.slider.js b/jquery.nivo.slider.js index 4f65389..6523552 100644 --- a/jquery.nivo.slider.js +++ b/jquery.nivo.slider.js @@ -56,7 +56,7 @@ vars.totalSlides++; }); - // START ADDED + // START ADDED // Parse image source from an element. // Checks in data-src, then in src var parse_src = function(elem) {