1 line
16 KiB
JavaScript
1 line
16 KiB
JavaScript
|
(function(b){var a={init:function(c){var e={set_width:false,set_height:false,horizontalScroll:false,scrollInertia:550,scrollEasing:"easeOutCirc",mouseWheel:"auto",autoDraggerLength:true,scrollButtons:{enable:false,scrollType:"continuous",scrollSpeed:20,scrollAmount:40},advanced:{updateOnBrowserResize:true,updateOnContentResize:false,autoExpandHorizontalScroll:false},callbacks:{onScroll:function(){},onTotalScroll:function(){},onTotalScrollOffset:0}},c=b.extend(true,e,c);b(document).data("mCS-is-touch-device",false);if(d()){b(document).data("mCS-is-touch-device",true)}function d(){return !!("ontouchstart" in window)?1:0}return this.each(function(){var m=b(this);if(c.set_width){m.css("width",c.set_width)}if(c.set_height){m.css("height",c.set_height)}if(!b(document).data("mCustomScrollbar-index")){b(document).data("mCustomScrollbar-index","1")}else{var s=parseInt(b(document).data("mCustomScrollbar-index"));b(document).data("mCustomScrollbar-index",s+1)}m.wrapInner("<div class='mCustomScrollBox' id='mCSB_"+b(document).data("mCustomScrollbar-index")+"' style='position:relative; height:100%; overflow:hidden; max-width:100%;' />").addClass("mCustomScrollbar _mCS_"+b(document).data("mCustomScrollbar-index"));var g=m.children(".mCustomScrollBox");if(c.horizontalScroll){g.addClass("mCSB_horizontal").wrapInner("<div class='mCSB_h_wrapper' style='position:relative; left:0; width:999999px;' />");var k=g.children(".mCSB_h_wrapper");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;' />")}var o=g.children(".mCSB_container");if(!b(document).data("mCS-is-touch-device")){o.after("<div class='mCSB_scrollTools' style='position:absolute;'><div class='mCSB_draggerContainer' style='position:relative;'><div class='mCSB_dragger' style='position:absolute;'><div class='mCSB_dragger_bar' style='position:relative;'></div></div><div class='mCSB_draggerRail'></div></div></div>");var l=g.children(".mCSB_scrollTools"),h=l.children(".mCSB_draggerContainer"),q=h.children(".mCSB_dragger");if(c.horizontalScroll){q.data("minDraggerWidth",q.width())}else{q.data("minDraggerHeight",q.height())}if(c.scrollButtons.enable){if(c.horizontalScroll){l.prepend("<a class='mCSB_buttonLeft' style='display:block; position:relative;'></a>").append("<a class='mCSB_buttonRight' style='display:block; position:relative;'></a>")}else{l.prepend("<a class='mCSB_buttonUp' style='display:block; position:relative;'></a>").append("<a class='mCSB_buttonDown' style='display:block; position:relative;'></a>")}}g.bind("scroll",function(){g.scrollTop(0).scrollLeft(0)});m.data({horizontalScroll:c.horizontalScroll,scrollInertia:c.scrollInertia,scrollEasing:c.scrollEasing,mouseWheel:c.mouseWheel,autoDraggerLength:c.autoDraggerLength,"scrollButtons-enable":c.scrollButtons.enable,"scrollButtons-scrollType":c.scrollButtons.scrollType,"scrollButtons-scrollSpeed":c.scrollButtons.scrollSpeed,"scrollButtons-scrollAmount":c.scrollButtons.scrollAmount,autoExpandHorizontalScroll:c.advanced.autoExpandHorizontalScroll,"onScroll-Callback":c.callbacks.onScroll,"onTotalScroll-Callback":c.callbacks.onTotalScroll,"onTotalScroll-Offset":c.callbacks.onTotalScrollOffset}).mCustomScrollbar("update");if(c.advanced.updateOnBrowserResize){var i;b(window).resize(function(){if(i){clearTimeout(i)}i=setTimeout(function(){m.mCustomScrollbar("update")},150)})}}else{var f=navigator.userAgent;if(f.indexOf("Android")!=-1){var r=parseFloat(f.slice(f.indexOf("Android")+8));if(r<3){j("mCSB_"+b(document).data("mCustomScrollbar-index"))}else{g.css({overflow:"auto","-webkit-overflow-scrolling":"touch"})}}else{g.css({overflow:"auto","-webkit-overflow-scrolling":"touch"})}o.addClass("mCS_no_scrollbar mCS_touch");m.data({horizontalScroll:c.horizontalScroll,scrollInertia:c.scrollInertia,scrollEasing:c.scrollEasing,autoExpandHorizontalScroll:c.advanced.autoExpandHorizontalScroll,"onScroll-Callback":c.callbacks.onScroll,"onTotalScroll-C
|