diff --git a/scripts/ckeditor-config.js b/scripts/ckeditor-config.js index 4a7b47e1..288377de 100755 --- a/scripts/ckeditor-config.js +++ b/scripts/ckeditor-config.js @@ -8,5 +8,4 @@ CKEDITOR.editorConfig = function( config ) { // config.language = 'fr'; // config.uiColor = '#AADC6E'; config.extraPlugins = 'abbr,timestamp,dndfiles,eqneditor'; - config.filebrowserUploadUrl = "./" }; diff --git a/scripts/ckeditor/plugins/dndfiles b/scripts/ckeditor/plugins/dndfiles index bc15610a..e339fdcd 160000 --- a/scripts/ckeditor/plugins/dndfiles +++ b/scripts/ckeditor/plugins/dndfiles @@ -1 +1 @@ -Subproject commit bc15610a6c29370d2ca1b4ddfd15a3692dabbabc +Subproject commit e339fdcd88b87ae2f742d68a48ad3b3197418dd3 diff --git a/scripts/ckeditor/plugins/image2/dialogs/image2.js b/scripts/ckeditor/plugins/image2/dialogs/image2.js index c1b70dca..be1c7037 100755 --- a/scripts/ckeditor/plugins/image2/dialogs/image2.js +++ b/scripts/ckeditor/plugins/image2/dialogs/image2.js @@ -9,6 +9,7 @@ 'use strict'; + CKEDITOR.dialog.add( 'image2', function( editor ) { // RegExp: 123, 123px, empty string "" @@ -526,7 +527,6 @@ CKEDITOR.dialog.add( 'image2', function( editor ) { }, { id: 'Upload', - hidden: true, filebrowser: 'uploadButton', label: lang.uploadTab, elements: [ @@ -539,8 +539,57 @@ CKEDITOR.dialog.add( 'image2', function( editor ) { { type: 'fileButton', id: 'uploadButton', - filebrowser: 'info:src', - label: "uploadaj ovde", + onLoad: function( a ) { + CKEDITOR.document.getById( this.domId ).on( 'click', function() { + + // 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; + var formData = new FormData(); + formData.append('drop-count', files.length); // number of files being uploaded + for (var i = 0; i < files.length; i++) { + formData.append('next_attachment', parent.next_attachment); + formData.append('encoding', "HTML"); + formData.append('attfile', files[i]); + formData.append('acmd', "Upload"); // Command for the server to recognize this as an ajax upload + } + + var URL = '/' + parent.logbook + '/upload.html?next_attachment=' + parent.next_attachment; + + $.ajax({ + xhr: function() + { + var xhr = new window.XMLHttpRequest(); + + //Upload progress + xhr.upload.addEventListener("progress", function(evt){ + if (evt.lengthComputable) { + var percentComplete = evt.loaded / evt.total; + //Do something with upload progress + // console.log(percentComplete); + } + }, false); + + return xhr; + }, + contentType: false, + processData: false, + type: 'POST', + url: URL, + data: formData, + success: function(data) { + dialog.getContentElement( 'info', 'src' ).setValue( data.attachments[0].fullName ); + }, + fail: function() { + console.log("error"); + } + }); + + // Do not call the built-in click command + return false; + }, this ); + }, + label: lang.btnUpload, 'for': [ 'Upload', 'upload' ] } ] diff --git a/scripts/load-ckeditor.js b/scripts/load-ckeditor.js index 1b04ce95..434cd852 100755 --- a/scripts/load-ckeditor.js +++ b/scripts/load-ckeditor.js @@ -22,5 +22,26 @@ $(document).ready(function() { ev.editor.commands.save.exec = overridecmd.exec; }); + // There is a default listener on the submit button that we + // need to get rid off in order to get custom upload working + CKEDITOR.on('dialogDefinition', function (ev) { + // Take the dialog name and its definition from the event data. + var dialogName = ev.data.name; + var dialogDefinition = ev.data.definition; + + // Check if the definition is from the dialog we're + // interested in (the 'image2' dialog). + if ( dialogName == 'image2' ) { + + var dialogObj = dialogDefinition.dialog; + dialogObj.on("show", function() { + // replace the submit function with something useless + dialogObj.getContentElement( 'Upload', 'upload' ).submit = function() { + return false; + }; + }); + } + }); + CKEDITOR.replace('Text'); }); \ No newline at end of file diff --git a/src/elogd.c b/src/elogd.c index aaabfed8..f7717026 100755 --- a/src/elogd.c +++ b/src/elogd.c @@ -26349,7 +26349,7 @@ void show_uploader_json(LOGBOOK *lbs) } if (!getcfg("global", "charset", charset, sizeof(charset))) strcpy(charset, DEFAULT_HTTP_CHARSET); - rsprintf("Content-Type: text/plain;charset=%s\r\n\r\n", charset); + rsprintf("Content-Type: application/json;charset=%s\r\n\r\n", charset); long attch_count = strtol(getparam("drop-count"), NULL, 10); diff --git a/src/git-revision.h b/src/git-revision.h index c21a104b..694fbc1b 100644 --- a/src/git-revision.h +++ b/src/git-revision.h @@ -1 +1 @@ -#define GIT_REVISION "Thu Jul 31 17:01:04 2014 +0200 - a883408" +#define GIT_REVISION "Wed Aug 6 15:19:55 2014 +0200 - d05e601" 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 71f5faf3..10050792 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 diff --git a/xcode/elogd.xcodeproj/xcuserdata/dmilicic.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/xcode/elogd.xcodeproj/xcuserdata/dmilicic.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist index 8030e1f9..23102d5a 100644 --- a/xcode/elogd.xcodeproj/xcuserdata/dmilicic.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +++ b/xcode/elogd.xcodeproj/xcuserdata/dmilicic.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -19,5 +19,21 @@ landmarkType = "7"> + + + +