From a3963aedefad0eaefe0ba9aed463de35ee144d24 Mon Sep 17 00:00:00 2001 From: patdenice Date: Fri, 22 Apr 2011 13:19:36 +0000 Subject: feature:2274 Create thumbnail through ajax. Remove $conf['tn_width'], $conf['tn_height'] and $conf['tn_compression_level'] parameters. git-svn-id: http://piwigo.org/svn/trunk@10570 68402e56-0260-453c-a942-63ccdbb3a9ee --- admin/themes/default/template/thumbnail.tpl | 223 +++++++++++++++++----------- 1 file changed, 136 insertions(+), 87 deletions(-) (limited to 'admin/themes/default/template') diff --git a/admin/themes/default/template/thumbnail.tpl b/admin/themes/default/template/thumbnail.tpl index 1981671ed..3c46b2c2e 100644 --- a/admin/themes/default/template/thumbnail.tpl +++ b/admin/themes/default/template/thumbnail.tpl @@ -1,119 +1,168 @@ +{combine_script id='jquery.ajaxmanager' load='footer' path='themes/default/js/plugins/jquery.ajaxmanager.js'} + +{footer_script} +var width_str = '{'Width'|@translate}'; +var height_str = '{'Height'|@translate}'; +var max_width_str = '{'Maximum Width'|@translate}'; +var max_height_str = '{'Maximum Height'|@translate}'; +var remaining = '{'photos without thumbnail (jpeg and png only)'|@translate}'; +var todo = {$TOTAL_NB_REMAINING}; +var done = 0; + +{literal} +var queuedManager = $.manageAjax.create('queued', { + queue: true, + cacheResponse: false, + maxRequests: 3, + complete: function() { + jQuery("#thumb_remaining").text(todo-(++done) + ' ' + remaining); + if (todo == done) { + jQuery('.waiting_bar, #thumb_remaining, .properties').hide(); + } + } +}); + +function processThumbs(width,height,crop,follow_orientation) { + jQuery('tr.nothumb').each(function() { + var image_path = jQuery(this).find('td.filepath').text(); + var td=this; + queuedManager.add({ + type: 'GET', + url: 'ws.php', + data: { + method: 'pwg.images.resize', + image_path: image_path, + type: 'thumbnail', + maxwidth: width, + maxheight: height, + crop: crop, + follow_orientation: follow_orientation, + format:'json' + }, + dataType: 'json', + success: (function(row) { return function(data) { + if (data.stat =='ok') { + if (todo < 200) + jQuery(row).find('td.thumbpic').html(''); + jQuery(row).find('td.thumbdim').html(""+data.result.width+" x "+data.result.height); + jQuery(row).find('td.thumbgentime').html(""+data.result.time); + jQuery(row).find('td.thumbsize').html(""+data.result.size); + jQuery(row).removeClass("nothumb"); + } else { + jQuery(row).find('td.thumbpic').html('#ERR#'+data.err+"# : "+data.message); + jQuery(row).removeClass("nothumb"); + jQuery(row).addClass("error"); + } + } + })(td) + }); + }); +} + +function toggleCropFields() { + if (jQuery("#thumb_crop").is(':checked')) { + jQuery("label[for='thumb_maxwidth']").text(width_str); + jQuery("label[for='thumb_maxheight']").text(height_str); + jQuery("#thumb_follow_orientation_li").show(); + } + else { + jQuery("label[for='thumb_maxwidth']").text(max_width_str); + jQuery("label[for='thumb_maxheight']").text(max_height_str); + jQuery("#thumb_follow_orientation_li").hide(); + } +} + +jQuery(document).ready(function(){ + jQuery('input#proceed').click (function () { + var width = jQuery('input[name="thumb_maxwidth"]').val(); + var height = jQuery('input[name="thumb_maxheight"]').val(); + var crop = jQuery('#crop').is(':checked'); + var follow_orientation = jQuery('#follow_orientation').is(':checked'); + jQuery(".waiting_bar").toggle(); + if (todo < 200) + jQuery('.thumbpic').show(); + jQuery('.thumbgentime, .thumbsize, .thumbdim').show(); + processThumbs(width,height,crop,follow_orientation); + }); + + jQuery('input#cancel').click (function () { + queuedManager.clear(); + queuedManager.abort(); + jQuery("input:not(.nodisable)").attr("disabled",false); + jQuery('tr.nothumb td.thumbpic').html(" "); + + }); + + toggleCropFields(); + jQuery("#thumb_crop").click(function () {toggleCropFields()}); + + jQuery('.thumbpic, .thumbgentime, .thumbsize, .thumbdim').hide(); +}); +{/literal}{/footer_script} +

{'Thumbnail creation'|@translate}

-{if isset($results) } -
{'Results of miniaturization'|@translate}
- - - - - - - - - {foreach from=$results.elements item=elt} - - - - - - - - {/foreach} -
{'Path'|@translate}{'Thumbnail'|@translate}{'generated in'|@translate}{'Filesize'|@translate}{'Dimensions'|@translate}
{$elt.PATH}{$elt.GEN_TIME}{$elt.TN_FILESIZE_IMG}{$elt.TN_WIDTH_IMG} x {$elt.TN_HEIGHT_IMG}
- - - - - - - - - - - - - - - - - - - - - - - - - -
{'General statistics'|@translate}
{'number of miniaturized photos'|@translate}{$results.TN_NB}
{'total time'|@translate}{$results.TN_TOTAL}
{'max time'|@translate}{$results.TN_MAX}
{'min time'|@translate}{$results.TN_MIN}
{'average time'|@translate}{$results.TN_AVERAGE}
-
-{/if} - -{if isset($params) } +{if !empty($remainings) }
- {'Miniaturization parameters'|@translate} + {'Thumbnail creation'|@translate}
  • - {'GD version'|@translate} - - + + +
  • +
  • + +
  • -
  • - - - - + + {'pixels'|@translate}
  • -
  • - - - - + + {'pixels'|@translate}
  • -
  • - {'Number of thumbnails to create'|@translate} - - - - + + %
-

+

+
-{/if} {*isset params*} -{if !empty($remainings) } -
{$TOTAL_NB_REMAINING} {'photos without thumbnail (jpeg and png only)'|@translate}
+
{$TOTAL_NB_REMAINING} {'photos without thumbnail (jpeg and png only)'|@translate}
- - - - + + + + + + + + {foreach from=$remainings item=elt name=remain_loop} - + - - - + + + + + + + {/foreach}
 {'Path'|@translate}{'Filesize'|@translate}{'Dimensions'|@translate} {'Path'|@translate}{'Filesize'|@translate}{'Dimensions'|@translate}{'Thumbnail'|@translate}{'generated in'|@translate}{'Filesize'|@translate}{'Dimensions'|@translate}
{$smarty.foreach.remain_loop.iteration}
{$elt.PATH}
{$elt.FILESIZE_IMG}
{$elt.WIDTH_IMG} x {$elt.HEIGHT_IMG}
{$elt.PATH}{$elt.FILESIZE_IMG}{$elt.WIDTH_IMG} x {$elt.HEIGHT_IMG}   
{else}
[ {'No missing thumbnail'|@translate} ]
-{/if} +{/if} \ No newline at end of file -- cgit v1.2.3