jquery.SuperSlide.2.1.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515
  1. /*!
  2. * SuperSlide v2.1
  3. * 轻松解决网站大部分特效展示问题
  4. * 详尽信息请看官网:http://www.SuperSlide2.com/
  5. *
  6. * Copyright 2011-2013, 大话主席
  7. *
  8. * 请尊重原创,保留头部版权
  9. * 在保留版权的前提下可应用于个人或商业用途
  10. */
  11. (function(a) {
  12. a.fn.slide = function(b) {
  13. return a.fn.slide.defaults = {
  14. type: "slide",
  15. effect: "fade",
  16. autoPlay: !1,
  17. delayTime: 500,
  18. interTime: 2500,
  19. triggerTime: 150,
  20. defaultIndex: 0,
  21. titCell: ".hd li",
  22. mainCell: ".bd",
  23. targetCell: null,
  24. trigger: "mouseover",
  25. scroll: 1,
  26. vis: 1,
  27. titOnClassName: "on",
  28. autoPage: !1,
  29. prevCell: ".prev",
  30. nextCell: ".next",
  31. pageStateCell: ".pageState",
  32. opp: !1,
  33. pnLoop: !0,
  34. easing: "swing",
  35. startFun: null,
  36. endFun: null,
  37. switchLoad: null,
  38. playStateCell: ".playState",
  39. mouseOverStop: !0,
  40. defaultPlay: !0,
  41. returnDefault: !1
  42. }, this.each(function() {
  43. var c = a.extend({}, a.fn.slide.defaults, b),
  44. d = a(this),
  45. e = c.effect,
  46. f = a(c.prevCell, d),
  47. g = a(c.nextCell, d),
  48. h = a(c.pageStateCell, d),
  49. i = a(c.playStateCell, d),
  50. j = a(c.titCell, d),
  51. k = j.size(),
  52. l = a(c.mainCell, d),
  53. m = l.children().size(),
  54. n = c.switchLoad,
  55. o = a(c.targetCell, d),
  56. p = parseInt(c.defaultIndex),
  57. q = parseInt(c.delayTime),
  58. r = parseInt(c.interTime);
  59. parseInt(c.triggerTime);
  60. var P, t = parseInt(c.scroll),
  61. u = parseInt(c.vis),
  62. v = "false" == c.autoPlay || 0 == c.autoPlay ? !1 : !0,
  63. w = "false" == c.opp || 0 == c.opp ? !1 : !0,
  64. x = "false" == c.autoPage || 0 == c.autoPage ? !1 : !0,
  65. y = "false" == c.pnLoop || 0 == c.pnLoop ? !1 : !0,
  66. z = "false" == c.mouseOverStop || 0 == c.mouseOverStop ? !1 : !0,
  67. A = "false" == c.defaultPlay || 0 == c.defaultPlay ? !1 : !0,
  68. B = "false" == c.returnDefault || 0 == c.returnDefault ? !1 : !0,
  69. C = 0,
  70. D = 0,
  71. E = 0,
  72. F = 0,
  73. G = c.easing,
  74. H = null,
  75. I = null,
  76. J = null,
  77. K = c.titOnClassName,
  78. L = j.index(d.find("." + K)),
  79. M = p = defaultIndex = -1 == L ? p : L,
  80. N = p,
  81. O = m >= u ? 0 != m % t ? m % t : t : 0,
  82. Q = "leftMarquee" == e || "topMarquee" == e ? !0 : !1,
  83. R = function() {
  84. a.isFunction(c.startFun) && c.startFun(p, k, d, a(c.titCell, d), l, o, f, g)
  85. },
  86. S = function() {
  87. a.isFunction(c.endFun) && c.endFun(p, k, d, a(c.titCell, d), l, o, f, g)
  88. },
  89. T = function() {
  90. j.removeClass(K), A && j.eq(defaultIndex).addClass(K)
  91. };
  92. if ("menu" == c.type) return A && j.removeClass(K).eq(p).addClass(K), j.hover(function() {
  93. P = a(this).find(c.targetCell);
  94. var b = j.index(a(this));
  95. I = setTimeout(function() {
  96. switch (p = b, j.removeClass(K).eq(p).addClass(K), R(), e) {
  97. case "fade":
  98. P.stop(!0, !0).animate({
  99. opacity: "show"
  100. }, q, G, S);
  101. break;
  102. case "slideDown":
  103. P.stop(!0, !0).animate({
  104. height: "show"
  105. }, q, G, S)
  106. }
  107. }, c.triggerTime)
  108. }, function() {
  109. switch (clearTimeout(I), e) {
  110. case "fade":
  111. P.animate({
  112. opacity: "hide"
  113. }, q, G);
  114. break;
  115. case "slideDown":
  116. P.animate({
  117. height: "hide"
  118. }, q, G)
  119. }
  120. }), B && d.hover(function() {
  121. clearTimeout(J)
  122. }, function() {
  123. J = setTimeout(T, q)
  124. }), void 0;
  125. if (0 == k && (k = m), Q && (k = 2), x) {
  126. if (m >= u)
  127. if ("leftLoop" == e || "topLoop" == e) k = 0 != m % t ? (0 ^ m / t) + 1 : m / t;
  128. else {
  129. var U = m - u;
  130. k = 1 + parseInt(0 != U % t ? U / t + 1 : U / t), 0 >= k && (k = 1)
  131. } else k = 1;
  132. j.html("");
  133. var V = "";
  134. if (1 == c.autoPage || "true" == c.autoPage)
  135. for (var W = 0; k > W; W++) V += "<li>" + (W + 1) + "</li>";
  136. else
  137. for (var W = 0; k > W; W++) V += c.autoPage.replace("$", W + 1);
  138. j.html(V);
  139. var j = j.children()
  140. }
  141. if (m >= u) {
  142. l.children().each(function() {
  143. a(this).width() > E && (E = a(this).width(), D = a(this).outerWidth(!0)), a(this).height() > F && (F = a(this).height(), C = a(this).outerHeight(!0))
  144. });
  145. var X = l.children(),
  146. Y = function() {
  147. for (var a = 0; u > a; a++) X.eq(a).clone().addClass("clone").appendTo(l);
  148. for (var a = 0; O > a; a++) X.eq(m - a - 1).clone().addClass("clone").prependTo(l)
  149. };
  150. switch (e) {
  151. case "fold":
  152. l.css({
  153. position: "relative",
  154. width: D,
  155. height: C
  156. }).children().css({
  157. position: "absolute",
  158. width: E,
  159. left: 0,
  160. top: 0,
  161. display: "none"
  162. });
  163. break;
  164. case "top":
  165. l.wrap('<div class="tempWrap" style="overflow:hidden; position:relative; height:' + u * C + 'px"></div>').css({
  166. top: -(p * t) * C,
  167. position: "relative",
  168. padding: "0",
  169. margin: "0"
  170. }).children().css({
  171. height: F
  172. });
  173. break;
  174. case "left":
  175. l.wrap('<div class="tempWrap" style="overflow:hidden; position:relative; width:' + u * D + 'px"></div>').css({
  176. width: m * D,
  177. left: -(p * t) * D,
  178. position: "relative",
  179. overflow: "hidden",
  180. padding: "0",
  181. margin: "0"
  182. }).children().css({
  183. "float": "left",
  184. width: E
  185. });
  186. break;
  187. case "leftLoop":
  188. case "leftMarquee":
  189. Y(), l.wrap('<div class="tempWrap" style="overflow:hidden; position:relative; width:' + u * D + 'px"></div>').css({
  190. width: (m + u + O) * D,
  191. position: "relative",
  192. overflow: "hidden",
  193. padding: "0",
  194. margin: "0",
  195. left: -(O + p * t) * D
  196. }).children().css({
  197. "float": "left",
  198. width: E
  199. });
  200. break;
  201. case "topLoop":
  202. case "topMarquee":
  203. Y(), l.wrap('<div class="tempWrap" style="overflow:hidden; position:relative; height:' + u * C + 'px"></div>').css({
  204. height: (m + u + O) * C,
  205. position: "relative",
  206. padding: "0",
  207. margin: "0",
  208. top: -(O + p * t) * C
  209. }).children().css({
  210. height: F
  211. })
  212. }
  213. }
  214. var Z = function(a) {
  215. var b = a * t;
  216. return a == k ? b = m : -1 == a && 0 != m % t && (b = -m % t), b
  217. },
  218. $ = function(b) {
  219. var c = function(c) {
  220. for (var d = c; u + c > d; d++) b.eq(d).find("img[" + n + "]").each(function() {
  221. var b = a(this);
  222. if (b.attr("src", b.attr(n)).removeAttr(n), l.find(".clone")[0])
  223. for (var c = l.children(), d = 0; c.size() > d; d++) c.eq(d).find("img[" + n + "]").each(function() {
  224. a(this).attr(n) == b.attr("src") && a(this).attr("src", a(this).attr(n)).removeAttr(n)
  225. })
  226. })
  227. };
  228. switch (e) {
  229. case "fade":
  230. case "fold":
  231. case "top":
  232. case "left":
  233. case "slideDown":
  234. c(p * t);
  235. break;
  236. case "leftLoop":
  237. case "topLoop":
  238. c(O + Z(N));
  239. break;
  240. case "leftMarquee":
  241. case "topMarquee":
  242. var d = "leftMarquee" == e ? l.css("left").replace("px", "") : l.css("top").replace("px", ""),
  243. f = "leftMarquee" == e ? D : C,
  244. g = O;
  245. if (0 != d % f) {
  246. var h = Math.abs(0 ^ d / f);
  247. g = 1 == p ? O + h : O + h - 1
  248. }
  249. c(g)
  250. }
  251. },
  252. _ = function(a) {
  253. if (!A || M != p || a || Q) {
  254. if (Q ? p >= 1 ? p = 1 : 0 >= p && (p = 0) : (N = p, p >= k ? p = 0 : 0 > p && (p = k - 1)), R(), null != n && $(l.children()), o[0] && (P = o.eq(p), null != n && $(o), "slideDown" == e ? (o.not(P).stop(!0, !0).slideUp(q), P.slideDown(q, G, function() {
  255. l[0] || S()
  256. })) : (o.not(P).stop(!0, !0).hide(), P.animate({
  257. opacity: "show"
  258. }, q, function() {
  259. l[0] || S()
  260. }))), m >= u) switch (e) {
  261. case "fade":
  262. l.children().stop(!0, !0).eq(p).animate({
  263. opacity: "show"
  264. }, q, G, function() {
  265. S()
  266. }).siblings().hide();
  267. break;
  268. case "fold":
  269. l.children().stop(!0, !0).eq(p).animate({
  270. opacity: "show"
  271. }, q, G, function() {
  272. S()
  273. }).siblings().animate({
  274. opacity: "hide"
  275. }, q, G);
  276. break;
  277. case "top":
  278. l.stop(!0, !1).animate({
  279. top: -p * t * C
  280. }, q, G, function() {
  281. S()
  282. });
  283. break;
  284. case "left":
  285. l.stop(!0, !1).animate({
  286. left: -p * t * D
  287. }, q, G, function() {
  288. S()
  289. });
  290. break;
  291. case "leftLoop":
  292. var b = N;
  293. l.stop(!0, !0).animate({
  294. left: -(Z(N) + O) * D
  295. }, q, G, function() {
  296. -1 >= b ? l.css("left", -(O + (k - 1) * t) * D) : b >= k && l.css("left", -O * D), S()
  297. });
  298. break;
  299. case "topLoop":
  300. var b = N;
  301. l.stop(!0, !0).animate({
  302. top: -(Z(N) + O) * C
  303. }, q, G, function() {
  304. -1 >= b ? l.css("top", -(O + (k - 1) * t) * C) : b >= k && l.css("top", -O * C), S()
  305. });
  306. break;
  307. case "leftMarquee":
  308. var c = l.css("left").replace("px", "");
  309. 0 == p ? l.animate({
  310. left: ++c
  311. }, 0, function() {
  312. l.css("left").replace("px", "") >= 0 && l.css("left", -m * D)
  313. }) : l.animate({
  314. left: --c
  315. }, 0, function() {
  316. -(m + O) * D >= l.css("left").replace("px", "") && l.css("left", -O * D)
  317. });
  318. break;
  319. case "topMarquee":
  320. var d = l.css("top").replace("px", "");
  321. 0 == p ? l.animate({
  322. top: ++d
  323. }, 0, function() {
  324. l.css("top").replace("px", "") >= 0 && l.css("top", -m * C)
  325. }) : l.animate({
  326. top: --d
  327. }, 0, function() {
  328. -(m + O) * C >= l.css("top").replace("px", "") && l.css("top", -O * C)
  329. })
  330. }
  331. j.removeClass(K).eq(p).addClass(K), M = p, y || (g.removeClass("nextStop"), f.removeClass("prevStop"), 0 == p && f.addClass("prevStop"), p == k - 1 && g.addClass("nextStop")), h.html("<span>" + (p + 1) + "</span>/" + k)
  332. }
  333. };
  334. A && _(!0), B && d.hover(function() {
  335. clearTimeout(J)
  336. }, function() {
  337. J = setTimeout(function() {
  338. p = defaultIndex, A ? _() : "slideDown" == e ? P.slideUp(q, T) : P.animate({
  339. opacity: "hide"
  340. }, q, T), M = p
  341. }, 300)
  342. });
  343. var ab = function(a) {
  344. H = setInterval(function() {
  345. w ? p-- : p++, _()
  346. }, a ? a : r)
  347. },
  348. bb = function(a) {
  349. H = setInterval(_, a ? a : r)
  350. },
  351. cb = function() {
  352. z || (clearInterval(H), ab())
  353. },
  354. db = function() {
  355. (y || p != k - 1) && (p++, _(), Q || cb())
  356. },
  357. eb = function() {
  358. (y || 0 != p) && (p--, _(), Q || cb())
  359. },
  360. fb = function() {
  361. clearInterval(H), Q ? bb() : ab(), i.removeClass("pauseState")
  362. },
  363. gb = function() {
  364. clearInterval(H), i.addClass("pauseState")
  365. };
  366. if (v ? Q ? (w ? p-- : p++, bb(), z && l.hover(gb, fb)) : (ab(), z && d.hover(gb, fb)) : (Q && (w ? p-- : p++), i.addClass("pauseState")), i.click(function() {
  367. i.hasClass("pauseState") ? fb() : gb()
  368. }), "mouseover" == c.trigger ? j.hover(function() {
  369. var a = j.index(this);
  370. I = setTimeout(function() {
  371. p = a, _(), cb()
  372. }, c.triggerTime)
  373. }, function() {
  374. clearTimeout(I)
  375. }) : j.click(function() {
  376. p = j.index(this), _(), cb()
  377. }), Q) {
  378. if (g.mousedown(db), f.mousedown(eb), y) {
  379. var hb, ib = function() {
  380. hb = setTimeout(function() {
  381. clearInterval(H), bb(0 ^ r / 10)
  382. }, 150)
  383. },
  384. jb = function() {
  385. clearTimeout(hb), clearInterval(H), bb()
  386. };
  387. g.mousedown(ib), g.mouseup(jb), f.mousedown(ib), f.mouseup(jb)
  388. }
  389. "mouseover" == c.trigger && (g.hover(db, function() {}), f.hover(eb, function() {}))
  390. } else g.click(db), f.click(eb)
  391. })
  392. }
  393. })(jQuery), jQuery.easing.jswing = jQuery.easing.swing, jQuery.extend(jQuery.easing, {
  394. def: "easeOutQuad",
  395. swing: function(a, b, c, d, e) {
  396. return jQuery.easing[jQuery.easing.def](a, b, c, d, e)
  397. },
  398. easeInQuad: function(a, b, c, d, e) {
  399. return d * (b /= e) * b + c
  400. },
  401. easeOutQuad: function(a, b, c, d, e) {
  402. return -d * (b /= e) * (b - 2) + c
  403. },
  404. easeInOutQuad: function(a, b, c, d, e) {
  405. return 1 > (b /= e / 2) ? d / 2 * b * b + c : -d / 2 * (--b * (b - 2) - 1) + c
  406. },
  407. easeInCubic: function(a, b, c, d, e) {
  408. return d * (b /= e) * b * b + c
  409. },
  410. easeOutCubic: function(a, b, c, d, e) {
  411. return d * ((b = b / e - 1) * b * b + 1) + c
  412. },
  413. easeInOutCubic: function(a, b, c, d, e) {
  414. return 1 > (b /= e / 2) ? d / 2 * b * b * b + c : d / 2 * ((b -= 2) * b * b + 2) + c
  415. },
  416. easeInQuart: function(a, b, c, d, e) {
  417. return d * (b /= e) * b * b * b + c
  418. },
  419. easeOutQuart: function(a, b, c, d, e) {
  420. return -d * ((b = b / e - 1) * b * b * b - 1) + c
  421. },
  422. easeInOutQuart: function(a, b, c, d, e) {
  423. return 1 > (b /= e / 2) ? d / 2 * b * b * b * b + c : -d / 2 * ((b -= 2) * b * b * b - 2) + c
  424. },
  425. easeInQuint: function(a, b, c, d, e) {
  426. return d * (b /= e) * b * b * b * b + c
  427. },
  428. easeOutQuint: function(a, b, c, d, e) {
  429. return d * ((b = b / e - 1) * b * b * b * b + 1) + c
  430. },
  431. easeInOutQuint: function(a, b, c, d, e) {
  432. return 1 > (b /= e / 2) ? d / 2 * b * b * b * b * b + c : d / 2 * ((b -= 2) * b * b * b * b + 2) + c
  433. },
  434. easeInSine: function(a, b, c, d, e) {
  435. return -d * Math.cos(b / e * (Math.PI / 2)) + d + c
  436. },
  437. easeOutSine: function(a, b, c, d, e) {
  438. return d * Math.sin(b / e * (Math.PI / 2)) + c
  439. },
  440. easeInOutSine: function(a, b, c, d, e) {
  441. return -d / 2 * (Math.cos(Math.PI * b / e) - 1) + c
  442. },
  443. easeInExpo: function(a, b, c, d, e) {
  444. return 0 == b ? c : d * Math.pow(2, 10 * (b / e - 1)) + c
  445. },
  446. easeOutExpo: function(a, b, c, d, e) {
  447. return b == e ? c + d : d * (-Math.pow(2, -10 * b / e) + 1) + c
  448. },
  449. easeInOutExpo: function(a, b, c, d, e) {
  450. return 0 == b ? c : b == e ? c + d : 1 > (b /= e / 2) ? d / 2 * Math.pow(2, 10 * (b - 1)) + c : d / 2 * (-Math.pow(2, -10 * --b) + 2) + c
  451. },
  452. easeInCirc: function(a, b, c, d, e) {
  453. return -d * (Math.sqrt(1 - (b /= e) * b) - 1) + c
  454. },
  455. easeOutCirc: function(a, b, c, d, e) {
  456. return d * Math.sqrt(1 - (b = b / e - 1) * b) + c
  457. },
  458. easeInOutCirc: function(a, b, c, d, e) {
  459. return 1 > (b /= e / 2) ? -d / 2 * (Math.sqrt(1 - b * b) - 1) + c : d / 2 * (Math.sqrt(1 - (b -= 2) * b) + 1) + c
  460. },
  461. easeInElastic: function(a, b, c, d, e) {
  462. var f = 1.70158,
  463. g = 0,
  464. h = d;
  465. if (0 == b) return c;
  466. if (1 == (b /= e)) return c + d;
  467. if (g || (g = .3 * e), Math.abs(d) > h) {
  468. h = d;
  469. var f = g / 4
  470. } else var f = g / (2 * Math.PI) * Math.asin(d / h);
  471. return -(h * Math.pow(2, 10 * (b -= 1)) * Math.sin((b * e - f) * 2 * Math.PI / g)) + c
  472. },
  473. easeOutElastic: function(a, b, c, d, e) {
  474. var f = 1.70158,
  475. g = 0,
  476. h = d;
  477. if (0 == b) return c;
  478. if (1 == (b /= e)) return c + d;
  479. if (g || (g = .3 * e), Math.abs(d) > h) {
  480. h = d;
  481. var f = g / 4
  482. } else var f = g / (2 * Math.PI) * Math.asin(d / h);
  483. return h * Math.pow(2, -10 * b) * Math.sin((b * e - f) * 2 * Math.PI / g) + d + c
  484. },
  485. easeInOutElastic: function(a, b, c, d, e) {
  486. var f = 1.70158,
  487. g = 0,
  488. h = d;
  489. if (0 == b) return c;
  490. if (2 == (b /= e / 2)) return c + d;
  491. if (g || (g = e * .3 * 1.5), Math.abs(d) > h) {
  492. h = d;
  493. var f = g / 4
  494. } else var f = g / (2 * Math.PI) * Math.asin(d / h);
  495. return 1 > b ? -.5 * h * Math.pow(2, 10 * (b -= 1)) * Math.sin((b * e - f) * 2 * Math.PI / g) + c : .5 * h * Math.pow(2, -10 * (b -= 1)) * Math.sin((b * e - f) * 2 * Math.PI / g) + d + c
  496. },
  497. easeInBack: function(a, b, c, d, e, f) {
  498. return void 0 == f && (f = 1.70158), d * (b /= e) * b * ((f + 1) * b - f) + c
  499. },
  500. easeOutBack: function(a, b, c, d, e, f) {
  501. return void 0 == f && (f = 1.70158), d * ((b = b / e - 1) * b * ((f + 1) * b + f) + 1) + c
  502. },
  503. easeInOutBack: function(a, b, c, d, e, f) {
  504. return void 0 == f && (f = 1.70158), 1 > (b /= e / 2) ? d / 2 * b * b * (((f *= 1.525) + 1) * b - f) + c : d / 2 * ((b -= 2) * b * (((f *= 1.525) + 1) * b + f) + 2) + c
  505. },
  506. easeInBounce: function(a, b, c, d, e) {
  507. return d - jQuery.easing.easeOutBounce(a, e - b, 0, d, e) + c
  508. },
  509. easeOutBounce: function(a, b, c, d, e) {
  510. return 1 / 2.75 > (b /= e) ? d * 7.5625 * b * b + c : 2 / 2.75 > b ? d * (7.5625 * (b -= 1.5 / 2.75) * b + .75) + c : 2.5 / 2.75 > b ? d * (7.5625 * (b -= 2.25 / 2.75) * b + .9375) + c : d * (7.5625 * (b -= 2.625 / 2.75) * b + .984375) + c
  511. },
  512. easeInOutBounce: function(a, b, c, d, e) {
  513. return e / 2 > b ? .5 * jQuery.easing.easeInBounce(a, 2 * b, 0, d, e) + c : .5 * jQuery.easing.easeOutBounce(a, 2 * b - e, 0, d, e) + .5 * d + c
  514. }
  515. });