﻿/**
* TP Slider Plugin for jQuery by Taylor & Pond
* http://www.taylorpond.com/
* Copyright 2010, Taylor & Pond
**/
(function(a) { a.fn.extend({ tpslider: function(b) { return this.each(function() { var l = { rotationSpeed: 1e4, transitionSpeed: 1e3, autoPlay: true, nav: "", navItem: "", navType: "none", onTransitionStart: function() { }, onTransitionEnd: function() { } }, c = a.extend(l, b), h = a(this), i, d = 0, g = 0, e = 0; function f(b) { var j = d; c.onTransitionStart(d, b); h.children().not(c.nav).fadeOut(c.transitionSpeed); h.children().filter(":nth-child(" + (b + 1) + ")").fadeIn(c.transitionSpeed, function() { c.onTransitionEnd(j, b) }); a(c.nav).children().removeClass("active"); a(c.nav).children().filter(":nth-child(" + (b + 1) + ")").addClass("active"); e = 0; d = b; if (b < g - 1) e = b + 1; if (c.autoPlay) i = setTimeout(function() { f(e) }, c.rotationSpeed) } function j() { a(c.nav).css("display", "block"); a(c.nav).children().first().addClass("active"); a(c.nav).children().click(function() { clearTimeout(i); var b = a(this).index(); if (parseInt(d) !== parseInt(b)) f(parseInt(b)); else { if (d < g - 1) e = d + 1; i = setTimeout(function() { f(e) }, c.rotationSpeed) } }) } function k() { var b = 0; if (c.navType === "dynamic") c.nav = a("<ul/>").attr("class", "tpslider-nav").css("display", "none").appendTo(h); h.children().not(c.nav).each(function() { b > 0 && a(this).css("display", "none"); a(this).css("position", "absolute"); c.navType === "dynamic" && a("<li/>").text(b + 1).appendTo(c.nav); b++ }); g = b; d = 0; if (g > 1) { c.navType !== "none" && j(); if (c.autoPlay) i = setTimeout(function() { f(1) }, c.rotationSpeed) } } k() }) } }) })(jQuery);
