Last change
on this file since 14537 was
13920,
checked in by flop25, 12 years ago
|
feature :
-ajax loading : js+loading.gif
bug correction :
-max width for Gmap
|
File size:
765 bytes
|
Rev | Line | |
---|
[13920] | 1 | var thumbnails_queue = jQuery.manageAjax.create('queued', { |
---|
| 2 | queue: true, |
---|
| 3 | cacheResponse: false, |
---|
| 4 | maxRequests: 3, |
---|
| 5 | preventDoubleRequests: false |
---|
| 6 | }); |
---|
| 7 | |
---|
| 8 | function add_thumbnail_to_queue(link, loop) { |
---|
| 9 | thumbnails_queue.add({ |
---|
| 10 | type: 'GET', |
---|
| 11 | url: link.data('src'), |
---|
| 12 | data: { ajaxload: 'true' }, |
---|
| 13 | dataType: 'json', |
---|
| 14 | success: function(result) { |
---|
| 15 | link.css('background-image', 'url('+result.url+')'); |
---|
| 16 | |
---|
| 17 | }, |
---|
| 18 | error: function() { |
---|
| 19 | if (loop < 3) |
---|
| 20 | add_thumbnail_to_queue(link, ++loop); // Retry 3 times |
---|
| 21 | } |
---|
| 22 | }); |
---|
| 23 | } |
---|
| 24 | |
---|
| 25 | function pwg_ajax_thumbnails_loader() { |
---|
| 26 | jQuery('a[data-src]').each(function() { |
---|
| 27 | add_thumbnail_to_queue(jQuery(this), 0); |
---|
| 28 | }); |
---|
| 29 | } |
---|
| 30 | |
---|
| 31 | jQuery(document).ready(pwg_ajax_thumbnails_loader); |
---|
Note: See
TracBrowser
for help on using the repository browser.