From 72a8401f14a6c09a60f48bf938d2fa79d89c2cb5 Mon Sep 17 00:00:00 2001 From: Dario Milicic Date: Tue, 7 Oct 2014 23:48:16 +0200 Subject: [PATCH] All files that are uploaded when creating a new entry now appear in the attachment section where they can be deleted from the server entirely. NOTE: This does NOT automatically remove them from the editor as well. --- scripts/ckeditor/plugins/dndfiles/plugin.js | 73 +++++++++++++------ .../plugins/fileupload/dialogs/fileupload.js | 34 +++++++-- .../ckeditor/plugins/image2/dialogs/image2.js | 54 +++++++++++--- 3 files changed, 123 insertions(+), 38 deletions(-) diff --git a/scripts/ckeditor/plugins/dndfiles/plugin.js b/scripts/ckeditor/plugins/dndfiles/plugin.js index c2a6335b..4cbd88d3 100755 --- a/scripts/ckeditor/plugins/dndfiles/plugin.js +++ b/scripts/ckeditor/plugins/dndfiles/plugin.js @@ -74,40 +74,24 @@ CKEDITOR.plugins.add( 'dndfiles', { } } - // This function is called when the upload of files succedes. Displays uploaded images - // into img tags and everything else as an tag - function uploadSuccess(data) { - // End the progress bar - progressJs().end(); - - var html = ''; - for(var idx = 0; idx < data.attachments.length; idx++) { - var att = data.attachments[idx]; - var name = att.fullName; - - // this is an image and it has a thumbnail - if(att.thumbName) { - html += ''; - } else { // this is not an image - html += " tag + success: function(data) { + var html = ''; + + // Extract the last attachment section of the returned page + var attch = $(".attachment", $(data)).slice(-files.length); + + // Create a new attachment section that will replace the current one + var attch_upload = $("#attachment_upload", $(data)); + + $("input", attch).each(function() { + + // Extract the url of the file + var src = $(this)[0].defaultValue; + + // Ignore inputs that have this value as it is not needed + if(src === "Delete") + return; + + if(src.indexOf(".png") >= 0 || src.indexOf(".jpg") >= 0 || src.indexOf(".jpeg") >= 0) { // This is an image + html += ''; + } else { // this is not an image + // Server appends 14 characters in front of the name so we should remove them + var server_suffix = 14; + html += "