source: extensions/regenerateThumbnails/element_set_global_action.tpl @ 32660

Last change on this file since 32660 was 10590, checked in by patdenice, 14 years ago

image path corrected

File size: 4.7 KB
RevLine 
[9917]1{combine_script id='jquery.progressBar' path='plugins/regenerateThumbnails/js/jquery.progressbar.min.js' load='footer'}
[9934]2{combine_script id='jquery.ajaxmanager' path='themes/default/js/plugins/jquery.ajaxmanager.js' load='footer'}
[9917]3
4{footer_script require='jquery.progressBar,jquery.ajaxmanager'}
[9931]5var elements = new Array();
[9917]6var all_elements = [{','|@implode:$all_elements}];
7
8{literal}
9var queuedManager = $.manageAjax.create('queued', {
10        queue: true, 
11        cacheResponse: false,
12        maxRequests: 3
13});
14
[9931]15function progress(val, max, success) {
16  jQuery('#progressBar').progressBar(val, {
17    max: max,
18    textFormat: 'fraction',
19    boxImage: 'plugins/regenerateThumbnails/images/progressbar.gif',
20    barImage: 'plugins/regenerateThumbnails/images/progressbg_orange.gif'
21  });
22  type = success ? 'regenerateThumbnailsSuccess': 'regenerateThumbnailsError'
23  s = jQuery('[name="'+type+'"]').val();
24  jQuery('[name="'+type+'"]').val(++s);
25
26  if (val == max)
27    jQuery('#applyAction').click();
28}
29
[9917]30jQuery(document).ready(function() {
31  jQuery('#applyAction').click(function() {
[9922]32    if (jQuery('[name="selectAction"]').val() == 'regenerateThumbnails') {
[9931]33      if (elements.length != 0)
34        return true;
35
[9917]36      if (jQuery('input[name="setSelected"]').attr('checked'))
37        elements = all_elements;
38      else
39        jQuery('input[name="selection[]"]').each(function() {
40          if (jQuery(this).attr('checked')) {
41            elements.push(jQuery(this).val());
42          }
43        });
[9922]44
[9917]45      maxwidth = jQuery('input[name="thumb_maxwidth"]').val();
46      maxheight = jQuery('input[name="thumb_maxheight"]').val();
47      square = jQuery('input[name="square"]').attr('checked');
48      progressBar_max = elements.length;
49      todo = 0;
50
51      jQuery('#thumb_config').hide();
52      jQuery('#applyActionBlock').hide();
53      jQuery('select[name="selectAction"]').hide();
54      jQuery('#regenerationMsg').show();
[10387]55      jQuery('#progressBar').progressBar(0, {
56        max: progressBar_max,
57        textFormat: 'fraction',
[10590]58        boxImage: 'plugins/regenerateThumbnails/images/progressbar.gif',
59        barImage: 'plugins/regenerateThumbnails/images/progressbg_orange.gif'
[10387]60      });
[9917]61
62      for (i=0;i<elements.length;i++) {
63        queuedManager.add({
64          type: 'GET',
65          url: 'ws.php',
66          data: {
67            method: 'pwg.images.regenerateThumbnail',
68            maxwidth: maxwidth,
69            maxheight: maxheight,
70            square: square,
71            image_id: elements[i],
72            format: 'json'
73          },
74          dataType: 'json',
[10387]75          success: ( function(data) { progress(++todo, progressBar_max, data['result']) }),
[9931]76          error: ( function(data) { progress(++todo, progressBar_max, false) })
[9917]77        });
78      }
79      return false;
80    }
81  });
82});
83{/literal}{/footer_script}
84
85<table style="margin-left:20px;" id="thumb_config">
86{if isset($SQUARE)}
87<tr>
88  <th><label for="square">{'Square Thumbnails'|@translate}</label></th>
89  <td><input type="checkbox" name="square" id="square" {if $SQUARE}checked="checked"{/if}></td>
90</tr>
[9922]91{footer_script require='jquery'}{literal}
92jQuery().ready(function(){
93  jQuery("input[name^='thumb_max']").keyup(function(){
94    if(jQuery("#square").attr("checked")){
95      if (this.name == "thumb_maxwidth"){
96        jQuery("input[name='thumb_maxheight']").attr("value", this.value);
97      }else{
98        jQuery("input[name='thumb_maxwidth']").attr("value", this.value);
99      }
100    }
101  });
102  jQuery("#square").click(function(){
103    if (this.checked)
104      jQuery("input[name^='thumb_maxheight']").attr("value", jQuery("input[name^='thumb_maxwidth']").attr("value"));
105  });
106});
107{/literal}{/footer_script}
[9917]108{else}
109<tr><td><input type="checkbox" name="square" id="square" style="display:none;"></td></tr>
110{/if}
111  <tr>
112    <th>{'Maximum Width'|@translate}</th>
113    <td><input type="text" name="thumb_maxwidth" value="{$upload_form_settings.thumb_maxwidth}" size="4" maxlength="4"> {'pixels'|@translate}</td>
114  </tr>
115  <tr>
116    <th>{'Maximum Height'|@translate}</th>
117    <td><input type="text" name="thumb_maxheight" value="{$upload_form_settings.thumb_maxheight}" size="4" maxlength="4"> {'pixels'|@translate}</td>
118  </tr>
119  <tr>
120    <th>{'Image Quality'|@translate}</th>
121    <td><input type="text" name="thumb_quality" value="{$upload_form_settings.thumb_quality}" size="3" maxlength="3"> %</td>
122  </tr>
123</table>
124
125<div id="regenerationMsg" style="display:none;">{'Thumbnails generation in progress...'|@translate}<br><br>
126<span class="progressBar" id="progressBar"></span>
127</div>
[9931]128
129<input type="hidden" name="regenerateThumbnailsSuccess" value="0">
130<input type="hidden" name="regenerateThumbnailsError" value="0">
Note: See TracBrowser for help on using the repository browser.