Index: /extensions/rv_tscroller/main.inc.php
===================================================================
--- /extensions/rv_tscroller/main.inc.php	(revision 27447)
+++ /extensions/rv_tscroller/main.inc.php	(revision 27448)
@@ -1,5 +1,5 @@
 <?php /*
 Plugin Name: RV Thumb Scroller
-Version: 2.6.a
+Version: 2.6.b
 Plugin URI: http://piwigo.org/ext/extension_view.php?eid=493
 Description: Infinite scroll - loads thumbnails on index page as you scroll down the page
@@ -7,5 +7,5 @@
 Author URI: http://www.modusoptimus.com
 */
-define('RVTS_VERSION', '25a');
+define('RVTS_VERSION', '26');
 
 class RVTS
@@ -100,5 +100,5 @@
 next: ".($start+$per_page).",
 total: $total,
-moreUrlModel: String.fromCharCode(".ord($url_model[0]).")+'".substr($url_model,1)."',
+urlModel: String.fromCharCode(".ord($url_model[0]).")+'".substr($url_model,1)."',
 moreMsg: '$moreMsg',
 prevMsg: '".l10n("Previous")."',
Index: /extensions/rv_tscroller/rv_tscroller.js
===================================================================
--- /extensions/rv_tscroller/rv_tscroller.js	(revision 27447)
+++ /extensions/rv_tscroller/rv_tscroller.js	(revision 27448)
@@ -6,6 +6,5 @@
 if (RVTS.start>0) {
 	var $f = $('.navigationBar A[rel=first]');
-	var f = '<a href="'+$f.attr("href")+'">'+$f.html()+'</a> | ';
-	$('#thumbnails').before( '<div id=rvtsUp style="text-align:center;font-size:120%;margin:10px">'+f+'<a href="javascript:RVTS.loadUp()">'+RVTS.prevMsg+"</a></div>" );
+	$('#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>" );
 }
 
@@ -62,5 +61,5 @@
 				RVTS.$thumbs.after(
 					'<div style="text-align:center;font-size:180%;margin:0 0 20px"><a href="'
-					+RVTS.moreUrlModel.replace('%start%', RVTS.next)+'">'
+					+RVTS.urlModel.replace('%start%', RVTS.next)+'">'
 					+RVTS.moreMsg.replace('%d', RVTS.total-RVTS.next)
 					+'</a></div>');
@@ -90,10 +89,12 @@
 	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>');
 
-	$w.scrollTop(0);
+	if ("#top" == window.location.hash)
+		window.scrollTo(0,0);
+
 	if ( RVTS.$thumbs.outerHeight() < $w.height() )
 		RVTS.adjust = 1;
 	else if ( RVTS.$thumbs.height() > 2*$w.height() )
 		RVTS.adjust = -1;
-	$w.bind('scroll resize', RVTS.checkAutoScroll);
+	$w.on('scroll resize', RVTS.checkAutoScroll);
 	if (RVTS.checkAutoScroll())
 		window.setTimeout(RVTS.checkAutoScroll,1500);
@@ -102,8 +103,29 @@
 
 $(document).ready( function() {
-	window.setTimeout(RVTS.engage,250);
+	if ("#top" == window.location.hash)
+		window.scrollTo(0,0);
+	window.setTimeout(RVTS.engage,150);
 });
 
-
-
+if (window.history.replaceState) {
+	var iniStart = RVTS.start;
+	$(window).one("RVTS_loaded", function() {
+		$(window).on("unload", function() {
+				var threshold = Math.max(0, $(window).scrollTop() - 60),
+					elts = RVTS.$thumbs.children("li");
+				for (var i=0; i<elts.length; i++) {
+					var offset = $(elts[i]).offset();
+					if (offset.top >= threshold) {
+						var start = RVTS.start+i,
+							delta = start-iniStart;
+						if (delta<0 || delta>=RVTS.perPage) {
+							var url = start ? RVTS.urlModel.replace("%start%", start) : RVTS.urlModel.replace("/start-%start%", "");
+							window.history.replaceState(null, "", url+ "#top");
+						}
+						break;
+					}
+				}
+		});
+	});
+}
 })(jQuery);
Index: /extensions/rv_tscroller/rv_tscroller.min.js
===================================================================
--- /extensions/rv_tscroller/rv_tscroller.min.js	(revision 27447)
+++ /extensions/rv_tscroller/rv_tscroller.min.js	(revision 27448)
@@ -1,1 +1,6 @@
-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);
+window.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%",
+a).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%",
+RVTS.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=
+0;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="'+
+RVTS.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;
+b(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);
