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