ss.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  1. /*!
  2. * SuperSlide v2.0
  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. effect: "fade",
  15. autoPlay: !1,
  16. delayTime: 500,
  17. interTime: 4000,
  18. triggerTime: 150,
  19. defaultIndex: 0,
  20. titCell: ".hd li",
  21. mainCell: ".bd",
  22. targetCell: null,
  23. trigger: "mouseover",
  24. scroll: 1,
  25. vis: 1,
  26. titOnClassName: "on",
  27. autoPage: !1,
  28. prevCell: ".prev",
  29. nextCell: ".next",
  30. pageStateCell: ".pageState",
  31. opp: !1,
  32. pnLoop: !0,
  33. easing: "linear",
  34. startFun: null,
  35. endFun: null,
  36. switchLoad: null
  37. }, this.each(function () {
  38. var c = a.extend({}, a.fn.slide.defaults, b),
  39. d = c.effect,
  40. e = a(c.prevCell, a(this)),
  41. f = a(c.nextCell, a(this)),
  42. g = a(c.pageStateCell, a(this)),
  43. h = a(c.titCell, a(this)),
  44. i = h.size(),
  45. j = a(c.mainCell, a(this)),
  46. k = j.children().size(),
  47. l = c.switchLoad;
  48. if (null != c.targetCell) var m = a(c.targetCell, a(this));
  49. var n = parseInt(c.defaultIndex),
  50. o = parseInt(c.delayTime),
  51. p = parseInt(c.interTime);
  52. parseInt(c.triggerTime);
  53. var r = parseInt(c.scroll),
  54. s = parseInt(c.vis),
  55. t = "false" == c.autoPlay || 0 == c.autoPlay ? !1 : !0,
  56. u = "false" == c.opp || 0 == c.opp ? !1 : !0,
  57. v = "false" == c.autoPage || 0 == c.autoPage ? !1 : !0,
  58. w = "false" == c.pnLoop || 0 == c.pnLoop ? !1 : !0,
  59. x = 0,
  60. y = 0,
  61. z = 0,
  62. A = 0,
  63. B = c.easing,
  64. C = null,
  65. D = n;
  66. if (0 == i && (i = k), v) {
  67. var E = k - s;
  68. i = 1 + parseInt(0 != E % r ? E / r + 1 : E / r), 0 >= i && (i = 1), h.html("");
  69. for (var F = 0; i > F; F++) h.append("<li>" + (F + 1) + "</li>");
  70. var h = a("li", h)
  71. }
  72. if (j.children().each(function () {
  73. a(this).width() > z && (z = a(this).width(), y = a(this).outerWidth(!0)), a(this).height() > A && (A = a(this).height(), x = a(this).outerHeight(!0))
  74. }), k >= s) switch (d) {
  75. case "fold":
  76. j.css({
  77. position: "relative",
  78. width: y,
  79. height: x
  80. }).children().css({
  81. position: "absolute",
  82. width: z,
  83. left: 0,
  84. top: 0,
  85. display: "none"
  86. });
  87. break;
  88. case "top":
  89. j.wrap('<div class="tempWrap" style="overflow:hidden; position:relative; height:' + s * x + 'px"></div>').css({
  90. position: "relative",
  91. padding: "0",
  92. margin: "0"
  93. }).children().css({
  94. height: A
  95. });
  96. break;
  97. case "left":
  98. j.wrap('<div class="tempWrap" style="overflow:hidden; position:relative; width:' + s * y + 'px"></div>').css({
  99. width: k * y,
  100. position: "relative",
  101. overflow: "hidden",
  102. padding: "0",
  103. margin: "0"
  104. }).children().css({
  105. "float": "left",
  106. width: z
  107. });
  108. break;
  109. case "leftLoop":
  110. case "leftMarquee":
  111. j.children().clone().appendTo(j).clone().prependTo(j), j.wrap('<div class="tempWrap" style="overflow:hidden; position:relative; width:' + s * y + 'px"></div>').css({
  112. width: 3 * k * y,
  113. position: "relative",
  114. overflow: "hidden",
  115. padding: "0",
  116. margin: "0",
  117. left: -k * y
  118. }).children().css({
  119. "float": "left",
  120. width: z
  121. });
  122. break;
  123. case "topLoop":
  124. case "topMarquee":
  125. j.children().clone().appendTo(j).clone().prependTo(j), j.wrap('<div class="tempWrap" style="overflow:hidden; position:relative; height:' + s * x + 'px"></div>').css({
  126. height: 3 * k * x,
  127. position: "relative",
  128. padding: "0",
  129. margin: "0",
  130. top: -k * x
  131. }).children().css({
  132. height: A
  133. })
  134. }
  135. var G = function () {
  136. a.isFunction(c.startFun) && c.startFun(n, i)
  137. },
  138. H = function () {
  139. a.isFunction(c.endFun) && c.endFun(n, i)
  140. },
  141. I = function (b) {
  142. b.eq(n).find("img").each(function () {
  143. a(this).attr(l) !== void 0 && a(this).attr("src", a(this).attr(l)).removeAttr(l)
  144. })
  145. },
  146. J = function (a) {
  147. if (D != n || a || "leftMarquee" == d || "topMarquee" == d) {
  148. switch (d) {
  149. case "fade":
  150. case "fold":
  151. case "top":
  152. case "left":
  153. n >= i ? n = 0 : 0 > n && (n = i - 1);
  154. break;
  155. case "leftMarquee":
  156. case "topMarquee":
  157. n >= 1 ? n = 1 : 0 >= n && (n = 0);
  158. break;
  159. case "leftLoop":
  160. case "topLoop":
  161. var b = n - D;
  162. i > 2 && b == -(i - 1) && (b = 1), i > 2 && b == i - 1 && (b = -1);
  163. var p = Math.abs(b * r);
  164. n >= i ? n = 0 : 0 > n && (n = i - 1)
  165. }
  166. if (G(), null != l && I(j.children()), m && (null != l && I(m), m.hide().eq(n).animate({
  167. opacity: "show"
  168. }, o, function () {
  169. j[0] || H()
  170. })), k >= s) switch (d) {
  171. case "fade":
  172. j.children().stop(!0, !0).eq(n).animate({
  173. opacity: "show"
  174. }, o, B, function () {
  175. H()
  176. }).siblings().hide();
  177. break;
  178. case "fold":
  179. j.children().stop(!0, !0).eq(n).animate({
  180. opacity: "show"
  181. }, o, B, function () {
  182. H()
  183. }).siblings().animate({
  184. opacity: "hide"
  185. }, o, B);
  186. break;
  187. case "top":
  188. j.stop(!0, !1).animate({
  189. top: -n * r * x
  190. }, o, B, function () {
  191. H()
  192. });
  193. break;
  194. case "left":
  195. j.stop(!0, !1).animate({
  196. left: -n * r * y
  197. }, o, B, function () {
  198. H()
  199. });
  200. break;
  201. case "leftLoop":
  202. 0 > b ? j.stop(!0, !0).animate({
  203. left: -(k - p) * y
  204. }, o, B, function () {
  205. for (var a = 0; p > a; a++) j.children().last().prependTo(j);
  206. j.css("left", -k * y), H()
  207. }) : j.stop(!0, !0).animate({
  208. left: -(k + p) * y
  209. }, o, B, function () {
  210. for (var a = 0; p > a; a++) j.children().first().appendTo(j);
  211. j.css("left", -k * y), H()
  212. });
  213. break;
  214. case "topLoop":
  215. 0 > b ? j.stop(!0, !0).animate({
  216. top: -(k - p) * x
  217. }, o, B, function () {
  218. for (var a = 0; p > a; a++) j.children().last().prependTo(j);
  219. j.css("top", -k * x), H()
  220. }) : j.stop(!0, !0).animate({
  221. top: -(k + p) * x
  222. }, o, B, function () {
  223. for (var a = 0; p > a; a++) j.children().first().appendTo(j);
  224. j.css("top", -k * x), H()
  225. });
  226. break;
  227. case "leftMarquee":
  228. var q = j.css("left").replace("px", "");
  229. 0 == n ? j.animate({
  230. left: ++q
  231. }, 0, function () {
  232. if (j.css("left").replace("px", "") >= 0) {
  233. for (var a = 0; k > a; a++) j.children().last().prependTo(j);
  234. j.css("left", -k * y)
  235. }
  236. }) : j.animate({
  237. left: --q
  238. }, 0, function () {
  239. if (2 * -k * y >= j.css("left").replace("px", "")) {
  240. for (var a = 0; k > a; a++) j.children().first().appendTo(j);
  241. j.css("left", -k * y)
  242. }
  243. });
  244. break;
  245. case "topMarquee":
  246. var t = j.css("top").replace("px", "");
  247. 0 == n ? j.animate({
  248. top: ++t
  249. }, 0, function () {
  250. if (j.css("top").replace("px", "") >= 0) {
  251. for (var a = 0; k > a; a++) j.children().last().prependTo(j);
  252. j.css("top", -k * x)
  253. }
  254. }) : j.animate({
  255. top: --t
  256. }, 0, function () {
  257. if (2 * -k * x >= j.css("top").replace("px", "")) {
  258. for (var a = 0; k > a; a++) j.children().first().appendTo(j);
  259. j.css("top", -k * x)
  260. }
  261. })
  262. }
  263. h.removeClass(c.titOnClassName).eq(n).addClass(c.titOnClassName), D = n, 0 == w && (f.removeClass("nextStop"), e.removeClass("prevStop"), 0 == n ? e.addClass("prevStop") : n == i - 1 && f.addClass("nextStop")), g.html("<span>" + (n + 1) + "</span>/" + i)
  264. }
  265. };
  266. J(!0), t && ("leftMarquee" == d || "topMarquee" == d ? (u ? n-- : n++, C = setInterval(J, p), j.hover(function () {
  267. t && clearInterval(C)
  268. }, function () {
  269. t && (clearInterval(C), C = setInterval(J, p))
  270. })) : (C = setInterval(function () {
  271. u ? n-- : n++, J()
  272. }, p), a(this).hover(function () {
  273. t && clearInterval(C)
  274. }, function () {
  275. t && (clearInterval(C), C = setInterval(function () {
  276. u ? n-- : n++, J()
  277. }, p))
  278. })));
  279. var K;
  280. "mouseover" == c.trigger ? h.hover(function () {
  281. n = h.index(this), K = window.setTimeout(J, c.triggerTime)
  282. }, function () {
  283. clearTimeout(K)
  284. }) : h.click(function () {
  285. n = h.index(this), J()
  286. }), f.click(function () {
  287. (1 == w || n != i - 1) && (n++, J())
  288. }), e.click(function () {
  289. (1 == w || 0 != n) && (n--, J())
  290. })
  291. })
  292. }
  293. })(jQuery), jQuery.easing.jswing = jQuery.easing.swing, jQuery.extend(jQuery.easing, {
  294. def: "easeOutQuad",
  295. swing: function (a, b, c, d, e) {
  296. return jQuery.easing[jQuery.easing.def](a, b, c, d, e)
  297. },
  298. easeInQuad: function (a, b, c, d, e) {
  299. return d * (b /= e) * b + c
  300. },
  301. easeOutQuad: function (a, b, c, d, e) {
  302. return -d * (b /= e) * (b - 2) + c
  303. },
  304. easeInOutQuad: function (a, b, c, d, e) {
  305. return 1 > (b /= e / 2) ? d / 2 * b * b + c : -d / 2 * (--b * (b - 2) - 1) + c
  306. },
  307. easeInCubic: function (a, b, c, d, e) {
  308. return d * (b /= e) * b * b + c
  309. },
  310. easeOutCubic: function (a, b, c, d, e) {
  311. return d * ((b = b / e - 1) * b * b + 1) + c
  312. },
  313. easeInOutCubic: function (a, b, c, d, e) {
  314. return 1 > (b /= e / 2) ? d / 2 * b * b * b + c : d / 2 * ((b -= 2) * b * b + 2) + c
  315. },
  316. easeInQuart: function (a, b, c, d, e) {
  317. return d * (b /= e) * b * b * b + c
  318. },
  319. easeOutQuart: function (a, b, c, d, e) {
  320. return -d * ((b = b / e - 1) * b * b * b - 1) + c
  321. },
  322. easeInOutQuart: function (a, b, c, d, e) {
  323. return 1 > (b /= e / 2) ? d / 2 * b * b * b * b + c : -d / 2 * ((b -= 2) * b * b * b - 2) + c
  324. },
  325. easeInQuint: function (a, b, c, d, e) {
  326. return d * (b /= e) * b * b * b * b + c
  327. },
  328. easeOutQuint: function (a, b, c, d, e) {
  329. return d * ((b = b / e - 1) * b * b * b * b + 1) + c
  330. },
  331. easeInOutQuint: function (a, b, c, d, e) {
  332. return 1 > (b /= e / 2) ? d / 2 * b * b * b * b * b + c : d / 2 * ((b -= 2) * b * b * b * b + 2) + c
  333. },
  334. easeInSine: function (a, b, c, d, e) {
  335. return -d * Math.cos(b / e * (Math.PI / 2)) + d + c
  336. },
  337. easeOutSine: function (a, b, c, d, e) {
  338. return d * Math.sin(b / e * (Math.PI / 2)) + c
  339. },
  340. easeInOutSine: function (a, b, c, d, e) {
  341. return -d / 2 * (Math.cos(Math.PI * b / e) - 1) + c
  342. },
  343. easeInExpo: function (a, b, c, d, e) {
  344. return 0 == b ? c : d * Math.pow(2, 10 * (b / e - 1)) + c
  345. },
  346. easeOutExpo: function (a, b, c, d, e) {
  347. return b == e ? c + d : d * (-Math.pow(2, -10 * b / e) + 1) + c
  348. },
  349. easeInOutExpo: function (a, b, c, d, e) {
  350. 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
  351. },
  352. easeInCirc: function (a, b, c, d, e) {
  353. return -d * (Math.sqrt(1 - (b /= e) * b) - 1) + c
  354. },
  355. easeOutCirc: function (a, b, c, d, e) {
  356. return d * Math.sqrt(1 - (b = b / e - 1) * b) + c
  357. },
  358. easeInOutCirc: function (a, b, c, d, e) {
  359. return 1 > (b /= e / 2) ? -d / 2 * (Math.sqrt(1 - b * b) - 1) + c : d / 2 * (Math.sqrt(1 - (b -= 2) * b) + 1) + c
  360. },
  361. easeInElastic: function (a, b, c, d, e) {
  362. var f = 1.70158,
  363. g = 0,
  364. h = d;
  365. if (0 == b) return c;
  366. if (1 == (b /= e)) return c + d;
  367. if (g || (g = .3 * e), Math.abs(d) > h) {
  368. h = d;
  369. var f = g / 4
  370. } else var f = g / (2 * Math.PI) * Math.asin(d / h);
  371. return -(h * Math.pow(2, 10 * (b -= 1)) * Math.sin((b * e - f) * 2 * Math.PI / g)) + c
  372. },
  373. easeOutElastic: function (a, b, c, d, e) {
  374. var f = 1.70158,
  375. g = 0,
  376. h = d;
  377. if (0 == b) return c;
  378. if (1 == (b /= e)) return c + d;
  379. if (g || (g = .3 * e), Math.abs(d) > h) {
  380. h = d;
  381. var f = g / 4
  382. } else var f = g / (2 * Math.PI) * Math.asin(d / h);
  383. return h * Math.pow(2, -10 * b) * Math.sin((b * e - f) * 2 * Math.PI / g) + d + c
  384. },
  385. easeInOutElastic: function (a, b, c, d, e) {
  386. var f = 1.70158,
  387. g = 0,
  388. h = d;
  389. if (0 == b) return c;
  390. if (2 == (b /= e / 2)) return c + d;
  391. if (g || (g = e * .3 * 1.5), Math.abs(d) > h) {
  392. h = d;
  393. var f = g / 4
  394. } else var f = g / (2 * Math.PI) * Math.asin(d / h);
  395. 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
  396. },
  397. easeInBack: function (a, b, c, d, e, f) {
  398. return void 0 == f && (f = 1.70158), d * (b /= e) * b * ((f + 1) * b - f) + c
  399. },
  400. easeOutBack: function (a, b, c, d, e, f) {
  401. return void 0 == f && (f = 1.70158), d * ((b = b / e - 1) * b * ((f + 1) * b + f) + 1) + c
  402. },
  403. easeInOutBack: function (a, b, c, d, e, f) {
  404. 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
  405. },
  406. easeInBounce: function (a, b, c, d, e) {
  407. return d - jQuery.easing.easeOutBounce(a, e - b, 0, d, e) + c
  408. },
  409. easeOutBounce: function (a, b, c, d, e) {
  410. 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
  411. },
  412. easeInOutBounce: function (a, b, c, d, e) {
  413. 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
  414. }
  415. });