Author: alevkovsky
Date: 2008-10-20 06:18:20 -0400 (Mon, 20 Oct 2008)
New Revision: 10826
Modified:
trunk/sandbox/ui/editor/src/main/resources/org/richfaces/renderkit/html/scripts/editor.js
trunk/sandbox/ui/editor/src/main/templates/editor.jspx
Log:
Add RichEditor prototype
Modified:
trunk/sandbox/ui/editor/src/main/resources/org/richfaces/renderkit/html/scripts/editor.js
===================================================================
---
trunk/sandbox/ui/editor/src/main/resources/org/richfaces/renderkit/html/scripts/editor.js 2008-10-19
15:26:35 UTC (rev 10825)
+++
trunk/sandbox/ui/editor/src/main/resources/org/richfaces/renderkit/html/scripts/editor.js 2008-10-20
10:18:20 UTC (rev 10826)
@@ -6,16 +6,46 @@
return Richfaces.Editor.ResourceHTML.replace("$1", baseURL);
};*/
-//Richfaces.Editor.ResourceHTML = "ghdfgsdfgsdfgsdfgdf sg sdfg$1fgsdfdfgdfg";
-/*
+
RichEditor = Class.create();
Object.extend(RichEditor.prototype, {
- initialize: function(id,parameters) {
- this["rich:destructor"] = "destructor";
+ initialize: function(id, parameters) {
+ this.id = id;
+ this.editorTextAreaId = this.id +'TextArea';
+ this.params = parameters;
+
+ this["rich:destructor"] = "destruct";
+
+ tinyMCE.init({
+ mode: this.params.mode,
+ theme: this.params.theme,
+ init_instance_callback : this.onInitInstanceCallback.bind(this),
+ });
+
+ this.onbeforeajaxListener = new A4J.AJAX.AjaxListener("onbeforeajax",
this.onBeforeAjax.bind(this));
+ A4J.AJAX.AddListener(this.onbeforeajaxListener);
+
},
- destructor: function()
- {
-
+ destruct: function() {
+
+ alert('destructor');
+ A4J.AJAX.removeListener(this.onbeforeajaxListener);
+ this.onbeforeajaxListener = null;
+ this.tinyMCE_editor.remove();
+ this.tinyMCE_editor = null;
+ alert('destructor done');
+ },
+
+ onBeforeAjax: function() {
+ alert('before ajax ');
+ this.tinyMCE_editor.save();
+ alert('before ajax done');
+ },
+
+ onInitInstanceCallback: function() {
+ this.tinyMCE_editor = tinyMCE.get(this.editorTextAreaId);
+
+ //TODO add user init_instance_callback function
}
-});*/
+});
\ No newline at end of file
Modified: trunk/sandbox/ui/editor/src/main/templates/editor.jspx
===================================================================
--- trunk/sandbox/ui/editor/src/main/templates/editor.jspx 2008-10-19 15:26:35 UTC (rev
10825)
+++ trunk/sandbox/ui/editor/src/main/templates/editor.jspx 2008-10-20 10:18:20 UTC (rev
10826)
@@ -12,7 +12,7 @@
<f:clientid var="clientId"/>
<h:styles>css/editor.xcss</h:styles>
- <h:scripts>scripts/editor.js,
scripts/tiny_mce/tiny_mce_src.js</h:scripts>
+ <h:scripts>new org.ajax4jsf.javascript.AjaxScript(), new
org.ajax4jsf.javascript.PrototypeScript(), scripts/editor.js,
scripts/tiny_mce/tiny_mce_src.js</h:scripts>
<div id="#{clientId}" x:passThruWithExclusions="id,value"
class="rich-editor">
@@ -30,13 +30,11 @@
</jsp:scriptlet>
</textarea>
- <script type="text/javascript">
-
-
- tinyMCE.init({
- mode: '#{component.attributes['mode']}',
- theme: '#{component.attributes['theme']}'
- });
+ <script type="text/javascript">
+ new RichEditor('#{clientId}', {
+ mode: '#{component.attributes['mode']}',
+ theme: '#{component.attributes['theme']}'
+ });
</script>
</div>
</f:root>
Show replies by date