Changeset 20212 for trunk/themes
- Timestamp:
- Jan 17, 2013, 7:38:54 PM (12 years ago)
- Location:
- trunk/themes/default
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/themes/default/js/thumbnails.loader.js
r20211 r20212 1 if ( typeof( max_requests ) == "undefined" ) 2 max_requests = 3; 3 1 4 var thumbnails_queue = jQuery.manageAjax.create('queued', { 2 5 queue: true, 3 6 cacheResponse: false, 4 maxRequests: 3,7 maxRequests: max_requests, 5 8 preventDoubleRequests: false 6 9 }); -
trunk/themes/default/template/comment_list.tpl
r20211 r20212 10 10 {/html_style}{/strip} 11 11 {/if} 12 {footer_script}var error_icon = "{$ROOT_URL}{$themeconf.icon_dir}/errors_small.png" {/footer_script}12 {footer_script}var error_icon = "{$ROOT_URL}{$themeconf.icon_dir}/errors_small.png";{/footer_script} 13 13 <div class="loader" style="display: none; position: fixed; right: 0;bottom: 0;"><img src="{$ROOT_URL}{$themeconf.img_dir}/ajax_loader.gif"></div> 14 14 <ul class="commentsList"> -
trunk/themes/default/template/mainpage_categories.tpl
r20161 r20212 8 8 } 9 9 {/html_style}{/strip} 10 {footer_script} 11 var error_icon = "{$ROOT_URL}{$themeconf.icon_dir}/errors_small.png"; 12 var max_requests = "{$maxRequests}"; 13 {/footer_script} 10 14 <div class="loader" style="display: none; position: fixed; right: 0;bottom: 0;"><img src="{$ROOT_URL}{$themeconf.img_dir}/ajax_loader.gif"></div> 11 15 <ul class="thumbnailCategories"> 12 16 {foreach from=$category_thumbnails item=cat name=cat_loop} 13 17 {assign var=derivative value=$pwg->derivative($derivative_params, $cat.representative.src_image)} 14 {if !$derivative->is_cached() and !$js_loaded}18 {if !$derivative->is_cached()} 15 19 {combine_script id='jquery.ajaxmanager' path='themes/default/js/plugins/jquery.ajaxmanager.js' load='footer'} 16 {*combine_script id='thumbnails.loader' path='themes/default/js/thumbnails.loader.js' require='jquery.ajaxmanager' load='footer'*} 17 {footer_script}{literal} 18 var thumbnails_queue = jQuery.manageAjax.create('queued', { 19 queue: true, 20 cacheResponse: false, 21 maxRequests: {/literal}{$maxRequests}{literal}, 22 preventDoubleRequests: false 23 }); 24 25 function add_thumbnail_to_queue(img, loop) { 26 thumbnails_queue.add({ 27 type: 'GET', 28 url: img.data('src'), 29 data: { ajaxload: 'true' }, 30 dataType: 'json', 31 beforeSend: function(){jQuery('.loader').show()}, 32 success: function(result) { 33 img.attr('src', result.url); 34 jQuery('.loader').hide(); 35 }, 36 error: function() { 37 if (loop < 3) 38 add_thumbnail_to_queue(img, ++loop); // Retry 3 times 39 img.attr('src', {/literal}"{$ROOT_URL}{$themeconf.icon_dir}/errors_small.png"{literal}); 40 jQuery('.loader').hide(); 41 } 42 }); 43 } 44 45 function pwg_ajax_thumbnails_loader() { 46 jQuery('img[data-src]').each(function() { 47 add_thumbnail_to_queue(jQuery(this), 0); 48 }); 49 } 50 jQuery(document).ready(pwg_ajax_thumbnails_loader); 51 {/literal}{/footer_script} 52 {assign var=js_loaded value=true} 20 {combine_script id='thumbnails.loader' path='themes/default/js/thumbnails.loader.js' require='jquery.ajaxmanager' load='footer'} 53 21 {/if} 54 22 <li class="{if $smarty.foreach.cat_loop.index is odd}odd{else}even{/if}"> -
trunk/themes/default/template/thumbnails.tpl
r20161 r20212 22 22 {/if} 23 23 {/html_style} 24 {footer_script} 25 var error_icon = "{$ROOT_URL}{$themeconf.icon_dir}/errors_small.png"; 26 var max_requests = "{$maxRequests}"; 27 {/footer_script} 24 28 {foreach from=$thumbnails item=thumbnail} 25 29 {assign var=derivative value=$pwg->derivative($derivative_params, $thumbnail.src_image)} 26 {if !$derivative->is_cached() and !$js_loaded}30 {if !$derivative->is_cached()} 27 31 {combine_script id='jquery.ajaxmanager' path='themes/default/js/plugins/jquery.ajaxmanager.js' load='footer'} 28 {*combine_script id='thumbnails.loader' path='themes/default/js/thumbnails.loader.js' require='jquery.ajaxmanager' load='footer'*} 29 {footer_script}{literal} 30 var thumbnails_queue = jQuery.manageAjax.create('queued', { 31 queue: true, 32 cacheResponse: false, 33 maxRequests: {/literal}{$maxRequests}{literal}, 34 preventDoubleRequests: false 35 }); 36 37 function add_thumbnail_to_queue(img, loop) { 38 thumbnails_queue.add({ 39 type: 'GET', 40 url: img.data('src'), 41 data: { ajaxload: 'true' }, 42 dataType: 'json', 43 beforeSend: function(){jQuery('.loader').show()}, 44 success: function(result) { 45 img.attr('src', result.url); 46 jQuery('.loader').hide(); 47 }, 48 error: function() { 49 if (loop < 3) 50 add_thumbnail_to_queue(img, ++loop); // Retry 3 times 51 img.attr('src', {/literal}"{$ROOT_URL}{$themeconf.icon_dir}/errors_small.png"{literal}); 52 jQuery('.loader').hide(); 53 } 54 }); 55 } 56 57 function pwg_ajax_thumbnails_loader() { 58 jQuery('img[data-src]').each(function() { 59 add_thumbnail_to_queue(jQuery(this), 0); 60 }); 61 } 62 jQuery(document).ready(pwg_ajax_thumbnails_loader); 63 {/literal}{/footer_script} 64 {assign var=js_loaded value=true} 32 {combine_script id='thumbnails.loader' path='themes/default/js/thumbnails.loader.js' require='jquery.ajaxmanager' load='footer'} 65 33 {/if} 66 34 <li>
Note: See TracChangeset
for help on using the changeset viewer.