[12417] | 1 | {footer_script} |
---|
[12409] | 2 | var rotateImagesMessage = "{'Images rotation in progress...'|@translate}"; |
---|
[13319] | 3 | var autoRotateOptionText = "{'auto (EXIF orientation tag)'|@translate}"; |
---|
[12417] | 4 | var ri_pwg_token = '{$RI_PWG_TOKEN}'; |
---|
[12409] | 5 | {literal} |
---|
[13319] | 6 | jQuery(document).ready(function() { |
---|
| 7 | function autoRotateOption() { |
---|
| 8 | if (jQuery("#rotate_hd").is(':checked')) { |
---|
| 9 | jQuery("<option/>") |
---|
| 10 | .attr("id", "autoRotateOption") |
---|
| 11 | .attr("value", "auto") |
---|
| 12 | .attr("selected", "selected") |
---|
| 13 | .text(autoRotateOptionText) |
---|
| 14 | .appendTo('select[name="rotate_angle"]') |
---|
| 15 | ; |
---|
| 16 | } |
---|
| 17 | else { |
---|
| 18 | jQuery("#autoRotateOption").remove(); |
---|
| 19 | } |
---|
| 20 | } |
---|
| 21 | |
---|
| 22 | autoRotateOption(); |
---|
| 23 | jQuery('#rotate_hd').click(function() { |
---|
| 24 | autoRotateOption(); |
---|
| 25 | }); |
---|
| 26 | |
---|
[12409] | 27 | jQuery('#applyAction').click(function(e) { |
---|
[16973] | 28 | if (typeof(elements) != "undefined") { |
---|
[12409] | 29 | return true; |
---|
| 30 | } |
---|
[16973] | 31 | if (jQuery('[name="selectAction"]').val() == 'rotateImg') |
---|
[12409] | 32 | { |
---|
[12417] | 33 | angle = jQuery('select[name="rotate_angle"]').val(); |
---|
[13314] | 34 | rotate_hd = jQuery("#rotate_hd").is(':checked'); |
---|
[12409] | 35 | e.stopPropagation(); |
---|
| 36 | } |
---|
| 37 | else |
---|
| 38 | { |
---|
| 39 | return true; |
---|
| 40 | } |
---|
[16973] | 41 | |
---|
[12409] | 42 | jQuery('.bulkAction').hide(); |
---|
| 43 | jQuery('#regenerationText').html(rotateImagesMessage); |
---|
| 44 | var maxRequests=1; |
---|
| 45 | |
---|
| 46 | var queuedManager = jQuery.manageAjax.create('queued', { |
---|
| 47 | queue: true, |
---|
| 48 | cacheResponse: false, |
---|
| 49 | maxRequests: maxRequests |
---|
| 50 | }); |
---|
[16973] | 51 | |
---|
| 52 | elements = Array(); |
---|
[26925] | 53 | |
---|
| 54 | if (jQuery('input[name=setSelected]').is(':checked')) { |
---|
[12409] | 55 | elements = all_elements; |
---|
[26925] | 56 | } |
---|
| 57 | else { |
---|
| 58 | jQuery('input[name="selection[]"]').filter(':checked').each(function() { |
---|
| 59 | elements.push(jQuery(this).val()); |
---|
[12409] | 60 | }); |
---|
[26925] | 61 | } |
---|
| 62 | |
---|
[12409] | 63 | progressBar_max = elements.length; |
---|
| 64 | todo = 0; |
---|
| 65 | |
---|
| 66 | jQuery('#applyActionBlock').hide(); |
---|
| 67 | jQuery('select[name="selectAction"]').hide(); |
---|
| 68 | jQuery('#regenerationMsg').show(); |
---|
| 69 | jQuery('#progressBar').progressBar(0, { |
---|
| 70 | max: progressBar_max, |
---|
| 71 | textFormat: 'fraction', |
---|
| 72 | boxImage: 'themes/default/images/progressbar.gif', |
---|
| 73 | barImage: 'themes/default/images/progressbg_orange.gif' |
---|
| 74 | }); |
---|
| 75 | |
---|
| 76 | for (i=0;i<elements.length;i++) { |
---|
| 77 | queuedManager.add({ |
---|
| 78 | type: 'GET', |
---|
| 79 | url: 'ws.php', |
---|
| 80 | data: { |
---|
| 81 | method: "pwg.image.rotate", |
---|
| 82 | format: 'json', |
---|
| 83 | angle: angle, |
---|
[13314] | 84 | rotate_hd: rotate_hd, |
---|
[12417] | 85 | pwg_token: ri_pwg_token, |
---|
[12409] | 86 | image_id: elements[i] |
---|
| 87 | }, |
---|
| 88 | dataType: 'json', |
---|
[16973] | 89 | success: ( function(data) { progressRotate(++todo, progressBar_max, data['result']) }), |
---|
| 90 | error: ( function(data) { progressRotate(++todo, progressBar_max, false) }) |
---|
[12409] | 91 | }); |
---|
| 92 | } |
---|
| 93 | return false; |
---|
| 94 | }); |
---|
[16973] | 95 | |
---|
| 96 | function progressRotate(val, max, success) { |
---|
| 97 | jQuery('#progressBar').progressBar(val, { |
---|
| 98 | max: max, |
---|
| 99 | textFormat: 'fraction', |
---|
| 100 | boxImage: 'themes/default/images/progressbar.gif', |
---|
| 101 | barImage: 'themes/default/images/progressbg_orange.gif' |
---|
| 102 | }); |
---|
| 103 | type = success ? 'regenerateSuccess': 'regenerateError' |
---|
| 104 | s = jQuery('[name="'+type+'"]').val(); |
---|
| 105 | jQuery('[name="'+type+'"]').val(++s); |
---|
| 106 | |
---|
| 107 | if (val == max) |
---|
| 108 | jQuery('#applyAction').click(); |
---|
| 109 | } |
---|
| 110 | |
---|
[13319] | 111 | }); |
---|
[12409] | 112 | {/literal}{/footer_script} |
---|
| 113 | |
---|
| 114 | <div id="rotate_image" class="bulkAction"> |
---|
[13319] | 115 | {if $library != 'gd'} |
---|
| 116 | <p><label> |
---|
| 117 | <input type="checkbox" name="rotate_hd" id="rotate_hd" checked="checked"> |
---|
| 118 | <strong>{'Also rotate HD image'|@translate}</strong> |
---|
| 119 | </label></p> |
---|
| 120 | {/if} |
---|
| 121 | <p><label> |
---|
| 122 | <strong>{'Angle'|@translate}</strong> |
---|
| 123 | <br> |
---|
| 124 | <select name="rotate_angle"> |
---|
| 125 | {foreach from=$angles item=angle} |
---|
| 126 | <option value="{$angle.value}" {if $saved_angle eq $angle.value}selected="selected"{/if}>{$angle.name}</option> |
---|
| 127 | {/foreach} |
---|
| 128 | </select> |
---|
| 129 | </label></p> |
---|
[12409] | 130 | </div> |
---|