jquery.mCustomScrollbar.min.js 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515
  1. (function(c) {
  2. var b = { init: function(e) {
  3. var f = { set_width: false, set_height: false, horizontalScroll: false, scrollInertia: 950, mouseWheel: true, mouseWheelPixels: "auto", autoDraggerLength: true, autoHideScrollbar: false, snapAmount: null, snapOffset: 0, scrollButtons: { enable: false, scrollType: "continuous", scrollSpeed: "auto", scrollAmount: 40 }, advanced: { updateOnBrowserResize: true, updateOnContentResize: false, autoExpandHorizontalScroll: false, autoScrollOnFocus: true, normalizeMouseWheelDelta: false }, contentTouchScroll: true, callbacks: { onScrollStart: function() {}, onScroll: function() {}, onTotalScroll: function() {}, onTotalScrollBack: function() {}, onTotalScrollOffset: 0, onTotalScrollBackOffset: 0, whileScrolling: function() {} }, theme: "light" },
  4. e = c.extend(true, f, e);
  5. return this.each(function() {
  6. var m = c(this);
  7. if (e.set_width) { m.css("width", e.set_width) }
  8. if (e.set_height) { m.css("height", e.set_height) }
  9. if (!c(document).data("mCustomScrollbar-index")) { c(document).data("mCustomScrollbar-index", "1") } else {
  10. var t = parseInt(c(document).data("mCustomScrollbar-index"));
  11. c(document).data("mCustomScrollbar-index", t + 1) }
  12. m.wrapInner("<div class='mCustomScrollBox mCS-" + e.theme + "' id='mCSB_" + c(document).data("mCustomScrollbar-index") + "' style='position:relative; height:100%; overflow:hidden; max-width:100%;' />").addClass("mCustomScrollbar _mCS_" + c(document).data("mCustomScrollbar-index"));
  13. var g = m.children(".mCustomScrollBox");
  14. if (e.horizontalScroll) { g.addClass("mCSB_horizontal").wrapInner("<div class='mCSB_h_wrapper' style='position:relative; left:0; width:999999px;' />");
  15. var k = g.children(".mCSB_h_wrapper");
  16. k.wrapInner("<div class='mCSB_container' style='position:absolute; left:0;' />").children(".mCSB_container").css({ width: k.children().outerWidth(), position: "relative" }).unwrap() } else { g.wrapInner("<div class='mCSB_container' style='position:relative; top:0;' />") }
  17. var o = g.children(".mCSB_container");
  18. if (c.support.touch) { o.addClass("mCS_touch") }
  19. o.after("<div class='mCSB_scrollTools' style='position:absolute;'><div class='mCSB_draggerContainer'><div class='mCSB_dragger' style='position:absolute;' oncontextmenu='return false;'><div class='mCSB_dragger_bar' style='position:relative;'></div></div><div class='mCSB_draggerRail'></div></div></div>");
  20. var l = g.children(".mCSB_scrollTools"),
  21. h = l.children(".mCSB_draggerContainer"),
  22. q = h.children(".mCSB_dragger");
  23. if (e.horizontalScroll) { q.data("minDraggerWidth", q.width()) } else { q.data("minDraggerHeight", q.height()) }
  24. if (e.scrollButtons.enable) {
  25. if (e.horizontalScroll) { l.prepend("<a class='mCSB_buttonLeft' oncontextmenu='return false;'></a>").append("<a class='mCSB_buttonRight' oncontextmenu='return false;'></a>") } else { l.prepend("<a class='mCSB_buttonUp' oncontextmenu='return false;'></a>").append("<a class='mCSB_buttonDown' oncontextmenu='return false;'></a>") } }
  26. g.bind("scroll", function() {
  27. if (!m.is(".mCS_disabled")) { g.scrollTop(0).scrollLeft(0) } });
  28. m.data({ mCS_Init: true, mCustomScrollbarIndex: c(document).data("mCustomScrollbar-index"), horizontalScroll: e.horizontalScroll, scrollInertia: e.scrollInertia, scrollEasing: "mcsEaseOut", mouseWheel: e.mouseWheel, mouseWheelPixels: e.mouseWheelPixels, autoDraggerLength: e.autoDraggerLength, autoHideScrollbar: e.autoHideScrollbar, snapAmount: e.snapAmount, snapOffset: e.snapOffset, scrollButtons_enable: e.scrollButtons.enable, scrollButtons_scrollType: e.scrollButtons.scrollType, scrollButtons_scrollSpeed: e.scrollButtons.scrollSpeed, scrollButtons_scrollAmount: e.scrollButtons.scrollAmount, autoExpandHorizontalScroll: e.advanced.autoExpandHorizontalScroll, autoScrollOnFocus: e.advanced.autoScrollOnFocus, normalizeMouseWheelDelta: e.advanced.normalizeMouseWheelDelta, contentTouchScroll: e.contentTouchScroll, onScrollStart_Callback: e.callbacks.onScrollStart, onScroll_Callback: e.callbacks.onScroll, onTotalScroll_Callback: e.callbacks.onTotalScroll, onTotalScrollBack_Callback: e.callbacks.onTotalScrollBack, onTotalScroll_Offset: e.callbacks.onTotalScrollOffset, onTotalScrollBack_Offset: e.callbacks.onTotalScrollBackOffset, whileScrolling_Callback: e.callbacks.whileScrolling, bindEvent_scrollbar_drag: false, bindEvent_content_touch: false, bindEvent_scrollbar_click: false, bindEvent_mousewheel: false, bindEvent_buttonsContinuous_y: false, bindEvent_buttonsContinuous_x: false, bindEvent_buttonsPixels_y: false, bindEvent_buttonsPixels_x: false, bindEvent_focusin: false, bindEvent_autoHideScrollbar: false, mCSB_buttonScrollRight: false, mCSB_buttonScrollLeft: false, mCSB_buttonScrollDown: false, mCSB_buttonScrollUp: false });
  29. if (e.horizontalScroll) {
  30. if (m.css("max-width") !== "none") {
  31. if (!e.advanced.updateOnContentResize) { e.advanced.updateOnContentResize = true } } } else {
  32. if (m.css("max-height") !== "none") {
  33. var s = false,
  34. r = parseInt(m.css("max-height"));
  35. if (m.css("max-height").indexOf("%") >= 0) { s = r, r = m.parent().height() * s / 100 }
  36. m.css("overflow", "hidden");
  37. g.css("max-height", r) } }
  38. m.mCustomScrollbar("update");
  39. if (e.advanced.updateOnBrowserResize) {
  40. var i, j = c(window).width(),
  41. u = c(window).height();
  42. c(window).bind("resize." + m.data("mCustomScrollbarIndex"), function() {
  43. if (i) { clearTimeout(i) }
  44. i = setTimeout(function() {
  45. if (!m.is(".mCS_disabled") && !m.is(".mCS_destroyed")) {
  46. var w = c(window).width(),
  47. v = c(window).height();
  48. if (j !== w || u !== v) {
  49. if (m.css("max-height") !== "none" && s) { g.css("max-height", m.parent().height() * s / 100) }
  50. m.mCustomScrollbar("update");
  51. j = w;
  52. u = v } } }, 150) }) }
  53. if (e.advanced.updateOnContentResize) {
  54. var p;
  55. if (e.horizontalScroll) {
  56. var n = o.outerWidth() } else {
  57. var n = o.outerHeight() }
  58. p = setInterval(function() {
  59. if (e.horizontalScroll) {
  60. if (e.advanced.autoExpandHorizontalScroll) { o.css({ position: "absolute", width: "auto" }).wrap("<div class='mCSB_h_wrapper' style='position:relative; left:0; width:999999px;' />").css({ width: o.outerWidth(), position: "relative" }).unwrap() }
  61. var v = o.outerWidth() } else {
  62. var v = o.outerHeight() }
  63. if (v != n) { m.mCustomScrollbar("update");
  64. n = v } }, 300) } }) }, update: function() {
  65. var n = c(this),
  66. k = n.children(".mCustomScrollBox"),
  67. q = k.children(".mCSB_container");
  68. q.removeClass("mCS_no_scrollbar");
  69. n.removeClass("mCS_disabled mCS_destroyed");
  70. k.scrollTop(0).scrollLeft(0);
  71. var y = k.children(".mCSB_scrollTools"),
  72. o = y.children(".mCSB_draggerContainer"),
  73. m = o.children(".mCSB_dragger");
  74. if (n.data("horizontalScroll")) {
  75. var A = y.children(".mCSB_buttonLeft"),
  76. t = y.children(".mCSB_buttonRight"),
  77. f = k.width();
  78. if (n.data("autoExpandHorizontalScroll")) { q.css({ position: "absolute", width: "auto" }).wrap("<div class='mCSB_h_wrapper' style='position:relative; left:0; width:999999px;' />").css({ width: q.outerWidth(), position: "relative" }).unwrap() }
  79. var z = q.outerWidth() } else {
  80. var w = y.children(".mCSB_buttonUp"),
  81. g = y.children(".mCSB_buttonDown"),
  82. r = k.height(),
  83. i = q.outerHeight() }
  84. if (i > r && !n.data("horizontalScroll")) { y.css("display", "block");
  85. var s = o.height();
  86. if (n.data("autoDraggerLength")) {
  87. var u = Math.round(r / i * s),
  88. l = m.data("minDraggerHeight");
  89. if (u <= l) { m.css({ height: l }) } else {
  90. if (u >= s - 10) {
  91. var p = s - 10;
  92. m.css({ height: p }) } else { m.css({ height: u }) } }
  93. m.children(".mCSB_dragger_bar").css({ "line-height": m.height() + "px" }) }
  94. var B = m.height(),
  95. x = (i - r) / (s - B);
  96. n.data("scrollAmount", x).mCustomScrollbar("scrolling", k, q, o, m, w, g, A, t);
  97. var D = Math.abs(q.position().top);
  98. n.mCustomScrollbar("scrollTo", D, { scrollInertia: 0, trigger: "internal" }) } else {
  99. if (z > f && n.data("horizontalScroll")) { y.css("display", "block");
  100. var h = o.width();
  101. if (n.data("autoDraggerLength")) {
  102. var j = Math.round(f / z * h),
  103. C = m.data("minDraggerWidth");
  104. if (j <= C) { m.css({ width: C }) } else {
  105. if (j >= h - 10) {
  106. var e = h - 10;
  107. m.css({ width: e }) } else { m.css({ width: j }) } } }
  108. var v = m.width(),
  109. x = (z - f) / (h - v);
  110. n.data("scrollAmount", x).mCustomScrollbar("scrolling", k, q, o, m, w, g, A, t);
  111. var D = Math.abs(q.position().left);
  112. n.mCustomScrollbar("scrollTo", D, { scrollInertia: 0, trigger: "internal" }) } else { k.unbind("mousewheel focusin");
  113. if (n.data("horizontalScroll")) { m.add(q).css("left", 0) } else { m.add(q).css("top", 0) }
  114. y.css("display", "none");
  115. q.addClass("mCS_no_scrollbar");
  116. n.data({ bindEvent_mousewheel: false, bindEvent_focusin: false }) } } }, scrolling: function(h, p, m, j, w, e, A, v) {
  117. var k = c(this);
  118. if (!k.data("bindEvent_scrollbar_drag")) {
  119. var n, o;
  120. if (c.support.msPointer) { j.bind("MSPointerDown", function(H) { H.preventDefault();
  121. k.data({ on_drag: true });
  122. j.addClass("mCSB_dragger_onDrag");
  123. var G = c(this),
  124. J = G.offset(),
  125. F = H.originalEvent.pageX - J.left,
  126. I = H.originalEvent.pageY - J.top;
  127. if (F < G.width() && F > 0 && I < G.height() && I > 0) { n = I;
  128. o = F } });
  129. c(document).bind("MSPointerMove." + k.data("mCustomScrollbarIndex"), function(H) { H.preventDefault();
  130. if (k.data("on_drag")) {
  131. var G = j,
  132. J = G.offset(),
  133. F = H.originalEvent.pageX - J.left,
  134. I = H.originalEvent.pageY - J.top;
  135. D(n, o, I, F) } }).bind("MSPointerUp." + k.data("mCustomScrollbarIndex"), function(x) { k.data({ on_drag: false });
  136. j.removeClass("mCSB_dragger_onDrag") }) } else { j.bind("mousedown touchstart", function(H) { H.preventDefault();
  137. H.stopImmediatePropagation();
  138. var G = c(this),
  139. K = G.offset(),
  140. F, J;
  141. if (H.type === "touchstart") {
  142. var I = H.originalEvent.touches[0] || H.originalEvent.changedTouches[0];
  143. F = I.pageX - K.left;
  144. J = I.pageY - K.top } else { k.data({ on_drag: true });
  145. j.addClass("mCSB_dragger_onDrag");
  146. F = H.pageX - K.left;
  147. J = H.pageY - K.top }
  148. if (F < G.width() && F > 0 && J < G.height() && J > 0) { n = J;
  149. o = F } }).bind("touchmove", function(H) { H.preventDefault();
  150. H.stopImmediatePropagation();
  151. var K = H.originalEvent.touches[0] || H.originalEvent.changedTouches[0],
  152. G = c(this),
  153. J = G.offset(),
  154. F = K.pageX - J.left,
  155. I = K.pageY - J.top;
  156. D(n, o, I, F) });
  157. c(document).bind("mousemove." + k.data("mCustomScrollbarIndex"), function(H) {
  158. if (k.data("on_drag")) {
  159. var G = j,
  160. J = G.offset(),
  161. F = H.pageX - J.left,
  162. I = H.pageY - J.top;
  163. D(n, o, I, F) } }).bind("mouseup." + k.data("mCustomScrollbarIndex"), function(x) { k.data({ on_drag: false });
  164. j.removeClass("mCSB_dragger_onDrag") }) }
  165. k.data({ bindEvent_scrollbar_drag: true }) }
  166. function D(G, H, I, F) {
  167. if (k.data("horizontalScroll")) { k.mCustomScrollbar("scrollTo", (j.position().left - (H)) + F, { moveDragger: true, trigger: "internal" }) } else { k.mCustomScrollbar("scrollTo", (j.position().top - (G)) + I, { moveDragger: true, trigger: "internal" }) } }
  168. if (c.support.touch && k.data("contentTouchScroll")) {
  169. if (!k.data("bindEvent_content_touch")) {
  170. var l, B, r, s, u, C, E;
  171. p.bind("touchstart", function(x) { x.stopImmediatePropagation();
  172. l = x.originalEvent.touches[0] || x.originalEvent.changedTouches[0];
  173. B = c(this);
  174. r = B.offset();
  175. u = l.pageX - r.left;
  176. s = l.pageY - r.top;
  177. C = s;
  178. E = u });
  179. p.bind("touchmove", function(x) { x.preventDefault();
  180. x.stopImmediatePropagation();
  181. l = x.originalEvent.touches[0] || x.originalEvent.changedTouches[0];
  182. B = c(this).parent();
  183. r = B.offset();
  184. u = l.pageX - r.left;
  185. s = l.pageY - r.top;
  186. if (k.data("horizontalScroll")) { k.mCustomScrollbar("scrollTo", E - u, { trigger: "internal" }) } else { k.mCustomScrollbar("scrollTo", C - s, { trigger: "internal" }) } }) } }
  187. if (!k.data("bindEvent_scrollbar_click")) { m.bind("click", function(F) {
  188. var x = (F.pageY - m.offset().top) * k.data("scrollAmount"),
  189. y = c(F.target);
  190. if (k.data("horizontalScroll")) { x = (F.pageX - m.offset().left) * k.data("scrollAmount") }
  191. if (y.hasClass("mCSB_draggerContainer") || y.hasClass("mCSB_draggerRail")) { k.mCustomScrollbar("scrollTo", x, { trigger: "internal", scrollEasing: "draggerRailEase" }) } });
  192. k.data({ bindEvent_scrollbar_click: true }) }
  193. if (k.data("mouseWheel")) {
  194. if (!k.data("bindEvent_mousewheel")) { h.bind("mousewheel", function(H, J) {
  195. var G, F = k.data("mouseWheelPixels"),
  196. x = Math.abs(p.position().top),
  197. I = j.position().top,
  198. y = m.height() - j.height();
  199. if (k.data("normalizeMouseWheelDelta")) {
  200. if (J < 0) { J = -1 } else { J = 1 } }
  201. if (F === "auto") { F = 100 + Math.round(k.data("scrollAmount") / 2) }
  202. if (k.data("horizontalScroll")) { I = j.position().left;
  203. y = m.width() - j.width();
  204. x = Math.abs(p.position().left) }
  205. if ((J > 0 && I !== 0) || (J < 0 && I !== y)) { H.preventDefault();
  206. H.stopImmediatePropagation() }
  207. G = x - (J * F);
  208. k.mCustomScrollbar("scrollTo", G, { trigger: "internal" }) });
  209. k.data({ bindEvent_mousewheel: true }) } }
  210. if (k.data("scrollButtons_enable")) {
  211. if (k.data("scrollButtons_scrollType") === "pixels") {
  212. if (k.data("horizontalScroll")) { v.add(A).unbind("mousedown touchstart MSPointerDown mouseup MSPointerUp mouseout MSPointerOut touchend", i, g);
  213. k.data({ bindEvent_buttonsContinuous_x: false });
  214. if (!k.data("bindEvent_buttonsPixels_x")) { v.bind("click", function(x) { x.preventDefault();
  215. q(Math.abs(p.position().left) + k.data("scrollButtons_scrollAmount")) });
  216. A.bind("click", function(x) { x.preventDefault();
  217. q(Math.abs(p.position().left) - k.data("scrollButtons_scrollAmount")) });
  218. k.data({ bindEvent_buttonsPixels_x: true }) } } else { e.add(w).unbind("mousedown touchstart MSPointerDown mouseup MSPointerUp mouseout MSPointerOut touchend", i, g);
  219. k.data({ bindEvent_buttonsContinuous_y: false });
  220. if (!k.data("bindEvent_buttonsPixels_y")) { e.bind("click", function(x) { x.preventDefault();
  221. q(Math.abs(p.position().top) + k.data("scrollButtons_scrollAmount")) });
  222. w.bind("click", function(x) { x.preventDefault();
  223. q(Math.abs(p.position().top) - k.data("scrollButtons_scrollAmount")) });
  224. k.data({ bindEvent_buttonsPixels_y: true }) } }
  225. function q(x) {
  226. if (!j.data("preventAction")) { j.data("preventAction", true);
  227. k.mCustomScrollbar("scrollTo", x, { trigger: "internal" }) } } } else {
  228. if (k.data("horizontalScroll")) { v.add(A).unbind("click");
  229. k.data({ bindEvent_buttonsPixels_x: false });
  230. if (!k.data("bindEvent_buttonsContinuous_x")) { v.bind("mousedown touchstart MSPointerDown", function(y) { y.preventDefault();
  231. var x = z();
  232. k.data({ mCSB_buttonScrollRight: setInterval(function() { k.mCustomScrollbar("scrollTo", Math.abs(p.position().left) + x, { trigger: "internal", scrollEasing: "easeOutCirc" }) }, 17) }) });
  233. var i = function(x) { x.preventDefault();
  234. clearInterval(k.data("mCSB_buttonScrollRight")) };
  235. v.bind("mouseup touchend MSPointerUp mouseout MSPointerOut", i);
  236. A.bind("mousedown touchstart MSPointerDown", function(y) { y.preventDefault();
  237. var x = z();
  238. k.data({ mCSB_buttonScrollLeft: setInterval(function() { k.mCustomScrollbar("scrollTo", Math.abs(p.position().left) - x, { trigger: "internal", scrollEasing: "easeOutCirc" }) }, 17) }) });
  239. var g = function(x) { x.preventDefault();
  240. clearInterval(k.data("mCSB_buttonScrollLeft")) };
  241. A.bind("mouseup touchend MSPointerUp mouseout MSPointerOut", g);
  242. k.data({ bindEvent_buttonsContinuous_x: true }) } } else { e.add(w).unbind("click");
  243. k.data({ bindEvent_buttonsPixels_y: false });
  244. if (!k.data("bindEvent_buttonsContinuous_y")) { e.bind("mousedown touchstart MSPointerDown", function(y) { y.preventDefault();
  245. var x = z();
  246. k.data({ mCSB_buttonScrollDown: setInterval(function() { k.mCustomScrollbar("scrollTo", Math.abs(p.position().top) + x, { trigger: "internal", scrollEasing: "easeOutCirc" }) }, 17) }) });
  247. var t = function(x) { x.preventDefault();
  248. clearInterval(k.data("mCSB_buttonScrollDown")) };
  249. e.bind("mouseup touchend MSPointerUp mouseout MSPointerOut", t);
  250. w.bind("mousedown touchstart MSPointerDown", function(y) { y.preventDefault();
  251. var x = z();
  252. k.data({ mCSB_buttonScrollUp: setInterval(function() { k.mCustomScrollbar("scrollTo", Math.abs(p.position().top) - x, { trigger: "internal", scrollEasing: "easeOutCirc" }) }, 17) }) });
  253. var f = function(x) { x.preventDefault();
  254. clearInterval(k.data("mCSB_buttonScrollUp")) };
  255. w.bind("mouseup touchend MSPointerUp mouseout MSPointerOut", f);
  256. k.data({ bindEvent_buttonsContinuous_y: true }) } }
  257. function z() {
  258. var x = k.data("scrollButtons_scrollSpeed");
  259. if (k.data("scrollButtons_scrollSpeed") === "auto") { x = Math.round((k.data("scrollInertia") + 100) / 40) }
  260. return x } } }
  261. if (k.data("autoScrollOnFocus")) {
  262. if (!k.data("bindEvent_focusin")) { h.bind("focusin", function() { h.scrollTop(0).scrollLeft(0);
  263. var x = c(document.activeElement);
  264. if (x.is("input,textarea,select,button,a[tabindex],area,object")) {
  265. var G = p.position().top,
  266. y = x.position().top,
  267. F = h.height() - x.outerHeight();
  268. if (k.data("horizontalScroll")) { G = p.position().left;
  269. y = x.position().left;
  270. F = h.width() - x.outerWidth() }
  271. if (G + y < 0 || G + y > F) { k.mCustomScrollbar("scrollTo", y, { trigger: "internal" }) } } });
  272. k.data({ bindEvent_focusin: true }) } }
  273. if (k.data("autoHideScrollbar")) {
  274. if (!k.data("bindEvent_autoHideScrollbar")) { h.bind("mouseenter", function(x) { h.addClass("mCS-mouse-over");
  275. d.showScrollbar.call(h.children(".mCSB_scrollTools")) }).bind("mouseleave touchend", function(x) { h.removeClass("mCS-mouse-over");
  276. if (x.type === "mouseleave") { d.hideScrollbar.call(h.children(".mCSB_scrollTools")) } });
  277. k.data({ bindEvent_autoHideScrollbar: true }) } } }, scrollTo: function(e, f) {
  278. var i = c(this),
  279. o = { moveDragger: false, trigger: "external", callbacks: true, scrollInertia: i.data("scrollInertia"), scrollEasing: i.data("scrollEasing") },
  280. f = c.extend(o, f),
  281. p, g = i.children(".mCustomScrollBox"),
  282. k = g.children(".mCSB_container"),
  283. r = g.children(".mCSB_scrollTools"),
  284. j = r.children(".mCSB_draggerContainer"),
  285. h = j.children(".mCSB_dragger"),
  286. t = draggerSpeed = f.scrollInertia,
  287. q, s, m, l;
  288. if (!k.hasClass("mCS_no_scrollbar")) { i.data({ mCS_trigger: f.trigger });
  289. if (i.data("mCS_Init")) { f.callbacks = false }
  290. if (e || e === 0) {
  291. if (typeof(e) === "number") {
  292. if (f.moveDragger) { p = e;
  293. if (i.data("horizontalScroll")) { e = h.position().left * i.data("scrollAmount") } else { e = h.position().top * i.data("scrollAmount") }
  294. draggerSpeed = 0 } else { p = e / i.data("scrollAmount") } } else {
  295. if (typeof(e) === "string") {
  296. var v;
  297. if (e === "top") { v = 0 } else {
  298. if (e === "bottom" && !i.data("horizontalScroll")) { v = k.outerHeight() - g.height() } else {
  299. if (e === "left") { v = 0 } else {
  300. if (e === "right" && i.data("horizontalScroll")) { v = k.outerWidth() - g.width() } else {
  301. if (e === "first") { v = i.find(".mCSB_container").find(":first") } else {
  302. if (e === "last") { v = i.find(".mCSB_container").find(":last") } else { v = i.find(e) } } } } } }
  303. if (v.length === 1) {
  304. if (i.data("horizontalScroll")) { e = v.position().left } else { e = v.position().top }
  305. p = e / i.data("scrollAmount") } else { p = e = v } } }
  306. if (i.data("horizontalScroll")) {
  307. if (i.data("onTotalScrollBack_Offset")) { s = -i.data("onTotalScrollBack_Offset") }
  308. if (i.data("onTotalScroll_Offset")) { l = g.width() - k.outerWidth() + i.data("onTotalScroll_Offset") }
  309. if (p < 0) { p = e = 0;
  310. clearInterval(i.data("mCSB_buttonScrollLeft"));
  311. if (!s) { q = true } } else {
  312. if (p >= j.width() - h.width()) { p = j.width() - h.width();
  313. e = g.width() - k.outerWidth();
  314. clearInterval(i.data("mCSB_buttonScrollRight"));
  315. if (!l) { m = true } } else { e = -e } }
  316. var n = i.data("snapAmount");
  317. if (n) { e = Math.round(e / n) * n - i.data("snapOffset") }
  318. d.mTweenAxis.call(this, h[0], "left", Math.round(p), draggerSpeed, f.scrollEasing);
  319. d.mTweenAxis.call(this, k[0], "left", Math.round(e), t, f.scrollEasing, { onStart: function() {
  320. if (f.callbacks && !i.data("mCS_tweenRunning")) { u("onScrollStart") }
  321. if (i.data("autoHideScrollbar")) { d.showScrollbar.call(r) } }, onUpdate: function() {
  322. if (f.callbacks) { u("whileScrolling") } }, onComplete: function() {
  323. if (f.callbacks) { u("onScroll");
  324. if (q || (s && k.position().left >= s)) { u("onTotalScrollBack") }
  325. if (m || (l && k.position().left <= l)) { u("onTotalScroll") } }
  326. h.data("preventAction", false);
  327. i.data("mCS_tweenRunning", false);
  328. if (i.data("autoHideScrollbar")) {
  329. if (!g.hasClass("mCS-mouse-over")) { d.hideScrollbar.call(r) } } } }) } else {
  330. if (i.data("onTotalScrollBack_Offset")) { s = -i.data("onTotalScrollBack_Offset") }
  331. if (i.data("onTotalScroll_Offset")) { l = g.height() - k.outerHeight() + i.data("onTotalScroll_Offset") }
  332. if (p < 0) { p = e = 0;
  333. clearInterval(i.data("mCSB_buttonScrollUp"));
  334. if (!s) { q = true } } else {
  335. if (p >= j.height() - h.height()) { p = j.height() - h.height();
  336. e = g.height() - k.outerHeight();
  337. clearInterval(i.data("mCSB_buttonScrollDown"));
  338. if (!l) { m = true } } else { e = -e } }
  339. var n = i.data("snapAmount");
  340. if (n) { e = Math.round(e / n) * n - i.data("snapOffset") }
  341. d.mTweenAxis.call(this, h[0], "top", Math.round(p), draggerSpeed, f.scrollEasing);
  342. d.mTweenAxis.call(this, k[0], "top", Math.round(e), t, f.scrollEasing, { onStart: function() {
  343. if (f.callbacks && !i.data("mCS_tweenRunning")) { u("onScrollStart") }
  344. if (i.data("autoHideScrollbar")) { d.showScrollbar.call(r) } }, onUpdate: function() {
  345. if (f.callbacks) { u("whileScrolling") } }, onComplete: function() {
  346. if (f.callbacks) { u("onScroll");
  347. if (q || (s && k.position().top >= s)) { u("onTotalScrollBack") }
  348. if (m || (l && k.position().top <= l)) { u("onTotalScroll") } }
  349. h.data("preventAction", false);
  350. i.data("mCS_tweenRunning", false);
  351. if (i.data("autoHideScrollbar")) {
  352. if (!g.hasClass("mCS-mouse-over")) { d.hideScrollbar.call(r) } } } }) }
  353. if (i.data("mCS_Init")) { i.data({ mCS_Init: false }) } } }
  354. function u(w) { this.mcs = { top: k.position().top, left: k.position().left, draggerTop: h.position().top, draggerLeft: h.position().left, topPct: Math.round((100 * Math.abs(k.position().top)) / Math.abs(k.outerHeight() - g.height())), leftPct: Math.round((100 * Math.abs(k.position().left)) / Math.abs(k.outerWidth() - g.width())) };
  355. switch (w) {
  356. case "onScrollStart":
  357. i.data("mCS_tweenRunning", true).data("onScrollStart_Callback").call(i, this.mcs);
  358. break;
  359. case "whileScrolling":
  360. i.data("whileScrolling_Callback").call(i, this.mcs);
  361. break;
  362. case "onScroll":
  363. i.data("onScroll_Callback").call(i, this.mcs);
  364. break;
  365. case "onTotalScrollBack":
  366. i.data("onTotalScrollBack_Callback").call(i, this.mcs);
  367. break;
  368. case "onTotalScroll":
  369. i.data("onTotalScroll_Callback").call(i, this.mcs);
  370. break } } }, stop: function() {
  371. var g = c(this),
  372. e = g.children().children(".mCSB_container"),
  373. f = g.children().children().children().children(".mCSB_dragger");
  374. d.mTweenAxisStop.call(this, e[0]);
  375. d.mTweenAxisStop.call(this, f[0]) }, disable: function(e) {
  376. var j = c(this),
  377. f = j.children(".mCustomScrollBox"),
  378. h = f.children(".mCSB_container"),
  379. g = f.children(".mCSB_scrollTools"),
  380. i = g.children().children(".mCSB_dragger");
  381. f.unbind("mousewheel focusin mouseenter mouseleave touchend");
  382. h.unbind("touchstart touchmove");
  383. if (e) {
  384. if (j.data("horizontalScroll")) { i.add(h).css("left", 0) } else { i.add(h).css("top", 0) } }
  385. g.css("display", "none");
  386. h.addClass("mCS_no_scrollbar");
  387. j.data({ bindEvent_mousewheel: false, bindEvent_focusin: false, bindEvent_content_touch: false, bindEvent_autoHideScrollbar: false }).addClass("mCS_disabled") }, destroy: function() {
  388. var e = c(this);
  389. e.removeClass("mCustomScrollbar _mCS_" + e.data("mCustomScrollbarIndex")).addClass("mCS_destroyed").children().children(".mCSB_container").unwrap().children().unwrap().siblings(".mCSB_scrollTools").remove();
  390. c(document).unbind("mousemove." + e.data("mCustomScrollbarIndex") + " mouseup." + e.data("mCustomScrollbarIndex") + " MSPointerMove." + e.data("mCustomScrollbarIndex") + " MSPointerUp." + e.data("mCustomScrollbarIndex"));
  391. c(window).unbind("resize." + e.data("mCustomScrollbarIndex")) } },
  392. d = { showScrollbar: function() { this.stop().animate({ opacity: 1 }, "fast") }, hideScrollbar: function() { this.stop().animate({ opacity: 0 }, "fast") }, mTweenAxis: function(g, i, h, f, o, y) {
  393. var y = y || {},
  394. v = y.onStart || function() {},
  395. p = y.onUpdate || function() {},
  396. w = y.onComplete || function() {};
  397. var n = t(),
  398. l, j = 0,
  399. r = g.offsetTop,
  400. s = g.style;
  401. if (i === "left") { r = g.offsetLeft }
  402. var m = h - r;
  403. q();
  404. e();
  405. function t() {
  406. if (window.performance && window.performance.now) {
  407. return window.performance.now() } else {
  408. if (window.performance && window.performance.webkitNow) {
  409. return window.performance.webkitNow() } else {
  410. if (Date.now) {
  411. return Date.now() } else {
  412. return new Date().getTime() } } } }
  413. function x() {
  414. if (!j) { v.call() }
  415. j = t() - n;
  416. u();
  417. if (j >= g._time) { g._time = (j > g._time) ? j + l - (j - g._time) : j + l - 1;
  418. if (g._time < j + 1) { g._time = j + 1 } }
  419. if (g._time < f) { g._id = _request(x) } else { w.call() } }
  420. function u() {
  421. if (f > 0) { g.currVal = k(g._time, r, m, f, o);
  422. s[i] = Math.round(g.currVal) + "px" } else { s[i] = h + "px" }
  423. p.call() }
  424. function e() { l = 1000 / 60;
  425. g._time = j + l;
  426. _request = (!window.requestAnimationFrame) ? function(z) { u();
  427. return setTimeout(z, 0.01) } : window.requestAnimationFrame;
  428. g._id = _request(x) }
  429. function q() {
  430. if (g._id == null) {
  431. return }
  432. if (!window.requestAnimationFrame) { clearTimeout(g._id) } else { window.cancelAnimationFrame(g._id) }
  433. g._id = null }
  434. function k(B, A, F, E, C) {
  435. switch (C) {
  436. case "linear":
  437. return F * B / E + A;
  438. break;
  439. case "easeOutQuad":
  440. B /= E;
  441. return -F * B * (B - 2) + A;
  442. break;
  443. case "easeInOutQuad":
  444. B /= E / 2;
  445. if (B < 1) {
  446. return F / 2 * B * B + A }
  447. B--;
  448. return -F / 2 * (B * (B - 2) - 1) + A;
  449. break;
  450. case "easeOutCubic":
  451. B /= E;
  452. B--;
  453. return F * (B * B * B + 1) + A;
  454. break;
  455. case "easeOutQuart":
  456. B /= E;
  457. B--;
  458. return -F * (B * B * B * B - 1) + A;
  459. break;
  460. case "easeOutQuint":
  461. B /= E;
  462. B--;
  463. return F * (B * B * B * B * B + 1) + A;
  464. break;
  465. case "easeOutCirc":
  466. B /= E;
  467. B--;
  468. return F * Math.sqrt(1 - B * B) + A;
  469. break;
  470. case "easeOutSine":
  471. return F * Math.sin(B / E * (Math.PI / 2)) + A;
  472. break;
  473. case "easeOutExpo":
  474. return F * (-Math.pow(2, -10 * B / E) + 1) + A;
  475. break;
  476. case "mcsEaseOut":
  477. var D = (B /= E) * B,
  478. z = D * B;
  479. return A + F * (0.499999999999997 * z * D + -2.5 * D * D + 5.5 * z + -6.5 * D + 4 * B);
  480. break;
  481. case "draggerRailEase":
  482. B /= E / 2;
  483. if (B < 1) {
  484. return F / 2 * B * B * B + A }
  485. B -= 2;
  486. return F / 2 * (B * B * B + 2) + A;
  487. break } } }, mTweenAxisStop: function(e) {
  488. if (e._id == null) {
  489. return }
  490. if (!window.requestAnimationFrame) { clearTimeout(e._id) } else { window.cancelAnimationFrame(e._id) }
  491. e._id = null }, rafPolyfill: function() {
  492. var f = ["ms", "moz", "webkit", "o"],
  493. e = f.length;
  494. while (--e > -1 && !window.requestAnimationFrame) { window.requestAnimationFrame = window[f[e] + "RequestAnimationFrame"];
  495. window.cancelAnimationFrame = window[f[e] + "CancelAnimationFrame"] || window[f[e] + "CancelRequestAnimationFrame"] } } };
  496. d.rafPolyfill.call();
  497. c.support.touch = !!("ontouchstart" in window);
  498. c.support.msPointer = window.navigator.msPointerEnabled;
  499. var a = ("https:" == document.location.protocol) ? "https:" : "http:";
  500. c.event.special.mousewheel || document.write('<script src="' + a + '//cdnjs.cloudflare.com/ajax/libs/jquery-mousewheel/3.0.6/jquery.mousewheel.min.js"><\/script>');
  501. c.fn.mCustomScrollbar = function(e) {
  502. if (b[e]) {
  503. return b[e].apply(this, Array.prototype.slice.call(arguments, 1)) } else {
  504. if (typeof e === "object" || !e) {
  505. return b.init.apply(this, arguments) } else { c.error("Method " + e + " does not exist") } } } })(jQuery);