6 lines
24 KiB
JavaScript
6 lines
24 KiB
JavaScript
|
|
/*
|
||
|
|
* jQuery Cycle2; v20130909
|
||
|
|
* http://jquery.malsup.com/cycle2/
|
||
|
|
* Copyright (c) 2013 M. Alsup; Dual licensed: MIT/GPL
|
||
|
|
*/
|
||
|
|
(function (e) { "use strict"; function t(e) { return (e || "").toLowerCase() } var i = "20130725"; e.fn.cycle = function (i) { var n; return 0 !== this.length || e.isReady ? this.each(function () { var n, s, o, c, r = e(this), l = e.fn.cycle.log; if (!r.data("cycle.opts")) { (r.data("cycle-log") === !1 || i && i.log === !1 || s && s.log === !1) && (l = e.noop), l("--c2 init--"), n = r.data(); for (var a in n) n.hasOwnProperty(a) && /^cycle[A-Z]+/.test(a) && (c = n[a], o = a.match(/^cycle(.*)/)[1].replace(/^[A-Z]/, t), l(o + ":", c, "(" + typeof c + ")"), n[o] = c); s = e.extend({}, e.fn.cycle.defaults, n, i || {}), s.timeoutId = 0, s.paused = s.paused || !1, s.container = r, s._maxZ = s.maxZ, s.API = e.extend({ _container: r }, e.fn.cycle.API), s.API.log = l, s.API.trigger = function (e, t) { return s.container.trigger(e, t), s.API }, r.data("cycle.opts", s), r.data("cycle.API", s.API), s.API.trigger("cycle-bootstrap", [s, s.API]), s.API.addInitialSlides(), s.API.preInitSlideshow(), s.slides.length && s.API.initSlideshow() } }) : (n = { s: this.selector, c: this.context }, e.fn.cycle.log("requeuing slideshow (dom not ready)"), e(function () { e(n.s, n.c).cycle(i) }), this) }, e.fn.cycle.API = { opts: function () { return this._container.data("cycle.opts") }, addInitialSlides: function () { var t = this.opts(), i = t.slides; t.slideCount = 0, t.slides = e(), i = i.jquery ? i : t.container.find(i), t.random && i.sort(function () { return Math.random() - .5 }), t.API.add(i) }, preInitSlideshow: function () { var t = this.opts(); t.API.trigger("cycle-pre-initialize", [t]); var i = e.fn.cycle.transitions[t.fx]; i && e.isFunction(i.preInit) && i.preInit(t), t._preInitialized = !0 }, postInitSlideshow: function () { var t = this.opts(); t.API.trigger("cycle-post-initialize", [t]); var i = e.fn.cycle.transitions[t.fx]; i && e.isFunction(i.postInit) && i.postInit(t) }, initSlideshow: function () { var t, i = this.opts(), n = i.container; i.API.calcFirstSlide(), "static" == i.container.css("position") && i.container.css("position", "relative"), e(i.slides[i.currSlide]).css("opacity", 1).show(), i.API.stackSlides(i.slides[i.currSlide], i.slides[i.nextSlide], !i.reverse), i.pauseOnHover && (i.pauseOnHover !== !0 && (n = e(i.pauseOnHover)), n.hover(function () { i.API.pause(!0) }, function () { i.API.resume(!0) })), i.timeout && (t = i.API.getSlideOpts(i.nextSlide), i.API.queueTransition(t, t.timeout + i.delay)), i._initialized = !0, i.API.updateView(!0), i.API.trigger("cycle-initialized", [i]), i.API.postInitSlideshow() }, pause: function (t) { var i = this.opts(), n = i.API.getSlideOpts(), s = i.hoverPaused || i.paused; t ? i.hoverPaused = !0 : i.paused = !0, s || (i.container.addClass("cycle-paused"), i.API.trigger("cycle-paused", [i]).log("cycle-paused"), n.timeout && (clearTimeout(i.timeoutId), i.timeoutId = 0, i._remainingTimeout -= e.now() - i._lastQueue, (0 > i._remainingTimeout || isNaN(i._remainingTimeout)) && (i._remainingTimeout = void 0))) }, resume: function (e) { var t = this.opts(), i = !t.hoverPaused && !t.paused; e ? t.hoverPaused = !1 : t.paused = !1, i || (t.container.removeClass("cycle-paused"), 0 === t.slides.filter(":animated").length && t.API.queueTransition(t.API.getSlideOpts(), t._remainingTimeout), t.API.trigger("cycle-resumed", [t, t._remainingTimeout]).log("cycle-resumed")) }, add: function (t, i) { var n, s = this.opts(), o = s.slideCount, c = !1; "string" == e.type(t) && (t = e.trim(t)), e(t).each(function () { var t, n = e(this); i ? s.container.prepend(n) : s.container.append(n), s.slideCount++, t = s.API.buildSlideOpts(n), s.slides = i ? e(n).add(s.slides) : s.slides.add(n), s.API.initSlide(t, n, --s._maxZ), n.data("cycle.opts", t), s.API.trigger("cycle-slide-added", [s, t, n]) }), s.API.updateView(!0), c = s._preInitialized && 2 > o && s.slideCount >= 1, c && (s._initialized ? s.timeout && (n = s.slides.length, s.nextSlide = s.reverse ? n - 1 : 1, s.timeoutId || s.API.queueTransition(s)) : s.API.initSlideshow()) }, calcFirstSlide: function () { var e, t = this.opts(); e = parseInt(t.startingSlide |
|