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

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

feature:2274
Bug corrected with crop option.
Clean code.
Add sentence in thumbnails page for regeneration.

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