Last change
on this file since 13444 was
13444,
checked in by patdenice, 12 years ago
|
Multisize
Load thumbnails with ajax.
|
File size:
668 bytes
|
Line | |
---|
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(img, loop) { |
---|
9 | thumbnails_queue.add({ |
---|
10 | type: 'GET', |
---|
11 | url: img.data('src'), |
---|
12 | data: { ajaxload: 'true' }, |
---|
13 | dataType: 'json', |
---|
14 | success: function(result) { |
---|
15 | img.attr('src', result.url); |
---|
16 | }, |
---|
17 | error: function() { |
---|
18 | if (loop < 3) |
---|
19 | add_thumbnail_to_queue(img, ++loop); // Retry 3 times |
---|
20 | } |
---|
21 | }); |
---|
22 | } |
---|
23 | |
---|
24 | jQuery('img').each(function() { |
---|
25 | var img = jQuery(this); |
---|
26 | if (typeof img.data('src') != 'undefined') { |
---|
27 | add_thumbnail_to_queue(img, 0); |
---|
28 | } |
---|
29 | }); |
---|
Note: See
TracBrowser
for help on using the repository browser.