/* * jquery nivo slider v2.7.1 * http://www.jiepin.net/ * * http://www.jiepin.net/ * * march 2010 */ (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") + '") center 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('
' + d.prevtext + '' + d.nexttext + "
"); 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 < g.length; k++) { if (d.controlnavthumbs) { var l = g.eq(k); if (!l.is("img")) { l = l.find("img:first") } if (d.controlnavthumbsfromrel) { j.append('') } 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") + '") center 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 < c.slices; e++) { var f = math.round(b.width() / c.slices); if (e == c.slices - 1) { b.append(a('
').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 < c.boxrows; g++) { for (var h = 0; h < c.boxcols; h++) { if (h == c.boxcols - 1) { b.append(a('
').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") + '") center no-repeat') } else { if (e == "prev") { b.css("background", 'url("' + f.currentimage.attr("src") + '") center no-repeat') } if (e == "next") { b.css("background", 'url("' + f.currentimage.attr("src") + '") center 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 < d.boxcols * 2; w++) { var x = w; for (var y = 0; y < d.boxrows; y++) { if (x >= 0 && x < d.boxcols) { (function(c, e, f, h, i) { var j = a(v[c][e]); var k = j.width(); var l = j.height(); if (g == "boxraingrow" || g == "boxraingrowreverse") { j.width(0).height(0) } if (h == i - 1) { settimeout(function() { j.animate({ opacity: "1", width: k, height: l }, d.animspeed / 1.3, "", function() { b.trigger("nivo:animfinished") }) }, 100 + f) } else { settimeout(function() { j.animate({ opacity: "1", width: k, height: l }, d.animspeed / 1.3) }, 100 + f) } })(y, x, j, k, r); k++ } x-- } j += 100 } } }; var p = function(a) { for (var b, c, d = a.length; d; b = parseint(math.random() * d), c = a[--d], a[d] = a[b], a[b] = c); return a }; var q = function(a) { if (this.console && typeof console.log != "undefined") console.log(a) }; this.stop = function() { if (!a(b).data("nivo:vars").stop) { a(b).data("nivo:vars").stop = true; q("stop slider") } }; this.start = function() { if (a(b).data("nivo:vars").stop) { a(b).data("nivo:vars").stop = false; q("start slider") } }; d.afterload.call(this); return this }; a.fn.nivoslider = function(c) { return this.each(function(d, e) { var f = a(this); if (f.data("nivoslider")) return f.data("nivoslider"); var g = new b(this, c); f.data("nivoslider", g) }) }; a.fn.nivoslider.defaults = { effect: "random", slices: 15, boxcols: 8, boxrows: 4, 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: .8, prevtext: "prev", nexttext: "next", randomstart: false, beforechange: function() {}, afterchange: function() {}, slideshowend: function() {}, lastslide: function() {}, afterload: function() {} }; a.fn._reverse = [].reverse })(jquery)