[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]'); |
---|
[27448] | 8 | $('#thumbnails').before( '<div id=rvtsUp style="text-align:center;font-size:120%;margin:10px"><a href="'+$f.attr("href")+'">'+$f.html()+'</a> | <a href="javascript:RVTS.loadUp()">'+RVTS.prevMsg+"</a></div>" ); |
---|
[13194] | 9 | } |
---|
[8900] | 10 | |
---|
| 11 | RVTS = $.fn.extend( RVTS, { |
---|
| 12 | loading: 0, |
---|
[13194] | 13 | loadingUp: 0, |
---|
[8900] | 14 | adjust: 0, |
---|
| 15 | |
---|
[13194] | 16 | loadUp: function() { |
---|
| 17 | if (RVTS.loadingUp || RVTS.start <= 0) return; |
---|
| 18 | var newStart = RVTS.start-RVTS.perPage, |
---|
| 19 | reqCount = RVTS.perPage; |
---|
| 20 | if (newStart<0) |
---|
| 21 | { |
---|
| 22 | reqCount += newStart; |
---|
| 23 | newStart = 0; |
---|
| 24 | } |
---|
| 25 | var url = RVTS.ajaxUrlModel.replace('%start%', newStart).replace('%per%', reqCount); |
---|
| 26 | $('#ajaxLoader').show(); |
---|
| 27 | RVTS.loadingUp = 1; |
---|
| 28 | $.ajax({ |
---|
| 29 | type:'GET', dataType:'html', 'url': url, |
---|
| 30 | success: function(htm) { |
---|
| 31 | RVTS.start = newStart; |
---|
| 32 | RVTS.$thumbs.prepend(htm); |
---|
| 33 | if (RVTS.start<=0) |
---|
| 34 | $("#rvtsUp").remove(); |
---|
| 35 | }, |
---|
| 36 | complete: function() { |
---|
| 37 | RVTS.loadingUp = 0; |
---|
| 38 | RVTS.loading || $('#ajaxLoader').hide(); |
---|
[16381] | 39 | $(window).trigger('RVTS_loaded', 0); |
---|
[13453] | 40 | if (typeof pwg_ajax_thumbnails_loader != 'undefined') |
---|
| 41 | pwg_ajax_thumbnails_loader(); |
---|
[13194] | 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="' |
---|
[27448] | 63 | +RVTS.urlModel.replace('%start%', RVTS.next)+'">' |
---|
[13194] | 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(); |
---|
[16381] | 72 | $(window).trigger('RVTS_loaded', 1); |
---|
[13453] | 73 | if (typeof pwg_ajax_thumbnails_loader != 'undefined') |
---|
| 74 | pwg_ajax_thumbnails_loader(); |
---|
[8900] | 75 | } |
---|
| 76 | }); |
---|
| 77 | }, |
---|
| 78 | |
---|
| 79 | checkAutoScroll: function(evt) { |
---|
| 80 | var tBot=RVTS.$thumbs.position().top+RVTS.$thumbs.outerHeight() |
---|
| 81 | ,wBot=$(window).scrollTop()+$(window).height(); |
---|
[12735] | 82 | tBot -= !evt ? 0:100; //begin 100 pixels before end |
---|
[8900] | 83 | return tBot <= wBot ? (RVTS.doAutoScroll(),1) : 0; |
---|
| 84 | }, |
---|
| 85 | |
---|
| 86 | engage: function() { |
---|
| 87 | var $w = $(window); |
---|
| 88 | RVTS.$thumbs = $('#thumbnails'); |
---|
[13194] | 89 | 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] | 90 | |
---|
[27448] | 91 | if ("#top" == window.location.hash) |
---|
| 92 | window.scrollTo(0,0); |
---|
| 93 | |
---|
[8900] | 94 | if ( RVTS.$thumbs.outerHeight() < $w.height() ) |
---|
| 95 | RVTS.adjust = 1; |
---|
| 96 | else if ( RVTS.$thumbs.height() > 2*$w.height() ) |
---|
| 97 | RVTS.adjust = -1; |
---|
[27448] | 98 | $w.on('scroll resize', RVTS.checkAutoScroll); |
---|
[8900] | 99 | if (RVTS.checkAutoScroll()) |
---|
| 100 | window.setTimeout(RVTS.checkAutoScroll,1500); |
---|
| 101 | } |
---|
| 102 | } );//end extend |
---|
| 103 | |
---|
| 104 | $(document).ready( function() { |
---|
[27448] | 105 | if ("#top" == window.location.hash) |
---|
| 106 | window.scrollTo(0,0); |
---|
| 107 | window.setTimeout(RVTS.engage,150); |
---|
[8900] | 108 | }); |
---|
| 109 | |
---|
[27448] | 110 | if (window.history.replaceState) { |
---|
| 111 | var iniStart = RVTS.start; |
---|
| 112 | $(window).one("RVTS_loaded", function() { |
---|
| 113 | $(window).on("unload", function() { |
---|
| 114 | var threshold = Math.max(0, $(window).scrollTop() - 60), |
---|
| 115 | elts = RVTS.$thumbs.children("li"); |
---|
| 116 | for (var i=0; i<elts.length; i++) { |
---|
| 117 | var offset = $(elts[i]).offset(); |
---|
| 118 | if (offset.top >= threshold) { |
---|
| 119 | var start = RVTS.start+i, |
---|
| 120 | delta = start-iniStart; |
---|
| 121 | if (delta<0 || delta>=RVTS.perPage) { |
---|
| 122 | var url = start ? RVTS.urlModel.replace("%start%", start) : RVTS.urlModel.replace("/start-%start%", ""); |
---|
| 123 | window.history.replaceState(null, "", url+ "#top"); |
---|
| 124 | } |
---|
| 125 | break; |
---|
| 126 | } |
---|
| 127 | } |
---|
| 128 | }); |
---|
| 129 | }); |
---|
| 130 | } |
---|
[8900] | 131 | })(jQuery); |
---|