<commit_before>/*!
 * Miniscroll small plugin of scrollbar desktop and mobile
 *
 * @author <NAME> <http://rogerluizm.com.br/>
 *					  <http://miniscroll.rogerluizm.com.br>
 *
 * @copyright (c) 2011, 2012 <http://rogerluizm.com.br/>
 *
 * @version 1.2.9
 *		update 1.2.9 | 10/09/2013 - fix multidimensional scrollwheel
 *		update 1.2.9 | 10/09/2013 - fix error in the scroll when the position is relative or absolute
 *		update 1.2.9 | 10/09/2013 - fix updating on the x axis
 *		update 1.2.8 | 03/09/2013 - add turn off mousewheel, ex: { mousewheel: true }
 *		update 1.2.7 | 03/09/2013 - add scrollTo, now its posible scroll to a custom position
 *		update 1.2.6 | 21/06/2013 - fix bug the whole scrollbar (not just the handler part) moves down when I drag it.
 *		update 1.2.5 | 18/05/2013 - fix bug thumb position with arrow keys
 * 		update 1.2.4 | 18/05/2013 - fix error it's time to catching the width and height
 * 		update 1.2.3 | 18/05/2013 - fix scrollbar position "x"
 * 		update 1.2.2 | 17/05/2013 - Key event added, now you can press the key down and key up for scrolling
 * 		update 1.2.1 | 15/05/2013 - Touch event added, now works for ipad, iphone and android
 */
(function(window,document,prototype){var config={touchEvents:("ontouchstart" in document.documentElement)},Miniscroll=function(selector,options){this.type="";this.is="static";this.target=this.getElement(selector);this.container;this.tracker;this.thumb;this.thumb_delta=new Point(0,0);this.thumb_pos=new Point(0,0);this.touch=new Point(0,0);this.settings=options;this.percent;this.keypos_thumb=new Point(0,0);this.scrolling=false;this.preventScrolling=false;this.turnOffWheel=true;this.initializing()},Point=function(x,y){this.x=x!=null?x:0;this.y=y!=null?y:0;return{x:this.x,y:this.y}};Miniscroll[prototype].initializing=function(){this.buildScrollbar();this.buildScrollbarTracker();this.buildScrolbarThumb();this.settings.isKeyEvent=(typeof this.settings.isKeyEvent==="undefined")?true:this.settings.isKeyEvent;this.turnOffWheel=(typeof this.settings.turnOffWheel==="undefined")?this.turnOffWheel:this.settings.turnOffWheel;if(this.settings.isKeyEvent){this.addKeyBoardEvent()}(!config.touchEvents)?this.setupEventHandler():this.setupTouchEvent();var _this=this;window.setInterval(function(){_this.update()},10)};Miniscroll[prototype].buildScrollbar=function(){var idname=(this.target.id)?this.target.id:this.target.className;this.container=this.create(this.target,"div",{"class":"miniscroll-container",id:"miniscroll-"+idname});var scrollHeight=(this.settings.scrollbarSize)?this.settings.scrollbarSize:this.offset(this.target).height;var scrollWidth=(this.settings.scrollbarSize)?this.settings.scrollbarSize:this.offset(this.target).width;var scrollX=this.offset(this.target).left+(this.offset(this.target).width-this.settings.size);var scrollY=this.offset(this.target).top+(this.offset(this.target).height-this.settings.size);this.css(this.container,{position:"absolute",visibility:"hidden",width:((this.settings.axis==="x")?scrollWidth:this.settings.size)+"px",height:((this.settings.axis==="y")?scrollHeight:this.settings.size)+"px",top:((this.settings.axis==="y")?this.offset(this.target).top:scrollY)+"px",left:((this.settings.axis==="x")?this.offset(this.target).left:scrollX)+"px",zIndex:999})};Miniscroll[prototype].buildScrollbarTracker=function(){this.tracker=this.create(this.container,"div",{"class":"miniscroll-tracker"});var trackerWidth=(this.settings.axis==="x")?this.offset(this.container).width:this.settings.size;var trackerHeight=(this.settings.axis==="y")?this.offset(this.container).height:this.settings.size;this.css(this.tracker,{width:trackerWidth+"px",height:trackerHeight+"px",backgroundColor:this.settings.trackerColor?this.settings.trackerColor:"#067f41"})};Miniscroll[prototype].buildScrolbarThumb=function(){this.thumb=this.create(this.container,"div",{"class":"miniscroll-thumb"});var offset=new Point((this.offset(this.container).width*this.offset(this.tracker).width)/this.target.scrollWidth,(this.offset(this.container).height*this.offset(this.tracker).height)/this.target.scrollHeight);var offset=new Point((this.offset(this.container).width*this.offset(this.tracker).width)/this.target.scrollWidth,(this.offset(this.container).height*this.offset(this.tracker).height)/this.target.scrollHeight);var thumbSize=new Point((this.settings.sizethumb===undefined||this.settings.sizethumb==="auto")?offset.x:this.settings.sizethumb,(this.settings.sizethumb===undefined||this.settings.sizethumb==="auto")?offset.y:this.settings.sizethumb);this.css(this.thumb,{position:"absolute",top:0+"px",left:0+"px",width:((this.settings.axis==="x")?thumbSize.x:this.settings.size)+"px",height:((this.settings.axis==="y")?thumbSize.y:this.settings.size)+"px",backgroundColor:this.settings.thumbColor?this.settings.thumbColor:"#2AD47D"})};Miniscroll[prototype].setupEventHandler=function(){this.bind(this.thumb,"mousedown",this.onScrollThumbPress);this.bind(this.tracker,"mousedown",this.onScrollTrackerPress);if(this.turnOffWheel){this.bind(this.target,"mousewheel",this.onScrollThumbWheel)}};Miniscroll[prototype].setupTouchEvent=function(){this.bind(this.target,"touchstart",this.onScrollTouchStart);this.bind(this.target,"touchmove",this.onScrollTouchMove)};Miniscroll[prototype].updateContainerPosition=function(){this.is=this.getCss(this.target,"position");if(this.is==="relative"||this.is==="absolute"){if(this.settings.axis==="y"){this.container.style.top=this.target.scrollTop+"px";this.container.style.left=(this.offset(this.target).width-this.settings.size)+"px"}else{this.container.style.top=(this.offset(this.target).height-this.settings.size)+"px";this.container.style.left=this.target.scrollLeft+"px"}}else{if(this.settings.axis==="y"){this.container.style.top=this.offset(this.target).top+"px"}else{this.container.style.left=this.offset(this.target).left+"px"}}};Miniscroll[prototype].setScrubPosition=function(percent){var container_width=this.offset(this.container).width,container_height=this.offset(this.container).height;var thumb_width=this.offset(this.thumb).width,thumb_height=this.offset(this.thumb).height;this.thumb_pos=new Point(Math.round((container_width-thumb_width)*percent),Math.round((container_height-thumb_height)*percent));if(this.settings.axis==="y"){this.thumb.style.top=Math.round(this.thumb_pos.y)+"px"}else{this.thumb.style.left=Math.round(this.thumb_pos.x)+"px"}};Miniscroll[prototype].addKeyBoardEvent=function(){this.target.setAttribute("tabindex","-1");this.css(this.target,{outline:"none"});this.bind(this.target,"focus",function(event,el){if(!("onkeydown" in el)&&("onkeydown" in document)){el=document}this.bind(el,"keydown",function(event){var keyCode=event.keyCode||event.which,arrow={left:37,up:38,right:39,down:40};switch(keyCode){case arrow.up:if(this.percent!==0){this.keypos_thumb.y-=10}break;case arrow.down:if(this.percent!==1){this.keypos_thumb.y+=10}break;case arrow.left:if(this.percent!==0){this.keypos_thumb.x-=10}break;case arrow.right:if(this.percent!==1){this.keypos_thumb.x+=10}break}if(this.settings.axis==="y"){this.percent=this.target.scrollTop/(this.target.scrollHeight-this.target.offsetHeight);this.setScrubPosition(this.percent);this.target.scrollTop=this.keypos_thumb.y}else{this.percent=this.target.scrollLeft/(this.target.scrollWidth-this.target.offsetWidth);this.setScrubPosition(this.percent);this.target.scrollLeft=this.keypos_thumb.x}if(this.percent>=1||this.percent<=0){this.preventScrolling=true}else{this.preventScrolling=false}this.updateContainerPosition()})});this.bind(this.target,"click",function(event,el){try{document.activeElement=el}catch(err){}el.focus()})};Miniscroll[prototype].onScrollTouchStart=function(event){var touches=event.touches[0];this.scrolling=true;this.touch=new Point(touches.pageX,touches.pageY);this.bind(this.target,"touchend",this.onScrollTouchEnd)};Miniscroll[prototype].onScrollTouchMove=function(event){var touches=event.touches[0];event.preventDefault();var touchMoved=new Point(this.touch.x-touches.pageX,this.touch.y-touches.pageY);this.touch=new Point(touches.pageX,touches.pageY);if(this.settings.axis==="y"){this.percent=this.target.scrollTop/(this.target.scrollHeight-this.target.offsetHeight);this.setScrubPosition(this.percent);this.target.scrollTop=this.target.scrollTop+touchMoved.y}else{this.percent=this.target.scrollLeft/(this.target.scrollWidth-this.target.offsetWidth);this.setScrubPosition(this.percent);this.target.scrollLeft=this.target.scrollLeft+touchMoved.x}this.updateContainerPosition()};Miniscroll[prototype].onScrollTouchEnd=function(event){this.scrolling=false;this.unbind(this.target,"touchend",this.onScrollTouchEnd)};Miniscroll[prototype].onScrollThumbPress=function(event){event=event?event:window.event;this.stopEvent(event);this.scrolling=true;this.thumb_delta=new Point(this.thumb_pos.x-this.mouse(event).x,this.thumb_pos.y-this.mouse(event).y);this.bind(document,"mousemove",this.onScrollThumbUpdate);this.bind(document,"mouseup",this.onScrollThumbRelease);this.updateContainerPosition()};Miniscroll[prototype].onScrollThumbUpdate=function(event){event=event?event:window.event;this.stopEvent(event);if(!this.scrolling){return false}this.thumb_pos=new Point(this.mouse(event).x+this.thumb_delta.x,this.mouse(event).y+this.thumb_delta.y);this.thumb_pos=new Point(Math.max(0,Math.min(this.container.offsetWidth-this.thumb.offsetWidth,this.thumb_pos.x)),Math.max(0,Math.min(this.container.offsetHeight-this.thumb.offsetHeight,this.thumb_pos.y)));this.percent=new Point(this.thumb_pos.x/(this.container.offsetWidth-this.thumb.offsetWidth),this.thumb_pos.y/(this.container.offsetHeight-this.thumb.offsetHeight));this.percent=new Point(Math.max(0,Math.min(1,this.percent.x)),Math.max(0,Math.min(1,this.percent.y)));if(this.settings.axis==="y"){this.thumb.style.top=Math.round(this.thumb_pos.y)+"px";this.target.scrollTop=Math.round((this.target.scrollHeight-this.target.offsetHeight)*this.percent.y)}else{this.thumb.style.left=Math.round(this.thumb_pos.x)+"px";this.target.scrollLeft=Math.round((this.target.scrollWidth-this.target.offsetWidth)*this.percent.x)}this.keypos_thumb=new Point(this.target.scrollLeft,this.target.scrollTop);this.updateContainerPosition()};Miniscroll[prototype].onScrollThumbWheel=function(event){event=event?event:window.event;if(!this.preventScrolling){this.stopEvent(event)}var orgEvent=event||window.event,args=[].slice.call(arguments,1),delta=0,returnValue=true,deltaX=0,deltaY=0;if(orgEvent.wheelDelta){delta=orgEvent.wheelDelta/120}if(orgEvent.detail){delta=-orgEvent.detail/3}deltaY=delta;deltaX=delta;if(orgEvent.axis!==undefined&&orgEvent.axis===orgEvent.HORIZONTAL_AXIS){deltaY=0;deltaX=-1*delta}if(orgEvent.wheelDeltaY!==undefined){deltaY=orgEvent.wheelDeltaY/120}if(orgEvent.wheelDeltaX!==undefined){deltaX=-1*orgEvent.wheelDeltaX/120}if(this.settings.axis==="y"){this.percent=this.target.scrollTop/(this.target.scrollHeight-this.target.offsetHeight);this.setScrubPosition(this.percent);this.target.scrollTop=Math.round(this.target.scrollTop-(deltaY*10))}else{this.percent=this.target.scrollLeft/(this.target.scrollWidth-this.target.offsetWidth);this.setScrubPosition(this.percent);this.target.scrollLeft=Math.round(this.target.scrollLeft-(deltaX*10))}if(this.percent>=1||this.percent<=0){this.preventScrolling=true}else{this.preventScrolling=false}if(orgEvent.wheelDeltaY!==undefined){}this.keypos_thumb=new Point(this.target.scrollLeft,this.target.scrollTop);this.updateContainerPosition()};Miniscroll[prototype].onScrollThumbRelease=function(event){event=event?event:window.event;this.stopEvent(event);this.scrolling=false;this.unbind(document,"mousemove",this.onScrollThumbUpdate);this.unbind(document,"mouseup",this.onScrollThumbRelease)};Miniscroll[prototype].onScrollTrackerPress=function(event){var mouseY=this.mouse(event).y-this.offset(this.container).top;this.scrolling=true;this.scrollTo(mouseY)};Miniscroll[prototype].scrollTo=function(value){var scrollY=Math.max(0,Math.min(this.offset(this.target).height-this.offset(this.thumb).height,value));if(this.settings.axis==="y"){this.thumb_pos.y=scrollY;this.thumb.style.top=Math.round(this.thumb_pos.y)+"px";this.target.scrollTop=scrollY;this.scrolling=false}};Miniscroll[prototype].update=function(){if(this.settings.axis==="y"){if(this.target.scrollHeight===this.offset(this.target).height){this.css(this.container,{visibility:"hidden"})}else{this.css(this.container,{visibility:"visible"})}}else{if(this.target.scrollWidth===this.offset(this.target).width){this.css(this.container,{visibility:"hidden"})}else{this.css(this.container,{visibility:"visible"})}}var scrollHeight=(this.settings.scrollbarSize)?this.settings.scrollbarSize:this.offset(this.target).height;var scrollWidth=(this.settings.scrollbarSize)?this.settings.scrollbarSize:this.offset(this.target).width;var scrollX=this.offset(this.target).left+(this.offset(this.target).width-this.settings.size);var scrollY=this.offset(this.target).top+(this.offset(this.target).height-this.settings.size);this.css(this.container,{width:((this.settings.axis==="x")?scrollWidth:this.settings.size)+"px",height:((this.settings.axis==="y")?scrollHeight:this.settings.size)+"px",top:((this.settings.axis==="y")?this.offset(this.target).top:scrollY)+"px",left:((this.settings.axis==="x")?this.offset(this.target).left:scrollX)+"px"});var trackerWidth=(this.settings.axis==="x")?this.offset(this.container).width:this.settings.size;var trackerHeight=(this.settings.axis==="y")?this.offset(this.container).height:this.settings.size;this.css(this.tracker,{width:trackerWidth+"px",height:trackerHeight+"px"});var offset=new Point((this.offset(this.container).width*this.offset(this.tracker).width)/this.target.scrollWidth,(this.offset(this.container).height*this.offset(this.tracker).height)/this.target.scrollHeight);var thumbSize=new Point((this.settings.sizethumb===undefined||this.settings.sizethumb==="auto")?offset.x:this.settings.sizethumb,(this.settings.sizethumb===undefined||this.settings.sizethumb==="auto")?offset.y:this.settings.sizethumb);this.css(this.thumb,{width:((this.settings.axis==="x")?thumbSize.x:this.settings.size)+"px",height:((this.settings.axis==="y")?thumbSize.y:this.settings.size)+"px"});if(this.settings.axis==="y"){this.percent=this.target.scrollTop/(this.target.scrollHeight-this.target.offsetHeight);if(!this.scrolling){this.setScrubPosition(this.percent)}}else{this.percent=this.target.scrollLeft/(this.target.scrollWidth-this.target.offsetWidth);if(!this.scrolling){this.setScrubPosition(this.percent)}}this.updateContainerPosition()};Miniscroll[prototype].getElement=function(selector){var element,$=this;if(selector===window||selector===document||selector==="body"||selector==="body, html"){return document.body}if(typeof selector==="string"||selector instanceof String){var token=selector.replace(/^\s+/,"").replace(/\s+$/,""),element;if(token.indexOf("#")>-1){this.type="id";var match=token.split("#");element=document.getElementById(match[1])}if(token.indexOf(".")>-1){this.type="class";var match=token.split("."),tags=document.getElementsByTagName("*"),len=tags.length,found=[],count=0;for(var i=0;i<len;i++){if(tags[i].className&&tags[i].className.match(new RegExp("(^|\\s)"+match[1]+"(\\s|$)"))){element=tags[i]}}}return element}else{return selector}};Miniscroll[prototype].create=function(element,tagName,attrs){var tag=document.createElement(tagName);if(attrs){for(var key in attrs){if(attrs.hasOwnProperty(key)){tag.setAttribute(key,attrs[key])}}element.appendChild(tag)}return tag};Miniscroll[prototype].css=function(element,arguments){for(var prop in arguments){if(prop==="opacity"){element.style.filter="alpha(opacity="+(arguments[prop]*100)+")";element.style.KhtmlOpacity=arguments[prop];element.style.MozOpacity=arguments[prop];element.style.opacity=arguments[prop]}else{element.style[prop]=arguments[prop]}}};Miniscroll[prototype].getCss=function(element,property){var result;if(!window.getComputedStyle){if(document.defaultView&&document.defaultView.getComputedStyle){result=document.defaultView.getComputedStyle.getPropertyValue(property)}else{if(element.currentStyle){result=element.currentStyle[property]}else{result=element.style[property]}}}else{result=window.getComputedStyle(element).getPropertyValue(property)}return result};Miniscroll[prototype].offset=function(element){var top=element.offsetTop,left=element.offsetLeft;var height=element.offsetHeight;if(typeof element.offsetHeight==="undefined"){height=parseInt(this.getCss(element,"height"))}var width=element.offsetWidth;if(typeof element.offsetWidth==="undefined"){width=parseInt(this.getCss(element,"width"))}return{top:top,left:left,width:width,height:height}};Miniscroll[prototype].mouse=function(event){var posx=0,posy=0;if(event.pageX||event.pageY){posx=event.pageX;posy=event.pageY}else{if(event.clientX||event.clientY){posx=event.clientX+document.body.scrollLeft+document.documentElement.scrollLeft;posy=event.clientY+document.body.scrollTop+document.documentElement.scrollTop}}return{x:posx,y:posy}};Miniscroll[prototype].bind=function(element,eventType,callback){var mousewheel=(/Firefox/i.test(navigator.userAgent))?"DOMMouseScroll":"mousewheel";var _this=this;if(element.addEventListener){if(eventType==="mousewheel"){element.addEventListener(mousewheel,function(event){callback.call(_this,event,this)},false)}else{element.addEventListener(eventType,function(event){callback.call(_this,event,this)},false)}}else{if(element.attachEvent){element.attachEvent("on"+eventType,function(event){callback.call(_this,event,this)})}else{element["on"+eventType]=function(event){callback.call(_this,event,this)}}}};Miniscroll[prototype].unbind=function(element,eventType,callback){var mousewheel=(/Firefox/i.test(navigator.userAgent))?"DOMMouseScroll":"mousewheel";if(element.addEventListener){if(eventType==="mousewheel"){element.removeEventListener(mousewheel,function(event){callback.call(_this,event,this)},false)}else{element.removeEventListener(eventType,function(event){callback.call(_this,event,this)},false)}}else{if(element.attachEvent){element.detachEvent("on"+eventType,function(event){callback.call(_this,event,this)})}else{element["on"+eventType]=null}}};Miniscroll[prototype].stopEvent=function(event){if(event.stopPropagation){event.stopPropagation()}else{event.cancelBubble=true}if(event.preventDefault){event.preventDefault()}else{event.returnValue=false}};window.Miniscroll=Miniscroll})(window,document,"prototype");<commit_msg>Update Point function<commit_after>/*!
 * Miniscroll small plugin of scrollbar desktop and mobile
 *
 * @author <NAME> <http://rogerluizm.com.br/>
 *					  <http://miniscroll.rogerluizm.com.br>
 *
 * @copyright (c) 2011, 2012 <http://rogerluizm.com.br/>
 *
 * @version 1.2.9
 *		update 1.2.9 | 10/09/2013 - fix multidimensional scrollwheel
 *		update 1.2.9 | 10/09/2013 - fix error in the scroll when the position is relative or absolute
 *		update 1.2.9 | 10/09/2013 - fix updating on the x axis
 *		update 1.2.8 | 03/09/2013 - add turn off mousewheel, ex: { mousewheel: true }
 *		update 1.2.7 | 03/09/2013 - add scrollTo, now its posible scroll to a custom position
 *		update 1.2.6 | 21/06/2013 - fix bug the whole scrollbar (not just the handler part) moves down when I drag it.
 *		update 1.2.5 | 18/05/2013 - fix bug thumb position with arrow keys
 * 		update 1.2.4 | 18/05/2013 - fix error it's time to catching the width and height
 * 		update 1.2.3 | 18/05/2013 - fix scrollbar position "x"
 * 		update 1.2.2 | 17/05/2013 - Key event added, now you can press the key down and key up for scrolling
 * 		update 1.2.1 | 15/05/2013 - Touch event added, now works for ipad, iphone and android
 */
!function(t,s,i){var e={touchEvents:"ontouchstart"in s.documentElement},h=function(t,s){this.type="",this.is="static",this.target=this.getElement(t),this.container,this.tracker,this.thumb,this.thumb_delta=o(0,0),this.thumb_pos=o(0,0),this.touch=o(0,0),this.settings=s,this.percent,this.keypos_thumb=o(0,0),this.scrolling=!1,this.preventScrolling=!1,this.turnOffWheel=!0,this.initializing()},o=function(t,s){return this instanceof o?(this.x=t?t:0,this.y=s?s:0,this):new o(t,s)};h[i].initializing=function(){this.buildScrollbar(),this.buildScrollbarTracker(),this.buildScrolbarThumb(),this.settings.isKeyEvent="undefined"==typeof this.settings.isKeyEvent?!0:this.settings.isKeyEvent,this.turnOffWheel="undefined"==typeof this.settings.turnOffWheel?this.turnOffWheel:this.settings.turnOffWheel,this.settings.isKeyEvent&&this.addKeyBoardEvent(),e.touchEvents?this.setupTouchEvent():this.setupEventHandler();var s=this;t.setInterval(function(){s.update()},10)},h[i].buildScrollbar=function(){var t=this.target.id?this.target.id:this.target.className;this.container=this.create(this.target,"div",{"class":"miniscroll-container",id:"miniscroll-"+t});var s=this.settings.scrollbarSize?this.settings.scrollbarSize:this.offset(this.target).height,i=this.settings.scrollbarSize?this.settings.scrollbarSize:this.offset(this.target).width,e=this.offset(this.target).left+(this.offset(this.target).width-this.settings.size),h=this.offset(this.target).top+(this.offset(this.target).height-this.settings.size);this.css(this.container,{position:"absolute",visibility:"hidden",width:("x"===this.settings.axis?i:this.settings.size)+"px",height:("y"===this.settings.axis?s:this.settings.size)+"px",top:("y"===this.settings.axis?this.offset(this.target).top:h)+"px",left:("x"===this.settings.axis?this.offset(this.target).left:e)+"px",zIndex:999})},h[i].buildScrollbarTracker=function(){this.tracker=this.create(this.container,"div",{"class":"miniscroll-tracker"});var t="x"===this.settings.axis?this.offset(this.container).width:this.settings.size,s="y"===this.settings.axis?this.offset(this.container).height:this.settings.size;this.css(this.tracker,{width:t+"px",height:s+"px",backgroundColor:this.settings.trackerColor?this.settings.trackerColor:"#067f41"})},h[i].buildScrolbarThumb=function(){this.thumb=this.create(this.container,"div",{"class":"miniscroll-thumb"});var t=o(this.offset(this.container).width*this.offset(this.tracker).width/this.target.scrollWidth,this.offset(this.container).height*this.offset(this.tracker).height/this.target.scrollHeight),t=o(this.offset(this.container).width*this.offset(this.tracker).width/this.target.scrollWidth,this.offset(this.container).height*this.offset(this.tracker).height/this.target.scrollHeight),s=o(void 0===this.settings.sizethumb||"auto"===this.settings.sizethumb?t.x:this.settings.sizethumb,void 0===this.settings.sizethumb||"auto"===this.settings.sizethumb?t.y:this.settings.sizethumb);this.css(this.thumb,{position:"absolute",top:"0px",left:"0px",width:("x"===this.settings.axis?s.x:this.settings.size)+"px",height:("y"===this.settings.axis?s.y:this.settings.size)+"px",backgroundColor:this.settings.thumbColor?this.settings.thumbColor:"#2AD47D"})},h[i].setupEventHandler=function(){this.bind(this.thumb,"mousedown",this.onScrollThumbPress),this.bind(this.tracker,"mousedown",this.onScrollTrackerPress),this.turnOffWheel&&this.bind(this.target,"mousewheel",this.onScrollThumbWheel)},h[i].setupTouchEvent=function(){this.bind(this.target,"touchstart",this.onScrollTouchStart),this.bind(this.target,"touchmove",this.onScrollTouchMove)},h[i].updateContainerPosition=function(){this.is=this.getCss(this.target,"position"),"relative"===this.is||"absolute"===this.is?"y"===this.settings.axis?(this.container.style.top=this.target.scrollTop+"px",this.container.style.left=this.offset(this.target).width-this.settings.size+"px"):(this.container.style.top=this.offset(this.target).height-this.settings.size+"px",this.container.style.left=this.target.scrollLeft+"px"):"y"===this.settings.axis?this.container.style.top=this.offset(this.target).top+"px":this.container.style.left=this.offset(this.target).left+"px"},h[i].setScrubPosition=function(t){var s=this.offset(this.container).width,i=this.offset(this.container).height,e=this.offset(this.thumb).width,h=this.offset(this.thumb).height;this.thumb_pos=o(Math.round((s-e)*t),Math.round((i-h)*t)),"y"===this.settings.axis?this.thumb.style.top=Math.round(this.thumb_pos.y)+"px":this.thumb.style.left=Math.round(this.thumb_pos.x)+"px"},h[i].addKeyBoardEvent=function(){this.target.setAttribute("tabindex","-1"),this.css(this.target,{outline:"none"}),this.bind(this.target,"focus",function(t,i){!("onkeydown"in i)&&"onkeydown"in s&&(i=s),this.bind(i,"keydown",function(t){var s=t.keyCode||t.which,i={left:37,up:38,right:39,down:40};switch(s){case i.up:0!==this.percent&&(this.keypos_thumb.y-=10);break;case i.down:1!==this.percent&&(this.keypos_thumb.y+=10);break;case i.left:0!==this.percent&&(this.keypos_thumb.x-=10);break;case i.right:1!==this.percent&&(this.keypos_thumb.x+=10)}"y"===this.settings.axis?(this.percent=this.target.scrollTop/(this.target.scrollHeight-this.target.offsetHeight),this.setScrubPosition(this.percent),this.target.scrollTop=this.keypos_thumb.y):(this.percent=this.target.scrollLeft/(this.target.scrollWidth-this.target.offsetWidth),this.setScrubPosition(this.percent),this.target.scrollLeft=this.keypos_thumb.x),this.preventScrolling=this.percent>=1||this.percent<=0?!0:!1,this.updateContainerPosition()})}),this.bind(this.target,"click",function(t,i){try{s.activeElement=i}catch(e){}i.focus()})},h[i].onScrollTouchStart=function(t){var s=t.touches[0];this.scrolling=!0,this.touch=o(s.pageX,s.pageY),this.bind(this.target,"touchend",this.onScrollTouchEnd)},h[i].onScrollTouchMove=function(t){var s=t.touches[0];t.preventDefault();var i=o(this.touch.x-s.pageX,this.touch.y-s.pageY);this.touch=o(s.pageX,s.pageY),"y"===this.settings.axis?(this.percent=this.target.scrollTop/(this.target.scrollHeight-this.target.offsetHeight),this.setScrubPosition(this.percent),this.target.scrollTop=this.target.scrollTop+i.y):(this.percent=this.target.scrollLeft/(this.target.scrollWidth-this.target.offsetWidth),this.setScrubPosition(this.percent),this.target.scrollLeft=this.target.scrollLeft+i.x),this.updateContainerPosition()},h[i].onScrollTouchEnd=function(){this.scrolling=!1,this.unbind(this.target,"touchend",this.onScrollTouchEnd)},h[i].onScrollThumbPress=function(i){i=i?i:t.event,this.stopEvent(i),this.scrolling=!0,this.thumb_delta=o(this.thumb_pos.x-this.mouse(i).x,this.thumb_pos.y-this.mouse(i).y),this.bind(s,"mousemove",this.onScrollThumbUpdate),this.bind(s,"mouseup",this.onScrollThumbRelease),this.updateContainerPosition()},h[i].onScrollThumbUpdate=function(s){return s=s?s:t.event,this.stopEvent(s),this.scrolling?(this.thumb_pos=o(this.mouse(s).x+this.thumb_delta.x,this.mouse(s).y+this.thumb_delta.y),this.thumb_pos=o(Math.max(0,Math.min(this.container.offsetWidth-this.thumb.offsetWidth,this.thumb_pos.x)),Math.max(0,Math.min(this.container.offsetHeight-this.thumb.offsetHeight,this.thumb_pos.y))),this.percent=o(this.thumb_pos.x/(this.container.offsetWidth-this.thumb.offsetWidth),this.thumb_pos.y/(this.container.offsetHeight-this.thumb.offsetHeight)),this.percent=o(Math.max(0,Math.min(1,this.percent.x)),Math.max(0,Math.min(1,this.percent.y))),"y"===this.settings.axis?(this.thumb.style.top=Math.round(this.thumb_pos.y)+"px",this.target.scrollTop=Math.round((this.target.scrollHeight-this.target.offsetHeight)*this.percent.y)):(this.thumb.style.left=Math.round(this.thumb_pos.x)+"px",this.target.scrollLeft=Math.round((this.target.scrollWidth-this.target.offsetWidth)*this.percent.x)),this.keypos_thumb=o(this.target.scrollLeft,this.target.scrollTop),void this.updateContainerPosition()):!1},h[i].onScrollThumbWheel=function(s){s=s?s:t.event,this.preventScrolling||this.stopEvent(s);var i=s||t.event,e=([].slice.call(arguments,1),0),h=0,n=0;i.wheelDelta&&(e=i.wheelDelta/120),i.detail&&(e=-i.detail/3),n=e,h=e,void 0!==i.axis&&i.axis===i.HORIZONTAL_AXIS&&(n=0,h=-1*e),void 0!==i.wheelDeltaY&&(n=i.wheelDeltaY/120),void 0!==i.wheelDeltaX&&(h=-1*i.wheelDeltaX/120),"y"===this.settings.axis?(this.percent=this.target.scrollTop/(this.target.scrollHeight-this.target.offsetHeight),this.setScrubPosition(this.percent),this.target.scrollTop=Math.round(this.target.scrollTop-10*n)):(this.percent=this.target.scrollLeft/(this.target.scrollWidth-this.target.offsetWidth),this.setScrubPosition(this.percent),this.target.scrollLeft=Math.round(this.target.scrollLeft-10*h)),this.preventScrolling=this.percent>=1||this.percent<=0?!0:!1,void 0!==i.wheelDeltaY,this.keypos_thumb=o(this.target.scrollLeft,this.target.scrollTop),this.updateContainerPosition()},h[i].onScrollThumbRelease=function(i){i=i?i:t.event,this.stopEvent(i),this.scrolling=!1,this.unbind(s,"mousemove",this.onScrollThumbUpdate),this.unbind(s,"mouseup",this.onScrollThumbRelease)},h[i].onScrollTrackerPress=function(t){var s=this.mouse(t).y-this.offset(this.container).top;this.scrolling=!0,this.scrollTo(s)},h[i].scrollTo=function(t){var s=Math.max(0,Math.min(this.offset(this.target).height-this.offset(this.thumb).height,t));"y"===this.settings.axis&&(this.thumb_pos.y=s,this.thumb.style.top=Math.round(this.thumb_pos.y)+"px",this.target.scrollTop=s,this.scrolling=!1)},h[i].update=function(){"y"===this.settings.axis?this.target.scrollHeight===this.offset(this.target).height?this.css(this.container,{visibility:"hidden"}):this.css(this.container,{visibility:"visible"}):this.target.scrollWidth===this.offset(this.target).width?this.css(this.container,{visibility:"hidden"}):this.css(this.container,{visibility:"visible"});var t=this.settings.scrollbarSize?this.settings.scrollbarSize:this.offset(this.target).height,s=this.settings.scrollbarSize?this.settings.scrollbarSize:this.offset(this.target).width,i=this.offset(this.target).left+(this.offset(this.target).width-this.settings.size),e=this.offset(this.target).top+(this.offset(this.target).height-this.settings.size);this.css(this.container,{width:("x"===this.settings.axis?s:this.settings.size)+"px",height:("y"===this.settings.axis?t:this.settings.size)+"px",top:("y"===this.settings.axis?this.offset(this.target).top:e)+"px",left:("x"===this.settings.axis?this.offset(this.target).left:i)+"px"});var h="x"===this.settings.axis?this.offset(this.container).width:this.settings.size,n="y"===this.settings.axis?this.offset(this.container).height:this.settings.size;this.css(this.tracker,{width:h+"px",height:n+"px"});var r=o(this.offset(this.container).width*this.offset(this.tracker).width/this.target.scrollWidth,this.offset(this.container).height*this.offset(this.tracker).height/this.target.scrollHeight),a=o(void 0===this.settings.sizethumb||"auto"===this.settings.sizethumb?r.x:this.settings.sizethumb,void 0===this.settings.sizethumb||"auto"===this.settings.sizethumb?r.y:this.settings.sizethumb);this.css(this.thumb,{width:("x"===this.settings.axis?a.x:this.settings.size)+"px",height:("y"===this.settings.axis?a.y:this.settings.size)+"px"}),"y"===this.settings.axis?(this.percent=this.target.scrollTop/(this.target.scrollHeight-this.target.offsetHeight),this.scrolling||this.setScrubPosition(this.percent)):(this.percent=this.target.scrollLeft/(this.target.scrollWidth-this.target.offsetWidth),this.scrolling||this.setScrubPosition(this.percent)),this.updateContainerPosition()},h[i].getElement=function(i){var e;if(i===t||i===s||"body"===i||"body, html"===i)return s.body;if("string"==typeof i||i instanceof String){var e,h=i.replace(/^\s+/,"").replace(/\s+$/,"");if(h.indexOf("#")>-1){this.type="id";var o=h.split("#");e=s.getElementById(o[1])}if(h.indexOf(".")>-1){this.type="class";for(var o=h.split("."),n=s.getElementsByTagName("*"),r=n.length,a=0;r>a;a++)n[a].className&&n[a].className.match(new RegExp("(^|\\s)"+o[1]+"(\\s|$)"))&&(e=n[a])}return e}return i},h[i].create=function(t,i,e){var h=s.createElement(i);if(e){for(var o in e)e.hasOwnProperty(o)&&h.setAttribute(o,e[o]);t.appendChild(h)}return h},h[i].css=function(t,s){for(var i in s)"opacity"===i?(t.style.filter="alpha(opacity="+100*s[i]+")",t.style.KhtmlOpacity=s[i],t.style.MozOpacity=s[i],t.style.opacity=s[i]):t.style[i]=s[i]},h[i].getCss=function(i,e){var h;return h=t.getComputedStyle?t.getComputedStyle(i).getPropertyValue(e):s.defaultView&&s.defaultView.getComputedStyle?s.defaultView.getComputedStyle.getPropertyValue(e):i.currentStyle?i.currentStyle[e]:i.style[e]},h[i].offset=function(t){var s=t.offsetTop,i=t.offsetLeft,e=t.offsetHeight;"undefined"==typeof t.offsetHeight&&(e=parseInt(this.getCss(t,"height")));var h=t.offsetWidth;return"undefined"==typeof t.offsetWidth&&(h=parseInt(this.getCss(t,"width"))),{top:s,left:i,width:h,height:e}},h[i].mouse=function(t){var i=0,e=0;return t.pageX||t.pageY?(i=t.pageX,e=t.pageY):(t.clientX||t.clientY)&&(i=t.clientX+s.body.scrollLeft+s.documentElement.scrollLeft,e=t.clientY+s.body.scrollTop+s.documentElement.scrollTop),{x:i,y:e}},h[i].bind=function(t,s,i){var e=/Firefox/i.test(navigator.userAgent)?"DOMMouseScroll":"mousewheel",h=this;t.addEventListener?"mousewheel"===s?t.addEventListener(e,function(t){i.call(h,t,this)},!1):t.addEventListener(s,function(t){i.call(h,t,this)},!1):t.attachEvent?t.attachEvent("on"+s,function(t){i.call(h,t,this)}):t["on"+s]=function(t){i.call(h,t,this)}},h[i].unbind=function(t,s,i){var e=/Firefox/i.test(navigator.userAgent)?"DOMMouseScroll":"mousewheel";t.addEventListener?"mousewheel"===s?t.removeEventListener(e,function(t){i.call(_this,t,this)},!1):t.removeEventListener(s,function(t){i.call(_this,t,this)},!1):t.attachEvent?t.detachEvent("on"+s,function(t){i.call(_this,t,this)}):t["on"+s]=null},h[i].stopEvent=function(t){t.stopPropagation?t.stopPropagation():t.cancelBubble=!0,t.preventDefault?t.preventDefault():t.returnValue=!1},t.Miniscroll=h}(window,document,"prototype");
{'fraction_non_alphanumeric': 0.20253390967357282, 'fraction_numerical': 0.014130272767923684, 'mean_word_length': 11.493854748603352, 'pattern_counts': {'":': 12, '<': 16, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4701501', 'n_tokens_mistral': 11827, 'n_tokens_neox': 11542, 'n_words': 473}