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