Changeset 13194


Ignore:
Timestamp:
Feb 16, 2012, 8:51:48 PM (9 years ago)
Author:
rvelices
Message:

rv_tscroller can load thumbnail up (if page[start]>0)

Location:
extensions/rv_tscroller
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • extensions/rv_tscroller/main.inc.php

    r12735 r13194  
    11<?php /*
    22Plugin Name: RV Thumb Scroller
    3 Version: 2.3.d
     3Version: 2.4.a
    44Plugin URI: http://piwigo.org/ext/extension_view.php?eid=493
    55Description: Loads async using ajax thumbnails on index page as you scroll down the page
     
    77Author URI: http://www.modusoptimus.com
    88*/
    9 define('RVTS_VERSION', '2.3.d');
     9define('RVTS_VERSION', '24a');
    1010
    1111class RVTS
     
    1414{
    1515        global $page;
    16         if (!@$page['start'])
     16        $page['nb_image_page'] *= pwg_get_session_var('rvts_mult', 1);
     17        if (count($page['items'])<$page['nb_image_page']+3)
    1718        {
    18                 if (script_basename()!='picture')
    19                         $page['nb_image_page'] *= pwg_get_session_var('rvts_mult', 1);
    20                 if (count($page['items'])<$page['nb_image_page']+3)
     19                if (!@$page['start'] || script_basename()=='picture')
    2120                        $page['nb_image_page'] = max($page['nb_image_page'], count($page['items']));
    2221        }
     
    3029        if (!$is_ajax)
    3130        {
    32                 if (empty($page['items']) || @$page['start']>0)
     31                if (empty($page['items']))
    3332                        add_event_handler('loc_end_index', array('RVTS','on_end_index'));
    3433                else
     
    6362                return $thumbs;
    6463        }
    65         $per_page = $page['nb_image_page'];
    6664        $url_model = str_replace('123456789', '%start%', duplicate_index_url( array('start'=>123456789) ) );
    6765        $ajax_url_model = add_url_params($url_model, array( 'rvts'=>'%per%' ) );
     
    8482                        'version' => RVTS_VERSION,
    8583                ), $template->smarty);
     84  $start = (int)$page['start'];
     85        $per_page = $page['nb_image_page'];
    8686        $moreMsg = 'See the remaining %d photos';
    8787        if ('en' != $GLOBALS['lang_info']['code'])
     
    9595                "var RVTS = {
    9696ajaxUrlModel: String.fromCharCode(".ord($ajax_url_model[0]).")+'".substr($ajax_url_model,1)."',
    97 start: $per_page,
     97start: $start,
     98perPage: $per_page,
     99next: ".($start+$per_page).",
    98100total: $total,
    99 perPage: $per_page,
    100101moreUrlModel: String.fromCharCode(".ord($url_model[0]).")+'".substr($url_model,1)."',
    101102moreMsg: '$moreMsg',
     103prevMsg: '".l10n("Previous")."',
    102104ajaxLoaderImage: '$ajax_loader_image'
    103105};",
     
    140142
    141143add_event_handler('loc_end_section_init', array('RVTS','on_end_section_init'));
    142 
    143144?>
  • extensions/rv_tscroller/rv_tscroller.js

    r12735 r13194  
    55(function($){
    66$('.navigationBar').hide();
     7if (RVTS.start>0) {
     8        var $f = $('.navigationBar A[rel=first]');
     9        var f = '<a href="'+$f.attr("href")+'">'+$f.html()+'</a> | ';
     10        $('#thumbnails').before( '<div id=rvtsUp style="text-align:center;font-size:120%;margin:10px">'+f+'<a href="javascript:RVTS.loadUp()">'+RVTS.prevMsg+"</a></div>" );
     11}
    712
    813RVTS = $.fn.extend( RVTS, {
    914loading: 0,
     15loadingUp: 0,
    1016adjust: 0,
    1117
     18loadUp: function() {
     19        if (RVTS.loadingUp || RVTS.start <= 0) return;
     20        var newStart = RVTS.start-RVTS.perPage,
     21                reqCount = RVTS.perPage;
     22        if (newStart<0)
     23        {
     24                reqCount += newStart;
     25                newStart = 0;
     26        }
     27        var url = RVTS.ajaxUrlModel.replace('%start%', newStart).replace('%per%', reqCount);
     28        $('#ajaxLoader').show();
     29        RVTS.loadingUp = 1;
     30        $.ajax({
     31                type:'GET', dataType:'html', 'url': url,
     32                success: function(htm) {
     33                        RVTS.start = newStart;
     34                        RVTS.$thumbs.prepend(htm);
     35                        if (RVTS.start<=0)
     36                                $("#rvtsUp").remove();
     37                },
     38                complete: function() {
     39                        RVTS.loadingUp = 0;
     40                        RVTS.loading || $('#ajaxLoader').hide();
     41                        $(window).trigger('RVTS_loaded');
     42                        }
     43                });
     44},
     45
    1246doAutoScroll: function() {
    13         if (RVTS.loading || RVTS.start >= RVTS.total) return;
    14         var url = RVTS.ajaxUrlModel.replace('%start%', RVTS.start).replace('%per%', RVTS.perPage);
     47        if (RVTS.loading || RVTS.next >= RVTS.total) return;
     48        var url = RVTS.ajaxUrlModel.replace('%start%', RVTS.next).replace('%per%', RVTS.perPage);
    1549        if (RVTS.adjust) {
    1650                url += '&adj=' + RVTS.adjust;
     
    2256                type:'GET', dataType:'html', 'url': url,
    2357                success: function(htm) {
    24                         RVTS.start+=RVTS.perPage;
     58                        RVTS.next+=RVTS.perPage;
    2559                        RVTS.$thumbs.append(htm);
    26                         if (RVTS.start>500 && RVTS.total>550) {
     60                        if (RVTS.next-RVTS.start>500 && RVTS.total-RVTS.next>50) {
    2761                                RVTS.$thumbs.after(
    2862                                        '<div style="text-align:center;font-size:180%;margin:0 0 20px"><a href="'
    29                                         +RVTS.moreUrlModel.replace('%start%', RVTS.start)+'">'
    30                                         +RVTS.moreMsg.replace('%d', RVTS.total-RVTS.start)
     63                                        +RVTS.moreUrlModel.replace('%start%', RVTS.next)+'">'
     64                                        +RVTS.moreMsg.replace('%d', RVTS.total-RVTS.next)
    3165                                        +'</a></div>');
    3266                                RVTS.total = 0;
     
    3569                complete: function() {
    3670                        RVTS.loading = 0;
    37                         $('#ajaxLoader').hide();
     71                        RVTS.loadingUp || $('#ajaxLoader').hide();
    3872                        $(window).trigger('RVTS_loaded');
    3973                        }
     
    5185        var $w = $(window);
    5286        RVTS.$thumbs = $('#thumbnails');
    53         RVTS.$thumbs.append('<div id="ajaxLoader" style="display:none;position:fixed;bottom:32px;right:1%;z-index:999"><img src="'+ RVTS.ajaxLoaderImage + '" width="128" height="15" alt="~"></div>');
     87        RVTS.$thumbs.after('<div id="ajaxLoader" style="display:none;position:fixed;bottom:32px;right:1%;z-index:999"><img src="'+ RVTS.ajaxLoaderImage + '" width="128" height="15" alt="~"></div>');
    5488
    5589        $w.scrollTop(0);
  • extensions/rv_tscroller/rv_tscroller.min.js

    r12735 r13194  
    1 window.jQuery&&window.RVTS&&function(a){a(".navigationBar").hide();RVTS=a.fn.extend(RVTS,{loading:0,adjust:0,doAutoScroll:function(){if(!(RVTS.loading||RVTS.start>=RVTS.total)){var b=RVTS.ajaxUrlModel.replace("%start%",RVTS.start).replace("%per%",RVTS.perPage);if(RVTS.adjust)b+="&adj="+RVTS.adjust,RVTS.adjust=0;a("#ajaxLoader").show();RVTS.loading=1;a.ajax({type:"GET",dataType:"html",url:b,success:function(a){RVTS.start+=RVTS.perPage;RVTS.$thumbs.append(a);if(500<RVTS.start&&550<RVTS.total)RVTS.$thumbs.after('<div style="text-align:center;font-size:180%;margin:0 0 20px"><a href="'+ RVTS.moreUrlModel.replace("%start%",RVTS.start)+'">'+RVTS.moreMsg.replace("%d",RVTS.total-RVTS.start)+"</a></div>"),RVTS.total=0},complete:function(){RVTS.loading=0;a("#ajaxLoader").hide();a(window).trigger("RVTS_loaded")}})}},
    2 checkAutoScroll:function(b){var c=RVTS.$thumbs.position().top+RVTS.$thumbs.outerHeight(),d=a(window).scrollTop()+a(window).height();return c-(!b?0:100)<=d?(RVTS.doAutoScroll(),1):0},engage:function(){var b=a(window);RVTS.$thumbs=a("#thumbnails");RVTS.$thumbs.append('<div id="ajaxLoader" style="display:none;position:fixed;bottom:32px;right:1%;z-index:999"><img src="'+ RVTS.ajaxLoaderImage+'" width="128" height="15" alt="~"></div>');b.scrollTop(0);if(RVTS.$thumbs.outerHeight()<b.height())RVTS.adjust=1;else if(RVTS.$thumbs.height()>2*b.height())RVTS.adjust=-1;b.bind("scroll resize",RVTS.checkAutoScroll);RVTS.checkAutoScroll()&&window.setTimeout(RVTS.checkAutoScroll,1500)}});a(document).ready(function(){window.setTimeout(RVTS.engage,250)})}(jQuery);
     1window.jQuery&&window.RVTS&&function(a){a(".navigationBar").hide();if(0<RVTS.start){var d=a(".navigationBar A[rel=first]"),d='<a href="'+d.attr("href")+'">'+d.html()+"</a> | ";a("#thumbnails").before('<div id=rvtsUp style="text-align:center;font-size:120%;margin:10px">'+d+'<a href="javascript:RVTS.loadUp()">'+RVTS.prevMsg+"</a></div>")}RVTS=a.fn.extend(RVTS,{loading:0,loadingUp:0,adjust:0,loadUp:function(){if(!(RVTS.loadingUp||0>=RVTS.start)){var b=RVTS.start-RVTS.perPage,c=RVTS.perPage;0>b&&(c+= b,b=0);c=RVTS.ajaxUrlModel.replace("%start%",b).replace("%per%",c);a("#ajaxLoader").show();RVTS.loadingUp=1;a.ajax({type:"GET",dataType:"html",url:c,success:function(c){RVTS.start=b;RVTS.$thumbs.prepend(c);0>=RVTS.start&&a("#rvtsUp").remove()},complete:function(){RVTS.loadingUp=0;RVTS.loading||a("#ajaxLoader").hide();a(window).trigger("RVTS_loaded")}})}},
     2doAutoScroll:function(){if(!(RVTS.loading||RVTS.next>=RVTS.total)){var b=RVTS.ajaxUrlModel.replace("%start%",RVTS.next).replace("%per%",RVTS.perPage); RVTS.adjust&&(b+="&adj="+RVTS.adjust,RVTS.adjust=0);a("#ajaxLoader").show();RVTS.loading=1;a.ajax({type:"GET",dataType:"html",url:b,success:function(a){RVTS.next+=RVTS.perPage;RVTS.$thumbs.append(a);500<RVTS.next-RVTS.start&&50<RVTS.total-RVTS.next&&(RVTS.$thumbs.after('<div style="text-align:center;font-size:180%;margin:0 0 20px"><a href="'+RVTS.moreUrlModel.replace("%start%",RVTS.next)+'">'+RVTS.moreMsg.replace("%d",RVTS.total-RVTS.next)+"</a></div>"),RVTS.total=0)},complete:function(){RVTS.loading= 0;RVTS.loadingUp||a("#ajaxLoader").hide();a(window).trigger("RVTS_loaded")}})}},checkAutoScroll:function(b){var c=RVTS.$thumbs.position().top+RVTS.$thumbs.outerHeight(),d=a(window).scrollTop()+a(window).height();return c-(!b?0:100)<=d?(RVTS.doAutoScroll(),1):0},engage:function(){var b=a(window);RVTS.$thumbs=a("#thumbnails");RVTS.$thumbs.after('<div id="ajaxLoader" style="display:none;position:fixed;bottom:32px;right:1%;z-index:999"><img src="'+RVTS.ajaxLoaderImage+'" width="128" height="15" alt="~"></div>'); b.scrollTop(0);RVTS.$thumbs.outerHeight()<b.height()?RVTS.adjust=1:RVTS.$thumbs.height()>2*b.height()&&(RVTS.adjust=-1);b.bind("scroll resize",RVTS.checkAutoScroll);RVTS.checkAutoScroll()&&window.setTimeout(RVTS.checkAutoScroll,1500)}});a(document).ready(function(){window.setTimeout(RVTS.engage,250)})}(jQuery);
Note: See TracChangeset for help on using the changeset viewer.