Changeset 28554


Ignore:
Timestamp:
May 28, 2014, 6:41:56 PM (10 years ago)
Author:
plg
Message:

feature 2616: better behavior at the end of upload (more like with uploadify, but no page reload)

Location:
trunk
Files:
2 edited

Legend:

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

    r28552 r28554  
     1{combine_script id='common' load='footer' path='admin/themes/default/js/common.js'}
    12{combine_script id='jquery.jgrowl' load='footer' require='jquery' path='themes/default/js/plugins/jquery.jgrowl_minimized.js'}
    23{combine_script id='jquery.plupload' load='footer' require='jquery' path='themes/default/js/plugins/plupload/plupload.full.min.js'}
     
    3637jQuery('[data-add-album]').pwgAddAlbum({ cache: categoriesCache });
    3738
    38 var uploadify_path = '{$uploadify_path}';
    39 var upload_id = '{$upload_id}';
    40 var session_id = '{$session_id}';
    4139var pwg_token = '{$pwg_token}';
    42 var buttonText = "{'Select files'|@translate}";
    43 var sizeLimit = Math.round({$upload_max_filesize} / 1024); /* in KBytes */
    44 
    45 var noAlbum_message = "{'Select an album'|translate}";
     40var photosUploaded_label = "{'%d photos uploaded'|translate}";
     41var batch_Label = "{'Manage this set of %d photos'|translate}";
     42var albumSummary_label = "{'Album "%s" now contains %d photos'|translate|escape}";
     43var uploadedPhotos = [];
     44var uploadCategory = null;
    4645
    4746{literal}
     
    9594        console.log('[BeforeUpload]', file);
    9695
     96        // no more change on category/level
     97        jQuery("select[name=level]").attr("disabled", "disabled");
     98
    9799        // You can override settings before the file is uploaded
    98100        // up.setOption('url', 'upload.php?id=' + file.id);
     
    122124        jQuery("#uploadedPhotos").prepend(html);
    123125
    124         up.removeFile(file);
     126        // do not remove file, or it will reset the progress bar :-/
     127        // up.removeFile(file);
     128        uploadedPhotos.push(parseInt(data.result.image_id));
     129        uploadCategory = data.result.category;
     130      },
     131
     132      UploadComplete: function(up, files) {
     133        // Called when all files are either uploaded or failed
     134        console.log('[UploadComplete]');
     135
     136        jQuery(".selectAlbum, .selectFiles, #permissions, .showFieldset").hide();
     137
     138        jQuery(".infos").append('<ul><li>'+sprintf(photosUploaded_label, uploadedPhotos.length)+'</li></ul>');
     139
     140        html = sprintf(
     141          albumSummary_label,
     142          '<a href="admin.php?page=album-'+uploadCategory.id+'">'+uploadCategory.label+'</a>',
     143          parseInt(uploadCategory.nb_photos)
     144        );
     145
     146        jQuery(".infos ul").append('<li>'+html+'</li>');
     147
     148        jQuery(".infos").show();
     149
     150        // TODO: use a new method pwg.caddie.empty +
     151        // pwg.caddie.add(uploadedPhotos) instead of relying on huge GET parameter
     152        // (and remove useless code from admin/photos_add_direct.php)
     153
     154        jQuery(".batchLink").attr("href", "admin.php?page=photos_add&section=direct&batch="+uploadedPhotos.join(","));
     155        jQuery(".batchLink").html(sprintf(batch_Label, uploadedPhotos.length));
     156
     157        jQuery(".afterUploadActions").show();
    125158      }
    126159    }
     
    137170<div id="photosAddContent">
    138171
    139 {*
    140 <div class="infos">
    141   <ul>
    142     <li>%d photos added..</li>
    143   </ul>
    144 </div>
    145 *}
     172<div class="infos" style="display:none"></div>
     173
     174<p class="afterUploadActions" style="margin:10px; display:none;"><a class="batchLink"></a> | <a href="">{'Add another set of photos'|@translate}</a></p>
    146175
    147176{if count($setup_errors) > 0}
     
    167196
    168197
    169 {if !empty($thumbnails)}
    170 <fieldset>
    171   <legend>{'Uploaded Photos'|@translate}</legend>
    172   <div>
    173   {foreach from=$thumbnails item=thumbnail}
    174     <a href="{$thumbnail.link}" class="externalLink">
    175       <img src="{$thumbnail.src}" alt="{$thumbnail.file}" title="{$thumbnail.title}" class="thumbnail">
    176     </a>
    177   {/foreach}
    178   </div>
    179   <p id="batchLink"><a href="{$batch_link}">{$batch_label}</a></p>
    180 </fieldset>
    181 <p style="margin:10px"><a href="{$another_upload_link}">{'Add another set of photos'|@translate}</a></p>
    182 {else}
    183 
    184198<form id="uploadForm" enctype="multipart/form-data" method="post" action="{$form_action}">
    185 {if $upload_mode eq 'multiple'}
    186     <input name="upload_id" value="{$upload_id}" type="hidden">
    187 {/if}
    188 
    189     <fieldset>
     199    <fieldset class="selectAlbum">
    190200      <legend>{'Drop into album'|@translate}</legend>
    191201
     
    231241</form>
    232242
    233 <div id="uploadProgress" style="display:none">
    234 {'Photo %s of %s'|@translate:'<span id="progressCurrent">1</span>':'<span id="progressMax">10</span>'}
    235 <br>
    236 <div id="progressbar"></div>
    237 </div>
    238 
    239243<fieldset style="display:none">
    240244  <legend>{'Uploaded Photos'|@translate}</legend>
     
    242246</fieldset>
    243247
    244 {/if} {* empty($thumbnails) *}
    245248{/if} {* $setup_errors *}
    246249
  • trunk/include/ws_functions/pwg.images.php

    r28552 r28554  
    13661366    $image_infos = pwg_db_fetch_assoc(pwg_query($query));
    13671367
     1368    $query = '
     1369SELECT
     1370    COUNT(*) AS nb_photos
     1371  FROM '.IMAGE_CATEGORY_TABLE.'
     1372  WHERE category_id = '.$params['category'][0].'
     1373;';
     1374    $category_infos = pwg_db_fetch_assoc(pwg_query($query));
     1375
     1376    $category_name = get_cat_display_name_from_id($params['category'][0], null);
     1377   
    13681378    return array(
    13691379      'image_id' => $image_id,
    13701380      'src' => DerivativeImage::thumb_url($image_infos),
    13711381      'name' => $image_infos['name'],
     1382      'category' => array(
     1383        'id' => $params['category'][0],
     1384        'nb_photos' => $category_infos['nb_photos'],
     1385        'label' => $category_name,
     1386        )
    13721387      );
    13731388  }
Note: See TracChangeset for help on using the changeset viewer.