All Downloads are FREE. Search and download functionalities are using the official Maven repository.

template.js.struts2.jquery.richtext.struts2-3.2.0.min.js Maven / Gradle / Ivy

There is a newer version: 6.0.0
Show newest version
/*!
 * jquery.richtext.struts2.js
 *
 * Integration of richtext editor with struts 2
 *
 * Requires use of jquery.struts2.js
 *
 * Copyright (c) 2010 Johannes Geppert http://www.jgeppert.com
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 *
 */
(function(a){a.struts2_jquery_richtext={debugPrefix:"[struts2_jquery_richtext] ",editors:[],editorsTinymce:[],ckeditorTimer:undefined,clean:function(c){var b=this;if(!window.CKEDITOR){return}a.each(b.editors,function(d,e){var f=CKEDITOR.instances[e];if(c.length===0||!f||f.textarea!==c[0]){a.struts2_jquery_richtext.editors.splice(d);delete CKEDITOR.instances[e]}})},ckeditor:function(c,g){var b=this;b.log("ckeditor for : "+g.id);b.require("js/ckeditor/ckeditor.js");b.require("js/ckeditor/adapters/jquery.js");var f=CKEDITOR.instances[g.id];if(f){CKEDITOR.remove(f)}b.clean(c);var e=function(){b.editors[b.editors.length]=g.id;if(g.onEditorReadyTopics){var h={};b.publishTopic(c,g.onEditorReadyTopics,h);b.publishTopic(c,g.onalw,h)}};if(g.editorLocal){g.language=g.editorLocal}else{g.language=b.local}g.resizable=false;if(g.editorResizable){g.resize_enabled=true}else{g.resize_enabled=false}if(g.href&&g.href!=="#"){var d="s2j_ckeditor_"+g.id;if(c.isSubscribed(d)){c.unsubscribe(d)}c.subscribe(d,function(h,i){c.ckeditor(e,g)});if(g.oncom&&g.oncom!==""){g.oncom=g.oncom+","+d}else{g.oncom=d}b.container(c,g)}else{b.container(c,g);c.ckeditor(e,g)}f=CKEDITOR.instances[g.id];if(g.onblurtopics){f.on("blur",function(i){var h=a(b.escId(i.editor.element.$.id));b.publishTopic(h,g.onblurtopics,{editor:h});b.publishTopic(h,g.onalw,{editor:h})})}if(g.onfocustopics){f.on("focus",function(i){var h=a(b.escId(i.editor.element.$.id));b.publishTopic(h,g.onfocustopics,{editor:h});b.publishTopic(h,g.onalw,{editor:h})})}if(g.oncha){f.on("change",function(i){var h=a(b.escId(i.editor.element.$.id));b.publishTopic(h,g.oncha,{editor:h});b.publishTopic(h,g.onalw,{editor:h})})}},tinymce:function(c,e){var b=this;b.log("tinymce for : "+e.id);b.require("js/tinymce/jquery.tinymce.js");e.resizable=false;if(e.editorResizable){e.theme_advanced_resizing=true}b.container(c,e);e.script_url=e.path+"tiny_mce.js";if(e.oncha){e.onchange_callback=function(f){if(tinyMCE.activeEditor.isDirty()){var g={};g.editor=f;g.content=f.getBody().innerHTML;b.publishTopic(c,e.oncha,g);b.publishTopic(c,e.onalw,g)}}}if(e.onsavetopics){e.save_callback=function(i,g,f){var h={};h.editorid=i;h.html=g;h.body=f;b.publishTopic(c,e.onsavetopics,h);b.publishTopic(c,e.onalw,h);return h.html}}if(e.oneventtopics){e.handle_event_callback=function(f){var g={};g.event=f;g.returnvalue=true;b.publishTopic(c,e.oneventtopics,g);b.publishTopic(c,e.onalw,g);return g.returnvalue}}e.setup=function(f){f.onInit.add(function(g){tinyMCE.execCommand("mceRepaint");var i=g.dom;var h=g.getDoc();if(e.onblurtopics){tinymce.dom.Event.add(h,"blur",function(j){b.publishTopic(c,e.onblurtopics,{editor:g});b.publishTopic(c,e.onalw,{editor:g})})}if(e.onfocustopics){tinymce.dom.Event.add(h,"focus",function(j){b.publishTopic(c,e.onfocustopics,{editor:g});b.publishTopic(c,e.onalw,{editor:g})})}});f.onSaveContent.add(function(h,g){return false});if(e.pasteplain){f.onKeyDown.add(function(g,h){if(h.ctrlKey&&(h.charCode===118||h.keyCode===86)){g.execCommand("mcePasteText",true);g.execCommand("mceAddUndoLevel");return tinymce.dom.Event.cancel(h)}})}};if(e.pasteplain){e.paste_text_sticky=true;e.paste_text_use_dialog=true}if(e.editorLocal){e.language=e.editorLocal}else{e.language=b.local}if(e.href&&e.href!=="#"){var d="s2j_tinymce_"+e.id;if(c.isSubscribed(d)){c.unsubscribe(d)}c.subscribe(d,function(f,g){c.tinymce(e)});e.oncom=d;b.container(c,e)}else{b.container(c,e);c.tinymce(e)}}};a.extend(a.struts2_jquery_richtext,a.struts2_jquery)})(jQuery);




© 2015 - 2025 Weber Informatics LLC | Privacy Policy