Ignore:
Timestamp:
Apr 15, 2011, 5:40:23 PM (14 years ago)
Author:
patdenice
Message:

feature:2259
Add thumbnails regeneration in batch manager

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/themes/default/template/batch_manager_global.tpl

    r10380 r10389  
    77
    88{combine_script id='jquery.fcbkcomplete' load='footer' require='jquery' path='themes/default/js/plugins/jquery.fcbkcomplete.js'}
     9{combine_script id='jquery.progressBar' load='footer' path='plugins/regenerateThumbnails/js/jquery.progressbar.min.js'}
     10{combine_script id='jquery.ajaxmanager' load='footer' path='themes/default/js/plugins/jquery.ajaxmanager.js'}
    911
    1012{footer_script require='jquery.fcbkcomplete'}{literal}
     
    2729var nb_thumbs_set = {$nb_thumbs_set};
    2830var applyOnDetails_pattern = "{'on the %d selected photos'|@translate}";
     31var elements = new Array();
     32var all_elements = [{','|@implode:$all_elements}];
    2933
    3034var selectedMessage_pattern = "{'%d of %d photos selected'|@translate}";
    3135var selectedMessage_none = "{'No photo selected, %d photos in current set'|@translate}";
    3236var selectedMessage_all = "{'All %d photos are selected'|@translate}";
     37var regenerateThumbnailsMessage = "{'Thumbnails generation in progress...'|@translate}";
    3338{literal}
     39var queuedManagerThumbnails = $.manageAjax.create('queued', {
     40        queue: true, 
     41        cacheResponse: false,
     42        maxRequests: 3
     43});
     44
    3445function str_repeat(i, m) {
    3546        for (var o = []; m > 0; o[--m] = i);
     
    7990}
    8091
     92function progress(val, max, success) {
     93  jQuery('#progressBar').progressBar(val, {
     94    max: max,
     95    textFormat: 'fraction',
     96    boxImage: 'themes/default/images/progressbar.gif',
     97    barImage: 'themes/default/images/progressbg_orange.gif'
     98  });
     99  type = success ? 'regenerateSuccess': 'regenerateError'
     100  s = jQuery('[name="'+type+'"]').val();
     101  jQuery('[name="'+type+'"]').val(++s);
     102
     103  if (val == max)
     104    jQuery('#applyAction').click();
     105}
     106
    81107$(document).ready(function() {
    82108  function checkPermitAction() {
     
    299325    });
    300326    return false;
     327  });
     328
     329  jQuery('#applyAction').click(function() {
     330    if (jQuery('[name="selectAction"]').val() == 'regenerateThumbnails') {
     331      if (elements.length != 0)
     332        return true;
     333
     334      if (jQuery('input[name="setSelected"]').attr('checked'))
     335        elements = all_elements;
     336      else
     337        jQuery('input[name="selection[]"]').each(function() {
     338          if (jQuery(this).attr('checked')) {
     339            elements.push(jQuery(this).val());
     340          }
     341        });
     342
     343      maxwidth = jQuery('input[name="thumb_maxwidth"]').val();
     344      maxheight = jQuery('input[name="thumb_maxheight"]').val();
     345      progressBar_max = elements.length;
     346      todo = 0;
     347
     348      jQuery('#thumb_config').hide();
     349      jQuery('#applyActionBlock').hide();
     350      jQuery('select[name="selectAction"]').hide();
     351      jQuery('#regenerationMsg').show();
     352      jQuery('#regenerationText').html(regenerateThumbnailsMessage);
     353      jQuery('#progressBar').progressBar(0, {
     354        max: progressBar_max,
     355        textFormat: 'fraction',
     356        boxImage: 'themes/default/images/progressbar.gif',
     357        barImage: 'themes/default/images/progressbg_orange.gif'
     358      });
     359
     360      for (i=0;i<elements.length;i++) {
     361        queuedManagerThumbnails.add({
     362          type: 'GET',
     363          url: 'ws.php',
     364          data: {
     365            method: 'pwg.images.resize',
     366            type: 'thumbnail',
     367            maxwidth: maxwidth,
     368            maxheight: maxheight,
     369            image_id: elements[i],
     370            format: 'json'
     371          },
     372          dataType: 'json',
     373          success: ( function(data) { progress(++todo, progressBar_max, data['result']) }),
     374          error: ( function(data) { progress(++todo, progressBar_max, false) })
     375        });
     376      }
     377      return false;
     378    }
    301379  });
    302380
     
    474552      <option value="add_to_caddie">{'add to caddie'|@translate}</option>
    475553  {/if}
     554      <option value="regenerateThumbnails">{'Regenerate Thumbnails'|@translate}</option>
    476555  {if !empty($element_set_global_plugins_actions)}
    477556    {foreach from=$element_set_global_plugins_actions item=action}
     
    560639    </div>
    561640
     641    <!-- regenerate thumbnails -->
     642    <div id="action_regenerateThumbnails" class="bulkAction">
     643      <table style="margin-left:20px;" id="thumb_config">
     644        <tr>
     645          <th>{'Maximum Width'|@translate}</th>
     646          <td><input type="text" name="thumb_maxwidth" value="{$upload_form_settings.thumb_maxwidth}" size="4" maxlength="4"> {'pixels'|@translate}</td>
     647        </tr>
     648        <tr>
     649          <th>{'Maximum Height'|@translate}</th>
     650          <td><input type="text" name="thumb_maxheight" value="{$upload_form_settings.thumb_maxheight}" size="4" maxlength="4"> {'pixels'|@translate}</td>
     651        </tr>
     652        <tr>
     653          <th>{'Image Quality'|@translate}</th>
     654          <td><input type="text" name="thumb_quality" value="{$upload_form_settings.thumb_quality}" size="3" maxlength="3"> %</td>
     655        </tr>
     656      </table>
     657    </div>
     658
     659    <!-- progress bar -->
     660    <div id="regenerationMsg" style="display:none;">
     661      <p id="regenerationText" style="margin-bottom:10px;"></p>
     662      <span class="progressBar" id="progressBar"></span>
     663      <input type="hidden" name="regenerateSuccess" value="0">
     664      <input type="hidden" name="regenerateError" value="0">
     665    </div>
     666
    562667    <!-- plugins -->
    563668{if !empty($element_set_global_plugins_actions)}
Note: See TracChangeset for help on using the changeset viewer.