Ignore:
Timestamp:
Aug 19, 2011, 6:04:43 PM (13 years ago)
Author:
plg
Message:

feature 2410 added: uploadify upgraded from version 2.1.0 to 3.0.0 (still beta,
but said as stable by users on uploadify forums)

bug 2411 fixed: thanks to uploadify 3.0.0, the "Browse" button is now localized
(text in any language)

bug 1653 fixed: if the selected file exceeds the upload_max_size (as defined in
the php.ini), an alert is shown and the file is not added to the queue.

bug 2412 fixed: ability to select GIF files with the Flash Uploader.

File:
1 edited

Legend:

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

    r11967 r11975  
    11{if $upload_mode eq 'multiple'}
    22{combine_script id='jquery.jgrowl' load='footer' require='jquery' path='themes/default/js/plugins/jquery.jgrowl_minimized.js' }
    3 {combine_script id='swfobject' load='footer' path='admin/include/uploadify/swfobject.js'}
    4 {combine_script id='jquery.uploadify' load='footer' require='jquery' path='admin/include/uploadify/jquery.uploadify.v2.1.0.min.js' }
     3{combine_script id='jquery.uploadify' load='footer' require='jquery' path='admin/include/uploadify/jquery.uploadify.v3.0.0.min.js' }
    54{combine_css path="admin/themes/default/uploadify.jGrowl.css"}
    65{combine_css path="admin/include/uploadify/uploadify.css"}
     
    177176var session_id = '{$session_id}';
    178177var pwg_token = '{$pwg_token}';
    179 var buttonText = 'Browse';
    180 var sizeLimit = {$upload_max_filesize};
     178var buttonText = "{'Select files'|@translate}";
     179var sizeLimit = Math.round({$upload_max_filesize} / 1024); /* in KBytes */
    181180
    182181{literal}
    183182  jQuery("#uploadify").uploadify({
    184     'uploader'       : uploadify_path + '/uploadify.swf',
    185     'script'         : uploadify_path + '/uploadify.php',
    186     'scriptData'     : {
    187       'upload_id' : upload_id,
    188       'session_id' : session_id,
    189       'pwg_token' : pwg_token,
    190     },
    191     'cancelImg'      : uploadify_path + '/cancel.png',
     183    'uploader'       : uploadify_path + '/uploadify.php',
     184    'langFile'       : uploadify_path + '/uploadifyLang_en.js',
     185    'swf'            : uploadify_path + '/uploadify.swf',
     186
     187    buttonCursor     : 'pointer',
     188    'buttonText'     : buttonText,
     189    'width'          : 300,
     190    'cancelImage'    : uploadify_path + '/cancel.png',
    192191    'queueID'        : 'fileQueue',
    193192    'auto'           : false,
    194     'buttonText'     : buttonText,
    195193    'multi'          : true,
    196     'fileDesc'       : 'Photo files (*.jpg,*.jpeg,*.png)',
    197     'fileExt'        : '*.jpg;*.JPG;*.jpeg;*.JPEG;*.png;*.PNG',
    198     'sizeLimit'      : sizeLimit,
     194    'fileTypeDesc'   : 'Photo files',
     195    'fileTypeExts'   : '*.jpg;*.JPG;*.jpeg;*.JPEG;*.png;*.PNG;*.gif;*.GIF',
     196    'fileSizeLimit'  : sizeLimit,
     197    'progressData'   : 'percentage',
     198    requeueErrors   : false,
    199199    'onSelect'       : function(event,ID,fileObj) {
    200200      jQuery("#fileQueue").show();
    201201    },
    202     'onAllComplete'  : function(event, data) {
    203       if (data.errors) {
     202    'onQueueComplete'  : function(stats) {
     203      jQuery("input[name=submit_upload]").click();
     204    },
     205    onUploadError: function (file,errorCode,errorMsg,errorString,swfuploadifyQueue) {
     206      /* uploadify calls the onUploadError trigger when the user cancels a file! */
     207      /* There no error so we skip it to avoid panic.                            */
     208      if ("Cancelled" == errorString) {
    204209        return false;
    205210      }
    206       else {
    207         jQuery("input[name=submit_upload]").click();
    208       }
    209     },
    210     onError: function (event, queueID ,fileObj, errorObj) {
    211       var msg;
    212 
    213       if (errorObj.type === "HTTP") {
    214         if (errorObj.info === 404) {
    215           alert('Could not find upload script.');
    216           msg = 'Could not find upload script.';
    217         }
    218         else {
    219           msg = errorObj.type+": "+errorObj.info;
    220         }
    221       }
    222       else if (errorObj.type ==="File Size") {
    223         msg = "File too big";
    224         msg = msg + '<br>'+fileObj.name+': '+humanReadableFileSize(fileObj.size);
    225         msg = msg + '<br>Limit: '+humanReadableFileSize(sizeLimit);
    226       }
    227       else {
    228         msg = errorObj.type+": "+errorObj.info;
    229       }
     211
     212      var msg = file.name+', '+errorString;
     213
     214      /* Let's put the error message in the form to display once the form is     */
     215      /* performed, it makes support easier when user can copy/paste the error   */
     216      /* thrown.                                                                 */
     217      jQuery("#uploadForm").append('<input type="hidden" name="onUploadError[]" value="'+msg+'">');
    230218
    231219      jQuery.jGrowl(
    232         '<p></p>'+msg,
     220        '<p></p>onUploadError '+msg,
    233221        {
    234222          theme:  'error',
    235223          header: 'ERROR',
    236           sticky: true
    237         }
    238       );
    239 
    240       jQuery("#fileUploadgrowl" + queueID).fadeOut(
    241         250,
    242         function() {
    243           jQuery("#fileUploadgrowl" + queueID).remove()
    244         }
    245       );
    246       return false;
    247     },
    248     onCancel: function (a, b, c, d) {
    249       var msg = "Cancelled uploading: "+c.name;
    250       jQuery.jGrowl(
    251         '<p></p>'+msg,
    252         {
    253           theme:  'warning',
    254           header: 'Cancelled Upload',
    255224          life:   4000,
    256225          sticky: false
    257226        }
    258227      );
     228
     229      return false;
    259230    },
    260     onClearQueue: function (a, b) {
    261       var msg = "Cleared "+b.fileCount+" files from queue";
    262       jQuery.jGrowl(
    263         '<p></p>'+msg,
    264         {
    265           theme:  'warning',
    266           header: 'Cleared Queue',
    267           life:   4000,
    268           sticky: false
    269         }
    270       );
    271     },
    272     onComplete: function (a, b ,c, response, e) {
    273       var size = Math.round(c.size/1024);
    274 
    275       var response = jQuery.parseJSON(response);
    276 
     231    onUploadSuccess: function (file,data,response) {
     232      var data = jQuery.parseJSON(data);
    277233      jQuery("#uploadedPhotos").parent("fieldset").show();
    278       jQuery("#uploadedPhotos").prepend('<img src="'+response.thumbnail_url+'" class="thumbnail"> ');
    279 
    280       jQuery.jGrowl(
    281         '<p></p>'+c.name+' - '+size+'KB',
    282         {
    283           theme:  'success',
    284           header: 'Upload Complete',
    285           life:   4000,
    286           sticky: false
    287         }
    288       );
     234
     235      /* Let's display the thumbnail of the uploaded photo, no need to wait the  */
     236      /* end of the queue                                                        */
     237      jQuery("#uploadedPhotos").prepend('<img src="'+data.thumbnail_url+'" class="thumbnail"> ');
    289238    }
    290239  });
     
    296245
    297246    jQuery("#uploadify").uploadifySettings(
    298       'scriptData',
     247      'postData',
    299248      {
    300249        'category_id' : jQuery("select[name=category] option:selected").val(),
    301250        'level' : jQuery("select[name=level] option:selected").val(),
     251        'upload_id' : upload_id,
     252        'session_id' : session_id,
     253        'pwg_token' : pwg_token,
    302254      }
    303255    );
     
    413365
    414366{elseif $upload_mode eq 'multiple'}
    415    
    416     <p>
    417       <input type="file" name="uploadify" id="uploadify">
    418     </p>
     367    <div id="uploadify">You've got a problem with your JavaScript</div>
    419368
    420369    <div id="fileQueue" style="display:none"></div>
Note: See TracChangeset for help on using the changeset viewer.