jquery.slides.min.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517
  1. /*
  2. SlidesJS 3.0.4 http://slidesjs.com
  3. (c) 2013 by Nathan Searles http://nathansearles.com
  4. Updated: June 26th, 2013
  5. Apache License: http://www.apache.org/licenses/LICENSE-2.0
  6. */
  7. (function () {
  8. (function (e, t, n) {
  9. var r, i, s;
  10. s = "slidesjs";
  11. i = {
  12. width: 940,
  13. height: 528,
  14. start: 1,
  15. navigation: {
  16. active: !0,
  17. effect: "slide"
  18. },
  19. pagination: {
  20. active: !0,
  21. effect: "slide"
  22. },
  23. play: {
  24. active: !1,
  25. effect: "slide",
  26. interval: 5e3,
  27. auto: !1,
  28. swap: !0,
  29. pauseOnHover: !1,
  30. restartDelay: 2500
  31. },
  32. effect: {
  33. slide: {
  34. speed: 0
  35. },
  36. fade: {
  37. speed: 0,
  38. crossfade: !0
  39. }
  40. },
  41. callback: {
  42. loaded: function () {},
  43. start: function () {},
  44. complete: function () {}
  45. }
  46. };
  47. r = function () {
  48. function t(t, n) {
  49. this.element = t;
  50. this.options = e.extend(!0, {}, i, n);
  51. this._defaults = i;
  52. this._name = s;
  53. this.init()
  54. }
  55. return t
  56. }();
  57. r.prototype.init = function () {
  58. var n, r, i, s, o, u, a = this;
  59. n = e(this.element);
  60. this.data = e.data(this);
  61. e.data(this, "animating", !1);
  62. e.data(this, "total", n.children().not(".slidesjs-navigation", n).length);
  63. e.data(this, "current", this.options.start - 1);
  64. e.data(this, "vendorPrefix", this._getVendorPrefix());
  65. if (typeof TouchEvent != "undefined") {
  66. e.data(this, "touch", !0);
  67. this.options.effect.slide.speed = this.options.effect.slide.speed / 2
  68. }
  69. n.css({
  70. overflow: "hidden"
  71. });
  72. n.slidesContainer = n.children().not(".slidesjs-navigation", n).wrapAll("<div class='slidesjs-container'>", n).parent().css({
  73. overflow: "hidden",
  74. position: "relative"
  75. });
  76. e(".slidesjs-container", n).wrapInner("<div class='slidesjs-control'>", n).children();
  77. e(".slidesjs-control", n).css({
  78. position: "relative",
  79. left: 0
  80. });
  81. e(".slidesjs-control", n).children().addClass("slidesjs-slide").css({
  82. position: "absolute",
  83. top: 0,
  84. left: 0,
  85. width: "100%",
  86. zIndex: 0,
  87. display: "none",
  88. webkitBackfaceVisibility: "hidden"
  89. });
  90. e.each(e(".slidesjs-control", n).children(), function (t) {
  91. var n;
  92. n = e(this);
  93. return n.attr("slidesjs-index", t)
  94. });
  95. if (this.data.touch) {
  96. e(".slidesjs-control", n).on("touchstart", function (e) {
  97. return a._touchstart(e)
  98. });
  99. e(".slidesjs-control", n).on("touchmove", function (e) {
  100. return a._touchmove(e)
  101. });
  102. e(".slidesjs-control", n).on("touchend", function (e) {
  103. return a._touchend(e)
  104. })
  105. }
  106. n.fadeIn(0);
  107. this.update();
  108. this.data.touch && this._setuptouch();
  109. e(".slidesjs-control", n).children(":eq(" + this.data.current + ")").eq(0).fadeIn(0, function () {
  110. return e(this).css({
  111. zIndex: 10
  112. })
  113. });
  114. if (this.options.navigation.active) {
  115. o = e("<a>", {
  116. "class": "slidesjs-previous slidesjs-navigation",
  117. href: "#",
  118. title: "Previous",
  119. text: "Previous"
  120. }).appendTo(n);
  121. r = e("<a>", {
  122. "class": "slidesjs-next slidesjs-navigation",
  123. href: "#",
  124. title: "Next",
  125. text: "Next"
  126. }).appendTo(n)
  127. }
  128. e(".slidesjs-next", n).click(function (e) {
  129. e.preventDefault();
  130. a.stop(!0);
  131. return a.next(a.options.navigation.effect)
  132. });
  133. e(".slidesjs-previous", n).click(function (e) {
  134. e.preventDefault();
  135. a.stop(!0);
  136. return a.previous(a.options.navigation.effect)
  137. });
  138. if (this.options.play.active) {
  139. s = e("<a>", {
  140. "class": "slidesjs-play slidesjs-navigation",
  141. href: "#",
  142. title: "Play",
  143. text: "Play"
  144. }).appendTo(n);
  145. u = e("<a>", {
  146. "class": "slidesjs-stop slidesjs-navigation",
  147. href: "#",
  148. title: "Stop",
  149. text: "Stop"
  150. }).appendTo(n);
  151. s.click(function (e) {
  152. e.preventDefault();
  153. return a.play(!0)
  154. });
  155. u.click(function (e) {
  156. e.preventDefault();
  157. return a.stop(!0)
  158. });
  159. this.options.play.swap && u.css({
  160. display: "none"
  161. })
  162. }
  163. if (this.options.pagination.active) {
  164. i = e("<ul>", {
  165. "class": "slidesjs-pagination"
  166. }).appendTo(n);
  167. e.each(new Array(this.data.total), function (t) {
  168. var n, r;
  169. n = e("<li>", {
  170. "class": "slidesjs-pagination-item"
  171. }).appendTo(i);
  172. r = e("<a>", {
  173. href: "#",
  174. "data-slidesjs-item": t,
  175. html: t + 1
  176. }).appendTo(n);
  177. return r.click(function (t) {
  178. t.preventDefault();
  179. a.stop(!0);
  180. return a.goto(e(t.currentTarget).attr("data-slidesjs-item") * 1 + 1)
  181. })
  182. })
  183. }
  184. e(t).bind("resize", function () {
  185. return a.update()
  186. });
  187. this._setActive();
  188. this.options.play.auto && this.play();
  189. return this.options.callback.loaded(this.options.start)
  190. };
  191. r.prototype._setActive = function (t) {
  192. var n, r;
  193. n = e(this.element);
  194. this.data = e.data(this);
  195. r = t > -1 ? t : this.data.current;
  196. e(".active", n).removeClass("active");
  197. return e(".slidesjs-pagination li:eq(" + r + ") a", n).addClass("active")
  198. };
  199. r.prototype.update = function () {
  200. var t, n, r;
  201. t = e(this.element);
  202. this.data = e.data(this);
  203. e(".slidesjs-control", t).children(":not(:eq(" + this.data.current + "))").css({
  204. display: "none",
  205. left: 0,
  206. zIndex: 0
  207. });
  208. r = t.width();
  209. n = this.options.height / this.options.width * r;
  210. this.options.width = r;
  211. this.options.height = n;
  212. return e(".slidesjs-control, .slidesjs-container", t).css({
  213. width: r,
  214. height: n
  215. })
  216. };
  217. r.prototype.next = function (t) {
  218. var n;
  219. n = e(this.element);
  220. this.data = e.data(this);
  221. e.data(this, "direction", "next");
  222. t === void 0 && (t = this.options.navigation.effect);
  223. return t === "fade" ? this._fade() : this._slide()
  224. };
  225. r.prototype.previous = function (t) {
  226. var n;
  227. n = e(this.element);
  228. this.data = e.data(this);
  229. e.data(this, "direction", "previous");
  230. t === void 0 && (t = this.options.navigation.effect);
  231. return t === "fade" ? this._fade() : this._slide()
  232. };
  233. r.prototype.goto = function (t) {
  234. var n, r;
  235. n = e(this.element);
  236. this.data = e.data(this);
  237. r === void 0 && (r = this.options.pagination.effect);
  238. t > this.data.total ? t = this.data.total : t < 1 && (t = 1);
  239. if (typeof t == "number") return r === "fade" ? this._fade(t) : this._slide(t);
  240. if (typeof t == "string") {
  241. if (t === "first") return r === "fade" ? this._fade(0) : this._slide(0);
  242. if (t === "last") return r === "fade" ? this._fade(this.data.total) : this._slide(this.data.total)
  243. }
  244. };
  245. r.prototype._setuptouch = function () {
  246. var t, n, r, i;
  247. t = e(this.element);
  248. this.data = e.data(this);
  249. i = e(".slidesjs-control", t);
  250. n = this.data.current + 1;
  251. r = this.data.current - 1;
  252. r < 0 && (r = this.data.total - 1);
  253. n > this.data.total - 1 && (n = 0);
  254. i.children(":eq(" + n + ")").css({
  255. display: "block",
  256. left: this.options.width
  257. });
  258. return i.children(":eq(" + r + ")").css({
  259. display: "block",
  260. left: -this.options.width
  261. })
  262. };
  263. r.prototype._touchstart = function (t) {
  264. var n, r;
  265. n = e(this.element);
  266. this.data = e.data(this);
  267. r = t.originalEvent.touches[0];
  268. this._setuptouch();
  269. e.data(this, "touchtimer", Number(new Date));
  270. e.data(this, "touchstartx", r.pageX);
  271. e.data(this, "touchstarty", r.pageY);
  272. return t.stopPropagation()
  273. };
  274. r.prototype._touchend = function (t) {
  275. var n, r, i, s, o, u, a, f = this;
  276. n = e(this.element);
  277. this.data = e.data(this);
  278. u = t.originalEvent.touches[0];
  279. s = e(".slidesjs-control", n);
  280. if (s.position().left > this.options.width * .5 || s.position().left > this.options.width * .1 && Number(new Date) - this.data.touchtimer < 250) {
  281. e.data(this, "direction", "previous");
  282. this._slide()
  283. } else if (s.position().left < -(this.options.width * .5) || s.position().left < -(this.options.width * .1) && Number(new Date) - this.data.touchtimer < 250) {
  284. e.data(this, "direction", "next");
  285. this._slide()
  286. } else {
  287. i = this.data.vendorPrefix;
  288. a = i + "Transform";
  289. r = i + "TransitionDuration";
  290. o = i + "TransitionTimingFunction";
  291. s[0].style[a] = "translateX(0px)";
  292. s[0].style[r] = this.options.effect.slide.speed * .85 + "ms"
  293. }
  294. s.on("transitionend webkitTransitionEnd oTransitionEnd otransitionend MSTransitionEnd", function () {
  295. i = f.data.vendorPrefix;
  296. a = i + "Transform";
  297. r = i + "TransitionDuration";
  298. o = i + "TransitionTimingFunction";
  299. s[0].style[a] = "";
  300. s[0].style[r] = "";
  301. return s[0].style[o] = ""
  302. });
  303. return t.stopPropagation()
  304. };
  305. r.prototype._touchmove = function (t) {
  306. var n, r, i, s, o;
  307. n = e(this.element);
  308. this.data = e.data(this);
  309. s = t.originalEvent.touches[0];
  310. r = this.data.vendorPrefix;
  311. i = e(".slidesjs-control", n);
  312. o = r + "Transform";
  313. e.data(this, "scrolling", Math.abs(s.pageX - this.data.touchstartx) < Math.abs(s.pageY - this.data.touchstarty));
  314. if (!this.data.animating && !this.data.scrolling) {
  315. t.preventDefault();
  316. this._setuptouch();
  317. i[0].style[o] = "translateX(" + (s.pageX - this.data.touchstartx) + "px)"
  318. }
  319. return t.stopPropagation()
  320. };
  321. r.prototype.play = function (t) {
  322. var n, r, i, s = this;
  323. n = e(this.element);
  324. this.data = e.data(this);
  325. if (!this.data.playInterval) {
  326. if (t) {
  327. r = this.data.current;
  328. this.data.direction = "next";
  329. this.options.play.effect === "fade" ? this._fade() : this._slide()
  330. }
  331. e.data(this, "playInterval", setInterval(function () {
  332. r = s.data.current;
  333. s.data.direction = "next";
  334. return s.options.play.effect === "fade" ? s._fade() : s._slide()
  335. }, this.options.play.interval));
  336. i = e(".slidesjs-container", n);
  337. if (this.options.play.pauseOnHover) {
  338. i.unbind();
  339. i.bind("mouseenter", function () {
  340. return s.stop()
  341. });
  342. i.bind("mouseleave", function () {
  343. return s.options.play.restartDelay ? e.data(s, "restartDelay", setTimeout(function () {
  344. return s.play(!0)
  345. }, s.options.play.restartDelay)) : s.play()
  346. })
  347. }
  348. e.data(this, "playing", !0);
  349. e(".slidesjs-play", n).addClass("slidesjs-playing");
  350. if (this.options.play.swap) {
  351. e(".slidesjs-play", n).hide();
  352. return e(".slidesjs-stop", n).show()
  353. }
  354. }
  355. };
  356. r.prototype.stop = function (t) {
  357. var n;
  358. n = e(this.element);
  359. this.data = e.data(this);
  360. clearInterval(this.data.playInterval);
  361. this.options.play.pauseOnHover && t && e(".slidesjs-container", n).unbind();
  362. e.data(this, "playInterval", null);
  363. e.data(this, "playing", !1);
  364. e(".slidesjs-play", n).removeClass("slidesjs-playing");
  365. if (this.options.play.swap) {
  366. e(".slidesjs-stop", n).hide();
  367. return e(".slidesjs-play", n).show()
  368. }
  369. };
  370. r.prototype._slide = function (t) {
  371. var n, r, i, s, o, u, a, f, l, c, h = this;
  372. n = e(this.element);
  373. this.data = e.data(this);
  374. if (!this.data.animating && t !== this.data.current + 1) {
  375. e.data(this, "animating", !0);
  376. r = this.data.current;
  377. if (t > -1) {
  378. t -= 1;
  379. c = t > r ? 1 : -1;
  380. i = t > r ? -this.options.width : this.options.width;
  381. o = t
  382. } else {
  383. c = this.data.direction === "next" ? 1 : -1;
  384. i = this.data.direction === "next" ? -this.options.width : this.options.width;
  385. o = r + c
  386. }
  387. o === -1 && (o = this.data.total - 1);
  388. o === this.data.total && (o = 0);
  389. this._setActive(o);
  390. a = e(".slidesjs-control", n);
  391. t > -1 && a.children(":not(:eq(" + r + "))").css({
  392. display: "none",
  393. left: 0,
  394. zIndex: 0
  395. });
  396. a.children(":eq(" + o + ")").css({
  397. display: "block",
  398. left: c * this.options.width,
  399. zIndex: 10
  400. });
  401. this.options.callback.start(r + 1);
  402. if (this.data.vendorPrefix) {
  403. u = this.data.vendorPrefix;
  404. l = u + "Transform";
  405. s = u + "TransitionDuration";
  406. f = u + "TransitionTimingFunction";
  407. a[0].style[l] = "translateX(" + i + "px)";
  408. a[0].style[s] = this.options.effect.slide.speed + "ms";
  409. return a.on("transitionend webkitTransitionEnd oTransitionEnd otransitionend MSTransitionEnd", function () {
  410. a[0].style[l] = "";
  411. a[0].style[s] = "";
  412. a.children(":eq(" + o + ")").css({
  413. left: 0
  414. });
  415. a.children(":eq(" + r + ")").css({
  416. display: "none",
  417. left: 0,
  418. zIndex: 0
  419. });
  420. e.data(h, "current", o);
  421. e.data(h, "animating", !1);
  422. a.unbind("transitionend webkitTransitionEnd oTransitionEnd otransitionend MSTransitionEnd");
  423. a.children(":not(:eq(" + o + "))").css({
  424. display: "none",
  425. left: 0,
  426. zIndex: 0
  427. });
  428. h.data.touch && h._setuptouch();
  429. return h.options.callback.complete(o + 1)
  430. })
  431. }
  432. return a.stop().animate({
  433. left: i
  434. }, this.options.effect.slide.speed, function () {
  435. a.css({
  436. left: 0
  437. });
  438. a.children(":eq(" + o + ")").css({
  439. left: 0
  440. });
  441. return a.children(":eq(" + r + ")").css({
  442. display: "none",
  443. left: 0,
  444. zIndex: 0
  445. }, e.data(h, "current", o), e.data(h, "animating", !1), h.options.callback.complete(o + 1))
  446. })
  447. }
  448. };
  449. r.prototype._fade = function (t) {
  450. var n, r, i, s, o, u = this;
  451. n = e(this.element);
  452. this.data = e.data(this);
  453. if (!this.data.animating && t !== this.data.current + 1) {
  454. e.data(this, "animating", !0);
  455. r = this.data.current;
  456. if (t) {
  457. t -= 1;
  458. o = t > r ? 1 : -1;
  459. i = t
  460. } else {
  461. o = this.data.direction === "next" ? 1 : -1;
  462. i = r + o
  463. }
  464. i === -1 && (i = this.data.total - 1);
  465. i === this.data.total && (i = 0);
  466. this._setActive(i);
  467. s = e(".slidesjs-control", n);
  468. s.children(":eq(" + i + ")").css({
  469. display: "none",
  470. left: 0,
  471. zIndex: 10
  472. });
  473. this.options.callback.start(r + 1);
  474. if (this.options.effect.fade.crossfade) {
  475. s.children(":eq(" + this.data.current + ")").stop().fadeOut(this.options.effect.fade.speed);
  476. return s.children(":eq(" + i + ")").stop().fadeIn(this.options.effect.fade.speed, function () {
  477. s.children(":eq(" + i + ")").css({
  478. zIndex: 0
  479. });
  480. e.data(u, "animating", !1);
  481. e.data(u, "current", i);
  482. return u.options.callback.complete(i + 1)
  483. })
  484. }
  485. return s.children(":eq(" + r + ")").stop().fadeOut(this.options.effect.fade.speed, function () {
  486. s.children(":eq(" + i + ")").stop().fadeIn(u.options.effect.fade.speed, function () {
  487. return s.children(":eq(" + i + ")").css({
  488. zIndex: 10
  489. })
  490. });
  491. e.data(u, "animating", !1);
  492. e.data(u, "current", i);
  493. return u.options.callback.complete(i + 1)
  494. })
  495. }
  496. };
  497. r.prototype._getVendorPrefix = function () {
  498. var e, t, r, i, s;
  499. e = n.body || n.documentElement;
  500. r = e.style;
  501. i = "transition";
  502. s = ["Moz", "Webkit", "Khtml", "O", "ms"];
  503. i = i.charAt(0).toUpperCase() + i.substr(1);
  504. t = 0;
  505. while (t < s.length) {
  506. if (typeof r[s[t] + i] == "string") return s[t];
  507. t++
  508. }
  509. return !1
  510. };
  511. return e.fn[s] = function (t) {
  512. return this.each(function () {
  513. if (!e.data(this, "plugin_" + s)) return e.data(this, "plugin_" + s, new r(this, t))
  514. })
  515. }
  516. })(jQuery, window, document)
  517. }).call(this);