source: extensions/rv_tscroller/rv_tscroller.js @ 13194

Last change on this file since 13194 was 13194, checked in by rvelices, 12 years ago

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

  • Property svn:eol-style set to LF
File size: 2.9 KB
Line 
1/*
2Don't use directly. Compile on http://closure-compiler.appspot.com/home
3*/
4if (window.jQuery && window.RVTS)
5(function($){
6$('.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}
12
13RVTS = $.fn.extend( RVTS, {
14loading: 0,
15loadingUp: 0,
16adjust: 0,
17
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
46doAutoScroll: function() {
47        if (RVTS.loading || RVTS.next >= RVTS.total) return;
48        var url = RVTS.ajaxUrlModel.replace('%start%', RVTS.next).replace('%per%', RVTS.perPage);
49        if (RVTS.adjust) {
50                url += '&adj=' + RVTS.adjust;
51                RVTS.adjust=0;
52        }
53        $('#ajaxLoader').show();
54        RVTS.loading = 1;
55        $.ajax({
56                type:'GET', dataType:'html', 'url': url,
57                success: function(htm) {
58                        RVTS.next+=RVTS.perPage;
59                        RVTS.$thumbs.append(htm);
60                        if (RVTS.next-RVTS.start>500 && RVTS.total-RVTS.next>50) {
61                                RVTS.$thumbs.after(
62                                        '<div style="text-align:center;font-size:180%;margin:0 0 20px"><a href="'
63                                        +RVTS.moreUrlModel.replace('%start%', RVTS.next)+'">'
64                                        +RVTS.moreMsg.replace('%d', RVTS.total-RVTS.next)
65                                        +'</a></div>');
66                                RVTS.total = 0;
67                        }
68                },
69                complete: function() {
70                        RVTS.loading = 0;
71                        RVTS.loadingUp || $('#ajaxLoader').hide();
72                        $(window).trigger('RVTS_loaded');
73                        }
74                });
75},
76
77checkAutoScroll: function(evt) {
78        var tBot=RVTS.$thumbs.position().top+RVTS.$thumbs.outerHeight()
79                ,wBot=$(window).scrollTop()+$(window).height();
80        tBot -= !evt ? 0:100; //begin 100 pixels before end
81        return tBot <= wBot ? (RVTS.doAutoScroll(),1) : 0;
82},
83
84engage: function() {
85        var $w = $(window);
86        RVTS.$thumbs = $('#thumbnails');
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>');
88
89        $w.scrollTop(0);
90        if ( RVTS.$thumbs.outerHeight() < $w.height() )
91                RVTS.adjust = 1;
92        else if ( RVTS.$thumbs.height() > 2*$w.height() )
93                RVTS.adjust = -1;
94        $w.bind('scroll resize', RVTS.checkAutoScroll);
95        if (RVTS.checkAutoScroll())
96                window.setTimeout(RVTS.checkAutoScroll,1500);
97}
98} );//end extend
99
100$(document).ready( function() {
101        window.setTimeout(RVTS.engage,250);
102});
103
104
105
106})(jQuery);
Note: See TracBrowser for help on using the repository browser.