diff options
| -rw-r--r-- | js/file-selector.js | 11 | ||||
| -rw-r--r-- | js/upload-selection.js | 2 | ||||
| -rw-r--r-- | templates/post_form.html | 7 |
3 files changed, 12 insertions, 8 deletions
diff --git a/js/file-selector.js b/js/file-selector.js index fc9c83e2..6aad9382 100644 --- a/js/file-selector.js +++ b/js/file-selector.js @@ -34,8 +34,16 @@ if (typeof max_images == 'undefined') { var max_images = 1; } +$('<div class="dropzone-wrap" style="display: none;">'+ + '<div class="dropzone" tabindex="0">'+ + '<div class="file-hint">'+_('Select/drop/paste files here')+'</div>'+ + '<div class="file-thumbs"></div>'+ + '</div>'+ + '</div>'+ +'</div>').prependTo('#upload td'); + var files = []; -$('#upload_file').hide(); // hide the original file selector +$('#upload_file').remove(); // remove the original file selector $('.dropzone-wrap').css('user-select', 'none').show(); // let jquery add browser specific prefix function addFile(file) { @@ -83,6 +91,7 @@ $(document).on('ajax_before_post', function (e, formData) { for (var i=0; i<max_images; i++) { var key = 'file'; if (i > 0) key += i + 1; + if (typeof files[i] === 'undefined') break; formData.append(key, files[i]); } }); diff --git a/js/upload-selection.js b/js/upload-selection.js index e2032748..b342a134 100644 --- a/js/upload-selection.js +++ b/js/upload-selection.js @@ -25,6 +25,7 @@ $(function(){ $("#upload_url").hide(); $("#upload_embed").hide(); $(".add_image").hide(); + $(".dropzone-wrap").hide(); $('[id^=upload_file]').each(function(i, v) { $(v).val(''); @@ -40,6 +41,7 @@ $(function(){ enable_file = function() { disable_all(); $("#upload").show(); + $(".dropzone-wrap").show(); $(".file_separator").show(); $("[id^=upload_file]").show(); $(".add_image").show(); diff --git a/templates/post_form.html b/templates/post_form.html index 00390daf..d6a77452 100644 --- a/templates/post_form.html +++ b/templates/post_form.html @@ -99,13 +99,6 @@ <td> <input type="file" name="file" id="upload_file"> - <div class="dropzone-wrap" style="display: none;"> - <div class="dropzone" tabindex="0"> - <div class="file-hint">Select/drop/paste files here</div> - <div class="file-thumbs"></div> - </div> - </div> - <script type="text/javascript">if (typeof init_file_selector !== 'undefined') init_file_selector({{ config.max_images }});</script> {% if config.allow_upload_by_url %} |
