mirror of
https://gitea.psi.ch/ELOG/elog.git
synced 2026-09-08 17:13:56 +00:00
Finished Drag & Drop, resize editor window (all modes) to fit exactly browser window.
This commit is contained in:
parent
16748f643b
commit
3d5f1cbc12
@ -8,6 +8,7 @@ CKEDITOR.editorConfig = function( config ) {
|
||||
// config.language = 'fr';
|
||||
// config.uiColor = '#AADC6E';
|
||||
config.extraPlugins = 'timestamp,dndfiles,eqneditor,fileupload';
|
||||
config.toolbarCanCollapse = true;
|
||||
|
||||
// Toolbar configuration
|
||||
config.toolbar = [
|
||||
|
||||
113
scripts/dnd.js
113
scripts/dnd.js
@ -30,14 +30,115 @@ function XMLHttpRequestGeneric()
|
||||
return request;
|
||||
}
|
||||
|
||||
// asend does an AJAX call to send current form data to server
|
||||
function asend() {
|
||||
var f = document.form1;
|
||||
var r = XMLHttpRequestGeneric();
|
||||
r.onreadystatechange = function()
|
||||
{
|
||||
if (r.readyState==4 && r.status==200)
|
||||
document.title = page_title;
|
||||
}
|
||||
|
||||
r.open("Post", ".");
|
||||
var f = new FormData(document.form1);
|
||||
f.append("jcmd", "Save");
|
||||
r.send(f);
|
||||
}
|
||||
|
||||
// getElementById
|
||||
function $id(id) {
|
||||
return document.getElementById(id);
|
||||
}
|
||||
|
||||
function drag(e)
|
||||
{
|
||||
console.log('drag');
|
||||
var uploading_dropped_files = false;
|
||||
|
||||
// upload file(s) after thei have been dropped
|
||||
function upload(files) {
|
||||
var formData = (!!window.FormData) ? new FormData() : null;
|
||||
|
||||
// add all the other attachments that were previously added
|
||||
$( "input[name^='attachment']" ).each(function(idx, el) {
|
||||
formData.append($(el).attr('name'), $(el).attr('value'));
|
||||
});
|
||||
|
||||
formData.append('drop-count', files.length); // number of files dropped that should be sent
|
||||
for (var i = 0; i < files.length; i++) {
|
||||
if (!!window.FormData) {
|
||||
formData.append('next_attachment', parent.next_attachment);
|
||||
formData.append('encoding', "HTML");
|
||||
formData.append('attfile', files[i]);
|
||||
|
||||
parent.next_attachment += 1;
|
||||
}
|
||||
}
|
||||
|
||||
formData.append('cmd', "Upload"); // Command for server to recognize this as an file upload
|
||||
|
||||
if (!!window.FormData) {
|
||||
var URL = 'upload.html?next_attachment=' + parent.next_attachment;
|
||||
|
||||
// set the flag so the chkupload validator doesn't trigger
|
||||
uploading_dropped_files = true;
|
||||
|
||||
var submiter = $("input[value='Upload']");
|
||||
var fileinput = $("input[type='File']");
|
||||
|
||||
// If we are uploading drag&drop files then ignore the validator
|
||||
submiter.on("click", function(e) {
|
||||
if(uploading_dropped_files == false) {
|
||||
return chkupload();
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
// We have finished uploading drag&drop files
|
||||
uploading_dropped_files = false;
|
||||
|
||||
$.ajax({
|
||||
xhr: function()
|
||||
{
|
||||
var xhr = new window.XMLHttpRequest();
|
||||
|
||||
// Start the progress bar
|
||||
progressJs().start();
|
||||
|
||||
//Upload progress
|
||||
xhr.upload.addEventListener("progress", function(evt){
|
||||
if (evt.lengthComputable) {
|
||||
var percentComplete = evt.loaded / evt.total;
|
||||
//Update the progress bar
|
||||
progressJs().set(percentComplete);
|
||||
}
|
||||
}, false);
|
||||
|
||||
return xhr;
|
||||
},
|
||||
contentType: false,
|
||||
processData: false,
|
||||
type: 'POST',
|
||||
url: URL,
|
||||
data: formData,
|
||||
success: function(data) {
|
||||
// End the progress bar
|
||||
progressJs().end();
|
||||
|
||||
var attch = $(".attachment", $(data));
|
||||
var attch_upload = $("#attachment_upload", $(data));
|
||||
|
||||
// add the new attachments to the current page
|
||||
$("#attachment_upload").before(attch.slice(-files.length));
|
||||
|
||||
// replace the attachment upload section
|
||||
$("#attachment_upload").replaceWith(attch_upload);
|
||||
},
|
||||
fail: function() {
|
||||
// End the progress bar
|
||||
progressJs().end();
|
||||
console.log("Error uploading files...");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function dragover(e)
|
||||
@ -51,7 +152,6 @@ function dragenter(e)
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
$id('holder').style.border = '6px dashed #0c0';
|
||||
console.log('dragenter');
|
||||
}
|
||||
|
||||
function dragleave(e)
|
||||
@ -59,14 +159,14 @@ function dragleave(e)
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
$id('holder').style.border = '6px dashed #ccc';
|
||||
console.log('dragleave');
|
||||
}
|
||||
|
||||
function drop(e)
|
||||
{
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
console.log('drop');
|
||||
$id('holder').style.border = '6px dashed #ccc';
|
||||
upload(e.dataTransfer.files);
|
||||
}
|
||||
|
||||
function dndInit()
|
||||
@ -79,7 +179,6 @@ function dndInit()
|
||||
});
|
||||
|
||||
d = $id('holder');
|
||||
d.addEventListener('drag', drag);
|
||||
d.addEventListener('dragover', dragover);
|
||||
d.addEventListener('dragenter', dragenter);
|
||||
d.addEventListener('dragleave', dragleave);
|
||||
|
||||
@ -26,8 +26,9 @@ $(document).ready(function() {
|
||||
var editor = ev.editor;
|
||||
|
||||
// Make the editor bigger (at least 500px high and 80% of the viewport otherwise)
|
||||
var width = Math.max(500, 0.8 * $(window).height() );
|
||||
editor.resize("100%", new String(width));
|
||||
//var width = Math.max(500, 0.7 * $(window).height() );
|
||||
//editor.resize("100%", new String(width));
|
||||
init_resize();
|
||||
|
||||
// Create a new command with the desired exec function
|
||||
var overridecmd = new CKEDITOR.command(editor, {
|
||||
@ -108,138 +109,4 @@ $(document).ready(function() {
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
var uploading_dropped_files = false;
|
||||
|
||||
// We should check if the browser supports these events
|
||||
var tests = {
|
||||
filereader: typeof FileReader != 'undefined',
|
||||
dnd: 'draggable' in document.createElement('span'),
|
||||
formdata: !!window.FormData,
|
||||
progress: "upload" in new XMLHttpRequest
|
||||
}
|
||||
|
||||
function upload(files) {
|
||||
// debugger;
|
||||
|
||||
var formData = tests.formdata ? new FormData() : null;
|
||||
|
||||
// add all the other attachments that were previously added
|
||||
$( "input[name^='attachment']" ).each(function(idx, el) {
|
||||
formData.append($(el).attr('name'), $(el).attr('value'));
|
||||
});
|
||||
|
||||
formData.append('drop-count', files.length); // number of files dropped that should be sent
|
||||
for (var i = 0; i < files.length; i++) {
|
||||
if (tests.formdata) {
|
||||
formData.append('next_attachment', parent.next_attachment);
|
||||
formData.append('encoding', "HTML");
|
||||
formData.append('attfile', files[i]);
|
||||
|
||||
parent.next_attachment += 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
formData.append('cmd', "Upload"); // Command for server to recognize this as an file upload
|
||||
|
||||
if (tests.formdata) {
|
||||
var URL = 'upload.html?next_attachment=' + parent.next_attachment;
|
||||
|
||||
// set the flag so the chkupload validator doesn't trigger
|
||||
uploading_dropped_files = true;
|
||||
|
||||
var submiter = $("input[value='Upload']");
|
||||
var fileinput = $("input[type='File']");
|
||||
|
||||
// If we are uploading drag&drop files then ignore the validator
|
||||
submiter.on("click", function(e) {
|
||||
if(uploading_dropped_files == false) {
|
||||
return chkupload();
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
// Start the POST request with dropped files
|
||||
// submiter.click();
|
||||
|
||||
// We have finished uploading drag&drop files
|
||||
uploading_dropped_files = false;
|
||||
|
||||
$.ajax({
|
||||
xhr: function()
|
||||
{
|
||||
var xhr = new window.XMLHttpRequest();
|
||||
|
||||
// Start the progress bar
|
||||
progressJs().start();
|
||||
|
||||
//Upload progress
|
||||
xhr.upload.addEventListener("progress", function(evt){
|
||||
if (evt.lengthComputable) {
|
||||
var percentComplete = evt.loaded / evt.total;
|
||||
//Update the progress bar
|
||||
progressJs().set(percentComplete);
|
||||
}
|
||||
}, false);
|
||||
|
||||
return xhr;
|
||||
},
|
||||
contentType: false,
|
||||
processData: false,
|
||||
type: 'POST',
|
||||
url: URL,
|
||||
data: formData,
|
||||
success: function(data) {
|
||||
// End the progress bar
|
||||
progressJs().end();
|
||||
|
||||
var attch = $(".attachment", $(data));
|
||||
var attch_upload = $("#attachment_upload", $(data));
|
||||
|
||||
// add the new attachments to the current page
|
||||
$("#attachment_upload").before(attch.slice(-files.length));
|
||||
|
||||
// replace the attachment upload section
|
||||
$("#attachment_upload").replaceWith(attch_upload);
|
||||
},
|
||||
fail: function() {
|
||||
// End the progress bar
|
||||
progressJs().end();
|
||||
console.log("Error uploading files...");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
var holder = $("#holder");
|
||||
holder.dndhover().on({
|
||||
'dndHoverStart' : function(event) {
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
console.log("holder-enter")
|
||||
holder.css("border", "6px dashed #0c0");
|
||||
return false;
|
||||
},
|
||||
'dragover' : function(event) {
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
return false;
|
||||
},
|
||||
'dndHoverEnd' : function(event) {
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
console.log("holder-leave");
|
||||
holder.css("border", "6px dashed #ccc");
|
||||
return false;
|
||||
},
|
||||
'drop' : function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
console.log("holder-drop");
|
||||
holder.css("border", "10px dashed #ccc");
|
||||
|
||||
upload(e.originalEvent.dataTransfer.files);
|
||||
}
|
||||
});
|
||||
});
|
||||
@ -26,7 +26,7 @@
|
||||
\********************************************************************/
|
||||
|
||||
/* Version of ELOG */
|
||||
#define VERSION "3.0.0"
|
||||
#define VERSION "3.1.0"
|
||||
|
||||
/* ELOG identification */
|
||||
static const char ELOGID[] = "elogd " VERSION " built " __DATE__ ", " __TIME__;
|
||||
|
||||
73
src/elogd.c
73
src/elogd.c
@ -10097,48 +10097,6 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL
|
||||
rsprintf(" return true;\n");
|
||||
rsprintf("}\n\n");
|
||||
|
||||
/* asend does an AJAX call to send current form data to server */
|
||||
rsprintf("function asend() {\n");
|
||||
rsprintf(" var multipart = \"\";\n");
|
||||
rsprintf(" r = XMLHttpRequestGeneric();\n");
|
||||
rsprintf(" r.onreadystatechange = function()\n");
|
||||
rsprintf(" {\n");
|
||||
rsprintf(" if (r.readyState==4 && r.status==200)\n");
|
||||
rsprintf(" document.title = '%s';\n", page_title);
|
||||
rsprintf(" }\n");
|
||||
rsprintf(" r.open('POST', '.', true);\n", loc("Back"), message_id);
|
||||
rsprintf(" var boundary = '----'+Math.random().toString().substr(2);\n");
|
||||
rsprintf(" r.setRequestHeader(\"Content-type\", \"multipart/form-data; boundary=\"+boundary);\n");
|
||||
|
||||
// Atttrib = value
|
||||
rsprintf(" for (var i = 0; i < document.form1.elements.length; i++) {\n");
|
||||
rsprintf(" e = document.form1.elements[i];\n");
|
||||
rsprintf(" if (e.type == 'text' || e.type == 'select-one' ||\n");
|
||||
rsprintf(" e.type == 'hidden' ||\n");
|
||||
rsprintf(" (e.type == 'checkbox' && e.checked == true) ||\n");
|
||||
rsprintf(" (e.type == 'radio' && e.checked == true))\n");
|
||||
rsprintf(" multipart += \"--\" + boundary\n");
|
||||
rsprintf(" + \"\\r\\nContent-Disposition: form-data; \"\n");
|
||||
rsprintf(" + \"name=\\\"\"+e.name+\"\\\"\\r\\n\\r\\n\"+e.value+\"\\r\\n\";\n");
|
||||
rsprintf(" }\n");
|
||||
|
||||
// Add text
|
||||
rsprintf(" if (typeof(CKEDITOR) != 'undefined')\n");
|
||||
rsprintf(" t = CKEDITOR.instances.Text.getData();\n");
|
||||
rsprintf(" else\n");
|
||||
rsprintf(" t = document.form1.Text.value;\n");
|
||||
rsprintf(" multipart += \"--\" + boundary\n");
|
||||
rsprintf(" + \"\\r\\nContent-Disposition: form-data; \"\n");
|
||||
rsprintf(" + \"name=\\\"Text\\\"\\r\\n\\r\\n\"+t+\"\\r\\n\";\n");
|
||||
|
||||
// jcmd = Save
|
||||
rsprintf(" multipart += \"--\" + boundary\n");
|
||||
rsprintf(" + \"\\r\\nContent-Disposition: form-data; name=\\\"jcmd\\\"\\r\\n\\r\\nSave\\r\\n\";\n");
|
||||
|
||||
rsprintf(" multipart += \"--\" + boundary + \"--\\r\\n\"\n");
|
||||
rsprintf(" r.send(multipart);\n");
|
||||
rsprintf("}\n\n");
|
||||
|
||||
/* go_back() gets called via "Back" button */
|
||||
rsprintf("function go_back()\n");
|
||||
rsprintf("{\n");
|
||||
@ -10265,7 +10223,7 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL
|
||||
rsprintf(" }\n");
|
||||
rsprintf("}\n\n");
|
||||
|
||||
if (enc_selected != 2 && !getcfg(lbs->name, "Message height", str, sizeof(str)) &&
|
||||
if (/*enc_selected != 2 && */ !getcfg(lbs->name, "Message height", str, sizeof(str)) &&
|
||||
!getcfg(lbs->name, "Message width", str, sizeof(str))) {
|
||||
/* javascript for resizing edit box */
|
||||
rsprintf("\nfunction init_resize()\n");
|
||||
@ -10275,22 +10233,26 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL
|
||||
rsprintf("}\n\n");
|
||||
rsprintf("function resize_textarea()\n");
|
||||
rsprintf("{\n");
|
||||
rsprintf(" p = document.form1.Text;\n");
|
||||
rsprintf(" p = $id('TextParent');\n");
|
||||
rsprintf(" t = p.offsetTop;\n");
|
||||
rsprintf(" while (p = p.offsetParent)\n");
|
||||
rsprintf(" t += p.offsetTop;\n");
|
||||
rsprintf(" if (window.innerHeight) // netscape\n");
|
||||
rsprintf(" height = window.innerHeight - t - 135 - 50 - 30;\n");
|
||||
rsprintf(" height = window.innerHeight - t - 135 - 50 - 20;\n");
|
||||
rsprintf(" else // IE\n");
|
||||
rsprintf(" height = document.body.offsetHeight - t - 135 - 50 - 30;\n");
|
||||
rsprintf(" height = document.body.offsetHeight - t - 135 - 50 - 20;\n");
|
||||
rsprintf(" if (height < 300)\n");
|
||||
rsprintf(" height = 300;\n");
|
||||
rsprintf(" document.form1.Text.style.height = height+\"px\";\n");
|
||||
rsprintf(" width = window.innerWidth;\n");
|
||||
rsprintf(" if (width < 300)\n");
|
||||
rsprintf(" width = 300;\n");
|
||||
rsprintf(" width = width - 20;");
|
||||
rsprintf(" document.form1.Text.style.width = width+\"px\";\n");
|
||||
rsprintf(" width = width - 6;\n");
|
||||
rsprintf(" if (typeof(CKEDITOR) != 'undefined')\n");
|
||||
rsprintf(" CKEDITOR.instances.Text.resize(width, height);\n");
|
||||
rsprintf(" else {\n");
|
||||
rsprintf(" document.form1.Text.style.height = height+6+\"px\";\n");
|
||||
rsprintf(" document.form1.Text.style.width = width-6+\"px\";\n");
|
||||
rsprintf(" }\n");
|
||||
rsprintf("}\n\n");
|
||||
}
|
||||
|
||||
@ -10324,6 +10286,8 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL
|
||||
rsprintf("var next_attachment = %d;\n", i + 1);
|
||||
break;
|
||||
}
|
||||
rsprintf("var page_title = '%s';\n", page_title);
|
||||
rsprintf("var message_id = '%d';\n", message_id);
|
||||
|
||||
rsprintf("\n");
|
||||
rsprintf("window.onbeforeunload = beforeunload;\n");
|
||||
@ -10345,11 +10309,12 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL
|
||||
|
||||
if (enc_selected == 2 && fckedit_exist && show_text && !fixed_text) {
|
||||
rsprintf("<script type=\"text/javascript\" src=\"../ckeditor/ckeditor.js\"></script>\n");
|
||||
rsprintf("<script type=\"text/javascript\" src=\"../jquery-1.11.1.min.js\"></script>\n");
|
||||
rsprintf("<script type=\"text/javascript\" src=\"../progress/progress.min.js\"></script>\n");
|
||||
rsprintf("<link rel=\"stylesheet\" type=\"text/css\" href=\"../progress/progressjs.min.css\">\n");
|
||||
}
|
||||
|
||||
|
||||
rsprintf("<script type=\"text/javascript\" src=\"../jquery-1.11.1.min.js\"></script>\n");
|
||||
rsprintf("<script type=\"text/javascript\" src=\"../progress/progress.min.js\"></script>\n");
|
||||
rsprintf("<link rel=\"stylesheet\" type=\"text/css\" href=\"../progress/progressjs.min.css\">\n");
|
||||
|
||||
/* drag-and-drip script */
|
||||
rsprintf("<script type=\"text/javascript\" src=\"../dnd.js\"></script>\n\n");
|
||||
|
||||
@ -11278,7 +11243,7 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL
|
||||
rsprintf("</td></tr>\n");
|
||||
}
|
||||
|
||||
rsprintf("<tr><td colspan=2 width=\"100%%\" class=\"attribvalue\" id=\"TextParent\">\n");
|
||||
rsprintf("<tr><td colspan=2 width=\"100%%\" class=\"attribvalue\" id=\"TextParent\" style=\"padding:0\">\n");
|
||||
|
||||
/* set textarea width */
|
||||
width = 112;
|
||||
|
||||
@ -49,7 +49,7 @@
|
||||
D548630D1ACAEF5400BA8C69 /* default.css */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.css; name = default.css; path = ../themes/default/default.css; sourceTree = "<group>"; };
|
||||
D58A366615AF103300682DC0 /* elog-version.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "elog-version.h"; path = "../src/elog-version.h"; sourceTree = SOURCE_ROOT; };
|
||||
D5AC5BF9154AC7200018DD90 /* config.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; name = config.html; path = ../doc/config.html; sourceTree = SOURCE_ROOT; };
|
||||
D5F11B9113AFA164002CE8BF /* elogd.cfg */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = elogd.cfg; path = ../elogd.cfg; sourceTree = SOURCE_ROOT; };
|
||||
D5C8CD7A1ACC02A0008B1201 /* elogd.cfg */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = elogd.cfg; path = ../../../elogdemo/elogd.cfg; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
@ -113,12 +113,12 @@
|
||||
D5F11B9013AFA146002CE8BF /* Resources */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
D5C8CD7A1ACC02A0008B1201 /* elogd.cfg */,
|
||||
D548630D1ACAEF5400BA8C69 /* default.css */,
|
||||
D5AC5BF9154AC7200018DD90 /* config.html */,
|
||||
D51F4A9214F27F3C00CB29E9 /* index.html */,
|
||||
D528A7C514F278DA00D33974 /* checklist.txt */,
|
||||
D528A7C314F278C800D33974 /* ChangeLog */,
|
||||
D5F11B9113AFA164002CE8BF /* elogd.cfg */,
|
||||
);
|
||||
name = Resources;
|
||||
path = elogd;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user