﻿(function (a) { var b = { init: function (b) { var c = { controls: null, startIndex: 0, delay: 0, hideControlsWhenSingle: false, showTimer: true, pauseTimerOnHover: true, stopTimerOnNav: true, timerSize: 20, timerLineSize: 4, timerColor: "rgba(255, 255, 255, 0.6)" }; if (b) { a.extend(c, b) } var d = this.eq(0); var e = a(c.controls); var f = a("<div>"); var g = a("<canvas>")[0]; var h; var i; var j = 0; var k; var l = false; var m = false; if (d.length && d.children().length > 1) { d.data("ss-currentIndex", c.startIndex); function n() { if (g.getContext && c.showTimer) { var a = g.getContext("2d"); a.clearRect(0, 0, c.timerSize, c.timerSize); a.strokeStyle = c.timerColor; a.lineWidth = c.timerLineSize; a.beginPath(); a.arc(c.timerSize / 2, c.timerSize / 2, c.timerSize / 2 - c.timerLineSize / 2, -Math.PI / 2, -Math.PI / 2 - (Math.PI * 2 - Math.PI * j), false); a.stroke() } j += .02; if (j > 2) { j = 0; d.trigger("ss-next") } } function o() { clearInterval(k); if (c.delay > 0 && !m) { k = setInterval(function () { n() }, c.delay / 100) } } function p(a) { clearInterval(k); if (a) { j = 0; n() } } function q(b) { i.each(function (c) { if (b == c) { a(this).data("dot").addClass("ss-active") } else { a(this).data("dot").removeClass("ss-active") } }) } function r(a, b) { var c = d.data("ss-currentIndex"); var e = i.eq(c); var f = i.eq(a); if (!l) { p(true); if (c != a) { l = true; q(a); h.css({ width: "200%" }); if (b && b > 0 || !(b && b < 0) && a > c) { e.after(f.show()); h.css({ left: 0 }).animate({ left: -d.width() }, function () { e.hide(); h.css({ left: 0, width: "100%" }); l = false; o() }) } else { e.before(f.show()); h.css({ left: -d.width() }).animate({ left: 0 }, function () { e.hide(); h.css({ width: "100%" }); l = false; o() }) } d.data("ss-currentIndex", a) } else { q(c); i.eq(c).show() } } } d.bind("ss-next", function (a, b) { currentIndex = d.data("ss-currentIndex"); nextIndex = currentIndex + 1; if (nextIndex >= h.children().length) nextIndex = 0; if (b && c.stopTimerOnNav) m = true; r(nextIndex, 1) }); d.bind("ss-previous", function (a, b) { currentIndex = d.data("ss-currentIndex"); prevIndex = currentIndex - 1; if (prevIndex < 0) prevIndex = h.children().length - 1; if (b && c.stopTimerOnNav) m = true; r(prevIndex, -1) }); d.bind("ss-goto", function (a, b) { if (c.stopTimerOnNav) m = true; r(b) }); i = d.children().css({ "float": "left", width: d.width(), height: d.height(), position: "relative" }).hide(); h = a("<div>").append(i).css({ width: "100%", height: "100%", position: "relative" }); f.css({ position: "absolute", bottom: 5, right: 5 }); d.append(h).append(f).css({ overflow: "hidden", position: "relative" }).hover(function () { if (c.pauseTimerOnHover) p(false) }, o); var s = a("<div>").addClass("ss-dots"); var t = a("<ul>").css({ listStyle: "none" }); s.append(t); i.each(function (b) { var c = a("<li>").css({ cursor: "pointer", "float": "left" }).click(function (a) { a.preventDefault(); d.trigger("ss-goto", b) }); a(this).data("dot", c); t.append(c) }); e.append(a("<div>").addClass("ss-arrow-left").css({ cursor: "pointer" }).click(function (a) { a.preventDefault(); d.trigger("ss-previous", true) })).append(a("<div>").addClass("ss-arrow-right").css({ cursor: "pointer" }).click(function (a) { a.preventDefault(); d.trigger("ss-next", true) })).append(s); r(d.data("ss-currentIndex")); f.append(g); g.width = c.timerSize; g.height = c.timerSize; o() } else if (c.hideControlsWhenSingle) { e.hide() } return this }, next: function () { return this.trigger("ss-next", true) }, previous: function () { return this.trigger("ss-previous", true) }, "goto": function (a) { return this.trigger("ss-goto", a) } }; a.fn.slickslider = function (c) { if (b[c]) { return b[c].apply(this, Array.prototype.slice.call(arguments, 1)) } else if (typeof c === "object" || !c) { return b.init.apply(this, arguments) } else { a.error("Method " + c + " does not exist") } } })(jQuery)
