[ Index ]

PHP Cross Reference of vtigercrm-6.1.0

title

Body

[close]

/libraries/jquery/malihu-custom-scrollbar/js/ -> jquery.mCustomScrollbar.js (source)

   1  /* 
   2  == malihu jquery custom scrollbars plugin == 
   3  version: 2.8 
   4  author: malihu (http://manos.malihu.gr) 
   5  plugin home: http://manos.malihu.gr/jquery-custom-content-scroller 
   6  */
   7  (function($){
   8      /*plugin script*/
   9      var methods={
  10          init:function(options){
  11              var defaults={ 
  12                  set_width:false, /*optional element width: boolean, pixels, percentage*/
  13                  set_height:false, /*optional element height: boolean, pixels, percentage*/
  14                  horizontalScroll:false, /*scroll horizontally: boolean*/
  15                  scrollInertia:950, /*scrolling inertia: integer (milliseconds)*/
  16                  mouseWheel:true, /*mousewheel support: boolean*/
  17                  mouseWheelPixels:"auto", /*mousewheel pixels amount: integer, "auto"*/
  18                  autoDraggerLength:true, /*auto-adjust scrollbar dragger length: boolean*/
  19                  autoHideScrollbar:false, /*auto-hide scrollbar when idle*/
  20                  scrollButtons:{ /*scroll buttons*/
  21                      enable:false, /*scroll buttons support: boolean*/
  22                      scrollType:"continuous", /*scroll buttons scrolling type: "continuous", "pixels"*/
  23                      scrollSpeed:"auto", /*scroll buttons continuous scrolling speed: integer, "auto"*/
  24                      scrollAmount:40 /*scroll buttons pixels scroll amount: integer (pixels)*/
  25                  },
  26                  advanced:{
  27                      updateOnBrowserResize:true, /*update scrollbars on browser resize (for layouts based on percentages): boolean*/
  28                      updateOnContentResize:false, /*auto-update scrollbars on content resize (for dynamic content): boolean*/
  29                      autoExpandHorizontalScroll:false, /*auto-expand width for horizontal scrolling: boolean*/
  30                      autoScrollOnFocus:true, /*auto-scroll on focused elements: boolean*/
  31                      normalizeMouseWheelDelta:false /*normalize mouse-wheel delta (-1/1)*/
  32                  },
  33                  contentTouchScroll:true, /*scrolling by touch-swipe content: boolean*/
  34                  callbacks:{
  35                      onScrollStart:function(){}, /*user custom callback function on scroll start event*/
  36                      onScroll:function(){}, /*user custom callback function on scroll event*/
  37                      onTotalScroll:function(){}, /*user custom callback function on scroll end reached event*/
  38                      onTotalScrollBack:function(){}, /*user custom callback function on scroll begin reached event*/
  39                      onTotalScrollOffset:0, /*scroll end reached offset: integer (pixels)*/
  40                      onTotalScrollBackOffset:0, /*scroll begin reached offset: integer (pixels)*/
  41                      whileScrolling:function(){} /*user custom callback function on scrolling event*/
  42                  },
  43                  theme:"light" /*"light", "dark", "light-2", "dark-2", "light-thick", "dark-thick", "light-thin", "dark-thin"*/
  44              },
  45              options=$.extend(true,defaults,options);
  46              return this.each(function(){
  47                  var $this=$(this);
  48                  /*set element width/height, create markup for custom scrollbars, add classes*/
  49                  if(options.set_width){
  50                      $this.css("width",options.set_width);
  51                  }
  52                  if(options.set_height){
  53                      $this.css("height",options.set_height);
  54                  }
  55                  if(!$(document).data("mCustomScrollbar-index")){
  56                      $(document).data("mCustomScrollbar-index","1");
  57                  }else{
  58                      var mCustomScrollbarIndex=parseInt($(document).data("mCustomScrollbar-index"));
  59                      $(document).data("mCustomScrollbar-index",mCustomScrollbarIndex+1);
  60                  }
  61                  $this.wrapInner("<div class='mCustomScrollBox"+" mCS-"+options.theme+"' id='mCSB_"+$(document).data("mCustomScrollbar-index")+"' style='position:relative; height:100%; overflow:hidden; max-width:100%;' />").addClass("mCustomScrollbar _mCS_"+$(document).data("mCustomScrollbar-index"));
  62                  var mCustomScrollBox=$this.children(".mCustomScrollBox");
  63                  if(options.horizontalScroll){
  64                      mCustomScrollBox.addClass("mCSB_horizontal").wrapInner("<div class='mCSB_h_wrapper' style='position:relative; left:0; width:999999px;' />");
  65                      var mCSB_h_wrapper=mCustomScrollBox.children(".mCSB_h_wrapper");
  66                      mCSB_h_wrapper.wrapInner("<div class='mCSB_container' style='position:absolute; left:0;' />").children(".mCSB_container").css({"width":mCSB_h_wrapper.children().outerWidth(),"position":"relative"}).unwrap();
  67                  }else{
  68                      mCustomScrollBox.wrapInner("<div class='mCSB_container' style='position:relative; top:0;' />");
  69                  }
  70                  var mCSB_container=mCustomScrollBox.children(".mCSB_container");
  71                  if($.support.touch){
  72                      mCSB_container.addClass("mCS_touch");
  73                  }
  74                  mCSB_container.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>");
  75                  var mCSB_scrollTools=mCustomScrollBox.children(".mCSB_scrollTools"),
  76                      mCSB_draggerContainer=mCSB_scrollTools.children(".mCSB_draggerContainer"),
  77                      mCSB_dragger=mCSB_draggerContainer.children(".mCSB_dragger");
  78                  if(options.horizontalScroll){
  79                      mCSB_dragger.data("minDraggerWidth",mCSB_dragger.width());
  80                  }else{
  81                      mCSB_dragger.data("minDraggerHeight",mCSB_dragger.height());
  82                  }
  83                  if(options.scrollButtons.enable){
  84                      if(options.horizontalScroll){
  85                          mCSB_scrollTools.prepend("<a class='mCSB_buttonLeft' oncontextmenu='return false;'></a>").append("<a class='mCSB_buttonRight' oncontextmenu='return false;'></a>");
  86                      }else{
  87                          mCSB_scrollTools.prepend("<a class='mCSB_buttonUp' oncontextmenu='return false;'></a>").append("<a class='mCSB_buttonDown' oncontextmenu='return false;'></a>");
  88                      }
  89                  }
  90                  /*mCustomScrollBox scrollTop and scrollLeft is always 0 to prevent browser focus scrolling*/
  91                  mCustomScrollBox.bind("scroll",function(){
  92                      if(!$this.is(".mCS_disabled")){ /*native focus scrolling for disabled scrollbars*/
  93                          mCustomScrollBox.scrollTop(0).scrollLeft(0);
  94                      }
  95                  });
  96                  /*store options, global vars/states, intervals*/
  97                  $this.data({
  98                      /*init state*/
  99                      "mCS_Init":true,
 100                      /*instance index*/
 101                      "mCustomScrollbarIndex":$(document).data("mCustomScrollbar-index"),
 102                      /*option parameters*/
 103                      "horizontalScroll":options.horizontalScroll,
 104                      "scrollInertia":options.scrollInertia,
 105                      "scrollEasing":"mcsEaseOut",
 106                      "mouseWheel":options.mouseWheel,
 107                      "mouseWheelPixels":options.mouseWheelPixels,
 108                      "autoDraggerLength":options.autoDraggerLength,
 109                      "autoHideScrollbar":options.autoHideScrollbar,
 110                      "scrollButtons_enable":options.scrollButtons.enable,
 111                      "scrollButtons_scrollType":options.scrollButtons.scrollType,
 112                      "scrollButtons_scrollSpeed":options.scrollButtons.scrollSpeed,
 113                      "scrollButtons_scrollAmount":options.scrollButtons.scrollAmount,
 114                      "autoExpandHorizontalScroll":options.advanced.autoExpandHorizontalScroll,
 115                      "autoScrollOnFocus":options.advanced.autoScrollOnFocus,
 116                      "normalizeMouseWheelDelta":options.advanced.normalizeMouseWheelDelta,
 117                      "contentTouchScroll":options.contentTouchScroll,
 118                      "onScrollStart_Callback":options.callbacks.onScrollStart,
 119                      "onScroll_Callback":options.callbacks.onScroll,
 120                      "onTotalScroll_Callback":options.callbacks.onTotalScroll,
 121                      "onTotalScrollBack_Callback":options.callbacks.onTotalScrollBack,
 122                      "onTotalScroll_Offset":options.callbacks.onTotalScrollOffset,
 123                      "onTotalScrollBack_Offset":options.callbacks.onTotalScrollBackOffset,
 124                      "whileScrolling_Callback":options.callbacks.whileScrolling,
 125                      /*events binding state*/
 126                      "bindEvent_scrollbar_drag":false,
 127                      "bindEvent_content_touch":false,
 128                      "bindEvent_scrollbar_click":false,
 129                      "bindEvent_mousewheel":false,
 130                      "bindEvent_buttonsContinuous_y":false,
 131                      "bindEvent_buttonsContinuous_x":false,
 132                      "bindEvent_buttonsPixels_y":false,
 133                      "bindEvent_buttonsPixels_x":false,
 134                      "bindEvent_focusin":false,
 135                      "bindEvent_autoHideScrollbar":false,
 136                      /*buttons intervals*/
 137                      "mCSB_buttonScrollRight":false,
 138                      "mCSB_buttonScrollLeft":false,
 139                      "mCSB_buttonScrollDown":false,
 140                      "mCSB_buttonScrollUp":false
 141                  });
 142                  /*max-width/max-height*/
 143                  if(options.horizontalScroll){
 144                      if($this.css("max-width")!=="none"){
 145                          if(!options.advanced.updateOnContentResize){ /*needs updateOnContentResize*/
 146                              options.advanced.updateOnContentResize=true;
 147                          }
 148                      }
 149                  }else{
 150                      if($this.css("max-height")!=="none"){
 151                          var percentage=false,maxHeight=parseInt($this.css("max-height"));
 152                          if($this.css("max-height").indexOf("%")>=0){
 153                              percentage=maxHeight,
 154                              maxHeight=$this.parent().height()*percentage/100;
 155                          }
 156                          $this.css("overflow","hidden");
 157                          mCustomScrollBox.css("max-height",maxHeight);
 158                      }
 159                  }
 160                  $this.mCustomScrollbar("update");
 161                  /*window resize fn (for layouts based on percentages)*/
 162                  if(options.advanced.updateOnBrowserResize){
 163                      var mCSB_resizeTimeout,currWinWidth=$(window).width(),currWinHeight=$(window).height();
 164                      $(window).bind("resize."+$this.data("mCustomScrollbarIndex"),function(){
 165                          if(mCSB_resizeTimeout){
 166                              clearTimeout(mCSB_resizeTimeout);
 167                          }
 168                          mCSB_resizeTimeout=setTimeout(function(){
 169                              if(!$this.is(".mCS_disabled") && !$this.is(".mCS_destroyed")){
 170                                  var winWidth=$(window).width(),winHeight=$(window).height();
 171                                  if(currWinWidth!==winWidth || currWinHeight!==winHeight){ /*ie8 fix*/
 172                                      if($this.css("max-height")!=="none" && percentage){
 173                                          mCustomScrollBox.css("max-height",$this.parent().height()*percentage/100);
 174                                      }
 175                                      $this.mCustomScrollbar("update");
 176                                      currWinWidth=winWidth; currWinHeight=winHeight;
 177                                  }
 178                              }
 179                          },150);
 180                      });
 181                  }
 182                  /*content resize fn (for dynamically generated content)*/
 183                  if(options.advanced.updateOnContentResize){
 184                      var mCSB_onContentResize;
 185                      if(options.horizontalScroll){
 186                          var mCSB_containerOldSize=mCSB_container.outerWidth();
 187                      }else{
 188                          var mCSB_containerOldSize=mCSB_container.outerHeight();
 189                      }
 190                      mCSB_onContentResize=setInterval(function(){
 191                          if(options.horizontalScroll){
 192                              if(options.advanced.autoExpandHorizontalScroll){
 193                                  mCSB_container.css({"position":"absolute","width":"auto"}).wrap("<div class='mCSB_h_wrapper' style='position:relative; left:0; width:999999px;' />").css({"width":mCSB_container.outerWidth(),"position":"relative"}).unwrap();
 194                              }
 195                              var mCSB_containerNewSize=mCSB_container.outerWidth();
 196                          }else{
 197                              var mCSB_containerNewSize=mCSB_container.outerHeight();
 198                          }
 199                          if(mCSB_containerNewSize!=mCSB_containerOldSize){
 200                              $this.mCustomScrollbar("update");
 201                              mCSB_containerOldSize=mCSB_containerNewSize;
 202                          }
 203                      },300);
 204                  }
 205              });
 206          },
 207          update:function(){
 208              var $this=$(this),
 209                  mCustomScrollBox=$this.children(".mCustomScrollBox"),
 210                  mCSB_container=mCustomScrollBox.children(".mCSB_container");
 211              mCSB_container.removeClass("mCS_no_scrollbar");
 212              $this.removeClass("mCS_disabled mCS_destroyed");
 213              mCustomScrollBox.scrollTop(0).scrollLeft(0); /*reset scrollTop/scrollLeft to prevent browser focus scrolling*/
 214              var mCSB_scrollTools=mCustomScrollBox.children(".mCSB_scrollTools"),
 215                  mCSB_draggerContainer=mCSB_scrollTools.children(".mCSB_draggerContainer"),
 216                  mCSB_dragger=mCSB_draggerContainer.children(".mCSB_dragger");
 217              if($this.data("horizontalScroll")){
 218                  var mCSB_buttonLeft=mCSB_scrollTools.children(".mCSB_buttonLeft"),
 219                      mCSB_buttonRight=mCSB_scrollTools.children(".mCSB_buttonRight"),
 220                      mCustomScrollBoxW=mCustomScrollBox.width();
 221                  if($this.data("autoExpandHorizontalScroll")){
 222                      mCSB_container.css({"position":"absolute","width":"auto"}).wrap("<div class='mCSB_h_wrapper' style='position:relative; left:0; width:999999px;' />").css({"width":mCSB_container.outerWidth(),"position":"relative"}).unwrap();
 223                  }
 224                  var mCSB_containerW=mCSB_container.outerWidth();
 225              }else{
 226                  var mCSB_buttonUp=mCSB_scrollTools.children(".mCSB_buttonUp"),
 227                      mCSB_buttonDown=mCSB_scrollTools.children(".mCSB_buttonDown"),
 228                      mCustomScrollBoxH=mCustomScrollBox.height(),
 229                      mCSB_containerH=mCSB_container.outerHeight();
 230              }
 231              if(mCSB_containerH>mCustomScrollBoxH && !$this.data("horizontalScroll")){ /*content needs vertical scrolling*/
 232                  mCSB_scrollTools.css("display","block");
 233                  var mCSB_draggerContainerH=mCSB_draggerContainer.height();
 234                  /*auto adjust scrollbar dragger length analogous to content*/
 235                  if($this.data("autoDraggerLength")){
 236                      var draggerH=Math.round(mCustomScrollBoxH/mCSB_containerH*mCSB_draggerContainerH),
 237                          minDraggerH=mCSB_dragger.data("minDraggerHeight");
 238                      if(draggerH<=minDraggerH){ /*min dragger height*/
 239                          mCSB_dragger.css({"height":minDraggerH});
 240                      }else if(draggerH>=mCSB_draggerContainerH-10){ /*max dragger height*/
 241                          var mCSB_draggerContainerMaxH=mCSB_draggerContainerH-10;
 242                          mCSB_dragger.css({"height":mCSB_draggerContainerMaxH});
 243                      }else{
 244                          mCSB_dragger.css({"height":draggerH});
 245                      }
 246                      mCSB_dragger.children(".mCSB_dragger_bar").css({"line-height":mCSB_dragger.height()+"px"});
 247                  }
 248                  var mCSB_draggerH=mCSB_dragger.height(),
 249                  /*calculate and store scroll amount, add scrolling*/
 250                      scrollAmount=(mCSB_containerH-mCustomScrollBoxH)/(mCSB_draggerContainerH-mCSB_draggerH);
 251                  $this.data("scrollAmount",scrollAmount).mCustomScrollbar("scrolling",mCustomScrollBox,mCSB_container,mCSB_draggerContainer,mCSB_dragger,mCSB_buttonUp,mCSB_buttonDown,mCSB_buttonLeft,mCSB_buttonRight);
 252                  /*scroll*/
 253                  var mCSB_containerP=Math.abs(mCSB_container.position().top);
 254                  $this.mCustomScrollbar("scrollTo",mCSB_containerP,{scrollInertia:0});
 255              }else if(mCSB_containerW>mCustomScrollBoxW && $this.data("horizontalScroll")){ /*content needs horizontal scrolling*/
 256                  mCSB_scrollTools.css("display","block");
 257                  var mCSB_draggerContainerW=mCSB_draggerContainer.width();
 258                  /*auto adjust scrollbar dragger length analogous to content*/
 259                  if($this.data("autoDraggerLength")){
 260                      var draggerW=Math.round(mCustomScrollBoxW/mCSB_containerW*mCSB_draggerContainerW),
 261                          minDraggerW=mCSB_dragger.data("minDraggerWidth");
 262                      if(draggerW<=minDraggerW){ /*min dragger height*/
 263                          mCSB_dragger.css({"width":minDraggerW});
 264                      }else if(draggerW>=mCSB_draggerContainerW-10){ /*max dragger height*/
 265                          var mCSB_draggerContainerMaxW=mCSB_draggerContainerW-10;
 266                          mCSB_dragger.css({"width":mCSB_draggerContainerMaxW});
 267                      }else{
 268                          mCSB_dragger.css({"width":draggerW});
 269                      }
 270                  }
 271                  var mCSB_draggerW=mCSB_dragger.width(),
 272                  /*calculate and store scroll amount, add scrolling*/
 273                      scrollAmount=(mCSB_containerW-mCustomScrollBoxW)/(mCSB_draggerContainerW-mCSB_draggerW);
 274                  $this.data("scrollAmount",scrollAmount).mCustomScrollbar("scrolling",mCustomScrollBox,mCSB_container,mCSB_draggerContainer,mCSB_dragger,mCSB_buttonUp,mCSB_buttonDown,mCSB_buttonLeft,mCSB_buttonRight);
 275                  /*scroll*/
 276                  var mCSB_containerP=Math.abs(mCSB_container.position().left);
 277                  $this.mCustomScrollbar("scrollTo",mCSB_containerP,{scrollInertia:0});
 278              }else{ /*content does not need scrolling*/
 279                  /*unbind events, reset content position, hide scrollbars, remove classes*/
 280                  mCustomScrollBox.unbind("mousewheel focusin");
 281                  if($this.data("horizontalScroll")){
 282                      mCSB_dragger.add(mCSB_container).css("left",0);
 283                  }else{
 284                      mCSB_dragger.add(mCSB_container).css("top",0);
 285                  }
 286                  mCSB_scrollTools.css("display","none");
 287                  mCSB_container.addClass("mCS_no_scrollbar");
 288                  $this.data({"bindEvent_mousewheel":false,"bindEvent_focusin":false});
 289              }
 290          },
 291          scrolling:function(mCustomScrollBox,mCSB_container,mCSB_draggerContainer,mCSB_dragger,mCSB_buttonUp,mCSB_buttonDown,mCSB_buttonLeft,mCSB_buttonRight){
 292              var $this=$(this);
 293              /*scrollbar drag scrolling*/
 294              if(!$this.data("bindEvent_scrollbar_drag")){
 295                  var mCSB_draggerDragY,mCSB_draggerDragX;
 296                  if($.support.msPointer){ /*MSPointer*/
 297                      mCSB_dragger.bind("MSPointerDown",function(e){
 298                          e.preventDefault();
 299                          $this.data({"on_drag":true}); mCSB_dragger.addClass("mCSB_dragger_onDrag");
 300                          var elem=$(this),
 301                              elemOffset=elem.offset(),
 302                              x=e.originalEvent.pageX-elemOffset.left,
 303                              y=e.originalEvent.pageY-elemOffset.top;
 304                          if(x<elem.width() && x>0 && y<elem.height() && y>0){
 305                              mCSB_draggerDragY=y;
 306                              mCSB_draggerDragX=x;
 307                          }
 308                      });
 309                      $(document).bind("MSPointerMove."+$this.data("mCustomScrollbarIndex"),function(e){
 310                          e.preventDefault();
 311                          if($this.data("on_drag")){
 312                              var elem=mCSB_dragger,
 313                                  elemOffset=elem.offset(),
 314                                  x=e.originalEvent.pageX-elemOffset.left,
 315                                  y=e.originalEvent.pageY-elemOffset.top;
 316                              scrollbarDrag(mCSB_draggerDragY,mCSB_draggerDragX,y,x);
 317                          }
 318                      }).bind("MSPointerUp."+$this.data("mCustomScrollbarIndex"),function(e){
 319                          e.preventDefault();
 320                          $this.data({"on_drag":false}); mCSB_dragger.removeClass("mCSB_dragger_onDrag");
 321                      });
 322                  }else{ /*mouse/touch*/
 323                      mCSB_dragger.bind("mousedown touchstart",function(e){
 324                          e.preventDefault(); e.stopImmediatePropagation();
 325                          var    elem=$(this),elemOffset=elem.offset(),x,y;
 326                          if(e.type==="touchstart"){
 327                              var touch=e.originalEvent.touches[0] || e.originalEvent.changedTouches[0];
 328                              x=touch.pageX-elemOffset.left; y=touch.pageY-elemOffset.top;
 329                          }else{
 330                              $this.data({"on_drag":true}); mCSB_dragger.addClass("mCSB_dragger_onDrag");
 331                              x=e.pageX-elemOffset.left; y=e.pageY-elemOffset.top;
 332                          }
 333                          if(x<elem.width() && x>0 && y<elem.height() && y>0){
 334                              mCSB_draggerDragY=y; mCSB_draggerDragX=x;
 335                          }
 336                      }).bind("touchmove",function(e){
 337                          e.preventDefault(); e.stopImmediatePropagation();
 338                          var touch=e.originalEvent.touches[0] || e.originalEvent.changedTouches[0],
 339                              elem=$(this),
 340                              elemOffset=elem.offset(),
 341                              x=touch.pageX-elemOffset.left,
 342                              y=touch.pageY-elemOffset.top;
 343                          scrollbarDrag(mCSB_draggerDragY,mCSB_draggerDragX,y,x);
 344                      });
 345                      $(document).bind("mousemove."+$this.data("mCustomScrollbarIndex"),function(e){
 346                          e.preventDefault();
 347                          if($this.data("on_drag")){
 348                              var elem=mCSB_dragger,
 349                                  elemOffset=elem.offset(),
 350                                  x=e.pageX-elemOffset.left,
 351                                  y=e.pageY-elemOffset.top;
 352                              scrollbarDrag(mCSB_draggerDragY,mCSB_draggerDragX,y,x);
 353                          }
 354                      }).bind("mouseup."+$this.data("mCustomScrollbarIndex"),function(e){
 355                          e.preventDefault();
 356                          $this.data({"on_drag":false}); mCSB_dragger.removeClass("mCSB_dragger_onDrag");
 357                      });
 358                  }
 359                  $this.data({"bindEvent_scrollbar_drag":true});
 360              }
 361  			function scrollbarDrag(mCSB_draggerDragY,mCSB_draggerDragX,y,x){
 362                  if($this.data("horizontalScroll")){
 363                      $this.mCustomScrollbar("scrollTo",(mCSB_dragger.position().left-(mCSB_draggerDragX))+x,{moveDragger:true,trigger:"internal"});
 364                  }else{
 365                      $this.mCustomScrollbar("scrollTo",(mCSB_dragger.position().top-(mCSB_draggerDragY))+y,{moveDragger:true,trigger:"internal"});
 366                  }
 367              }
 368              /*content touch-drag*/
 369              if($.support.touch && $this.data("contentTouchScroll")){
 370                  if(!$this.data("bindEvent_content_touch")){
 371                      var touch,
 372                          elem,elemOffset,y,x,mCSB_containerTouchY,mCSB_containerTouchX;
 373                      mCSB_container.bind("touchstart",function(e){
 374                          e.stopImmediatePropagation();
 375                          touch=e.originalEvent.touches[0] || e.originalEvent.changedTouches[0];
 376                          elem=$(this);
 377                          elemOffset=elem.offset();
 378                          x=touch.pageX-elemOffset.left;
 379                          y=touch.pageY-elemOffset.top;
 380                          mCSB_containerTouchY=y;
 381                          mCSB_containerTouchX=x;
 382                      });
 383                      mCSB_container.bind("touchmove",function(e){
 384                          e.preventDefault(); e.stopImmediatePropagation();
 385                          touch=e.originalEvent.touches[0] || e.originalEvent.changedTouches[0];
 386                          elem=$(this).parent();
 387                          elemOffset=elem.offset();
 388                          x=touch.pageX-elemOffset.left;
 389                          y=touch.pageY-elemOffset.top;
 390                          if($this.data("horizontalScroll")){
 391                              $this.mCustomScrollbar("scrollTo",mCSB_containerTouchX-x,{trigger:"internal"});
 392                          }else{
 393                              $this.mCustomScrollbar("scrollTo",mCSB_containerTouchY-y,{trigger:"internal"});
 394                          }
 395                      });
 396                  }
 397              }
 398              /*dragger rail click scrolling*/
 399              if(!$this.data("bindEvent_scrollbar_click")){
 400                  mCSB_draggerContainer.bind("click",function(e){
 401                      var scrollToPos=(e.pageY-mCSB_draggerContainer.offset().top)*$this.data("scrollAmount"),target=$(e.target);
 402                      if($this.data("horizontalScroll")){
 403                          scrollToPos=(e.pageX-mCSB_draggerContainer.offset().left)*$this.data("scrollAmount");
 404                      }
 405                      if(target.hasClass("mCSB_draggerContainer") || target.hasClass("mCSB_draggerRail")){
 406                          $this.mCustomScrollbar("scrollTo",scrollToPos,{trigger:"internal",scrollEasing:"draggerRailEase"});
 407                      }
 408                  });
 409                  $this.data({"bindEvent_scrollbar_click":true});
 410              }
 411              /*mousewheel scrolling*/
 412              if($this.data("mouseWheel")){
 413                  if(!$this.data("bindEvent_mousewheel")){
 414                      mCustomScrollBox.bind("mousewheel",function(e,delta){
 415                          var scrollTo,mouseWheelPixels=$this.data("mouseWheelPixels"),absPos=Math.abs(mCSB_container.position().top),
 416                              draggerPos=mCSB_dragger.position().top,limit=mCSB_draggerContainer.height()-mCSB_dragger.height();
 417                          if($this.data("normalizeMouseWheelDelta")){
 418                              if(delta<0){delta=-1;}else{delta=1;}
 419                          }
 420                          if(mouseWheelPixels==="auto"){
 421                              mouseWheelPixels=100+Math.round($this.data("scrollAmount")/2);
 422                          }
 423                          if($this.data("horizontalScroll")){
 424                              draggerPos=mCSB_dragger.position().left; 
 425                              limit=mCSB_draggerContainer.width()-mCSB_dragger.width();
 426                              absPos=Math.abs(mCSB_container.position().left);
 427                          }
 428                          if((delta>0 && draggerPos!==0) || (delta<0 && draggerPos!==limit)){e.preventDefault(); e.stopImmediatePropagation();}
 429                          scrollTo=absPos-(delta*mouseWheelPixels);
 430                          $this.mCustomScrollbar("scrollTo",scrollTo,{trigger:"internal"});
 431                      });
 432                      $this.data({"bindEvent_mousewheel":true});
 433                  }
 434              }
 435              /*buttons scrolling*/
 436              if($this.data("scrollButtons_enable")){
 437                  if($this.data("scrollButtons_scrollType")==="pixels"){ /*scroll by pixels*/
 438                      if($this.data("horizontalScroll")){
 439                          mCSB_buttonRight.add(mCSB_buttonLeft).unbind("mousedown touchstart MSPointerDown mouseup MSPointerUp mouseout MSPointerOut touchend",mCSB_buttonRight_stop,mCSB_buttonLeft_stop);
 440                          $this.data({"bindEvent_buttonsContinuous_x":false});
 441                          if(!$this.data("bindEvent_buttonsPixels_x")){
 442                              /*scroll right*/
 443                              mCSB_buttonRight.bind("click",function(e){
 444                                  e.preventDefault();
 445                                  PixelsScrollTo(Math.abs(mCSB_container.position().left)+$this.data("scrollButtons_scrollAmount"));
 446                              });
 447                              /*scroll left*/
 448                              mCSB_buttonLeft.bind("click",function(e){
 449                                  e.preventDefault();
 450                                  PixelsScrollTo(Math.abs(mCSB_container.position().left)-$this.data("scrollButtons_scrollAmount"));
 451                              });
 452                              $this.data({"bindEvent_buttonsPixels_x":true});
 453                          }
 454                      }else{
 455                          mCSB_buttonDown.add(mCSB_buttonUp).unbind("mousedown touchstart MSPointerDown mouseup MSPointerUp mouseout MSPointerOut touchend",mCSB_buttonRight_stop,mCSB_buttonLeft_stop);
 456                          $this.data({"bindEvent_buttonsContinuous_y":false});
 457                          if(!$this.data("bindEvent_buttonsPixels_y")){
 458                              /*scroll down*/
 459                              mCSB_buttonDown.bind("click",function(e){
 460                                  e.preventDefault();
 461                                  PixelsScrollTo(Math.abs(mCSB_container.position().top)+$this.data("scrollButtons_scrollAmount"));
 462                              });
 463                              /*scroll up*/
 464                              mCSB_buttonUp.bind("click",function(e){
 465                                  e.preventDefault();
 466                                  PixelsScrollTo(Math.abs(mCSB_container.position().top)-$this.data("scrollButtons_scrollAmount"));
 467                              });
 468                              $this.data({"bindEvent_buttonsPixels_y":true});
 469                          }
 470                      }
 471  					function PixelsScrollTo(to){
 472                          if(!mCSB_dragger.data("preventAction")){
 473                              mCSB_dragger.data("preventAction",true);
 474                              $this.mCustomScrollbar("scrollTo",to,{trigger:"internal"});
 475                          }
 476                      }
 477                  }else{ /*continuous scrolling*/
 478                      if($this.data("horizontalScroll")){
 479                          mCSB_buttonRight.add(mCSB_buttonLeft).unbind("click");
 480                          $this.data({"bindEvent_buttonsPixels_x":false});
 481                          if(!$this.data("bindEvent_buttonsContinuous_x")){
 482                              /*scroll right*/
 483                              mCSB_buttonRight.bind("mousedown touchstart MSPointerDown",function(e){
 484                                  e.preventDefault();
 485                                  var scrollButtonsSpeed=ScrollButtonsSpeed();
 486                                  $this.data({"mCSB_buttonScrollRight":setInterval(function(){
 487                                      $this.mCustomScrollbar("scrollTo",Math.abs(mCSB_container.position().left)+scrollButtonsSpeed,{trigger:"internal",scrollEasing:"easeOutCirc"});
 488                                  },17)});
 489                              });
 490                              var mCSB_buttonRight_stop=function(e){
 491                                  e.preventDefault(); clearInterval($this.data("mCSB_buttonScrollRight"));
 492                              }
 493                              mCSB_buttonRight.bind("mouseup touchend MSPointerUp mouseout MSPointerOut",mCSB_buttonRight_stop);
 494                              /*scroll left*/
 495                              mCSB_buttonLeft.bind("mousedown touchstart MSPointerDown",function(e){
 496                                  e.preventDefault();
 497                                  var scrollButtonsSpeed=ScrollButtonsSpeed();
 498                                  $this.data({"mCSB_buttonScrollLeft":setInterval(function(){
 499                                      $this.mCustomScrollbar("scrollTo",Math.abs(mCSB_container.position().left)-scrollButtonsSpeed,{trigger:"internal",scrollEasing:"easeOutCirc"});
 500                                  },17)});
 501                              });    
 502                              var mCSB_buttonLeft_stop=function(e){
 503                                  e.preventDefault(); clearInterval($this.data("mCSB_buttonScrollLeft"));
 504                              }
 505                              mCSB_buttonLeft.bind("mouseup touchend MSPointerUp mouseout MSPointerOut",mCSB_buttonLeft_stop);
 506                              $this.data({"bindEvent_buttonsContinuous_x":true});
 507                          }
 508                      }else{
 509                          mCSB_buttonDown.add(mCSB_buttonUp).unbind("click");
 510                          $this.data({"bindEvent_buttonsPixels_y":false});
 511                          if(!$this.data("bindEvent_buttonsContinuous_y")){
 512                              /*scroll down*/
 513                              mCSB_buttonDown.bind("mousedown touchstart MSPointerDown",function(e){
 514                                  e.preventDefault();
 515                                  var scrollButtonsSpeed=ScrollButtonsSpeed();
 516                                  $this.data({"mCSB_buttonScrollDown":setInterval(function(){
 517                                      $this.mCustomScrollbar("scrollTo",Math.abs(mCSB_container.position().top)+scrollButtonsSpeed,{trigger:"internal",scrollEasing:"easeOutCirc"});
 518                                  },17)});
 519                              });
 520                              var mCSB_buttonDown_stop=function(e){
 521                                  e.preventDefault(); clearInterval($this.data("mCSB_buttonScrollDown"));
 522                              }
 523                              mCSB_buttonDown.bind("mouseup touchend MSPointerUp mouseout MSPointerOut",mCSB_buttonDown_stop);
 524                              /*scroll up*/
 525                              mCSB_buttonUp.bind("mousedown touchstart MSPointerDown",function(e){
 526                                  e.preventDefault();
 527                                  var scrollButtonsSpeed=ScrollButtonsSpeed();
 528                                  $this.data({"mCSB_buttonScrollUp":setInterval(function(){
 529                                      $this.mCustomScrollbar("scrollTo",Math.abs(mCSB_container.position().top)-scrollButtonsSpeed,{trigger:"internal",scrollEasing:"easeOutCirc"});
 530                                  },17)});
 531                              });    
 532                              var mCSB_buttonUp_stop=function(e){
 533                                  e.preventDefault(); clearInterval($this.data("mCSB_buttonScrollUp"));
 534                              }
 535                              mCSB_buttonUp.bind("mouseup touchend MSPointerUp mouseout MSPointerOut",mCSB_buttonUp_stop);
 536                              $this.data({"bindEvent_buttonsContinuous_y":true});
 537                          }
 538                      }
 539  					function ScrollButtonsSpeed(){
 540                          var speed=$this.data("scrollButtons_scrollSpeed");
 541                          if($this.data("scrollButtons_scrollSpeed")==="auto"){
 542                              speed=Math.round(($this.data("scrollInertia")+100)/40);
 543                          }
 544                          return speed;
 545                      }
 546                  }
 547              }
 548              /*scrolling on element focus (e.g. via TAB key)*/
 549              if($this.data("autoScrollOnFocus")){
 550                  if(!$this.data("bindEvent_focusin")){
 551                      mCustomScrollBox.bind("focusin",function(){
 552                          mCustomScrollBox.scrollTop(0).scrollLeft(0);
 553                          var focusedElem=$(document.activeElement);
 554                          if(focusedElem.is("input,textarea,select,button,a[tabindex],area,object")){
 555                              var mCSB_containerPos=mCSB_container.position().top,
 556                                  focusedElemPos=focusedElem.position().top,
 557                                  visibleLimit=mCustomScrollBox.height()-focusedElem.outerHeight();
 558                              if($this.data("horizontalScroll")){
 559                                  mCSB_containerPos=mCSB_container.position().left;
 560                                  focusedElemPos=focusedElem.position().left;
 561                                  visibleLimit=mCustomScrollBox.width()-focusedElem.outerWidth();
 562                              }
 563                              if(mCSB_containerPos+focusedElemPos<0 || mCSB_containerPos+focusedElemPos>visibleLimit){
 564                                  $this.mCustomScrollbar("scrollTo",focusedElemPos,{trigger:"internal"});
 565                              }
 566                          }
 567                      });
 568                      $this.data({"bindEvent_focusin":true});
 569                  }
 570              }
 571              /*auto-hide scrollbar*/
 572              if($this.data("autoHideScrollbar")){
 573                  if(!$this.data("bindEvent_autoHideScrollbar")){
 574                      mCustomScrollBox.bind("mouseenter",function(e){
 575                          mCustomScrollBox.addClass("mCS-mouse-over");
 576                          functions.showScrollbar.call(mCustomScrollBox.children(".mCSB_scrollTools"));
 577                      }).bind("mouseleave touchend",function(e){
 578                          mCustomScrollBox.removeClass("mCS-mouse-over");
 579                          if(e.type==="mouseleave"){functions.hideScrollbar.call(mCustomScrollBox.children(".mCSB_scrollTools"));}
 580                      });
 581                      $this.data({"bindEvent_autoHideScrollbar":true});
 582                  }
 583              }
 584          },
 585          scrollTo:function(scrollTo,options){
 586              var $this=$(this),
 587                  defaults={
 588                      moveDragger:false,
 589                      trigger:"external",
 590                      callbacks:true,
 591                      scrollInertia:$this.data("scrollInertia"),
 592                      scrollEasing:$this.data("scrollEasing")
 593                  },
 594                  options=$.extend(defaults,options),
 595                  draggerScrollTo,
 596                  mCustomScrollBox=$this.children(".mCustomScrollBox"),
 597                  mCSB_container=mCustomScrollBox.children(".mCSB_container"),
 598                  mCSB_scrollTools=mCustomScrollBox.children(".mCSB_scrollTools"),
 599                  mCSB_draggerContainer=mCSB_scrollTools.children(".mCSB_draggerContainer"),
 600                  mCSB_dragger=mCSB_draggerContainer.children(".mCSB_dragger"),
 601                  contentSpeed=draggerSpeed=options.scrollInertia,
 602                  scrollBeginning,scrollBeginningOffset,totalScroll,totalScrollOffset;
 603              $this.data({"mCS_trigger":options.trigger});
 604              if($this.data("mCS_Init")){options.callbacks=false;}
 605              if(scrollTo || scrollTo===0){
 606                  if(typeof(scrollTo)==="number"){ /*if integer, scroll by number of pixels*/
 607                      if(options.moveDragger){ /*scroll dragger*/
 608                          draggerScrollTo=scrollTo;
 609                          if($this.data("horizontalScroll")){
 610                              scrollTo=mCSB_dragger.position().left*$this.data("scrollAmount");
 611                          }else{
 612                              scrollTo=mCSB_dragger.position().top*$this.data("scrollAmount");
 613                          }
 614                          draggerSpeed=0;
 615                      }else{ /*scroll content by default*/
 616                          draggerScrollTo=scrollTo/$this.data("scrollAmount");
 617                      }
 618                  }else if(typeof(scrollTo)==="string"){ /*if string, scroll by element position*/
 619                      var target;
 620                      if(scrollTo==="top"){ /*scroll to top*/
 621                          target=0;
 622                      }else if(scrollTo==="bottom" && !$this.data("horizontalScroll")){ /*scroll to bottom*/
 623                          target=mCSB_container.outerHeight()-mCustomScrollBox.height();
 624                      }else if(scrollTo==="left"){ /*scroll to left*/
 625                          target=0;
 626                      }else if(scrollTo==="right" && $this.data("horizontalScroll")){ /*scroll to right*/
 627                          target=mCSB_container.outerWidth()-mCustomScrollBox.width();
 628                      }else if(scrollTo==="first"){ /*scroll to first element position*/
 629                          target=$this.find(".mCSB_container").find(":first");
 630                      }else if(scrollTo==="last"){ /*scroll to last element position*/
 631                          target=$this.find(".mCSB_container").find(":last");
 632                      }else{ /*scroll to element position*/
 633                          target=$this.find(scrollTo);
 634                      }
 635                      if(target.length===1){ /*if such unique element exists, scroll to it*/
 636                          if($this.data("horizontalScroll")){
 637                              scrollTo=target.position().left;
 638                          }else{
 639                              scrollTo=target.position().top;
 640                          }
 641                          draggerScrollTo=scrollTo/$this.data("scrollAmount");
 642                      }else{
 643                          draggerScrollTo=scrollTo=target;
 644                      }
 645                  }
 646                  /*scroll to*/
 647                  if($this.data("horizontalScroll")){
 648                      if($this.data("onTotalScrollBack_Offset")){ /*scroll beginning offset*/
 649                          scrollBeginningOffset=-$this.data("onTotalScrollBack_Offset");
 650                      }
 651                      if($this.data("onTotalScroll_Offset")){ /*total scroll offset*/
 652                          totalScrollOffset=mCustomScrollBox.width()-mCSB_container.outerWidth()+$this.data("onTotalScroll_Offset");
 653                      }
 654                      if(draggerScrollTo<0){ /*scroll start position*/
 655                          draggerScrollTo=scrollTo=0; clearInterval($this.data("mCSB_buttonScrollLeft"));
 656                          if(!scrollBeginningOffset){scrollBeginning=true;}
 657                      }else if(draggerScrollTo>=mCSB_draggerContainer.width()-mCSB_dragger.width()){ /*scroll end position*/
 658                          draggerScrollTo=mCSB_draggerContainer.width()-mCSB_dragger.width();
 659                          scrollTo=mCustomScrollBox.width()-mCSB_container.outerWidth(); clearInterval($this.data("mCSB_buttonScrollRight"));
 660                          if(!totalScrollOffset){totalScroll=true;}
 661                      }else{scrollTo=-scrollTo;}
 662                      /*scrolling animation*/
 663                      functions.mTweenAxis.call(this,mCSB_dragger[0],"left",Math.round(draggerScrollTo),draggerSpeed,options.scrollEasing);
 664                      functions.mTweenAxis.call(this,mCSB_container[0],"left",Math.round(scrollTo),contentSpeed,options.scrollEasing,{
 665                          onStart:function(){
 666                              if(options.callbacks && !$this.data("mCS_tweenRunning")){callbacks("onScrollStart");}
 667                              if($this.data("autoHideScrollbar")){functions.showScrollbar.call(mCSB_scrollTools);}
 668                          },
 669                          onUpdate:function(){
 670                              if(options.callbacks){callbacks("whileScrolling");}
 671                          },
 672                          onComplete:function(){
 673                              if(options.callbacks){
 674                                  callbacks("onScroll");
 675                                  if(scrollBeginning || (scrollBeginningOffset && mCSB_container.position().left>=scrollBeginningOffset)){callbacks("onTotalScrollBack");}
 676                                  if(totalScroll || (totalScrollOffset && mCSB_container.position().left<=totalScrollOffset)){callbacks("onTotalScroll");}
 677                              }
 678                              mCSB_dragger.data("preventAction",false); $this.data("mCS_tweenRunning",false);
 679                              if($this.data("autoHideScrollbar")){if(!mCustomScrollBox.hasClass("mCS-mouse-over")){functions.hideScrollbar.call(mCSB_scrollTools);}}
 680                          },
 681                      });
 682                  }else{
 683                      if($this.data("onTotalScrollBack_Offset")){ /*scroll beginning offset*/
 684                          scrollBeginningOffset=-$this.data("onTotalScrollBack_Offset");
 685                      }
 686                      if($this.data("onTotalScroll_Offset")){ /*total scroll offset*/
 687                          totalScrollOffset=mCustomScrollBox.height()-mCSB_container.outerHeight()+$this.data("onTotalScroll_Offset");
 688                      }
 689                      if(draggerScrollTo<0){ /*scroll start position*/
 690                          draggerScrollTo=scrollTo=0; clearInterval($this.data("mCSB_buttonScrollUp"));
 691                          if(!scrollBeginningOffset){scrollBeginning=true;}
 692                      }else if(draggerScrollTo>=mCSB_draggerContainer.height()-mCSB_dragger.height()){ /*scroll end position*/
 693                          draggerScrollTo=mCSB_draggerContainer.height()-mCSB_dragger.height();
 694                          scrollTo=mCustomScrollBox.height()-mCSB_container.outerHeight(); clearInterval($this.data("mCSB_buttonScrollDown"));
 695                          if(!totalScrollOffset){totalScroll=true;}
 696                      }else{scrollTo=-scrollTo;}
 697                      /*scrolling animation*/
 698                      functions.mTweenAxis.call(this,mCSB_dragger[0],"top",Math.round(draggerScrollTo),draggerSpeed,options.scrollEasing);
 699                      functions.mTweenAxis.call(this,mCSB_container[0],"top",Math.round(scrollTo),contentSpeed,options.scrollEasing,{
 700                          onStart:function(){
 701                              if(options.callbacks && !$this.data("mCS_tweenRunning")){callbacks("onScrollStart");}
 702                              if($this.data("autoHideScrollbar")){functions.showScrollbar.call(mCSB_scrollTools);}
 703                          },
 704                          onUpdate:function(){
 705                              if(options.callbacks){callbacks("whileScrolling");}
 706                          },
 707                          onComplete:function(){
 708                              if(options.callbacks){
 709                                  callbacks("onScroll");
 710                                  if(scrollBeginning || (scrollBeginningOffset && mCSB_container.position().top>=scrollBeginningOffset)){callbacks("onTotalScrollBack");}
 711                                  if(totalScroll || (totalScrollOffset && mCSB_container.position().top<=totalScrollOffset)){callbacks("onTotalScroll");}
 712                              }
 713                              mCSB_dragger.data("preventAction",false); $this.data("mCS_tweenRunning",false);
 714                              if($this.data("autoHideScrollbar")){if(!mCustomScrollBox.hasClass("mCS-mouse-over")){functions.hideScrollbar.call(mCSB_scrollTools);}}
 715                          },
 716                      });
 717                  }
 718                  if($this.data("mCS_Init")){$this.data({"mCS_Init":false});}
 719              }
 720              /*callbacks*/
 721  			function callbacks(cb){
 722                  this.mcs={
 723                      top:mCSB_container.position().top,left:mCSB_container.position().left,
 724                      draggerTop:mCSB_dragger.position().top,draggerLeft:mCSB_dragger.position().left,
 725                      topPct:Math.round((100*Math.abs(mCSB_container.position().top))/Math.abs(mCSB_container.outerHeight()-mCustomScrollBox.height())),
 726                      leftPct:Math.round((100*Math.abs(mCSB_container.position().left))/Math.abs(mCSB_container.outerWidth()-mCustomScrollBox.width()))
 727                  };
 728                  switch(cb){
 729                      /*start scrolling callback*/
 730                      case "onScrollStart":
 731                          $this.data("mCS_tweenRunning",true).data("onScrollStart_Callback").call($this,this.mcs);
 732                          break;
 733                      case "whileScrolling":
 734                          $this.data("whileScrolling_Callback").call($this,this.mcs);
 735                          break;
 736                      case "onScroll":
 737                          $this.data("onScroll_Callback").call($this,this.mcs);
 738                          break;
 739                      case "onTotalScrollBack":
 740                          $this.data("onTotalScrollBack_Callback").call($this,this.mcs);
 741                          break;
 742                      case "onTotalScroll":
 743                          $this.data("onTotalScroll_Callback").call($this,this.mcs);
 744                          break;
 745                  }
 746              }
 747          },
 748          stop:function(){
 749              var $this=$(this),
 750                  mCSB_container=$this.children().children(".mCSB_container"),
 751                  mCSB_dragger=$this.children().children().children().children(".mCSB_dragger");
 752              functions.mTweenAxisStop.call(this,mCSB_container[0]);
 753              functions.mTweenAxisStop.call(this,mCSB_dragger[0]);
 754          },
 755          disable:function(resetScroll){
 756              var $this=$(this),
 757                  mCustomScrollBox=$this.children(".mCustomScrollBox"),
 758                  mCSB_container=mCustomScrollBox.children(".mCSB_container"),
 759                  mCSB_scrollTools=mCustomScrollBox.children(".mCSB_scrollTools"),
 760                  mCSB_dragger=mCSB_scrollTools.children().children(".mCSB_dragger");
 761              mCustomScrollBox.unbind("mousewheel focusin mouseenter mouseleave touchend");
 762              mCSB_container.unbind("touchstart touchmove")
 763              if(resetScroll){
 764                  if($this.data("horizontalScroll")){
 765                      mCSB_dragger.add(mCSB_container).css("left",0);
 766                  }else{
 767                      mCSB_dragger.add(mCSB_container).css("top",0);
 768                  }
 769              }
 770              mCSB_scrollTools.css("display","none");
 771              mCSB_container.addClass("mCS_no_scrollbar");
 772              $this.data({"bindEvent_mousewheel":false,"bindEvent_focusin":false,"bindEvent_content_touch":false,"bindEvent_autoHideScrollbar":false}).addClass("mCS_disabled");
 773          },
 774          destroy:function(){
 775              var $this=$(this);
 776              $this.removeClass("mCustomScrollbar _mCS_"+$this.data("mCustomScrollbarIndex")).addClass("mCS_destroyed").children().children(".mCSB_container").unwrap().children().unwrap().siblings(".mCSB_scrollTools").remove();
 777              $(document).unbind("mousemove."+$this.data("mCustomScrollbarIndex")+" mouseup."+$this.data("mCustomScrollbarIndex")+" MSPointerMove."+$this.data("mCustomScrollbarIndex")+" MSPointerUp."+$this.data("mCustomScrollbarIndex"));
 778              $(window).unbind("resize."+$this.data("mCustomScrollbarIndex"));
 779          }
 780      },
 781      functions={
 782          /*hide/show scrollbar*/
 783          showScrollbar:function(){
 784              this.stop().animate({opacity:1},"fast");
 785          },
 786          hideScrollbar:function(){
 787              this.stop().animate({opacity:0},"fast");
 788          },
 789          /*js animation tween*/
 790          mTweenAxis:function(el,prop,to,duration,easing,callbacks){
 791              var callbacks=callbacks || {},
 792                  onStart=callbacks.onStart || function(){},onUpdate=callbacks.onUpdate || function(){},onComplete=callbacks.onComplete || function(){};
 793              var startTime=_getTime(),_delay,progress=0,from=el.offsetTop,elStyle=el.style;
 794              if(prop==="left"){from=el.offsetLeft;}
 795              var diff=to-from;
 796              _cancelTween();
 797              _startTween();
 798  			function _getTime(){
 799                  if(window.performance && window.performance.now){
 800                      return window.performance.now();
 801                  }else{
 802                      if(window.performance && window.performance.webkitNow){
 803                          return window.performance.webkitNow();
 804                      }else{
 805                          if(Date.now){return Date.now();}else{return new Date().getTime();}
 806                      }
 807                  }
 808              }
 809  			function _step(){
 810                  if(!progress){onStart.call();}
 811                  progress=_getTime()-startTime;
 812                  _tween();
 813                  if(progress>=el._time){
 814                      el._time=(progress>el._time) ? progress+_delay-(progress- el._time) : progress+_delay-1;
 815                      if(el._time<progress+1){el._time=progress+1;}
 816                  }
 817                  if(el._time<duration){el._id=_request(_step);}else{onComplete.call();}
 818              }
 819  			function _tween(){
 820                  if(duration>0){
 821                      el.currVal=_ease(el._time,from,diff,duration,easing);
 822                      elStyle[prop]=Math.round(el.currVal)+"px";
 823                  }else{
 824                      elStyle[prop]=to+"px";
 825                  }
 826                  onUpdate.call();
 827              }
 828  			function _startTween(){
 829                  _delay=1000/60;
 830                  el._time=progress+_delay;
 831                  _request=(!window.requestAnimationFrame) ? function(f){_tween(); return setTimeout(f,0.01);} : window.requestAnimationFrame;
 832                  el._id=_request(_step);
 833              }
 834  			function _cancelTween(){
 835                  if(el._id==null){return;}
 836                  if(!window.requestAnimationFrame){clearTimeout(el._id);
 837                  }else{window.cancelAnimationFrame(el._id);}
 838                  el._id=null;
 839              }
 840  			function _ease(t,b,c,d,type){
 841                  switch(type){
 842                      case "linear":
 843                          return c*t/d + b;
 844                          break;
 845                      case "easeOutQuad":
 846                          t /= d; return -c * t*(t-2) + b;
 847                          break;
 848                      case "easeInOutQuad":
 849                          t /= d/2;
 850                          if (t < 1) return c/2*t*t + b;
 851                          t--;
 852                          return -c/2 * (t*(t-2) - 1) + b;
 853                          break;
 854                      case "easeOutCubic":
 855                          t /= d; t--; return c*(t*t*t + 1) + b;
 856                          break;
 857                      case "easeOutQuart":
 858                          t /= d; t--; return -c * (t*t*t*t - 1) + b;
 859                          break;
 860                      case "easeOutQuint":
 861                          t /= d; t--; return c*(t*t*t*t*t + 1) + b;
 862                          break;
 863                      case "easeOutCirc":
 864                          t /= d; t--; return c * Math.sqrt(1 - t*t) + b;
 865                          break;
 866                      case "easeOutSine":
 867                          return c * Math.sin(t/d * (Math.PI/2)) + b;
 868                          break;
 869                      case "easeOutExpo":
 870                          return c * ( -Math.pow( 2, -10 * t/d ) + 1 ) + b;
 871                          break;
 872                      case "mcsEaseOut":
 873                          var ts=(t/=d)*t,tc=ts*t;
 874                          return b+c*(0.499999999999997*tc*ts + -2.5*ts*ts + 5.5*tc + -6.5*ts + 4*t);
 875                          break;
 876                      case "draggerRailEase":
 877                          t /= d/2;
 878                          if (t < 1) return c/2*t*t*t + b;
 879                          t -= 2;
 880                          return c/2*(t*t*t + 2) + b;
 881                          break;
 882                  }
 883              }
 884          },
 885          /*stop js animation tweens*/
 886          mTweenAxisStop:function(el){
 887              if(el._id==null){return;}
 888              if(!window.requestAnimationFrame){clearTimeout(el._id);
 889              }else{window.cancelAnimationFrame(el._id);}
 890              el._id=null;
 891          },
 892          /*detect requestAnimationFrame and polyfill*/
 893          rafPolyfill:function(){
 894              var pfx=["ms","moz","webkit","o"],i=pfx.length;
 895              while(--i > -1 && !window.requestAnimationFrame){
 896                  window.requestAnimationFrame=window[pfx[i]+"RequestAnimationFrame"];
 897                  window.cancelAnimationFrame=window[pfx[i]+"CancelAnimationFrame"] || window[pfx[i]+"CancelRequestAnimationFrame"];
 898              }
 899          }
 900      }
 901      /*detect features*/
 902      functions.rafPolyfill.call(); /*requestAnimationFrame*/
 903      $.support.touch=!!('ontouchstart' in window); /*touch*/
 904      $.support.msPointer=window.navigator.msPointerEnabled; /*MSPointer support*/
 905      /*plugin dependencies*/
 906      var _dlp=("https:"==document.location.protocol) ? "https:" : "http:";
 907      $.event.special.mousewheel || document.write('<script src="'+_dlp+'//cdnjs.cloudflare.com/ajax/libs/jquery-mousewheel/3.0.6/jquery.mousewheel.min.js"><\/script>');
 908      /*plugin fn*/
 909      $.fn.mCustomScrollbar=function(method){
 910          if(methods[method]){
 911              return methods[method].apply(this,Array.prototype.slice.call(arguments,1));
 912          }else if(typeof method==="object" || !method){
 913              return methods.init.apply(this,arguments);
 914          }else{
 915              $.error("Method "+method+" does not exist");
 916          }
 917      };
 918  })(jQuery);


Generated: Fri Nov 28 20:08:37 2014 Cross-referenced by PHPXref 0.7.1