[12735] | 1 | /* |
---|
| 2 | Don't use directly. Compile on http://closure-compiler.appspot.com/home |
---|
| 3 | */ |
---|
[8900] | 4 | if (window.jQuery && window.RVTS) |
---|
| 5 | (function($){ |
---|
[13194] | 6 | if (RVTS.start>0) { |
---|
| 7 | var $f = $('.navigationBar A[rel=first]'); |
---|
| 8 | var f = '<a href="'+$f.attr("href")+'">'+$f.html()+'</a> | '; |
---|
| 9 | $('#thumbnails').before( '<div id=rvtsUp style="text-align:center;font-size:120%;margin:10px">'+f+'<a href="javascript:RVTS.loadUp()">'+RVTS.prevMsg+"</a></div>" ); |
---|
| 10 | } |
---|
[8900] | 11 | |
---|
| 12 | RVTS = $.fn.extend( RVTS, { |
---|
| 13 | loading: 0, |
---|
[13194] | 14 | loadingUp: 0, |
---|
[8900] | 15 | adjust: 0, |
---|
| 16 | |
---|
[13194] | 17 | loadUp: function() { |
---|
| 18 | if (RVTS.loadingUp || RVTS.start <= 0) return; |
---|
| 19 | var newStart = RVTS.start-RVTS.perPage, |
---|
| 20 | reqCount = RVTS.perPage; |
---|
| 21 | if (newStart<0) |
---|
| 22 | { |
---|
| 23 | reqCount += newStart; |
---|
| 24 | newStart = 0; |
---|
| 25 | } |
---|
| 26 | var url = RVTS.ajaxUrlModel.replace('%start%', newStart).replace('%per%', reqCount); |
---|
| 27 | $('#ajaxLoader').show(); |
---|
| 28 | RVTS.loadingUp = 1; |
---|
| 29 | $.ajax({ |
---|
| 30 | type:'GET', dataType:'html', 'url': url, |
---|
| 31 | success: function(htm) { |
---|
| 32 | RVTS.start = newStart; |
---|
| 33 | RVTS.$thumbs.prepend(htm); |
---|
| 34 | if (RVTS.start<=0) |
---|
| 35 | $("#rvtsUp").remove(); |
---|
| 36 | }, |
---|
| 37 | complete: function() { |
---|
| 38 | RVTS.loadingUp = 0; |
---|
| 39 | RVTS.loading || $('#ajaxLoader').hide(); |
---|
[16381] | 40 | $(window).trigger('RVTS_loaded', 0); |
---|
[13453] | 41 | if (typeof pwg_ajax_thumbnails_loader != 'undefined') |
---|
| 42 | pwg_ajax_thumbnails_loader(); |
---|
[13194] | 43 | } |
---|
| 44 | }); |
---|
| 45 | }, |
---|
| 46 | |
---|
[8900] | 47 | doAutoScroll: function() { |
---|
[13194] | 48 | if (RVTS.loading || RVTS.next >= RVTS.total) return; |
---|
| 49 | var url = RVTS.ajaxUrlModel.replace('%start%', RVTS.next).replace('%per%', RVTS.perPage); |
---|
[8900] | 50 | if (RVTS.adjust) { |
---|
| 51 | url += '&adj=' + RVTS.adjust; |
---|
| 52 | RVTS.adjust=0; |
---|
| 53 | } |
---|
| 54 | $('#ajaxLoader').show(); |
---|
| 55 | RVTS.loading = 1; |
---|
| 56 | $.ajax({ |
---|
| 57 | type:'GET', dataType:'html', 'url': url, |
---|
| 58 | success: function(htm) { |
---|
[13194] | 59 | RVTS.next+=RVTS.perPage; |
---|
[8900] | 60 | RVTS.$thumbs.append(htm); |
---|
[13194] | 61 | if (RVTS.next-RVTS.start>500 && RVTS.total-RVTS.next>50) { |
---|
[8900] | 62 | RVTS.$thumbs.after( |
---|
| 63 | '<div style="text-align:center;font-size:180%;margin:0 0 20px"><a href="' |
---|
[13194] | 64 | +RVTS.moreUrlModel.replace('%start%', RVTS.next)+'">' |
---|
| 65 | +RVTS.moreMsg.replace('%d', RVTS.total-RVTS.next) |
---|
[8900] | 66 | +'</a></div>'); |
---|
| 67 | RVTS.total = 0; |
---|
| 68 | } |
---|
| 69 | }, |
---|
| 70 | complete: function() { |
---|
| 71 | RVTS.loading = 0; |
---|
[13194] | 72 | RVTS.loadingUp || $('#ajaxLoader').hide(); |
---|
[16381] | 73 | $(window).trigger('RVTS_loaded', 1); |
---|
[13453] | 74 | if (typeof pwg_ajax_thumbnails_loader != 'undefined') |
---|
| 75 | pwg_ajax_thumbnails_loader(); |
---|
[8900] | 76 | } |
---|
| 77 | }); |
---|
| 78 | }, |
---|
| 79 | |
---|
| 80 | checkAutoScroll: function(evt) { |
---|
| 81 | var tBot=RVTS.$thumbs.position().top+RVTS.$thumbs.outerHeight() |
---|
| 82 | ,wBot=$(window).scrollTop()+$(window).height(); |
---|
[12735] | 83 | tBot -= !evt ? 0:100; //begin 100 pixels before end |
---|
[8900] | 84 | return tBot <= wBot ? (RVTS.doAutoScroll(),1) : 0; |
---|
| 85 | }, |
---|
| 86 | |
---|
| 87 | engage: function() { |
---|
| 88 | var $w = $(window); |
---|
| 89 | RVTS.$thumbs = $('#thumbnails'); |
---|
[13194] | 90 | 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>'); |
---|
[8900] | 91 | |
---|
| 92 | $w.scrollTop(0); |
---|
| 93 | if ( RVTS.$thumbs.outerHeight() < $w.height() ) |
---|
| 94 | RVTS.adjust = 1; |
---|
| 95 | else if ( RVTS.$thumbs.height() > 2*$w.height() ) |
---|
| 96 | RVTS.adjust = -1; |
---|
| 97 | $w.bind('scroll resize', RVTS.checkAutoScroll); |
---|
| 98 | if (RVTS.checkAutoScroll()) |
---|
| 99 | window.setTimeout(RVTS.checkAutoScroll,1500); |
---|
| 100 | } |
---|
| 101 | } );//end extend |
---|
| 102 | |
---|
| 103 | $(document).ready( function() { |
---|
| 104 | window.setTimeout(RVTS.engage,250); |
---|
| 105 | }); |
---|
| 106 | |
---|
| 107 | |
---|
| 108 | |
---|
| 109 | })(jQuery); |
---|