[geeklog-hg] geeklog: Optimized?code for Advanced Editor. added a new functio...
geeklog-cvs at lists.geeklog.net
geeklog-cvs at lists.geeklog.net
Mon Aug 12 13:51:31 EDT 2013
changeset 9248:558a578f5126
url: http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/558a578f5126
user: dengen <taharaxp at gmail.com>
date: Tue Aug 13 02:40:47 2013 +0900
description:
Optimized?code for Advanced Editor. added a new function COM_setupAdvancedEditor to improve the ease of use.
diffstat:
public_html/admin/plugins/staticpages/index.php | 6 +-
public_html/admin/story.php | 7 +-
public_html/ckeditor/functions.js | 26 ++-
public_html/ckeditor/functions.php | 56 ++++++++
public_html/fckeditor/functions.js | 18 +-
public_html/fckeditor/functions.php | 56 ++++++++
public_html/javascript/advanced_editor.js | 151 ++++++++++++++++++++++
public_html/javascript/staticpages_adveditor.js | 49 ++----
public_html/javascript/storyeditor_adveditor.js | 81 +++--------
public_html/javascript/submitcomment_adveditor.js | 42 +----
public_html/javascript/submitstory_adveditor.js | 42 +----
public_html/lib-common.php | 64 ++++++++-
public_html/submit.php | 6 +-
system/classes/scripts.class.php | 13 +-
system/lib-comment.php | 7 +-
15 files changed, 422 insertions(+), 202 deletions(-)
diffs (truncated from 869 to 300 lines):
diff -r a8911d56bddc -r 558a578f5126 public_html/admin/plugins/staticpages/index.php
--- a/public_html/admin/plugins/staticpages/index.php Wed Aug 07 21:01:26 2013 +0900
+++ b/public_html/admin/plugins/staticpages/index.php Tue Aug 13 02:40:47 2013 +0900
@@ -102,10 +102,8 @@
}
$sp_template->set_var('noscript', COM_getNoScript(false, '', $link_message));
- // Add JavaScript
- $_SCRIPTS->setJavaScriptFile('adveditor', $_CONF['advanced_editor_js']);
- $_SCRIPTS->setJavaScriptFile('adveditor_functions', "/{$_CONF['advanced_editor_name']}/functions.js");
- $_SCRIPTS->setJavaScriptFile('staticpages_adveditor', '/javascript/staticpages_adveditor.js');
+ // Setup Advanced Editor
+ COM_setupAdvancedEditor('/javascript/staticpages_adveditor.js');
$sp_template->set_var('lang_expandhelp', $LANG24[67]);
$sp_template->set_var('lang_reducehelp', $LANG24[68]);
diff -r a8911d56bddc -r 558a578f5126 public_html/admin/story.php
--- a/public_html/admin/story.php Wed Aug 07 21:01:26 2013 +0900
+++ b/public_html/admin/story.php Tue Aug 13 02:40:47 2013 +0900
@@ -750,11 +750,8 @@
. "});", TRUE, TRUE
);
- if ($advanced_editormode) {
- $_SCRIPTS->setJavaScriptFile('adveditor', $_CONF['advanced_editor_js']);
- $_SCRIPTS->setJavaScriptFile('adveditor_functions', "/{$_CONF['advanced_editor_name']}/functions.js");
- $_SCRIPTS->setJavaScriptFile('storyeditor_adveditor', '/javascript/storyeditor_adveditor.js');
- }
+ // Setup Advanced Editor
+ COM_setupAdvancedEditor('/javascript/storyeditor_adveditor.js');
$story_templates->set_var('saved_images', $saved_images);
$story_templates->set_var('image_form_elements', $fileinputs);
diff -r a8911d56bddc -r 558a578f5126 public_html/ckeditor/functions.js
--- a/public_html/ckeditor/functions.js Wed Aug 07 21:01:26 2013 +0900
+++ b/public_html/ckeditor/functions.js Tue Aug 13 02:40:47 2013 +0900
@@ -1,5 +1,5 @@

-function adve_newEditor(instanceName, options) {
+function ckeditor_newEditor(instanceName, options) {
switch (options['toolbar']) {
case 0:
name = 'toolbar1';
@@ -16,15 +16,15 @@
CKEDITOR.replace(instanceName, {toolbar:name});
}
-function adve_getContent(instanceName) {
+function ckeditor_setContent(instanceName, content) {
+ CKEDITOR.instances[instanceName].setData(content);
+}
+
+function ckeditor_getContent(instanceName) {
return CKEDITOR.instances[instanceName].getData();
}
-function adve_setContent(instanceName, content) {
- CKEDITOR.instances[instanceName].setData(content);
-}
-
-function adve_changeToolbar(instanceName, toolbar) {
+function ckeditor_changeToolbar(instanceName, toolbar) {
var name = '';
switch (toolbar) {
case 'editor-toolbar1':
@@ -43,10 +43,10 @@
CKEDITOR.replace(instanceName, {toolbar:name});
}
-function adve_changeTextAreaSize(instanceName, option) {
+function ckeditor_changeTextAreaSize(instanceName, option) {
var oEditor = CKEDITOR.instances[instanceName];
var height = oEditor.ui.space('contents').getStyle('height');
- currentSize = parseInt(height.replace("px", ""));
+ var currentSize = parseInt(height.replace("px", ""));
if (option == 'larger') {
var newsize = currentSize + 50;
} else if (option == 'smaller') {
@@ -54,3 +54,11 @@
}
oEditor.resize('100%', newsize, true);
}
+
+AdvancedEditor.api['ckeditor'] = {
+ newEditor: ckeditor_newEditor,
+ setContent: ckeditor_setContent,
+ getContent: ckeditor_getContent,
+ changeToolbar: ckeditor_changeToolbar,
+ changeTextAreaSize: ckeditor_changeTextAreaSize
+};
diff -r a8911d56bddc -r 558a578f5126 public_html/ckeditor/functions.php
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/public_html/ckeditor/functions.php Tue Aug 13 02:40:47 2013 +0900
@@ -0,0 +1,56 @@
+<?php
+
+/* Reminder: always indent with 4 spaces (no tabs). */
+// +---------------------------------------------------------------------------+
+// | Geeklog 2.0 |
+// +---------------------------------------------------------------------------+
+// | functions.php |
+// | |
+// | Functions implementing the Advanced Editor API |
+// +---------------------------------------------------------------------------+
+// | Copyright (C) 2013 by the following authors: |
+// | |
+// | Authors: Yoshinori Tahara - dengenxp AT gmail DOT com |
+// +---------------------------------------------------------------------------+
+// | |
+// | This program is free software; you can redistribute it and/or |
+// | modify it under the terms of the GNU General Public License |
+// | as published by the Free Software Foundation; either version 2 |
+// | of the License, or (at your option) any later version. |
+// | |
+// | This program is distributed in the hope that it will be useful, |
+// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
+// | GNU General Public License for more details. |
+// | |
+// | You should have received a copy of the GNU General Public License |
+// | along with this program; if not, write to the Free Software Foundation, |
+// | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
+// | |
+// +---------------------------------------------------------------------------+
+
+// this file can't be used on its own
+if (strpos(strtolower($_SERVER['PHP_SELF']), 'functions.php') !== false) {
+ die('This file can not be used on its own!');
+}
+
+/**
+ * Return the configuration values for the advanced editor
+ */
+function adveditor_config_ckeditor()
+{
+ return array(
+ 'file' => '/ckeditor/ckeditor.js',
+ 'footer' => true, // Not requred, default = true
+ 'priority' => 110 // Not requred, default = 100
+ );
+}
+
+/**
+ * Do any other initialisation here
+ */
+function adveditor_init_ckeditor()
+{
+}
+
+?>
diff -r a8911d56bddc -r 558a578f5126 public_html/fckeditor/functions.js
--- a/public_html/fckeditor/functions.js Wed Aug 07 21:01:26 2013 +0900
+++ b/public_html/fckeditor/functions.js Tue Aug 13 02:40:47 2013 +0900
@@ -1,5 +1,5 @@

-function adve_newEditor(instanceName, options) {
+function fckeditor_newEditor(instanceName, options) {
var oEditor = new FCKeditor(instanceName);
oEditor.BasePath = geeklogEditorBasePath;
oEditor.Config['CustomConfigurationsPath'] = geeklogEditorBaseUrl + '/fckeditor/myconfig.js';
@@ -8,19 +8,19 @@
oEditor.ReplaceTextarea();
}
-function adve_getContent(instanceName) {
+function fckeditor_getContent(instanceName) {
return FCKeditorAPI.GetInstance(instanceName).GetXHTML(true);
}
-function adve_setContent(instanceName, content) {
+function fckeditor_setContent(instanceName, content) {
FCKeditorAPI.GetInstance(instanceName).SetHTML(content);
}
-function adve_changeToolbar(instanceName, toolbar) {
+function fckeditor_changeToolbar(instanceName, toolbar) {
FCKeditorAPI.GetInstance(instanceName).ToolbarSet.Load(toolbar);
}
-function adve_changeTextAreaSize(instanceName, option) {
+function fckeditor_changeTextAreaSize(instanceName, option) {
var currentSize = parseInt(document.getElementById(instanceName + '___Frame').style.height);
if (option == 'larger') {
var newsize = currentSize + 50;
@@ -29,3 +29,11 @@
}
document.getElementById(instanceName + '___Frame').style.height = newsize + 'px';
}
+
+AdvancedEditor.api['fckeditor'] = {
+ newEditor: fckeditor_newEditor,
+ setContent: fckeditor_setContent,
+ getContent: fckeditor_getContent,
+ changeToolbar: fckeditor_changeToolbar,
+ changeTextAreaSize: fckeditor_changeTextAreaSize
+};
diff -r a8911d56bddc -r 558a578f5126 public_html/fckeditor/functions.php
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/public_html/fckeditor/functions.php Tue Aug 13 02:40:47 2013 +0900
@@ -0,0 +1,56 @@
+<?php
+
+/* Reminder: always indent with 4 spaces (no tabs). */
+// +---------------------------------------------------------------------------+
+// | Geeklog 2.0 |
+// +---------------------------------------------------------------------------+
+// | functions.php |
+// | |
+// | Functions implementing the Advanced Editor API |
+// +---------------------------------------------------------------------------+
+// | Copyright (C) 2013 by the following authors: |
+// | |
+// | Authors: Yoshinori Tahara - dengenxp AT gmail DOT com |
+// +---------------------------------------------------------------------------+
+// | |
+// | This program is free software; you can redistribute it and/or |
+// | modify it under the terms of the GNU General Public License |
+// | as published by the Free Software Foundation; either version 2 |
+// | of the License, or (at your option) any later version. |
+// | |
+// | This program is distributed in the hope that it will be useful, |
+// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
+// | GNU General Public License for more details. |
+// | |
+// | You should have received a copy of the GNU General Public License |
+// | along with this program; if not, write to the Free Software Foundation, |
+// | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
+// | |
+// +---------------------------------------------------------------------------+
+
+// this file can't be used on its own
+if (strpos(strtolower($_SERVER['PHP_SELF']), 'functions.php') !== false) {
+ die('This file can not be used on its own!');
+}
+
+/**
+ * Return the configuration values for the advanced editor
+ */
+function adveditor_config_fckeditor()
+{
+ return array(
+ 'file' => '/fckeditor/fckeditor.js',
+ 'footer' => true, // Not requred, default = true
+ 'priority' => 110 // Not requred, default = 100
+ );
+}
+
+/**
+ * Do any other initialisation here
+ */
+function adveditor_init_fckeditor()
+{
+}
+
+?>
diff -r a8911d56bddc -r 558a578f5126 public_html/javascript/advanced_editor.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/public_html/javascript/advanced_editor.js Tue Aug 13 02:40:47 2013 +0900
@@ -0,0 +1,151 @@
+/* Reminder: always indent with 4 spaces (no tabs). */
+// +---------------------------------------------------------------------------+
+// | Geeklog 2.0 |
+// +---------------------------------------------------------------------------+
+// | Javascript functions for WYSIWYG HTML Editor Integration into Geeklog |
+// | |
+// +---------------------------------------------------------------------------+
+// | Copyright (C) 2003-2013 by the following authors: |
+// | |
+// | Authors: Blaine Lang - blaine AT portalparts DOT com |
+// | Yoshinori Tahara - dengenxp AT gmail DOT com |
+// +---------------------------------------------------------------------------+
+// | |
+// | This program is free software; you can redistribute it and/or |
+// | modify it under the terms of the GNU General Public License |
+// | as published by the Free Software Foundation; either version 2 |
+// | of the License, or (at your option) any later version. |
+// | |
+// | This program is distributed in the hope that it will be useful, |
+// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
+// | GNU General Public License for more details. |
+// | |
+// | You should have received a copy of the GNU General Public License |
+// | along with this program; if not, write to the Free Software Foundation, |
+// | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
+// | |
+// +---------------------------------------------------------------------------+
+
+AdvancedEditor = new Object();
+
+AdvancedEditor.TextareaId = [];
+
+AdvancedEditor.ContainerId = 'advanced_editor';
+
+AdvancedEditor.SelToolbarId = 'fckeditor_toolbar_selector';
+
+AdvancedEditor.EditModeId = 'sel_editmode';
+
+AdvancedEditor.ValModeAdvanced = 'adveditor';
More information about the geeklog-cvs
mailing list