source: trunk/admin/themes/default/template/thumbnail.tpl @ 10686

Last change on this file since 10686 was 10686, checked in by patdenice, 13 years ago

feature:2259
Create two different methods in webservice to create/regenerate thumbnail and to regenerate websize.

  • Property svn:eol-style set to LF
File size: 6.6 KB
Line 
1{combine_script id='jquery.ajaxmanager' load='footer' path='themes/default/js/plugins/jquery.ajaxmanager.js'}
2
3{footer_script}
4var width_str = '{'Width'|@translate}';
5var height_str = '{'Height'|@translate}';
6var max_width_str = '{'Maximum Width'|@translate}';
7var max_height_str = '{'Maximum Height'|@translate}';
8var remaining = '{'photos without thumbnail (jpeg and png only)'|@translate}';
9var todo = {$TOTAL_NB_REMAINING};
10var done = 0;
11
12{literal}
13var queuedManager = $.manageAjax.create('queued', {
14  queue: true, 
15  cacheResponse: false,
16  maxRequests: 3,
17  complete: function() {
18    jQuery("#thumb_remaining").text(todo-(++done) + ' ' + remaining);
19    if (todo == done) {
20      jQuery('.waiting_bar, #thumb_remaining, .properties').hide();
21    }
22  }
23});
24
25function processThumbs(width,height,crop,follow_orientation) {
26  jQuery('tr.nothumb').each(function() {
27    var image_path = jQuery(this).find('td.filepath').text();
28    var td=this;
29    queuedManager.add({
30      type: 'GET',
31      url: 'ws.php',
32      data: {
33        method: 'pwg.images.resizeThumbnail',
34        image_path: image_path,
35        maxwidth: width,
36        maxheight: height,
37        crop: crop,
38        follow_orientation: follow_orientation,
39        format:'json'
40      },
41      dataType: 'json',
42      success: (function(row) { return function(data) {
43          if (data.stat =='ok') {
44            if (todo < 200)
45              jQuery(row).find('td.thumbpic').html('<img src="'+data.result.destination+'"/>');
46            jQuery(row).find('td.thumbdim').html(""+data.result.width+" x "+data.result.height);
47            jQuery(row).find('td.thumbgentime').html(""+data.result.time);
48            jQuery(row).find('td.thumbsize').html(""+data.result.size);
49            jQuery(row).removeClass("nothumb");
50          } else {
51            jQuery(row).find('td.thumbdim').html('#ERR#'+data.err+"# : "+data.message);
52            jQuery(row).removeClass("nothumb");
53            jQuery(row).addClass("error");
54          }
55        }
56      })(td)
57    });
58  });
59}
60
61function toggleCropFields() {
62  if (jQuery("#thumb_crop").is(':checked')) {
63    jQuery("label[for='thumb_maxwidth']").text(width_str);
64    jQuery("label[for='thumb_maxheight']").text(height_str);
65    jQuery("#thumb_follow_orientation_li").show();
66  }
67  else {
68    jQuery("label[for='thumb_maxwidth']").text(max_width_str);
69    jQuery("label[for='thumb_maxheight']").text(max_height_str);
70    jQuery("#thumb_follow_orientation_li").hide();
71  }
72}
73
74jQuery(document).ready(function(){
75  jQuery('input#proceed').click (function () {
76    var width = jQuery('input[name="thumb_maxwidth"]').val();
77    var height = jQuery('input[name="thumb_maxheight"]').val();
78    var crop = jQuery('#thumb_crop').is(':checked');
79    var follow_orientation = jQuery('#thumb_follow_orientation').is(':checked');
80    jQuery(".waiting_bar").toggle();
81    if (todo < 200)
82      jQuery('.thumbpic').show();
83    jQuery('.thumbgentime, .thumbsize, .thumbdim').show();
84    processThumbs(width,height,crop,follow_orientation);
85  });
86
87  jQuery('input#cancel').click (function () {
88    queuedManager.clear();
89    queuedManager.abort();
90    jQuery("input:not(.nodisable)").attr("disabled",false);
91    jQuery('tr.nothumb td.thumbpic').html("&nbsp;");
92   
93  });
94
95  toggleCropFields();
96  jQuery("#thumb_crop").click(function () {toggleCropFields()});
97
98  jQuery('.thumbpic, .thumbgentime, .thumbsize, .thumbdim').hide();
99});
100{/literal}{/footer_script}
101
102<div class="titrePage">
103  <h2>{'Thumbnail creation'|@translate}</h2>
104</div>
105
106{if !empty($remainings) }
107<form method="post" action="{$params.F_ACTION}" class="properties">
108
109  <fieldset>
110    <legend>{'Thumbnail creation'|@translate}</legend>
111
112    <ul>
113      <li>
114        <span class="property"><label for="thumb_crop">{'Crop'|@translate}</label></span>
115        <input type="checkbox" name="thumb_crop" id="thumb_crop" {$values.thumb_crop}>
116      </li>
117      <li id="thumb_follow_orientation_li">
118        <span class="property"><label for="thumb_follow_orientation">{'Follow Orientation'|@translate}</label></span>
119        <input type="checkbox" name="thumb_follow_orientation" id="thumb_follow_orientation" {$values.thumb_follow_orientation}>
120      </li>
121      <li>
122        <span class="property"><label for="thumb_maxwidth">{'Maximum Width'|@translate}</label></span>
123        <input type="text" name="thumb_maxwidth" id="thumb_maxwidth" value="{$values.thumb_maxwidth}" size="4" maxlength="4"> {'pixels'|@translate}
124      </li>
125      <li>
126        <span class="property"><label for="thumb_maxheight">{'Maximum Height'|@translate}</label></span>
127        <input type="text" name="thumb_maxheight" id="thumb_maxheight" value="{$values.thumb_maxheight}" size="4" maxlength="4"> {'pixels'|@translate}
128      </li>
129      <li>
130        <span class="property"><label for="thumb_quality">{'Image Quality'|@translate}</label></span>
131        <input type="text" name="thumb_quality" id="thumb_quality" value="{$values.thumb_quality}" size="3" maxlength="3"> %
132      </li>
133    </ul>
134  </fieldset>
135
136  <p class="waiting_bar"><input type="button" name="submit" id="proceed" value="{'Submit'|@translate}"></p>
137  <p class="waiting_bar" style="display:none;">{'Please wait...'|@translate}<br><img src="admin/themes/default/images/ajax-loader-bar.gif"></p>
138</form>
139
140<div class="admin"><span id="thumb_remaining">{$TOTAL_NB_REMAINING} {'photos without thumbnail (jpeg and png only)'|@translate}</span></div>
141<table style="width:100%;">
142  <tr class="throw">
143    <th>&nbsp;</th>
144    <th style="width:60%;">{'Path'|@translate}</th>
145    <th>{'Filesize'|@translate}</th>
146    <th>{'Dimensions'|@translate}</th>
147    <th class="thumbpic">{'Thumbnail'|@translate}</th>
148    <th class="thumbgentime">{'generated in'|@translate}</th>
149    <th class="thumbsize">{'Filesize'|@translate}</th>
150    <th class="thumbdim">{'Dimensions'|@translate}</th>
151  </tr>
152  {foreach from=$remainings item=elt name=remain_loop}
153  <tr class="{if $smarty.foreach.remain_loop.index is odd}row1{else}row2{/if} nothumb item" id="th_{$smarty.foreach.remain_loop.iteration}">
154    <td>{$smarty.foreach.remain_loop.iteration}</td>
155    <td class="filepath">{$elt.PATH}</td>
156    <td>{$elt.FILESIZE_IMG}</td>
157    <td>{$elt.WIDTH_IMG} x {$elt.HEIGHT_IMG}</td>
158  <td class="thumbpic"><img src="admin/themes/default/images/ajax-loader.gif"></td>
159  <td class="thumbgentime">&nbsp;</td>
160  <td class="thumbsize">&nbsp;</td>
161  <td class="thumbdim">&nbsp;</td>
162  </tr>
163  {/foreach}
164</table>
165{else}
166<p style="text-align:left;margin:20px;">
167<b>{'No missing thumbnail'|@translate}</b><br><br>
168{'If you want to regenerate thumbnails, please go to the <a href="%s">Batch Manager</a>.'|@translate|@sprintf:"admin.php?page=batch_manager"}
169</p>
170{/if}
Note: See TracBrowser for help on using the repository browser.