<commit_before>/*
 * Jquery Ajax Paginator Plugin
 * @requires jQuery 1.3 or later
 * @requires jQuery Address Plugin v1.4 http://www.asual.com/jquery/address/
 * 
 */
(function($){
/*
 * Example of usage:
  
    $('.ajax-pagination').ajaxPaginator({
        container: $('.watch-page-content'),
        onPageChange: function(page, callback){
            VideosApi.load_watch_page(page, function(data){
                this.options.container.html(data.content || '');
                callback.call(this, data);
            }, this);
        },
    });
    
 *  For more information see options.
 */

 $.widget("unisub.ajaxPaginator", {
     prevLink: null,
     nextLink: null,
     fromValueNode: null,
     toValueNode: null,
     totalValueNode: null,
     pageInfoNode: null,
     loadingIndicator: null,
     container: null,
     
     page: 1, //current page
     pages: null,  //total number of pages. Can be empty on page load, when we don't know have many pages have
     timeoutId: null, //callback timer ID
     
     options: {
         pages: null,
         prevLink: '.pag_prev',
         nextLink: '.pag_next',
         pageInfoNode: '.page-info',
         loadingIndicator: '.loading-indicator',
         fromValueNode: '.from-value',
         toValueNode: '.to-value',
         totalValueNode: '.total-value',
         container: null,
         
         //null - for scrolling to container, false - not scroll,
         //'top' - to page top, or some other jQuery node
         scrollTo: null, 
         scrollSpeed: 500,
         scrollOffset: -10,
         
         onPageChange: function(page, callback){
             /*
              * This method get page number and should load/change page content.
              * Callback should be executed with changed metadata in format:
              * {
              *     total: <int>,
              *     pages: <int>,
              *     from: <int>,
              *     to: <int>
              * }
              */
         }
     },
     
     _create: function() {
         var elements = ['prevLink', 'nextLink', 'fromValueNode', 'toValueNode', 
            'pageInfoNode', 'totalValueNode', 'loadingIndicator'];
         
         for (var i=elements.length; i--;){
             var name = elements[i];
             if (typeof this.options[name] == 'string'){
                 this[name] = $(this.options[name], this.element);
             }else{
                 this[name] = this.options[name];
             }                     
         };
         //I just hate this.options, so like add them to this
         this.pages = this.options.pages;
         this.onPageChange = this.options.onPageChange;
         this.container = this.options.container;
     },
     _init: function(){
         var page = $.address.parameter('page')-0;
         page = page || this.page;
         this.setPage(page, true);
         
         var that = this;
         
         this.prevLink.click(function(){
             that._onPrevClick.apply(that, arguments);
             return false;
         });
         
         this.nextLink.click(function(){
             that._onNextClick.apply(that, arguments);
             return false;
         });
         
         $.address.change(function(){
             that._onAdressChange.apply(that, arguments);
         });
     },
     _onAdressChange: function(event){
         var page = event.parameters.page-0;
         if (page && page !== this.page){
             this.setPage(page, true);
         }
     },
     _onNextClick: function(){
         if (this.pages && this.page < this.pages){
             this.setPage(this.page + 1);
         }
     },
     _onPrevClick: function(){
         if (this.page > 1){
            this.setPage(this.page - 1);
         }
     },
     _createDelegate: function(func, args, scope){
         return function(){
             callArgs = Array.prototype.slice.call(arguments, 0);
             callArgs = callArgs.concat(args);
             return func.apply(scope || window, callArgs);
         }
     },
     updateContent: function(data){
        var $c = this.container;
        
        //fix Chrome page jumping
        $.browser.webkit && $c.css('height', $c.height()+'px');
        
        $c.html(data.content || '');
        
        //fix Chrome page jumping
        if ($.browser.webkit) {
            setTimeout(function(){
                $c.css('height', $c.children().height()+'px');
            }, 1);
        };
     },
     scrollAfterUpdate: function(data, likeReload){
         var speed = $.address.parameter('speed')-0 || this.options.scrollSpeed;

         if ($.address.parameter('top') || this.options.scrollTo === 'top' || likeReload){
             if (speed == 1 || likeReload){
                 $('html, body').scrollTop(0);
                 $.jGrowl('Instance scroll to the TOP');
             }else{
                 $('html, body').animate({scrollTop: 0}, speed);
                 $.jGrowl('Scrool to TOP with for '+speed+'ms');
             }
         }else if(this.options.scrollTo !== false){
             if (this.options.scrollTo){
                 var offset = this.options.scrollTo.offset().top + this.options.scrollOffset;
             }else{
                 var offset = this.container.offset().top + this.options.scrollOffset;
             }
             if (speed==1){
                 $('html, body').scrollTop(offset);
                 $.jGrowl('Instance scroll to the CONTAINER TOP');
             }else{
                 $('html, body').animate({scrollTop: offset}, speed);
                 $.jGrowl('Scrool to CONTAINER TOP with for '+speed+'ms');
             }             
         }         
     },
     _pageLoadCallback: function(data, likeReload){
         /*
          * This function is executed after page loading and update
          * metadata 
          */
         data.total && this.totalValueNode.html(data.total);
         data.from && this.fromValueNode.html(data.from);
         data.to && this.toValueNode.html(data.to);
         data.pages && this.setPages(data.pages);
         
         this.updateContent(data, likeReload);<commit_msg>set default scroll style for AJAX-pagination<commit_after>/*
 * Jquery Ajax Paginator Plugin
 * @requires jQuery 1.3 or later
 * @requires jQuery Address Plugin v1.4 http://www.asual.com/jquery/address/
 * 
 */
(function($){
/*
 * Example of usage:
  
    $('.ajax-pagination').ajaxPaginator({
        container: $('.watch-page-content'),
        onPageChange: function(page, callback){
            VideosApi.load_watch_page(page, function(data){
                this.options.container.html(data.content || '');
                callback.call(this, data);
            }, this);
        },
    });
    
 *  For more information see options.
 */

 $.widget("unisub.ajaxPaginator", {
     prevLink: null,
     nextLink: null,
     fromValueNode: null,
     toValueNode: null,
     totalValueNode: null,
     pageInfoNode: null,
     loadingIndicator: null,
     container: null,
     
     page: 1, //current page
     pages: null,  //total number of pages. Can be empty on page load, when we don't know have many pages have
     timeoutId: null, //callback timer ID
     
     options: {
         pages: null,
         prevLink: '.pag_prev',
         nextLink: '.pag_next',
         pageInfoNode: '.page-info',
         loadingIndicator: '.loading-indicator',
         fromValueNode: '.from-value',
         toValueNode: '.to-value',
         totalValueNode: '.total-value',
         container: null,
         
         //null - for scrolling to container, false - not scroll,
         //'top' - to page top, or some other jQuery node
         scrollTo: 'top', 
         scrollSpeed: 200,
         scrollOffset: -10,
         
         onPageChange: function(page, callback){
             /*
              * This method get page number and should load/change page content.
              * Callback should be executed with changed metadata in format:
              * {
              *     total: <int>,
              *     pages: <int>,
              *     from: <int>,
              *     to: <int>
              * }
              */
         }
     },
     
     _create: function() {
         var elements = ['prevLink', 'nextLink', 'fromValueNode', 'toValueNode', 
            'pageInfoNode', 'totalValueNode', 'loadingIndicator'];
         
         for (var i=elements.length; i--;){
             var name = elements[i];
             if (typeof this.options[name] == 'string'){
                 this[name] = $(this.options[name], this.element);
             }else{
                 this[name] = this.options[name];
             }                     
         };
         //I just hate this.options, so like add them to this
         this.pages = this.options.pages;
         this.onPageChange = this.options.onPageChange;
         this.container = this.options.container;
     },
     _init: function(){
         var page = $.address.parameter('page')-0;
         page = page || this.page;
         this.setPage(page, true);
         
         var that = this;
         
         this.prevLink.click(function(){
             that._onPrevClick.apply(that, arguments);
             return false;
         });
         
         this.nextLink.click(function(){
             that._onNextClick.apply(that, arguments);
             return false;
         });
         
         $.address.change(function(){
             that._onAdressChange.apply(that, arguments);
         });
     },
     _onAdressChange: function(event){
         var page = event.parameters.page-0;
         if (page && page !== this.page){
             this.setPage(page, true);
         }
     },
     _onNextClick: function(){
         if (this.pages && this.page < this.pages){
             this.setPage(this.page + 1);
         }
     },
     _onPrevClick: function(){
         if (this.page > 1){
            this.setPage(this.page - 1);
         }
     },
     _createDelegate: function(func, args, scope){
         return function(){
             callArgs = Array.prototype.slice.call(arguments, 0);
             callArgs = callArgs.concat(args);
             return func.apply(scope || window, callArgs);
         }
     },
     updateContent: function(data){
        var $c = this.container;
        
        //fix Chrome page jumping
        $.browser.webkit && $c.css('height', $c.height()+'px');
        
        $c.html(data.content || '');
        
        //fix Chrome page jumping
        if ($.browser.webkit) {
            setTimeout(function(){
                $c.css('height', $c.children().height()+'px');
            }, 1);
        };
     },
     scrollAfterUpdate: function(data, likeReload){
         if (this.options.scrollTo === 'top' || likeReload){
             if (this.options.scrollSpeed == 1 || likeReload){
                 $('html, body').scrollTop(0);
             }else{
                 $('html, body').animate({scrollTop: 0}, this.options.scrollSpeed);
             }
         }else if(this.options.scrollTo !== false){
             if (this.options.scrollTo){
                 var offset = this.options.scrollTo.offset().top + this.options.scrollOffset;
             }else{
                 var offset = this.container.offset().top + this.options.scrollOffset;
             }
             if (this.options.scrollSpeed==1){
                 $('html, body').scrollTop(offset);
             }else{
                 $('html, body').animate({scrollTop: offset}, this.options.scrollSpeed);
             }             
         }         
     },
     _pageLoadCallback: function(data, likeReload){
         /*
          * This function is executed after page loading and update
          * metadata 
          */
         data.total && this.totalValueNode.html(data.total);
         data.from && this.fromValueNode.html(data.from);
         data.to && this.toValueNode.html(data.to);
         data.pages && this.setPages(data.pages);
         
         this.updateContent(data, likeReload);
{'fraction_non_alphanumeric': 0.13174050107848018, 'fraction_numerical': 0.0035672805707648914, 'mean_word_length': 1.5980603448275863, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4250293', 'n_tokens_mistral': 3319, 'n_tokens_neox': 3254, 'n_words': 739}