source: extensions/rotateImage/rotate_image.tpl @ 16973

Last change on this file since 16973 was 16973, checked in by plg, 12 years ago

compatibility with Piwigo 2.4

ability to use jpegtran with $confrotate_image_jpegtran = true : lossless photo rotation

File size: 3.7 KB
Line 
1{footer_script}
2var rotateImagesMessage = "{'Images rotation in progress...'|@translate}";
3var autoRotateOptionText = "{'auto (EXIF orientation tag)'|@translate}";
4var ri_pwg_token = '{$RI_PWG_TOKEN}';
5{literal}
6jQuery(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
27  jQuery('#applyAction').click(function(e) {
28    if (typeof(elements) != "undefined") {
29      return true;
30    }
31    if (jQuery('[name="selectAction"]').val() == 'rotateImg')
32    {
33      angle = jQuery('select[name="rotate_angle"]').val();
34      rotate_hd = jQuery("#rotate_hd").is(':checked');
35      e.stopPropagation();
36    }
37    else
38    {
39      return true;
40    }
41
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    });
51
52    elements = Array();
53    if (jQuery('input[name="setSelected"]').attr('checked'))
54      elements = all_elements;
55    else
56      jQuery('input[name="selection[]"]').each(function() {
57        if (jQuery(this).attr('checked')) {
58          elements.push(jQuery(this).val());
59        }
60      });
61    progressBar_max = elements.length;
62    todo = 0;
63
64    jQuery('#applyActionBlock').hide();
65    jQuery('select[name="selectAction"]').hide();
66    jQuery('#regenerationMsg').show();
67    jQuery('#progressBar').progressBar(0, {
68      max: progressBar_max,
69      textFormat: 'fraction',
70      boxImage: 'themes/default/images/progressbar.gif',
71      barImage: 'themes/default/images/progressbg_orange.gif'
72    });
73
74    for (i=0;i<elements.length;i++) {
75      queuedManager.add({
76        type: 'GET',
77        url: 'ws.php',
78        data: {
79          method: "pwg.image.rotate",
80          format: 'json',
81          angle: angle,
82          rotate_hd: rotate_hd,
83          pwg_token: ri_pwg_token,
84          image_id: elements[i]
85        },
86        dataType: 'json',
87        success: ( function(data) { progressRotate(++todo, progressBar_max, data['result']) }),
88        error: ( function(data) { progressRotate(++todo, progressBar_max, false) })
89      });
90    }
91    return false;
92  });
93
94  function progressRotate(val, max, success) {
95    jQuery('#progressBar').progressBar(val, {
96      max: max,
97      textFormat: 'fraction',
98      boxImage: 'themes/default/images/progressbar.gif',
99      barImage: 'themes/default/images/progressbg_orange.gif'
100    });
101    type = success ? 'regenerateSuccess': 'regenerateError'
102    s = jQuery('[name="'+type+'"]').val();
103    jQuery('[name="'+type+'"]').val(++s);
104
105    if (val == max)
106      jQuery('#applyAction').click();
107  }
108
109});
110{/literal}{/footer_script}
111
112<div id="rotate_image" class="bulkAction">
113{if $library != 'gd'}
114  <p><label>
115    <input type="checkbox" name="rotate_hd" id="rotate_hd" checked="checked">
116    <strong>{'Also rotate HD image'|@translate}</strong>
117  </label></p>
118{/if}
119  <p><label>
120    <strong>{'Angle'|@translate}</strong>
121    <br>
122    <select name="rotate_angle">
123{foreach from=$angles item=angle}
124      <option value="{$angle.value}" {if $saved_angle eq $angle.value}selected="selected"{/if}>{$angle.name}</option>
125{/foreach}
126    </select>
127  </label></p>
128</div>
Note: See TracBrowser for help on using the repository browser.