From 7b3783c9814173d05d5efb216d5b383a4aa2a8fe Mon Sep 17 00:00:00 2001 From: plegall Date: Wed, 28 May 2014 16:41:56 +0000 Subject: feature 2616: better behavior at the end of upload (more like with uploadify, but no page reload) git-svn-id: http://piwigo.org/svn/trunk@28554 68402e56-0260-453c-a942-63ccdbb3a9ee --- .../themes/default/template/photos_add_direct.tpl | 87 +++++++++++----------- 1 file changed, 45 insertions(+), 42 deletions(-) (limited to 'admin/themes/default') diff --git a/admin/themes/default/template/photos_add_direct.tpl b/admin/themes/default/template/photos_add_direct.tpl index 8f7bee6e1..0a23ca8f0 100644 --- a/admin/themes/default/template/photos_add_direct.tpl +++ b/admin/themes/default/template/photos_add_direct.tpl @@ -1,3 +1,4 @@ +{combine_script id='common' load='footer' path='admin/themes/default/js/common.js'} {combine_script id='jquery.jgrowl' load='footer' require='jquery' path='themes/default/js/plugins/jquery.jgrowl_minimized.js'} {combine_script id='jquery.plupload' load='footer' require='jquery' path='themes/default/js/plugins/plupload/plupload.full.min.js'} {combine_script id='jquery.plupload.queue' load='footer' require='jquery' path='themes/default/js/plugins/plupload/jquery.plupload.queue/jquery.plupload.queue.min.js'} @@ -35,14 +36,12 @@ categoriesCache.selectize(jQuery('[data-selectize=categories]'), { jQuery('[data-add-album]').pwgAddAlbum({ cache: categoriesCache }); -var uploadify_path = '{$uploadify_path}'; -var upload_id = '{$upload_id}'; -var session_id = '{$session_id}'; var pwg_token = '{$pwg_token}'; -var buttonText = "{'Select files'|@translate}"; -var sizeLimit = Math.round({$upload_max_filesize} / 1024); /* in KBytes */ - -var noAlbum_message = "{'Select an album'|translate}"; +var photosUploaded_label = "{'%d photos uploaded'|translate}"; +var batch_Label = "{'Manage this set of %d photos'|translate}"; +var albumSummary_label = "{'Album "%s" now contains %d photos'|translate|escape}"; +var uploadedPhotos = []; +var uploadCategory = null; {literal} jQuery(document).ready(function(){ @@ -94,6 +93,9 @@ jQuery(document).ready(function(){ BeforeUpload: function(up, file) { console.log('[BeforeUpload]', file); + // no more change on category/level + jQuery("select[name=level]").attr("disabled", "disabled"); + // You can override settings before the file is uploaded // up.setOption('url', 'upload.php?id=' + file.id); up.setOption( @@ -121,7 +123,38 @@ jQuery(document).ready(function(){ jQuery("#uploadedPhotos").prepend(html); - up.removeFile(file); + // do not remove file, or it will reset the progress bar :-/ + // up.removeFile(file); + uploadedPhotos.push(parseInt(data.result.image_id)); + uploadCategory = data.result.category; + }, + + UploadComplete: function(up, files) { + // Called when all files are either uploaded or failed + console.log('[UploadComplete]'); + + jQuery(".selectAlbum, .selectFiles, #permissions, .showFieldset").hide(); + + jQuery(".infos").append(''); + + html = sprintf( + albumSummary_label, + ''+uploadCategory.label+'', + parseInt(uploadCategory.nb_photos) + ); + + jQuery(".infos ul").append('
  • '+html+'
  • '); + + jQuery(".infos").show(); + + // TODO: use a new method pwg.caddie.empty + + // pwg.caddie.add(uploadedPhotos) instead of relying on huge GET parameter + // (and remove useless code from admin/photos_add_direct.php) + + jQuery(".batchLink").attr("href", "admin.php?page=photos_add§ion=direct&batch="+uploadedPhotos.join(",")); + jQuery(".batchLink").html(sprintf(batch_Label, uploadedPhotos.length)); + + jQuery(".afterUploadActions").show(); } } }); @@ -136,13 +169,9 @@ jQuery(document).ready(function(){
    -{* -
    -
      -
    • %d photos added..
    • -
    -
    -*} + + + {if count($setup_errors) > 0}
    @@ -166,27 +195,8 @@ jQuery(document).ready(function(){ {/if} -{if !empty($thumbnails)} -
    - {'Uploaded Photos'|@translate} -
    - {foreach from=$thumbnails item=thumbnail} - - {$thumbnail.file} - - {/foreach} -
    - -
    -

    {'Add another set of photos'|@translate}

    -{else} -
    -{if $upload_mode eq 'multiple'} - -{/if} - -
    +
    {'Drop into album'|@translate}
    -- cgit v1.2.3