<commit_before>
(function ($) {
    var OverviewClass = function (element, opts, scrollbarPixels) {
        var contentDiv = $("div:eq(0)", element), viewportDiv = $("div:eq(1)", element), coef = 0, content = { obj: null, sizeX: 0, sizeY: 0, resized: function () { this.sizeX = this.obj.width(); this.sizeY = this.obj.height(); }, resizedOverflow: function () { this.sizeX = this.obj[0].scrollWidth; this.sizeY = this.obj[0].scrollHeight; } }, viewport = { obj: null, sizeX: 0, sizeY: 0, resized: function () { this.sizeX = this.obj.width(); this.sizeY = this.obj.height(); } }, onResize = function (event) {
            if (opts.viewport === window) { content.resized(); } else { content.resizedOverflow(); }
            viewport.resized(); if (opts.autoHide) {
                if (content.sizeX <= viewport.sizeX && content.sizeY <= viewport.sizeY) { $(this).hide(); return; }
                $(this).show();
            }
            var coefX = content.sizeX / element.width(); var coefY = content.sizeY / element.height(); coef = Math.max(coefX, coefY); coefX = (viewport.sizeX - scrollbarPixels) / element.width(); coefY = (viewport.sizeY - scrollbarPixels) / element.height(); coef = Math.max(Math.max(coefX, coefY), coef); var calcWidth = content.sizeX / coef; var calcHeight = content.sizeY / coef; contentDiv.width(calcWidth).height(calcHeight); if (opts.center) { contentDiv.css('left', (element.width() - calcWidth) / 2).css('top', (element.height() - calcHeight) / 2); }
            $(this).trigger('rsOverview.render');
        }, onRender = function (event) { var calcWidth = (viewport.sizeX - scrollbarPixels) / coef, calcHeight = (viewport.sizeY - scrollbarPixels) / coef; viewportDiv.width(calcWidth).height(calcHeight).css('left', (viewport.obj.scrollLeft() / coef) + (opts.center ? contentDiv.position().left : 0)).css('top', (viewport.obj.scrollTop() / coef) + (opts.center ? contentDiv.position().top : 0)); }, init = function () {
            viewport.obj = $(opts.viewport); if (opts.viewport === window) { content.obj = $(document); } else { content.obj = viewport.obj; }
            viewport.obj.scroll(function () { element.trigger('rsOverview.render'); }).resize(function () { element.trigger('rsOverview.resize'); }); viewportDiv.mousedown(function (e) { var dragInfo = { initPos: viewportDiv.offset(), initClick: { X: e.pageX, Y: e.pageY} }; this.onselectstart = function () { return false; }; viewportDiv.bind('mousemove', function (e) { var pos = [element.position(), contentDiv.position()]; viewport.obj.scrollLeft(coef * (e.pageX - dragInfo.initClick.X + dragInfo.initPos.left - pos[0].left - pos[1].left)).scrollTop(coef * (e.pageY - dragInfo.initClick.Y + dragInfo.initPos.top - pos[0].top - pos[1].top)); }); e.preventDefault(); }); $("body").mouseup(function () { viewportDiv.unbind('mousemove'); }); contentDiv.mousedown(function (e) { (opts.viewport === window ? $("body, html") : viewport.obj).animate({ scrollLeft: coef * (e.pageX - element.position().left - $(this).position().left), scrollTop: coef * (e.pageY - element.position().top - $(this).position().top) }, opts.scrollSpeed); e.preventDefault(); }); element.bind('rsOverview.resize', onResize); element.bind('rsOverview.render', onRender); element.trigger('rsOverview.resize');
        }; init();
    }
    $.fn.rsOverview = function (options) { var opts = $.extend({}, $.fn.rsOverview.defaults, options), scrollbarWidth = function () { var calcDiv = $("<div style='visibily: hidden; overflow: scroll; width: 100px;'></div>"); $("body").append(calcDiv); try { return 100 - calcDiv[0].clientWidth; } finally { calcDiv.remove(); } }, scrollbarPixels = opts.viewport === window ? 0 : scrollbarWidth(); return this.each(function () { new OverviewClass($(this), opts, scrollbarPixels); }); }; $.fn.rsOverview.contentSizeChanged = function (element) { element.trigger('rsOverview.resize'); }; $.fn.rsOverview.defaults = { viewport: window, center: true, autoHide: false, scrollSpeed: 'medium' };
})(jQuery);<commit_msg>Refactoring on the way instance methods are handled<commit_after>
(function($){var OverviewClass=function(element,opts,scrollbarPixels){var contentDiv=$("div:eq(0)",element),viewportDiv=$("div:eq(1)",element),coef=0,content={obj:null,sizeX:0,sizeY:0,resized:function(){this.sizeX=this.obj.width();this.sizeY=this.obj.height();},resizedOverflow:function(){this.sizeX=this.obj[0].scrollWidth;this.sizeY=this.obj[0].scrollHeight;}},viewport={obj:null,sizeX:0,sizeY:0,resized:function(){this.sizeX=this.obj.width();this.sizeY=this.obj.height();}},onResize=function(event){if(opts.viewport===window){content.resized();}else{content.resizedOverflow();}
viewport.resized();if(opts.autoHide){if(content.sizeX<=viewport.sizeX&&content.sizeY<=viewport.sizeY){$(this).hide();return;}
$(this).show();}
var coefX=content.sizeX/element.width();var coefY=content.sizeY/element.height();coef=Math.max(coefX,coefY);coefX=(viewport.sizeX-scrollbarPixels)/element.width();coefY=(viewport.sizeY-scrollbarPixels)/element.height();coef=Math.max(Math.max(coefX,coefY),coef);var calcWidth=content.sizeX/coef;var calcHeight=content.sizeY/coef;contentDiv.width(calcWidth).height(calcHeight);if(opts.center){contentDiv.css('left',(element.width()-calcWidth)/2).css('top',(element.height()-calcHeight)/2);}
$(this).trigger('rsOverview.render');},onRender=function(event){var calcWidth=(viewport.sizeX-scrollbarPixels)/coef,calcHeight=(viewport.sizeY-scrollbarPixels)/coef;viewportDiv.width(calcWidth).height(calcHeight).css('left',(viewport.obj.scrollLeft()/coef)+(opts.center?contentDiv.position().left:0)).css('top',(viewport.obj.scrollTop()/coef)+(opts.center?contentDiv.position().top:0));},init=function(){viewport.obj=$(opts.viewport);if(opts.viewport===window){content.obj=$(document);}else{content.obj=viewport.obj;}
viewport.obj.scroll(function(){element.trigger('rsOverview.render');}).resize(function(){element.trigger('rsOverview.resize');});viewportDiv.mousedown(function(e){var dragInfo={initPos:viewportDiv.offset(),initClick:{X:e.pageX,Y:e.pageY}};this.onselectstart=function(){return false;};viewportDiv.bind('mousemove',function(e){var pos=[element.position(),contentDiv.position()];viewport.obj.scrollLeft(coef*(e.pageX-dragInfo.initClick.X+dragInfo.initPos.left-pos[0].left-pos[1].left)).scrollTop(coef*(e.pageY-dragInfo.initClick.Y+dragInfo.initPos.top-pos[0].top-pos[1].top));});e.preventDefault();});$("body").mouseup(function(){viewportDiv.unbind('mousemove');});contentDiv.mousedown(function(e){(opts.viewport===window?$("body, html"):viewport.obj).animate({scrollLeft:coef*(e.pageX-element.position().left-$(this).position().left),scrollTop:coef*(e.pageY-element.position().top-$(this).position().top)},opts.scrollSpeed);e.preventDefault();});element.bind('rsOverview.resize',onResize);element.bind('rsOverview.render',onRender);element.trigger('rsOverview.resize');};init();}
$.fn.rsOverview=function(options){var contentSizeChanged=function(){this.trigger('rsOverview.resize');};if(typeof options=='string'&&options=='contentSizeChanged')
return contentSizeChanged.apply(this,Array.prototype.slice.call(arguments,1));var opts=$.extend({},$.fn.rsOverview.defaults,options),scrollbarWidth=function(){var calcDiv=$("<div style='visibily: hidden; overflow: scroll; width: 100px;'></div>");$("body").append(calcDiv);try{return 100-calcDiv[0].clientWidth;}finally{calcDiv.remove();}},scrollbarPixels=opts.viewport===window?0:scrollbarWidth();return this.each(function(){new OverviewClass($(this),opts,scrollbarPixels);});};$.fn.rsOverview.defaults={viewport:window,center:true,autoHide:false,scrollSpeed:'medium'};})(jQuery);
{'fraction_non_alphanumeric': 0.20660290842394866, 'fraction_numerical': 0.0066815144766146995, 'mean_word_length': 6.805725971370143, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 7, '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': '4193196', 'n_tokens_mistral': 2500, 'n_tokens_neox': 2447, 'n_words': 302}