/* * version: 1.1.1 * update: 2012/06/28 * by: oliver, http://www.note12.com * mail: oliver@note12.com * qq:18015001 * * * * * 修复fade效果 , 增加容器 succescont 增加fadeeasing * * 增加侧面缩图选项 * * * */ (function(a) { a.fn.olvslides = function(b) { a.fn.olvslides.option = { succescont: "succescont", control: "control", change: "change", createnextprev: true, next: "ssnext", prev: "ssprev", createpagination: false, paginationclass: "pageclass", currentclass: "cur", thumb: true, thumbpage: true, // thumbprev: "thumbprev", // thumbnext: "thumbnext", thumbdirection: "x", bigtarget: false, bigtargetprev: "bigtargetprev", bigtargetnext: "bigtargetnext", fadespeed: 350, slidespeed: 350, start: 1, effect: "slide", fadeeasing: "", play: 5000, pause: 2000, hoverpause: false, }; b = a.extend({}, a.fn.olvslides.option, b); return this.each(function() { a(this).children().wrapall('
'); var b = a(this), o = a("." + b.control, b), q = a("." + b.change, b), g = a(".thumbwrap", b), c = a(".thumbcont", g), h = b.thumb ? h = c.children(":eq(0)").children().size() : h = q.children().size(), h = parseint(b.start, 10) >= h ? h - 1 : parseint(b.start - 1, 10), x = o.outerwidth(), t = b.effect, v = 0, u = 0, d = 0, w = 0, m, n, g, e, r, k, f, c, d, p, f, s, z; if (h < 2) { o.fadein(b.fadespeed); a("." + b.next + ", ." + b.prev).fadeout(0); return false } function j(k, j, i) { if (!m) { m = true; switch (k) { case "next": u = w; v = w + 1; v = h === v ? 0 : v; g = x * 2; k = -x * 2; w = v; break; case "prev": u = w; v = w - 1; v = v === -1 ? h - 1 : v; g = 0; k = 0; w = v; break; case "pagination": v = parseint(i, 10); u = a("." + b.paginationclass + " a." + b.currentclass, b).attr("href").match("[^#/]+$"); if (v > u) { g = x * 2; k = -x * 2 } else { g = 0; k = 0 } w = v; break; case "thumbclick": v = parseint(i, 10); u = a("li." + b.currentclass, c).data("data"); if (v > u) { g = x * 2; k = -x * 2 } else { g = 0; k = 0 } w = v; break } if (j === "slide") { q.children(":eq(" + v + ")").css({ left: g, display: "block" }); q.animate({ left: k }, b.slidespeed, function() { q.css({ left: -x }); q.children(":eq(" + v + ")").css({ left: x, zindex: 5 }); q.children(":eq(" + u + ")").css({ left: x, display: "none", zindex: 0 }); m = false }) } else { q.children(":eq(" + v + ")", b).css({ zindex: 8 }).fadein(b.fadespeed, b.fadeeasing, function() { q.children(":eq(" + u + ")", b).css({ display: "none", zindex: 0 }); q.children(":eq(" + v + ")", b).css({ zindex: 0 }); m = false }) } if (b.createpagination) { a("." + b.paginationclass + " a", b).removeclass(b.currentclass); a("." + b.paginationclass + " a:eq(" + v + ")", b).addclass(b.currentclass) } if (b.thumb) { if (b.thumbdirection == "y") { f = c.children(":eq(0)").position().top; c = ((d - p) / 2) - (p * w); if (c < s) { c = s } else { if (c > 0) { c = 0 } } c.children(":eq(0)").animate({ top: c }); c.children(":eq(0)").children("li").removeclass("cur"); c.children(":eq(0)").children("li:eq(" + w + ")").addclass("cur") } else { f = c.children(":eq(0)").position().left; c = ((d - p) / 2) - (p * w); if (c < s) { c = s } else { if (c > 0) { c = 0 } } c.children(":eq(0)").animate({ left: c }); c.children(":eq(0)").children("li").removeclass("cur"); c.children(":eq(0)").children("li:eq(" + w + ")").addclass("cur") } } } } function y() { clearinterval(b.data("interval")) } function l() { if (b.pause) { cleartimeout(b.data("pause")); clearinterval(b.data("interval")); r = settimeout(function() { cleartimeout(b.data("pause")); k = setinterval(function() { j("next", t) }, b.play); b.data("interval", k) }, b.pause); b.data("pause", r) } else { y() } } if (h < 2) { return } if (h < 0) { h = 0 } if (b.start) { w = h } b.css({ overflow: "hidden", position: "relative" }); o.css({ overflow: "hidden", position: "relative" }); o.css({ display: "block" }); if (b.thumb) { startt = h + 1; g.show(); c.bind("mouseover", function() { y() }); c.bind("mouseleave", function() { l() }); if (b.thumbpage) { g.append('updown') } if (b.thumbdirection === "y") { d = c.outerheight(); p = c.children(":eq(0)").children(":eq(0)").outerheight(); f = math.ceil(d / p); s = -p * h + d; f = c.children(":eq(0)").position().top; c.children(":eq(0)").css({ height: p * h + "px", width: "100%", position: "absolute", left: "0px", top: "0px" }); if (b.start > f) { if ("-" + math.ceil((p * startt) - (d / 2) - (p / 2)) < -p * h + d) { c.children(":eq(0)").css({ top: -p * h + d + "px" }) } else { c.children(":eq(0)").css({ top: "-" + math.ceil((p * startt) - (d / 2) - (p / 2)) + "px" }) } } a("." + b.thumbprev, b).click(function(i) { i.preventdefault(); if (b.play) { l() } e("prev") }); a("." + b.thumbnext, b).click(function(i) { i.preventdefault(); if (b.play) { l() } e("next") }) } else { d = c.outerwidth(); p = c.children(":eq(0)").children(":eq(0)").outerwidth(); f = math.ceil(d / p); s = -p * h + d; f = c.children(":eq(0)").position().left; c.children(":eq(0)").css({ width: p * h + "px", height: "100%", position: "absolute", left: "0px", top: "0px" }); if (b.start > f) { if ("-" + math.ceil((p * startt) - (d / 2) - (p / 2)) < -p * h + d) { c.children(":eq(0)").css({ left: -p * h + d + "px" }) } else { c.children(":eq(0)").css({ left: "-" + math.ceil((p * startt) - (d / 2) - (p / 2)) + "px" }) } } a("." + b.thumbprev, b).click(function(i) { i.preventdefault(); if (b.play) { l() } e("prev") }); a("." + b.thumbnext, b).click(function(i) { i.preventdefault(); if (b.play) { l() } e("next") }) } c.children(":eq(0)").children().click(function(i) { i.preventdefault(); c = ((d - p) / 2) - (p * a(this).index()); if (c < s) { c = s } else { if (c > 0) { c = 0 } } if (b.play) { l() } n = a(this).index(); if (w != n) { j("thumbclick", t, n) } if (b.thumbdirection === "y") { c.children(":eq(0)").animate({ top: c }, b.slidespeed) } else { c.children(":eq(0)").animate({ left: c }, b.slidespeed) } c.children(":eq(0)").children().removeclass(b.currentclass); a(this).addclass(b.currentclass); return false }); c.children(":eq(0)").children().each(function(l) { var n = a(this).find("img").attr("bigimg"); var j = a(this).find("img").attr("url"); var i = a(this).find("img").attr("alt"); var m = a(this).find("img").attr("text"); var k = '
  • ' + i + '
    ' + m + "
  • "; a(this).data("data", l); q.append(k) }); c.children(":eq(0)").children("li:eq(" + h + ")").addclass("cur") } else { g.hide().remove() } if (b.createpagination && b.thumb === false) { o.after('
    '); for (i = 0; i < h; i++) { a("." + b.paginationclass, b).append('' + (i + 1) + "") } a("." + b.paginationclass + " a:eq(" + v + ")", b).addclass(b.currentclass) } a("." + b.paginationclass + " a", b).click(function() { if (b.play) { l() } n = a(this).attr("href").match("[^#/]+$"); if (w != n) { j("pagination", t, n) } return false }); if (b.createnextprev) { o.append('prev'); a("." + b.prev, b).after('next') } a("." + b.prev, b).click(function(i) { i.preventdefault(); if (b.play) { l() } j("prev", t) }); a("." + b.next, b).click(function(i) { i.preventdefault(); if (b.play) { l() } j("next", t) }); q.children().css({ position: "absolute", top: 0, left: o.outerwidth(), zindex: 0, display: "none" }); q.css({ position: "relative", width: (x * 3), left: -x }); q.children(":eq(" + h + ")").fadein(b.fadespeed); function e(i) { if (b.thumbdirection == "y") { if (i == "prev") { f = f + d; if (f > 0) { f = 0 } } else { if (i == "next") { f = f - d; if (f < s) { f = s } } } c.children(":eq(0)").animate({ top: f }) } else { if (i == "prev") { f = f + d; if (f > 0) { f = 0 } } else { if (i == "next") { f = f - d; if (f < s) { f = s } } } c.children(":eq(0)").animate({ left: f }) } } function a(i) {} if (b.bigtarget) { o.append('
    '); a("." + b.bigtargetprev, b).click(function(i) { i.preventdefault(); if (b.play) { l() } j("prev", t) }); a("." + b.bigtargetnext, b).click(function(i) { i.preventdefault(); if (b.play) { l() } j("next", t) }) } if (b.hoverpause && b.play) { q.bind("mouseover", function() { y() }); q.bind("mouseleave", function() { l() }) } if (b.play) { k = setinterval(function() { j("next", t) }, b.play); b.data("interval", k) } }) } })(jquery);