source: extensions/rv_tscroller/rv_tscroller.js @ 12703

Last change on this file since 12703 was 12703, checked in by patdenice, 12 years ago

Add "RVTS_loaded" jquery trigger for GThumb+ compatibility.

  • Property svn:eol-style set to LF
File size: 1.9 KB
Line 
1if (window.jQuery && window.RVTS)
2(function($){
3$('.navigationBar').hide();
4
5RVTS = $.fn.extend( RVTS, {
6loading: 0,
7adjust: 0,
8
9doAutoScroll: function() {
10        if (RVTS.loading || RVTS.start >= RVTS.total) return;
11        var url = RVTS.ajaxUrlModel.replace('%start%', RVTS.start).replace('%per%', RVTS.perPage);
12        if (RVTS.adjust) {
13                url += '&adj=' + RVTS.adjust;
14                RVTS.adjust=0;
15        }
16        $('#ajaxLoader').show();
17        RVTS.loading = 1;
18        $.ajax({
19                type:'GET', dataType:'html', 'url': url,
20                success: function(htm) {
21                        RVTS.start+=RVTS.perPage;
22                        RVTS.$thumbs.append(htm);
23                        if (RVTS.start>500 && RVTS.total>550) {
24                                RVTS.$thumbs.after(
25                                        '<div style="text-align:center;font-size:180%;margin:0 0 20px"><a href="'
26                                        +RVTS.moreUrlModel.replace('%start%', RVTS.start)+'">'
27                                        +RVTS.moreMsg.replace('%d', RVTS.total-RVTS.start)
28                                        +'</a></div>');
29                                RVTS.total = 0;
30                        }
31                },
32                complete: function() {
33                        RVTS.loading = 0;
34                        $('#ajaxLoader').hide();
35                        $(window).trigger('RVTS_loaded');
36                        }
37                });
38},
39
40checkAutoScroll: function(evt) {
41        var tBot=RVTS.$thumbs.position().top+RVTS.$thumbs.outerHeight()
42                ,wBot=$(window).scrollTop()+$(window).height();
43        tBot -= !evt ? 0:90; //begin 90 pixels before end
44        return tBot <= wBot ? (RVTS.doAutoScroll(),1) : 0;
45},
46
47engage: function() {
48        var $w = $(window);
49        RVTS.$thumbs = $('#thumbnails');
50        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>');
51
52        $w.scrollTop(0);
53        if ( RVTS.$thumbs.outerHeight() < $w.height() )
54                RVTS.adjust = 1;
55        else if ( RVTS.$thumbs.height() > 2*$w.height() )
56                RVTS.adjust = -1;
57        $w.bind('scroll resize', RVTS.checkAutoScroll);
58        if (RVTS.checkAutoScroll())
59                window.setTimeout(RVTS.checkAutoScroll,1500);
60}
61} );//end extend
62
63$(document).ready( function() {
64        window.setTimeout(RVTS.engage,250);
65});
66
67
68
69})(jQuery);
Note: See TracBrowser for help on using the repository browser.