Author: alevkovsky
Date: 2008-12-04 10:48:40 -0500 (Thu, 04 Dec 2008)
New Revision: 11551
Modified:
trunk/ui/editor/src/main/java/org/richfaces/renderkit/EditorRendererBase.java
trunk/ui/editor/src/main/resources/org/richfaces/renderkit/html/scripts/editor.js
Log:
https://jira.jboss.org/jira/browse/RF-5195
Modified: trunk/ui/editor/src/main/java/org/richfaces/renderkit/EditorRendererBase.java
===================================================================
---
trunk/ui/editor/src/main/java/org/richfaces/renderkit/EditorRendererBase.java 2008-12-04
15:43:48 UTC (rev 11550)
+++
trunk/ui/editor/src/main/java/org/richfaces/renderkit/EditorRendererBase.java 2008-12-04
15:48:40 UTC (rev 11551)
@@ -326,23 +326,23 @@
+ ";\n", null);
}
if (component.getOninit() != null && component.getOninit().length() > 0) {
- writer.writeText("tinyMceParams.oninit = function () {\n"
+ writer.writeText("tinyMceParams.oninit = function (event) {\n"
+ component.getOninit() + "\n" + "};\n", null);
}
if (component.getOnsave() != null && component.getOnsave().length() > 0) {
writer.writeText(
- "tinyMceParams.save_callback = function (element_id, html, body) {\n"
+ "tinyMceParams.save_callback = function (event, element_id, html, body)
{\n"
+ component.getOnsave() + "\n" + "};\n", null);
}
if (component.getOnchange() != null
&& component.getOnchange().length() > 0) {
writer.writeText(
- "tinyMceParams.onchange_callback = function (inst) {\n"
+ "tinyMceParams.onchange_callback = function (event, inst) {\n"
+ component.getOnchange() + "\n" + "};\n", null);
}
if (component.getOnsetup() != null
&& component.getOnsetup().length() > 0) {
- writer.writeText("tinyMceParams.setup = function (ed) {\n"
+ writer.writeText("tinyMceParams.setup = function (event, ed) {\n"
+ component.getOnsetup() + "\n" + "};\n", null);
}
Modified:
trunk/ui/editor/src/main/resources/org/richfaces/renderkit/html/scripts/editor.js
===================================================================
---
trunk/ui/editor/src/main/resources/org/richfaces/renderkit/html/scripts/editor.js 2008-12-04
15:43:48 UTC (rev 11550)
+++
trunk/ui/editor/src/main/resources/org/richfaces/renderkit/html/scripts/editor.js 2008-12-04
15:48:40 UTC (rev 11551)
@@ -23,13 +23,21 @@
this.synchronizeConfiguration();
this.tinyMCE_editor = null;
- this.onInitInstanceCallbackFunction = this.tinyparams.onInitInstanceCallback;
-
+ this.onInitInstanceCallbackFunction = this.tinyparams.init_instance_callback;
+ this.onChangeCallbackFunction = this.tinyparams.onchange_callback;
+ this.onInitCallbackFunction = this.tinyparams.oninit;
+ this.onSaveCallbackFunction = this.tinyparams.save_callback;
+ this.onSetupCallbackFunction = this.tinyparams.setup;
+
this.tinyparams.mode = 'exact';
this.tinyparams.elements = this.editorTextAreaId;
this.tinyparams.editor_selector = null;
this.tinyparams.editor_deselector = null;
this.tinyparams.init_instance_callback = this.onInitInstanceCallback.bind(this);
+ this.tinyparams.onchange_callback = this.onChangeCallback.bind(this);
+ this.tinyparams.oninit = this.onInitCallback.bind(this);
+ this.tinyparams.save_callback = this.onSaveCallback.bind(this);
+ this.tinyparams.setup = this.onSetupCallback.bind(this);
tinyMCE.init(this.tinyparams);
@@ -56,6 +64,26 @@
if (this.onInitInstanceCallbackFunction)
this.onInitInstanceCallbackFunction.call(this, inst);
},
+ onChangeCallback: function(inst) {
+ this.invokeEvent(this.onChangeCallbackFunction, $A(arguments));
+ },
+
+ onInitCallback: function() {
+ this.invokeEvent(this.onInitCallbackFunction, $A(arguments));
+ },
+
+ onSaveCallback: function(element_id, html, body) {
+ if(this.onSaveCallbackFunction){
+ return this.invokeEvent(this.onSaveCallbackFunction, $A(arguments));
+ }else{
+ return html;
+ }
+ },
+
+ onSetupCallback: function(ed) {
+ this.invokeEvent(this.onSetupCallbackFunction, $A(arguments));
+ },
+
synchronizeConfiguration: function(){
if(this.params.useSeamText){
this.tinyparams.plugins = Richfaces.Editor.SeamTextConfiguration.plugins;
@@ -69,9 +97,30 @@
//this.tinyparams.theme_advanced_buttons3 =
Richfaces.Editor.SeamTextConfiguration.theme_advanced_buttons3;
//this.tinyparams.theme_advanced_buttons4 =
Richfaces.Editor.SeamTextConfiguration.theme_advanced_buttons4;
}
+ },
+
+ invokeEvent: function(callback, args){
+ if (!callback) return;
+ var eventObj;
+ var result;
+
+ if( document.createEventObject ) {
+ eventObj = document.createEventObject();
+ } else if( document.createEvent ) {
+ eventObj = document.createEvent('Events');
+ eventObj.initEvent( callback + 'Event', true, false );
+ }
+
+ eventObj.rich = {component:this, tinyMceInstance: this.tinyMCE_editor};
+ args.unshift(eventObj);
+
+ try {
+ result = callback.apply(this, args);
+ } catch (e) {
+ LOG.warn("Exception: " + e.Message + "\n[on " + callback + "
]");
+ }
+ return result;
}
-
-
});
Richfaces.Editor.SeamTextConfiguration = {