[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($){ |
---|
| 6 | $('.navigationBar').hide(); |
---|
[13194] | 7 | if (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 | } |
---|
[8900] | 12 | |
---|
| 13 | RVTS = $.fn.extend( RVTS, { |
---|
| 14 | loading: 0, |
---|
[13194] | 15 | loadingUp: 0, |
---|
[8900] | 16 | adjust: 0, |
---|
| 17 | |
---|
[13194] | 18 | loadUp: 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 | |
---|
[8900] | 46 | doAutoScroll: function() { |
---|
[13194] | 47 | if (RVTS.loading || RVTS.next >= RVTS.total) return; |
---|
| 48 | var url = RVTS.ajaxUrlModel.replace('%start%', RVTS.next).replace('%per%', RVTS.perPage); |
---|
[8900] | 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) { |
---|
[13194] | 58 | RVTS.next+=RVTS.perPage; |
---|
[8900] | 59 | RVTS.$thumbs.append(htm); |
---|
[13194] | 60 | if (RVTS.next-RVTS.start>500 && RVTS.total-RVTS.next>50) { |
---|
[8900] | 61 | RVTS.$thumbs.after( |
---|
| 62 | '<div style="text-align:center;font-size:180%;margin:0 0 20px"><a href="' |
---|
[13194] | 63 | +RVTS.moreUrlModel.replace('%start%', RVTS.next)+'">' |
---|
| 64 | +RVTS.moreMsg.replace('%d', RVTS.total-RVTS.next) |
---|
[8900] | 65 | +'</a></div>'); |
---|
| 66 | RVTS.total = 0; |
---|
| 67 | } |
---|
| 68 | }, |
---|
| 69 | complete: function() { |
---|
| 70 | RVTS.loading = 0; |
---|
[13194] | 71 | RVTS.loadingUp || $('#ajaxLoader').hide(); |
---|
[12703] | 72 | $(window).trigger('RVTS_loaded'); |
---|
[8900] | 73 | } |
---|
| 74 | }); |
---|
| 75 | }, |
---|
| 76 | |
---|
| 77 | checkAutoScroll: function(evt) { |
---|
| 78 | var tBot=RVTS.$thumbs.position().top+RVTS.$thumbs.outerHeight() |
---|
| 79 | ,wBot=$(window).scrollTop()+$(window).height(); |
---|
[12735] | 80 | tBot -= !evt ? 0:100; //begin 100 pixels before end |
---|
[8900] | 81 | return tBot <= wBot ? (RVTS.doAutoScroll(),1) : 0; |
---|
| 82 | }, |
---|
| 83 | |
---|
| 84 | engage: function() { |
---|
| 85 | var $w = $(window); |
---|
| 86 | RVTS.$thumbs = $('#thumbnails'); |
---|
[13194] | 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>'); |
---|
[8900] | 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); |
---|