Changeset 27448


Ignore:
Timestamp:
02/22/14 07:38:56 (5 years ago)
Author:
rvelices
Message:

tscroller manage browser back button

Location:
extensions/rv_tscroller
Files:
3 edited

Legend:

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

    r25974 r27448  
    11<?php /* 
    22Plugin Name: RV Thumb Scroller 
    3 Version: 2.6.a 
     3Version: 2.6.b 
    44Plugin URI: http://piwigo.org/ext/extension_view.php?eid=493 
    55Description: Infinite scroll - loads thumbnails on index page as you scroll down the page 
     
    77Author URI: http://www.modusoptimus.com 
    88*/ 
    9 define('RVTS_VERSION', '25a'); 
     9define('RVTS_VERSION', '26'); 
    1010 
    1111class RVTS 
     
    100100next: ".($start+$per_page).", 
    101101total: $total, 
    102 moreUrlModel: String.fromCharCode(".ord($url_model[0]).")+'".substr($url_model,1)."', 
     102urlModel: String.fromCharCode(".ord($url_model[0]).")+'".substr($url_model,1)."', 
    103103moreMsg: '$moreMsg', 
    104104prevMsg: '".l10n("Previous")."', 
  • extensions/rv_tscroller/rv_tscroller.js

    r18904 r27448  
    66if (RVTS.start>0) { 
    77        var $f = $('.navigationBar A[rel=first]'); 
    8         var f = '<a href="'+$f.attr("href")+'">'+$f.html()+'</a> | '; 
    9         $('#thumbnails').before( '<div id=rvtsUp style="text-align:center;font-size:120%;margin:10px">'+f+'<a href="javascript:RVTS.loadUp()">'+RVTS.prevMsg+"</a></div>" ); 
     8        $('#thumbnails').before( '<div id=rvtsUp style="text-align:center;font-size:120%;margin:10px"><a href="'+$f.attr("href")+'">'+$f.html()+'</a> | <a href="javascript:RVTS.loadUp()">'+RVTS.prevMsg+"</a></div>" ); 
    109} 
    1110 
     
    6261                                RVTS.$thumbs.after( 
    6362                                        '<div style="text-align:center;font-size:180%;margin:0 0 20px"><a href="' 
    64                                         +RVTS.moreUrlModel.replace('%start%', RVTS.next)+'">' 
     63                                        +RVTS.urlModel.replace('%start%', RVTS.next)+'">' 
    6564                                        +RVTS.moreMsg.replace('%d', RVTS.total-RVTS.next) 
    6665                                        +'</a></div>'); 
     
    9089        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>'); 
    9190 
    92         $w.scrollTop(0); 
     91        if ("#top" == window.location.hash) 
     92                window.scrollTo(0,0); 
     93 
    9394        if ( RVTS.$thumbs.outerHeight() < $w.height() ) 
    9495                RVTS.adjust = 1; 
    9596        else if ( RVTS.$thumbs.height() > 2*$w.height() ) 
    9697                RVTS.adjust = -1; 
    97         $w.bind('scroll resize', RVTS.checkAutoScroll); 
     98        $w.on('scroll resize', RVTS.checkAutoScroll); 
    9899        if (RVTS.checkAutoScroll()) 
    99100                window.setTimeout(RVTS.checkAutoScroll,1500); 
     
    102103 
    103104$(document).ready( function() { 
    104         window.setTimeout(RVTS.engage,250); 
     105        if ("#top" == window.location.hash) 
     106                window.scrollTo(0,0); 
     107        window.setTimeout(RVTS.engage,150); 
    105108}); 
    106109 
    107  
    108  
     110if (window.history.replaceState) { 
     111        var iniStart = RVTS.start; 
     112        $(window).one("RVTS_loaded", function() { 
     113                $(window).on("unload", function() { 
     114                                var threshold = Math.max(0, $(window).scrollTop() - 60), 
     115                                        elts = RVTS.$thumbs.children("li"); 
     116                                for (var i=0; i<elts.length; i++) { 
     117                                        var offset = $(elts[i]).offset(); 
     118                                        if (offset.top >= threshold) { 
     119                                                var start = RVTS.start+i, 
     120                                                        delta = start-iniStart; 
     121                                                if (delta<0 || delta>=RVTS.perPage) { 
     122                                                        var url = start ? RVTS.urlModel.replace("%start%", start) : RVTS.urlModel.replace("/start-%start%", ""); 
     123                                                        window.history.replaceState(null, "", url+ "#top"); 
     124                                                } 
     125                                                break; 
     126                                        } 
     127                                } 
     128                }); 
     129        }); 
     130} 
    109131})(jQuery); 
  • extensions/rv_tscroller/rv_tscroller.min.js

    r18904 r27448  
    1 window.jQuery&&window.RVTS&&function(a){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",0);"undefined"!=typeof pwg_ajax_thumbnails_loader&&pwg_ajax_thumbnails_loader()}})}},doAutoScroll: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",1);"undefined"!=typeof pwg_ajax_thumbnails_loader&&pwg_ajax_thumbnails_loader()}})}},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); 
     1window.jQuery&&window.RVTS&&function(b){if(0<RVTS.start){var e=b(".navigationBar A[rel=first]");b("#thumbnails").before('<div id=rvtsUp style="text-align:center;font-size:120%;margin:10px"><a href="'+e.attr("href")+'">'+e.html()+'</a> | <a href="javascript:RVTS.loadUp()">'+RVTS.prevMsg+"</a></div>")}RVTS=b.fn.extend(RVTS,{loading:0,loadingUp:0,adjust:0,loadUp:function(){if(!(RVTS.loadingUp||0>=RVTS.start)){var a=RVTS.start-RVTS.perPage,c=RVTS.perPage;0>a&&(c+=a,a=0);c=RVTS.ajaxUrlModel.replace("%start%", 
     2a).replace("%per%",c);b("#ajaxLoader").show();RVTS.loadingUp=1;b.ajax({type:"GET",dataType:"html",url:c,success:function(c){RVTS.start=a;RVTS.$thumbs.prepend(c);0>=RVTS.start&&b("#rvtsUp").remove()},complete:function(){RVTS.loadingUp=0;RVTS.loading||b("#ajaxLoader").hide();b(window).trigger("RVTS_loaded",0);"undefined"!=typeof pwg_ajax_thumbnails_loader&&pwg_ajax_thumbnails_loader()}})}},doAutoScroll:function(){if(!(RVTS.loading||RVTS.next>=RVTS.total)){var a=RVTS.ajaxUrlModel.replace("%start%",RVTS.next).replace("%per%", 
     3RVTS.perPage);RVTS.adjust&&(a+="&adj="+RVTS.adjust,RVTS.adjust=0);b("#ajaxLoader").show();RVTS.loading=1;b.ajax({type:"GET",dataType:"html",url:a,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.urlModel.replace("%start%",RVTS.next)+'">'+RVTS.moreMsg.replace("%d",RVTS.total-RVTS.next)+"</a></div>"),RVTS.total=0)},complete:function(){RVTS.loading= 
     40;RVTS.loadingUp||b("#ajaxLoader").hide();b(window).trigger("RVTS_loaded",1);"undefined"!=typeof pwg_ajax_thumbnails_loader&&pwg_ajax_thumbnails_loader()}})}},checkAutoScroll:function(a){var c=RVTS.$thumbs.position().top+RVTS.$thumbs.outerHeight(),d=b(window).scrollTop()+b(window).height();return c-(a?100:0)<=d?(RVTS.doAutoScroll(),1):0},engage:function(){var a=b(window);RVTS.$thumbs=b("#thumbnails");RVTS.$thumbs.after('<div id="ajaxLoader" style="display:none;position:fixed;bottom:32px;right:1%;z-index:999"><img src="'+ 
     5RVTS.ajaxLoaderImage+'" width="128" height="15" alt="~"></div>');"#top"==window.location.hash&&window.scrollTo(0,0);RVTS.$thumbs.outerHeight()<a.height()?RVTS.adjust=1:RVTS.$thumbs.height()>2*a.height()&&(RVTS.adjust=-1);a.on("scroll resize",RVTS.checkAutoScroll);RVTS.checkAutoScroll()&&window.setTimeout(RVTS.checkAutoScroll,1500)}});b(document).ready(function(){"#top"==window.location.hash&&window.scrollTo(0,0);window.setTimeout(RVTS.engage,150)});if(window.history.replaceState){var f=RVTS.start; 
     6b(window).one("RVTS_loaded",function(){b(window).on("unload",function(){for(var a=Math.max(0,b(window).scrollTop()-60),c=RVTS.$thumbs.children("li"),d=0;d<c.length;d++)if(b(c[d]).offset().top>=a){a=RVTS.start+d;c=a-f;if(0>c||c>=RVTS.perPage)a=a?RVTS.urlModel.replace("%start%",a):RVTS.urlModel.replace("/start-%start%",""),window.history.replaceState(null,"",a+"#top");break}})})}}(jQuery); 
Note: See TracChangeset for help on using the changeset viewer.