Index: /extensions/rv_tscroller/language/en_UK/lang.php
===================================================================
--- /extensions/rv_tscroller/language/en_UK/lang.php	(revision 8900)
+++ /extensions/rv_tscroller/language/en_UK/lang.php	(revision 8900)
@@ -0,0 +1,3 @@
+<?php
+$lang['See the remaining %d photos']='See the remaining %d photos';
+?>
Index: /extensions/rv_tscroller/language/fr_FR/lang.php
===================================================================
--- /extensions/rv_tscroller/language/fr_FR/lang.php	(revision 8900)
+++ /extensions/rv_tscroller/language/fr_FR/lang.php	(revision 8900)
@@ -0,0 +1,3 @@
+<?php
+$lang['See the remaining %d photos']='Voir les %d photos restantes';
+?>
Index: /extensions/rv_tscroller/main.inc.php
===================================================================
--- /extensions/rv_tscroller/main.inc.php	(revision 8900)
+++ /extensions/rv_tscroller/main.inc.php	(revision 8900)
@@ -0,0 +1,139 @@
+<?php /*
+Plugin Name: RV Thumb Scroller
+Version: 2.2.a
+Plugin URI: http://piwigo.org/ext/extension_view.php?eid=493
+Description: Loads async using ajax thumbnails on index page as you scroll down the page
+Author: rvelices
+Author URI: http://www.modusoptimus.com
+*/
+define('RVTS_VERSION', 3);
+
+class RVTS
+{
+static function on_end_section_init()
+{
+	global $page;
+	if (!@$page['start'])
+	{
+		if (script_basename()!='picture')
+			$page['nb_image_page'] *= pwg_get_session_var('rvts_mult', 1);
+		if (count($page['items'])<$page['nb_image_page']+3)
+			$page['nb_image_page'] = max($page['nb_image_page'], count($page['items']));
+	}
+	add_event_handler('loc_begin_index', array('RVTS','on_index_begin'));
+}
+
+static function on_index_begin()
+{
+	global $page;
+	$is_ajax = isset($_GET['rvts']);
+	if (!$is_ajax)
+	{
+		if (empty($page['items']) || @$page['start']>0)
+			add_event_handler('loc_end_index', array('RVTS','on_end_index'));
+		else
+			add_event_handler('loc_end_index_thumbnails', array('RVTS','on_index_thumbnails'), EVENT_HANDLER_PRIORITY_NEUTRAL, 1);
+	}
+	else
+	{
+		$adj = (int)@$_GET['adj'];
+		if ($adj)
+		{
+			$mult = pwg_get_session_var('rvts_mult', 1);
+			if ($adj>0 && $mult<5)
+				pwg_set_session_var('rvts_mult', ++$mult);
+			if ($adj<0 && $mult>1)
+				pwg_set_session_var('rvts_mult', --$mult);
+		}
+		$page['nb_image_page']=(int)$_GET['rvts'];
+		add_event_handler('loc_end_index_thumbnails', array('RVTS','on_index_thumbnails_ajax'), EVENT_HANDLER_PRIORITY_NEUTRAL+5, 1);
+		set_make_full_url();
+		global $user, $template, $conf;
+		include(PHPWG_ROOT_PATH.'include/category_default.inc.php');
+	}
+}
+
+static function on_index_thumbnails($thumbs)
+{
+	global $page, $template;
+	$total = count($page['items']);
+	if (count($thumbs) >= $total)
+	{
+		add_event_handler('loc_end_index', array('RVTS','on_end_index'));
+		return $thumbs;
+	}
+	$per_page = $page['nb_image_page'];
+	$url_model = str_replace('123456789', '%start%', duplicate_index_url( array('start'=>123456789) ) );
+	$ajax_url_model = add_url_params($url_model, array( 'rvts'=>'' ) );
+
+	$url_model = str_replace('&amp;', '&', $url_model);
+	$ajax_url_model = str_replace('&amp;', '&', $ajax_url_model);
+	
+	$my_base_name = basename(dirname(__FILE__));
+	$ajax_loader_image = get_root_url()."plugins/$my_base_name/ajax-loader.gif";
+	$template->func_combine_script( array(
+			'id'=> 'jquery',
+			'load'=> 'footer',
+			'path'=> 'themes/default/js/jquery.min.js',
+		), $template->smarty);
+	$template->func_combine_script( array(
+			'id'=> $my_base_name,
+			'load'=> 'async',
+			'path'=> 'plugins/'.$my_base_name.'/rv_tscroller.min.js',
+			'require' => 'jquery',
+			'version' => RVTS_VERSION,
+		), $template->smarty);
+	$moreMsg = 'See the remaining %d photos';
+	load_language('lang', dirname(__FILE__).'/');
+	$moreMsg = l10n($moreMsg);
+	$repeat=false;
+	$template->block_footer_script(null,
+		"var RVTS = {
+ajaxUrlModel: '$ajax_url_model'+'%per%',
+start: $per_page,
+total: $total,
+perPage: $per_page,
+urlModel: '$url_model',
+moreMsg: '$moreMsg',
+ajaxLoaderImage: '$ajax_loader_image'
+};",
+		$template->smarty, $repeat);
+	return $thumbs;
+}
+
+static function on_index_thumbnails_ajax($thumbs)
+{
+	global $template;
+	$template->assign('thumbnails', $thumbs);
+	header('Content-Type: text/html; charset='.get_pwg_charset());
+	$template->pparse('index_thumbnails');
+	exit;
+}
+
+static function on_end_index()
+{
+	global $template;
+	$req = null;
+	foreach($template->scriptLoader->get_all() as $script)
+	{
+		if($script->load_mode==2 && !$script->is_remote())
+			$req = $script->id;
+	}
+	if($req!=null)
+	{
+		$my_base_name = basename(dirname(__FILE__));
+		$template->func_combine_script( array(
+			'id'=> $my_base_name,
+			'load'=> 'async',
+			'path'=> 'plugins/'.$my_base_name.'/rv_tscroller.min.js',
+			'require' => $req,
+			'version' => RVTS_VERSION,
+		), $template->smarty);
+	}
+}
+
+}
+
+add_event_handler('loc_end_section_init', array('RVTS','on_end_section_init'));
+
+?>
Index: /extensions/rv_tscroller/rv_tscroller.js
===================================================================
--- /extensions/rv_tscroller/rv_tscroller.js	(revision 8900)
+++ /extensions/rv_tscroller/rv_tscroller.js	(revision 8900)
@@ -0,0 +1,68 @@
+if (window.jQuery && window.RVTS)
+(function($){
+$('.navigationBar').hide();
+
+RVTS = $.fn.extend( RVTS, {
+loading: 0,
+adjust: 0,
+
+doAutoScroll: function() {
+	if (RVTS.loading || RVTS.start >= RVTS.total) return;
+	var url = RVTS.ajaxUrlModel.replace('%start%', RVTS.start).replace('%per%', RVTS.perPage);
+	if (RVTS.adjust) {
+		url += '&adj=' + RVTS.adjust;
+		RVTS.adjust=0;
+	}
+	$('#ajaxLoader').show();
+	RVTS.loading = 1;
+	$.ajax({
+		type:'GET', dataType:'html', 'url': url,
+		success: function(htm) {
+			RVTS.start+=RVTS.perPage;
+			RVTS.$thumbs.append(htm);
+			if (RVTS.start>500 && RVTS.total>550) {
+				RVTS.$thumbs.after(
+					'<div style="text-align:center;font-size:180%;margin:0 0 20px"><a href="'
+					+RVTS.urlModel.replace('%start%', RVTS.start)+'">'
+					+RVTS.moreMsg.replace('%d', RVTS.total-RVTS.start)
+					+'</a></div>');
+				RVTS.total = 0;
+			}
+		},
+		complete: function() {
+			RVTS.loading = 0;
+			$('#ajaxLoader').hide();
+			}
+		});
+},
+
+checkAutoScroll: function(evt) {
+	var tBot=RVTS.$thumbs.position().top+RVTS.$thumbs.outerHeight()
+		,wBot=$(window).scrollTop()+$(window).height();
+	tBot -= !evt ? 0:40; //begin 40 pixels before end
+	return tBot <= wBot ? (RVTS.doAutoScroll(),1) : 0;
+},
+
+engage: function() {
+	var $w = $(window);
+	RVTS.$thumbs = $('#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>');
+
+	$w.scrollTop(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);
+	if (RVTS.checkAutoScroll())
+		window.setTimeout(RVTS.checkAutoScroll,1500);
+}
+} );//end extend
+
+$(document).ready( function() {
+	window.setTimeout(RVTS.engage,250);
+});
+
+
+
+})(jQuery);
Index: /extensions/rv_tscroller/rv_tscroller.min.js
===================================================================
--- /extensions/rv_tscroller/rv_tscroller.min.js	(revision 8900)
+++ /extensions/rv_tscroller/rv_tscroller.min.js	(revision 8900)
@@ -0,0 +1,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(c){RVTS.start+=RVTS.perPage;RVTS.$thumbs.append(c);if(RVTS.start>500&&RVTS.total>550){RVTS.$thumbs.after('<div style="text-align:center;font-size:180%;margin:0 0 20px"><a href="'+ RVTS.urlModel.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()}})}},checkAutoScroll:function(b){var c=RVTS.$thumbs.position().top+RVTS.$thumbs.outerHeight(),d=a(window).scrollTop()+a(window).height();c-=!b?0:40;return c<=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);
