/* * jquery nivo slider v3.2 * 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(e) { var t = function(t, n) { var r = e.extend({}, e.fn.nivoslider.defaults, n); var i = { currentslide: 0, currentimage: "", totalslides: 0, running: false, paused: false, stop: false, controlnavel: false }; var s = e(t); s.data("nivo:vars", i).addclass("nivoslider"); var o = s.children(); o.each(function() { var t = e(this); var n = ""; if (!t.is("img")) { if (t.is("a")) { t.addclass("nivo-imagelink"); n = t } t = t.find("img:first") } var r = r === 0 ? t.attr("width") : t.width() , s = s === 0 ? t.attr("height") : t.height(); if (n !== "") { n.css("display", "none") } t.css("display", "none"); i.totalslides++ }); if (r.randomstart) { r.startslide = math.floor(math.random() * i.totalslides) } if (r.startslide > 0) { if (r.startslide >= i.totalslides) { r.startslide = i.totalslides - 1 } i.currentslide = r.startslide } if (e(o[i.currentslide]).is("img")) { i.currentimage = e(o[i.currentslide]) } else { i.currentimage = e(o[i.currentslide]).find("img:first") } if (e(o[i.currentslide]).is("a")) { e(o[i.currentslide]).css("display", "block") } var u = e("").addclass("nivo-main-image"); u.attr("src", i.currentimage.attr("src")).show(); s.append(u); e(window).resize(function() { s.children("img").width(s.width()); u.attr("src", i.currentimage.attr("src")); u.stop().height("auto"); e(".nivo-slice").remove(); e(".nivo-box").remove() }); s.append(e('
')); var a = function(t) { var n = e(".nivo-caption", s); if (i.currentimage.attr("title") != "" && i.currentimage.attr("title") != undefined) { var r = i.currentimage.attr("title"); if (r.substr(0, 1) == "#") r = e(r).html(); if (n.css("display") == "block") { settimeout(function() { n.html(r) }, t.animspeed) } else { n.html(r); n.stop().fadein(t.animspeed) } } else { n.stop().fadeout(t.animspeed) } } ; a(r); var f = 0; if (!r.manualadvance && o.length > 1) { f = setinterval(function() { d(s, o, r, false) }, r.pausetime) } if (r.directionnav) { s.append('
' + r.prevtext + '' + r.nexttext + "
"); e(s).on("click", "a.nivo-prevnav", function() { if (i.running) { return false } clearinterval(f); f = ""; i.currentslide -= 2; d(s, o, r, "prev") }); e(s).on("click", "a.nivo-nextnav", function() { if (i.running) { return false } clearinterval(f); f = ""; d(s, o, r, "next") }) } /*============================added active thumbnail img==========================*/ if (r.controlnav) { i.controlnavel = e('
'); s.after(i.controlnavel); for (var l = 0; l < o.length; l++) { if (r.controlnavthumbs) { i.controlnavel.addclass("nivo-thumbs-enabled"); var c = o.eq(l); if (!c.is("img")) { c = c.find("img:first") } if (c.attr("data-thumb") && !c.attr("data-thumb-active")){ i.controlnavel.append('
') } else if (c.attr("data-thumb") && c.attr("data-thumb-active")){ i.controlnavel.append('
') } } else { i.controlnavel.append('' + (l + 1) + "") } } e("a:eq(" + i.currentslide + ")", i.controlnavel).addclass("active"); e("a", i.controlnavel).bind("click", function() { if (i.running) return false; if (e(this).hasclass("active")) return false; clearinterval(f); f = ""; u.attr("src", i.currentimage.attr("src")); i.currentslide = e(this).attr("rel") - 1; d(s, o, r, "control") }) } if (r.pauseonhover) { s.hover(function() { i.paused = true; clearinterval(f); f = "" }, function() { i.paused = false; if (f === "" && !r.manualadvance) { f = setinterval(function() { d(s, o, r, false) }, r.pausetime) } }) } s.bind("nivo:animfinished", function() { u.attr("src", i.currentimage.attr("src")); i.running = false; e(o).each(function() { if (e(this).is("a")) { e(this).css("display", "none") } }); if (e(o[i.currentslide]).is("a")) { e(o[i.currentslide]).css("display", "block") } if (f === "" && !i.paused && !r.manualadvance) { f = setinterval(function() { d(s, o, r, false) }, r.pausetime) } r.afterchange.call(this) }); var h = function(t, n, r) { if (e(r.currentimage).parent().is("a")) e(r.currentimage).parent().css("display", "block"); e('img[src="' + r.currentimage.attr("src") + '"]', t).not(".nivo-main-image,.nivo-control img").width(t.width()).css("visibility", "hidden").show(); var i = e('img[src="' + r.currentimage.attr("src") + '"]', t).not(".nivo-main-image,.nivo-control img").parent().is("a") ? e('img[src="' + r.currentimage.attr("src") + '"]', t).not(".nivo-main-image,.nivo-control img").parent().height() : e('img[src="' + r.currentimage.attr("src") + '"]', t).not(".nivo-main-image,.nivo-control img").height(); for (var s = 0; s < n.slices; s++) { var o = math.round(t.width() / n.slices); if (s === n.slices - 1) { t.append(e('
').css({ left: o * s + "px", width: t.width() - o * s + "px", height: i + "px", opacity: "0", overflow: "hidden" })) } else { t.append(e('
').css({ left: o * s + "px", width: o + "px", height: i + "px", opacity: "0", overflow: "hidden" })) } } e(".nivo-slice", t).height(i); u.stop().animate({ height: e(r.currentimage).height() }, n.animspeed) } ; var p = function(t, n, r) { if (e(r.currentimage).parent().is("a")) e(r.currentimage).parent().css("display", "block"); e('img[src="' + r.currentimage.attr("src") + '"]', t).not(".nivo-main-image,.nivo-control img").width(t.width()).css("visibility", "hidden").show(); var i = math.round(t.width() / n.boxcols) , s = math.round(e('img[src="' + r.currentimage.attr("src") + '"]', t).not(".nivo-main-image,.nivo-control img").height() / n.boxrows); for (var o = 0; o < n.boxrows; o++) { for (var a = 0; a < n.boxcols; a++) { if (a === n.boxcols - 1) { t.append(e('
').css({ opacity: 0, left: i * a + "px", top: s * o + "px", width: t.width() - i * a + "px" })); e('.nivo-box[name="' + a + '"]', t).height(e('.nivo-box[name="' + a + '"] img', t).height() + "px") } else { t.append(e('
').css({ opacity: 0, left: i * a + "px", top: s * o + "px", width: i + "px" })); e('.nivo-box[name="' + a + '"]', t).height(e('.nivo-box[name="' + a + '"] img', t).height() + "px") } } } u.stop().animate({ height: e(r.currentimage).height() }, n.animspeed) } ; var d = function(t, n, r, i) { var s = t.data("nivo:vars"); if (s && s.currentslide === s.totalslides - 1) { r.lastslide.call(this) } if ((!s || s.stop) && !i) { return false } r.beforechange.call(this); if (!i) { u.attr("src", s.currentimage.attr("src")) } else { if (i === "prev") { u.attr("src", s.currentimage.attr("src")) } if (i === "next") { u.attr("src", s.currentimage.attr("src")) } } s.currentslide++; if (s.currentslide === s.totalslides) { s.currentslide = 0; r.slideshowend.call(this) } if (s.currentslide < 0) { s.currentslide = s.totalslides - 1 } if (e(n[s.currentslide]).is("img")) { s.currentimage = e(n[s.currentslide]) } else { s.currentimage = e(n[s.currentslide]).find("img:first") } if (r.controlnav) { e("a", s.controlnavel).removeclass("active"); e("a:eq(" + s.currentslide + ")", s.controlnavel).addclass("active") } a(r); e(".nivo-slice", t).remove(); e(".nivo-box", t).remove(); var o = r.effect , f = ""; if (r.effect === "random") { f = new array("slicedownright","slicedownleft","sliceupright","sliceupleft","sliceupdown","sliceupdownleft","fold","fade","boxrandom","boxrain","boxrainreverse","boxraingrow","boxraingrowreverse"); o = f[math.floor(math.random() * (f.length + 1))]; if (o === undefined) { o = "fade" } } if (r.effect.indexof(",") !== -1) { f = r.effect.split(","); o = f[math.floor(math.random() * f.length)]; if (o === undefined) { o = "fade" } } if (s.currentimage.attr("data-transition")) { o = s.currentimage.attr("data-transition") } s.running = true; var l = 0 , c = 0 , d = "" , m = "" , g = "" , y = ""; if (o === "slicedown" || o === "slicedownright" || o === "slicedownleft") { h(t, r, s); l = 0; c = 0; d = e(".nivo-slice", t); if (o === "slicedownleft") { d = e(".nivo-slice", t)._reverse() } d.each(function() { var n = e(this); n.css({ top: "0px" }); if (c === r.slices - 1) { settimeout(function() { n.animate({ opacity: "1.0" }, r.animspeed, "", function() { t.trigger("nivo:animfinished") }) }, 100 + l) } else { settimeout(function() { n.animate({ opacity: "1.0" }, r.animspeed) }, 100 + l) } l += 50; c++ }) } else if (o === "sliceup" || o === "sliceupright" || o === "sliceupleft") { h(t, r, s); l = 0; c = 0; d = e(".nivo-slice", t); if (o === "sliceupleft") { d = e(".nivo-slice", t)._reverse() } d.each(function() { var n = e(this); n.css({ bottom: "0px" }); if (c === r.slices - 1) { settimeout(function() { n.animate({ opacity: "1.0" }, r.animspeed, "", function() { t.trigger("nivo:animfinished") }) }, 100 + l) } else { settimeout(function() { n.animate({ opacity: "1.0" }, r.animspeed) }, 100 + l) } l += 50; c++ }) } else if (o === "sliceupdown" || o === "sliceupdownright" || o === "sliceupdownleft") { h(t, r, s); l = 0; c = 0; var b = 0; d = e(".nivo-slice", t); if (o === "sliceupdownleft") { d = e(".nivo-slice", t)._reverse() } d.each(function() { var n = e(this); if (c === 0) { n.css("top", "0px"); c++ } else { n.css("bottom", "0px"); c = 0 } if (b === r.slices - 1) { settimeout(function() { n.animate({ opacity: "1.0" }, r.animspeed, "", function() { t.trigger("nivo:animfinished") }) }, 100 + l) } else { settimeout(function() { n.animate({ opacity: "1.0" }, r.animspeed) }, 100 + l) } l += 50; b++ }) } else if (o === "fold") { h(t, r, s); l = 0; c = 0; e(".nivo-slice", t).each(function() { var n = e(this); var i = n.width(); n.css({ top: "0px", width: "0px" }); if (c === r.slices - 1) { settimeout(function() { n.animate({ width: i, opacity: "1.0" }, r.animspeed, "", function() { t.trigger("nivo:animfinished") }) }, 100 + l) } else { settimeout(function() { n.animate({ width: i, opacity: "1.0" }, r.animspeed) }, 100 + l) } l += 50; c++ }) } else if (o === "fade") { h(t, r, s); m = e(".nivo-slice:first", t); m.css({ width: t.width() + "px" }); m.animate({ opacity: "1.0" }, r.animspeed * 2, "", function() { t.trigger("nivo:animfinished") }) } else if (o === "slideinright") { h(t, r, s); m = e(".nivo-slice:first", t); m.css({ width: "0px", opacity: "1" }); m.animate({ width: t.width() + "px" }, r.animspeed * 2, "", function() { t.trigger("nivo:animfinished") }) } else if (o === "slideinleft") { h(t, r, s); m = e(".nivo-slice:first", t); m.css({ width: "0px", opacity: "1", left: "", right: "0px" }); m.animate({ width: t.width() + "px" }, r.animspeed * 2, "", function() { m.css({ left: "0px", right: "" }); t.trigger("nivo:animfinished") }) } else if (o === "boxrandom") { p(t, r, s); g = r.boxcols * r.boxrows; c = 0; l = 0; y = v(e(".nivo-box", t)); y.each(function() { var n = e(this); if (c === g - 1) { settimeout(function() { n.animate({ opacity: "1" }, r.animspeed, "", function() { t.trigger("nivo:animfinished") }) }, 100 + l) } else { settimeout(function() { n.animate({ opacity: "1" }, r.animspeed) }, 100 + l) } l += 20; c++ }) } else if (o === "boxrain" || o === "boxrainreverse" || o === "boxraingrow" || o === "boxraingrowreverse") { p(t, r, s); g = r.boxcols * r.boxrows; c = 0; l = 0; var w = 0; var e = 0; var s = []; s[w] = []; y = e(".nivo-box", t); if (o === "boxrainreverse" || o === "boxraingrowreverse") { y = e(".nivo-box", t)._reverse() } y.each(function() { s[w][e] = e(this); e++; if (e === r.boxcols) { w++; e = 0; s[w] = [] } }); for (var x = 0; x < r.boxcols * 2; x++) { var t = x; for (var n = 0; n < r.boxrows; n++) { if (t >= 0 && t < r.boxcols) { (function(n, i, s, u, a) { var f = e(s[n][i]); var l = f.width(); var c = f.height(); if (o === "boxraingrow" || o === "boxraingrowreverse") { f.width(0).height(0) } if (u === a - 1) { settimeout(function() { f.animate({ opacity: "1", width: l, height: c }, r.animspeed / 1.3, "", function() { t.trigger("nivo:animfinished") }) }, 100 + s) } else { settimeout(function() { f.animate({ opacity: "1", width: l, height: c }, r.animspeed / 1.3) }, 100 + s) } })(n, t, l, c, g); c++ } t-- } l += 100 } } } ; var v = function(e) { for (var t, n, r = e.length; r; t = parseint(math.random() * r, 10), n = e[--r], e[r] = e[t], e[t] = n) ; return e } ; var m = function(e) { if (this.console && typeof console.log !== "undefined") { console.log(e) } } ; this.stop = function() { if (!e(t).data("nivo:vars").stop) { e(t).data("nivo:vars").stop = true; m("stop slider") } } ; this.start = function() { if (e(t).data("nivo:vars").stop) { e(t).data("nivo:vars").stop = false; m("start slider") } } ; r.afterload.call(this); return this } ; e.fn.nivoslider = function(n) { return this.each(function(r, i) { var s = e(this); if (s.data("nivoslider")) { return s.data("nivoslider") } var o = new t(this,n); s.data("nivoslider", o) }) } ; e.fn.nivoslider.defaults = { effect: "random", slices: 15, boxcols: 8, boxrows: 4, animspeed: 500, pausetime: 3e3, startslide: 0, directionnav: true, controlnav: true, controlnavthumbs: false, pauseonhover: true, manualadvance: false, prevtext: "prev", nexttext: "next", randomstart: false, beforechange: function() {}, afterchange: function() {}, slideshowend: function() {}, lastslide: function() {}, afterload: function() {} }; e.fn._reverse = [].reverse })(jquery)