diff --git a/scripts/ckeditor/plugins/fileupload/dialogs/fileupload.js b/scripts/ckeditor/plugins/fileupload/dialogs/fileupload.js index 2ff1f086..80e5c5f5 100644 --- a/scripts/ckeditor/plugins/fileupload/dialogs/fileupload.js +++ b/scripts/ckeditor/plugins/fileupload/dialogs/fileupload.js @@ -9,9 +9,7 @@ CKEDITOR.dialog.add( 'fileuploadDialog', function( editor ) { var lang = editor.lang.image2; - console.log(editor.lang); - console.log(lang.btnUpload); - +4 return { // Basic properties of the dialog window: title, minimum size. @@ -46,6 +44,13 @@ CKEDITOR.dialog.add( 'fileuploadDialog', function( editor ) { // grab the file(s) from the file input tag and upload it using AJAX var dialog = this.getDialog(); var files = dialog.getContentElement("Upload", "upload").getInputElement().$.files; + + // no files were selected + if(files.length == 0) { + alert("Please select a file!"); + return false; + } + var formData = new FormData(); formData.append('drop-count', files.length); // number of files being uploaded formData.append('acmd', "Upload"); // Command for the server to recognize this as an ajax upload @@ -70,7 +75,7 @@ CKEDITOR.dialog.add( 'fileuploadDialog', function( editor ) { if (evt.lengthComputable) { var percentComplete = evt.loaded / evt.total; //Do something with upload progress - // console.log(percentComplete); + console.log(percentComplete); } }, false); @@ -82,7 +87,11 @@ CKEDITOR.dialog.add( 'fileuploadDialog', function( editor ) { url: URL, data: formData, success: function(data) { - dialog.getContentElement( 'Upload', 'src' ).setValue( data.attachments[0].fullName ); + if(data.attachments[0]) { // check if we have the correct response + dialog.getContentElement( 'Upload', 'src' ).setValue( data.attachments[0].fullName ); + } else { + console.log("Data returned is not json..."); + } }, fail: function() { console.log("error"); @@ -119,9 +128,6 @@ CKEDITOR.dialog.add( 'fileuploadDialog', function( editor ) { onOk: function() { var dialog = this; - console.log(dialog.getValueOf( 'Upload', 'src' )); - console.log(dialog.getValueOf( 'Upload', 'name' )); - var file = editor.document.createElement( 'a' ); file.setAttribute( 'href', dialog.getValueOf( 'Upload', 'src' ) ); file.setText( dialog.getValueOf( 'Upload', 'name' ) ); diff --git a/scripts/ckeditor/plugins/image2/dialogs/image2.js b/scripts/ckeditor/plugins/image2/dialogs/image2.js index be1c7037..03efb92c 100755 --- a/scripts/ckeditor/plugins/image2/dialogs/image2.js +++ b/scripts/ckeditor/plugins/image2/dialogs/image2.js @@ -545,6 +545,13 @@ CKEDITOR.dialog.add( 'image2', function( editor ) { // grab the file(s) from the file input tag and upload it using AJAX var dialog = this.getDialog(); var files = dialog.getContentElement("Upload", "upload").getInputElement().$.files; + + // no files were selected + if(files.length == 0) { + alert("Please select a file!"); + return false; + } + var formData = new FormData(); formData.append('drop-count', files.length); // number of files being uploaded for (var i = 0; i < files.length; i++) { @@ -578,7 +585,11 @@ CKEDITOR.dialog.add( 'image2', function( editor ) { url: URL, data: formData, success: function(data) { - dialog.getContentElement( 'info', 'src' ).setValue( data.attachments[0].fullName ); + if(data.attachments) { // check if we have the correct response + dialog.getContentElement( 'info', 'src' ).setValue( data.attachments[0].fullName ); + } else { + console.log("Data returned is not json..."); + } }, fail: function() { console.log("error"); diff --git a/scripts/load-ckeditor.js b/scripts/load-ckeditor.js index bb4bd323..f9e19df8 100755 --- a/scripts/load-ckeditor.js +++ b/scripts/load-ckeditor.js @@ -30,8 +30,8 @@ $(document).ready(function() { var dialogDefinition = ev.data.definition; // Check if the definition is from the dialog we're - // interested in (the 'image2' and 'fileupload' dialog). - if ( dialogName == 'image2' || dialogName == 'fileupload') { + // interested in (the 'image2' and 'fileuploadDialog' dialog). + if ( dialogName == 'image2' || dialogName == 'fileuploadDialog') { var dialogObj = dialogDefinition.dialog; dialogObj.on("show", function() { diff --git a/xcode/elogd.xcodeproj/project.xcworkspace/xcuserdata/dmilicic.xcuserdatad/UserInterfaceState.xcuserstate b/xcode/elogd.xcodeproj/project.xcworkspace/xcuserdata/dmilicic.xcuserdatad/UserInterfaceState.xcuserstate index 2fb5c5ce..d8eab8fb 100644 Binary files a/xcode/elogd.xcodeproj/project.xcworkspace/xcuserdata/dmilicic.xcuserdatad/UserInterfaceState.xcuserstate and b/xcode/elogd.xcodeproj/project.xcworkspace/xcuserdata/dmilicic.xcuserdatad/UserInterfaceState.xcuserstate differ