From 86636176e4f12938bade97f4e2452e3d748ae56c Mon Sep 17 00:00:00 2001
From: Stefan Ritt
Date: Thu, 20 Sep 2007 21:19:37 +0000
Subject: [PATCH] Insertion of pictures half finished
SVN revision: 1925
---
.../editor/plugins/elog/fckplugin.js | 24 ++++
scripts/fckeditor/fckelog.js | 2 +-
src/elogd.c | 117 ++++++++++++------
3 files changed, 105 insertions(+), 38 deletions(-)
diff --git a/scripts/fckeditor/editor/plugins/elog/fckplugin.js b/scripts/fckeditor/editor/plugins/elog/fckplugin.js
index b8e5dbcc..b1a2e287 100644
--- a/scripts/fckeditor/editor/plugins/elog/fckplugin.js
+++ b/scripts/fckeditor/editor/plugins/elog/fckplugin.js
@@ -46,6 +46,30 @@ oELOGSubmitCommand.GetState = function()
FCKCommands.RegisterCommand('ELOGSubmit', oELOGSubmitCommand);
+/*---- 'ELOGImage' ------------------------------------------------*/
+
+// Register 'ELOGImage' toolbar button
+var oELOGImage = new FCKToolbarButton('ELOGImage', 'Insert Image', null, null, true, null, 37);
+FCKToolbarItems.RegisterItem('ELOGImage', oELOGImage);
+
+// Register 'ELOGImage' command
+var oELOGImageCommand = new Object();
+oELOGImageCommand.Name = 'ELOGImage';
+
+oELOGImageCommand.Execute = function()
+{
+ window.open('../../'+parent.logbook+'/upload.html?next_attachment='+parent.next_attachment, '',
+ 'top=280,left=350,width=500,height=120,dependent=yes,menubar=no,status=no,scrollbars=no,location=no,resizable=yes');
+}
+
+oELOGImageCommand.GetState = function()
+{
+ // This function is always enabled.
+ return FCK_TRISTATE_OFF ;
+}
+
+FCKCommands.RegisterCommand('ELOGImage', oELOGImageCommand);
+
/*---- 'InsertTime' ------------------------------------------------*/
// Create 'InsertTime' toolbar button
diff --git a/scripts/fckeditor/fckelog.js b/scripts/fckeditor/fckelog.js
index ef5c6900..d6eed09f 100644
--- a/scripts/fckeditor/fckelog.js
+++ b/scripts/fckeditor/fckelog.js
@@ -13,7 +13,7 @@ FCKConfig.ToolbarSets["Default"] = [
['OrderedList','UnorderedList','-','Outdent','Indent'],
['JustifyLeft','JustifyCenter','JustifyRight','JustifyFull'],
['Link','Unlink','Anchor'],
- ['Image','Table','Rule','Smiley','SpecialChar','InsertTime'],
+ ['ELOGImage','Table','Rule','Smiley','SpecialChar','InsertTime'],
['Style','FontFormat','FontName','FontSize'],
['TextColor','BGColor'],
['About']
diff --git a/src/elogd.c b/src/elogd.c
index f4679303..198cb018 100755
--- a/src/elogd.c
+++ b/src/elogd.c
@@ -7147,11 +7147,12 @@ void show_standard_header(LOGBOOK * lbs, BOOL expires, char *title, char *path,
rsprintf("\n");
rsprintf("\n\n");
@@ -9455,28 +9456,30 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL
rsprintf(" document.form1.submit();\n");
rsprintf("}\n\n");
- if (!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");
- rsprintf("{\n");
- rsprintf(" window.onresize = resize_textarea;\n");
- rsprintf(" resize_textarea();\n");
- rsprintf("}\n\n");
- rsprintf("function resize_textarea()\n");
- rsprintf("{\n");
- rsprintf(" p = document.form1.Text;\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;\n");
- rsprintf(" else // IE\n");
- rsprintf(" height = document.body.offsetHeight - t - 135;\n");
- rsprintf(" if (height < 300)\n");
- rsprintf(" height = 300;\n");
- rsprintf(" document.form1.Text.style.height = height;\n");
- rsprintf("}\n\n");
+ if (enc_selected != 2) {
+ if (!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");
+ rsprintf("{\n");
+ rsprintf(" window.onresize = resize_textarea;\n");
+ rsprintf(" resize_textarea();\n");
+ rsprintf("}\n\n");
+ rsprintf("function resize_textarea()\n");
+ rsprintf("{\n");
+ rsprintf(" p = document.form1.Text;\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;\n");
+ rsprintf(" else // IE\n");
+ rsprintf(" height = document.body.offsetHeight - t - 135;\n");
+ rsprintf(" if (height < 300)\n");
+ rsprintf(" height = 300;\n");
+ rsprintf(" document.form1.Text.style.height = height;\n");
+ rsprintf("}\n\n");
+ }
}
/* strings for elcode.js */
@@ -9487,12 +9490,19 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL
}
if (stristr(browser, "MSIE") && !stristr(browser, "opera"))
- rsprintf("browser = \"MSIE\";\n");
+ rsprintf("var browser = \"MSIE\";\n");
else if (stristr(browser, "Mozilla") && !stristr(browser, "opera") && !stristr(browser, "konqueror"))
- rsprintf("browser = \"Mozilla\";\n");
+ rsprintf("var browser = \"Mozilla\";\n");
else
- rsprintf("browser = \"Other\";\n");
+ rsprintf("var browser = \"Other\";\n");
+ rsprintf("var logbook = \"%s\";\n", lbs->name_enc);
+ for (i = 0; i < MAX_ATTACHMENTS; i++)
+ if (!att[i][0]) {
+ /* put first free attachment for uploader */
+ rsprintf("var next_attachment = %d;\n", i + 1);
+ break;
+ }
rsprintf("//-->\n");
rsprintf("\n");
@@ -9533,7 +9543,7 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL
else
strcat(script, " OnLoad=\"elKeyInit();\" OnFocus=\"elKeyInit();\"");
} else if (enc_selected == 2 && fckedit_exist) {
- strcat(script, " OnLoad=\"init_resize(); initFCKedit();\"");
+ strcat(script, " OnLoad=\"initFCKedit();\"");
} else
strcat(script, " OnLoad=\"init_resize();\"");
@@ -10539,6 +10549,31 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL
rsprintf("[quote]");
rsputs3(text);
rsprintf("[/quote]\r\n");
+
+ } else if (enc_selected == 2) {
+
+ rsprintf("\n");
+ rsprintf("
\n");
+ rsprintf("\n");
+ rsprintf("\n");
+ rsprintf("| ");
+
+ /* check for author */
+ if (orig_author[0]) {
+ rsprintf(loc("%s wrote"), orig_author);
+ } else {
+ rsprintf(loc("Quote"));
+ }
+ rsprintf(": |
\n");
+ rsprintf("\n");
+ rsprintf("| ");
+ rsputs3(text);
+ rsprintf(" | \n");
+ rsprintf("
\n");
+ rsprintf("\n");
+ rsprintf("
\n");
+ rsprintf("
\n");
+
} else {
do {
if (strchr(p, '\n')) {
@@ -23950,21 +23985,29 @@ void show_uploader_finished(LOGBOOK * lbs)
rsprintf(" function update()\n");
rsprintf(" {\n");
- rsprintf(" i = opener.document.form1.next_attachment.value;\n");
- rsprintf(" elcode2(opener.document, opener.document.form1.Text, 'IMG', 'elog:/'+i);\n");
- rsprintf(" opener.document.form1.inlineatt.value = '%s';\n", att);
- rsprintf(" opener.document.form1.jcmd.value = 'Upload';\n");
- rsprintf(" opener.document.form1.submit();\n");
+ rsprintf(" if (opener.document.title == \"FCKeditor\") {\n");
+ rsprintf(" i = opener.parent.next_attachment;\n");
+ rsprintf(" opener.FCKeditorAPI.GetInstance('Text').InsertHtml('
');\n");
+ rsprintf(" opener.parent.document.form1.inlineatt.value = '%s';\n", att);
+ rsprintf(" opener.parent.document.form1.jcmd.value = 'Upload';\n");
+ rsprintf(" opener.parent.document.form1.submit();\n");
+ rsprintf(" } else {\n");
+ rsprintf(" i = opener.document.form1.next_attachment.value;\n");
+ rsprintf(" elcode2(opener.document, opener.document.form1.Text, 'IMG', 'elog:/'+i);\n");
+ rsprintf(" opener.document.form1.inlineatt.value = '%s';\n", att);
+ rsprintf(" opener.document.form1.jcmd.value = 'Upload';\n");
+ rsprintf(" opener.document.form1.submit();\n");
+ rsprintf(" }\n");
rsprintf(" window.close();\n");
rsprintf(" }\n\n");
/* strings for elcode.js */
if (stristr(browser, "MSIE") && !stristr(browser, "opera"))
- rsprintf("browser = 'MSIE';\n");
+ rsprintf("var browser = 'MSIE';\n");
else if (stristr(browser, "Mozilla") && !stristr(browser, "opera") && !stristr(browser, "konqueror"))
- rsprintf("browser = 'Mozilla';\n");
+ rsprintf("var browser = 'Mozilla';\n");
else
- rsprintf("browser = 'Other';\n\n");
+ rsprintf("var browser = 'Other';\n\n");
rsprintf("\n\n");