source: extensions/stripped_black_bloc/js/tscroller.js @ 16787

Last change on this file since 16787 was 16787, checked in by flop25, 12 years ago

compatible with rv thumb scroller
cookie plugin minified

File size: 3.8 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        $('#content_cell').before( '<div id=rvtsUp_sc style="text-align:center;font-size:120%;margin:10px">'+f+'<a href="javascript:RVTS.loadUp()">'+RVTS.prevMsg+"</a></div>" );
11  $(window).trigger('rvtsUp');
12}
13 RVTS.doAutoScroll = undefined;
14 RVTS.checkAutoScroll = undefined;
15 RVTS.engage = undefined;
16 RVTS.loadUp = undefined;
17
18RVTS = $.fn.extend( RVTS, {
19loading: 0,
20loadingUp: 0,
21adjust: 0,
22
23loadUp: function() {
24        if (RVTS.loadingUp || RVTS.start <= 0) return;
25        var newStart = RVTS.start-RVTS.perPage,
26                reqCount = RVTS.perPage;
27        if (newStart<0)
28        {
29                reqCount += newStart;
30                newStart = 0;
31        }
32        var url = RVTS.ajaxUrlModel.replace('%start%', newStart).replace('%per%', reqCount);
33        $('#ajaxLoader').show();
34        RVTS.loadingUp = 1;
35        $.ajax({
36                type:'GET', dataType:'html', 'url': url,
37                success: function(htm) {
38                        RVTS.start = newStart;
39                        //RVTS.$thumbs.prepend(htm);
40      var $newItems = $(htm);
41      //$('#content_cell').prepend( $newItems ).isotope( 'reloadItems' ).isotope({ sortBy: 'original-order' });
42      $('#thumbnails').prepend( $newItems );
43      $('#content_cell').isotope( 'reloadItems' ).isotope({ sortBy: 'original-order' });
44                        if (RVTS.start<=0)
45                                $("#rvtsUp").remove();
46                },
47                complete: function() {
48                        RVTS.loadingUp = 0;
49                        RVTS.loading || $('#ajaxLoader').hide();
50                        $(window).trigger('RVTS_loaded');
51                        if (typeof pwg_ajax_thumbnails_loader != 'undefined')
52                                pwg_ajax_thumbnails_loader();
53                        }
54                });
55},
56
57doAutoScroll: function() {
58        if (RVTS.loading || RVTS.next >= RVTS.total) return;
59        var url = RVTS.ajaxUrlModel.replace('%start%', RVTS.next).replace('%per%', RVTS.perPage);
60        if (RVTS.adjust) {
61                url += '&adj=' + RVTS.adjust;
62                RVTS.adjust=0;
63        }
64        $('#ajaxLoader').show();
65        RVTS.loading = 1;
66        $.ajax({
67                type:'GET', dataType:'html', 'url': url,
68                success: function(htm) {
69                        RVTS.next+=RVTS.perPage;
70                        //RVTS.$thumbs.append(htm);
71      var $newItems = $(htm);
72      $('#content_cell').append( $newItems ).isotope( 'appended', $newItems );
73     
74                        if (RVTS.next-RVTS.start>500 && RVTS.total-RVTS.next>50) {
75                                RVTS.$thumbs.after(
76                                        '<div style="text-align:center;font-size:180%;margin:0 0 20px"><a href="'
77                                        +RVTS.moreUrlModel.replace('%start%', RVTS.next)+'">'
78                                        +RVTS.moreMsg.replace('%d', RVTS.total-RVTS.next)
79                                        +'</a></div>');
80                                RVTS.total = 0;
81                        }
82                },
83                complete: function() {
84                        RVTS.loading = 0;
85                        RVTS.loadingUp || $('#ajaxLoader').hide();
86                        $(window).trigger('RVTS_loaded');
87                        if (typeof pwg_ajax_thumbnails_loader != 'undefined')
88                                pwg_ajax_thumbnails_loader();
89                        }
90                });
91},
92
93checkAutoScroll: function(evt) {
94        var tBot=$('#content_cell').position().top+$('#content_cell').outerHeight()
95                ,wBot=$(window).scrollTop()+$(window).height();
96        tBot -= !evt ? 0:100; //begin 100 pixels before end
97        return tBot <= wBot ? (RVTS.doAutoScroll(),1) : 0;
98},
99
100engage: function() {
101        var $w = $(window);
102        RVTS.$thumbs = $('#thumbnails');
103        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>');
104
105        $w.scrollTop(0);
106        if ( RVTS.$thumbs.outerHeight() < $w.height() )
107                RVTS.adjust = 1;
108        else if ( RVTS.$thumbs.height() > 2*$w.height() )
109                RVTS.adjust = -1;
110        $w.bind('scroll resize', RVTS.checkAutoScroll);
111        if (RVTS.checkAutoScroll())
112                window.setTimeout(RVTS.checkAutoScroll,1500);
113}
114} );//end extend
115
116$(document).ready( function() {
117        window.setTimeout(RVTS.engage,250);
118});
119
120
121
122})(jQuery);
Note: See TracBrowser for help on using the repository browser.