/* * jquery nivo slider v2.4 * 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 */ (function(a) { var a = function(s, v) { var f = a.extend({}, a.fn.nivoslider.defaults, v), g = { currentslide: 0, currentimage: "", totalslides: 0, randanim: "", running: false, paused: false, stop: false }, e = a(s); e.data("nivo:vars", g); e.css("position", "relative"); e.addclass("nivoslider"); var j = e.children(); j.each(function() { var b = a(this), h = ""; if (!b.is("img")) { if (b.is("a")) { b.addclass("nivo-imagelink"); h = b } b = b.find("img:first") } var c = b.width(); if (c == 0) c = b.attr("width"); var o = b.height(); if (o == 0) o = b.attr("height"); c > e.width() && e.width(c); o > e.height() && e.height(o); h != "" && h.css("display", "none"); b.css("display", "none"); g.totalslides++ }); if (f.startslide > 0) { if (f.startslide >= g.totalslides) f.startslide = g.totalslides - 1; g.currentslide = f.startslide } g.currentimage = a(j[g.currentslide]).is("img") ? a(j[g.currentslide]) : a(j[g.currentslide]).find("img:first"); a(j[g.currentslide]).is("a") && a(j[g.currentslide]).css("display", "block"); e.css("background", 'url("' + g.currentimage.attr("src") + '") no-repeat'); for (var k = 0; k < f.slices; k++) { var p = math.round(e.width() / f.slices); k == f.slices - 1 ? e.append(a('
').css({ left: p * k + "px", width: e.width() - p * k + "px" })) : e.append(a('').css({ left: p * k + "px", width: p + "px" })) } e.append(a(' ').css({ display: "none", opacity: f.captionopacity })); if (g.currentimage.attr("title") != "") { k = g.currentimage.attr("title"); if (k.substr(0, 1) == "#") k = a(k).html(); a(".nivo-caption p", e).html(k); a(".nivo-caption", e).fadein(f.animspeed) } var l = 0; if (!f.manualadvance && j.length > 1) l = setinterval(function() { r(e, j, f, false) }, f.pausetime); if (f.directionnav) { e.append(''); if (f.directionnavhide) { a(".nivo-directionnav", e).hide(); e.hover(function() { a(".nivo-directionnav", e).show() }, function() { a(".nivo-directionnav", e).hide() }) } a("a.nivo-prevnav", e).live("click", function() { if (g.running) return false; clearinterval(l); l = ""; g.currentslide -= 2; r(e, j, f, "prev") }); a("a.nivo-nextnav", e).live("click", function() { if (g.running) return false; clearinterval(l); l = ""; r(e, j, f, "next") }) } if (f.controlnav) { p = a(''); e.append(p); for (k = 0; k < j.length; k++) if (f.controlnavthumbs) { var t = j.eq(k); t.is("img") || (t = t.find("img:first")); f.controlnavthumbsfromrel ? p.append('') : p.append('') } else p.append('' + (k + 1) + ""); a(".nivo-controlnav a:eq(" + g.currentslide + ")", e).addclass("active"); a(".nivo-controlnav a", e).live("click", function() { if (g.running) return false; if (a(this).hasclass("active")) return false; clearinterval(l); l = ""; e.css("background", 'url("' + g.currentimage.attr("src") + '") no-repeat'); g.currentslide = a(this).attr("rel") - 1; r(e, j, f, "control") }) } f.keyboardnav && a(window).keypress(function(b) { if (b.keycode == "37") { if (g.running) return false; clearinterval(l); l = ""; g.currentslide -= 2; r(e, j, f, "prev") } if (b.keycode == "39") { if (g.running) return false; clearinterval(l); l = ""; r(e, j, f, "next") } }); f.pauseonhover && e.hover(function() { g.paused = true; clearinterval(l); l = "" }, function() { g.paused = false; if (l == "" && !f.manualadvance) l = setinterval(function() { r(e, j, f, false) }, f.pausetime) }); e.bind("nivo:animfinished", function() { g.running = false; a(j).each(function() { a(this).is("a") && a(this).css("display", "none") }); a(j[g.currentslide]).is("a") && a(j[g.currentslide]).css("display", "block"); if (l == "" && !g.paused && !f.manualadvance) l = setinterval(function() { r(e, j, f, false) }, f.pausetime); f.afterchange.call(this) }); var w = function(b, h) { var c = 0; a(".nivo-slice", b).each(function() { var o = a(this), d = math.round(b.width() / h.slices); c == h.slices - 1 ? o.css("width", b.width() - d * c + "px") : o.css("width", d + "px"); c++ }) }, r = function(b, h, c, o) { var d = b.data("nivo:vars"); d && d.currentslide == d.totalslides - 1 && c.lastslide.call(this); if ((!d || d.stop) && !o) return false; c.beforechange.call(this); if (o) { o == "prev" && b.css("background", 'url("' + d.currentimage.attr("src") + '") no-repeat'); o == "next" && b.css("background", 'url("' + d.currentimage.attr("src") + '") no-repeat') } else b.css("background", 'url("' + d.currentimage.attr("src") + '") no-repeat'); d.currentslide++; if (d.currentslide == d.totalslides) { d.currentslide = 0; c.slideshowend.call(this) } if (d.currentslide < 0) d.currentslide = d.totalslides - 1; d.currentimage = a(h[d.currentslide]).is("img") ? a(h[d.currentslide]) : a(h[d.currentslide]).find("img:first"); if (c.controlnav) { a(".nivo-controlnav a", b).removeclass("active"); a(".nivo-controlnav a:eq(" + d.currentslide + ")", b).addclass("active") } if (d.currentimage.attr("title") != "") { var u = d.currentimage.attr("title"); if (u.substr(0, 1) == "#") u = a(u).html(); a(".nivo-caption", b).css("display") == "block" ? a(".nivo-caption p", b).fadeout(c.animspeed, function() { a(this).html(u); a(this).fadein(c.animspeed) }) : a(".nivo-caption p", b).html(u); a(".nivo-caption", b).fadein(c.animspeed) } else a(".nivo-caption", b).fadeout(c.animspeed); var m = 0; a(".nivo-slice", b).each(function() { var i = math.round(b.width() / c.slices); a(this).css({ height: "0px", opacity: "0", background: 'url("' + d.currentimage.attr("src") + '") no-repeat -' + (i + m * i - i) + "px 0%" }); m++ }); if (c.effect == "random") { h = ["slicedownright", "slicedownleft", "sliceupright", "sliceupleft", "sliceupdown", "sliceupdownleft", "fold", "fade", "slideinright", "slideinleft"]; d.randanim = h[math.floor(math.random() * (h.length + 1))]; if (d.randanim == undefined) d.randanim = "fade" } if (c.effect.indexof(",") != -1) { h = c.effect.split(","); d.randanim = h[math.floor(math.random() * h.length)]; if (d.randanim == undefined) d.randanim = "fade" } d.running = true; if (c.effect == "slicedown" || c.effect == "slicedownright" || d.randanim == "slicedownright" || c.effect == "slicedownleft" || d.randanim == "slicedownleft") { var n = 0; m = 0; w(b, c); h = a(".nivo-slice", b); if (c.effect == "slicedownleft" || d.randanim == "slicedownleft") h = a(".nivo-slice", b)._reverse(); h.each(function() { var i = a(this); i.css({ top: "0px" }); m == c.slices - 1 ? settimeout(function() { i.animate({ height: "100%", opacity: "1.0" }, c.animspeed, "", function() { b.trigger("nivo:animfinished") }) }, 100 + n) : settimeout(function() { i.animate({ height: "100%", opacity: "1.0" }, c.animspeed) }, 100 + n); n += 50; m++ }) } else if (c.effect == "sliceup" || c.effect == "sliceupright" || d.randanim == "sliceupright" || c.effect == "sliceupleft" || d.randanim == "sliceupleft") { m = n = 0; w(b, c); h = a(".nivo-slice", b); if (c.effect == "sliceupleft" || d.randanim == "sliceupleft") h = a(".nivo-slice", b)._reverse(); h.each(function() { var i = a(this); i.css({ bottom: "0px" }); m == c.slices - 1 ? settimeout(function() { i.animate({ height: "100%", opacity: "1.0" }, c.animspeed, "", function() { b.trigger("nivo:animfinished") }) }, 100 + n) : settimeout(function() { i.animate({ height: "100%", opacity: "1.0" }, c.animspeed) }, 100 + n); n += 50; m++ }) } else if (c.effect == "sliceupdown" || c.effect == "sliceupdownright" || d.randanim == "sliceupdown" || c.effect == "sliceupdownleft" || d.randanim == "sliceupdownleft") { var x = m = n = 0; w(b, c); h = a(".nivo-slice", b); if (c.effect == "sliceupdownleft" || d.randanim == "sliceupdownleft") h = a(".nivo-slice", b)._reverse(); h.each(function() { var i = a(this); if (m == 0) { i.css("top", "0px"); m++ } else { i.css("bottom", "0px"); m = 0 } x == c.slices - 1 ? settimeout(function() { i.animate({ height: "100%", opacity: "1.0" }, c.animspeed, "", function() { b.trigger("nivo:animfinished") }) }, 100 + n) : settimeout(function() { i.animate({ height: "100%", opacity: "1.0" }, c.animspeed) }, 100 + n); n += 50; x++ }) } else if (c.effect == "fold" || d.randanim == "fold") { m = n = 0; w(b, c); a(".nivo-slice", b).each(function() { var i = a(this), y = i.width(); i.css({ top: "0px", height: "100%", width: "0px" }); m == c.slices - 1 ? settimeout(function() { i.animate({ width: y, opacity: "1.0" }, c.animspeed, "", function() { b.trigger("nivo:animfinished") }) }, 100 + n) : settimeout(function() { i.animate({ width: y, opacity: "1.0" }, c.animspeed) }, 100 + n); n += 50; m++ }) } else if (c.effect == "fade" || d.randanim == "fade") { var q = a(".nivo-slice:first", b); q.css({ height: "100%", width: b.width() + "px" }); q.animate({ opacity: "1.0" }, c.animspeed * 2, "", function() { b.trigger("nivo:animfinished") }) } else if (c.effect == "slideinright" || d.randanim == "slideinright") { q = a(".nivo-slice:first", b); q.css({ height: "100%", width: "0px", opacity: "1" }); q.animate({ width: b.width() + "px" }, c.animspeed * 2, "", function() { b.trigger("nivo:animfinished") }) } else if (c.effect == "slideinleft" || d.randanim == "slideinleft") { q = a(".nivo-slice:first", b); q.css({ height: "100%", width: "0px", opacity: "1", left: "", right: "0px" }); q.animate({ width: b.width() + "px" }, c.animspeed * 2, "", function() { q.css({ left: "0px", right: "" }); b.trigger("nivo:animfinished") }) } }, z = function(b) { this.console && typeof console.log != "undefined" && console.log(b) }; this.stop = function() { if (!a(s).data("nivo:vars").stop) { a(s).data("nivo:vars").stop = true; z("stop slider") } }; this.start = function() { if (a(s).data("nivo:vars").stop) { a(s).data("nivo:vars").stop = false; z("start slider") } }; f.afterload.call(this) }; a.fn.nivoslider = function(s) { return this.each(function() { var v = a(this); if (!v.data("nivoslider")) { var f = new a(this, s); v.data("nivoslider", f) } }) }; a.fn.nivoslider.defaults = { effect: "random", slices: 15, animspeed: 500, pausetime: 3e3, 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, beforechange: function() {}, afterchange: function() {}, slideshowend: function() {}, lastslide: function() {}, afterload: function() {} }; a.fn._reverse = [].reverse })(jquery);