Index: xinha-integration/src/main/java/org/hippoecm/frontend/plugins/xinha/js/editormanager/editormanager-debug.js IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- xinha-integration/src/main/java/org/hippoecm/frontend/plugins/xinha/js/editormanager/editormanager-debug.js (revision 35978) +++ xinha-integration/src/main/java/org/hippoecm/frontend/plugins/xinha/js/editormanager/editormanager-debug.js (revision ) @@ -27,25 +27,32 @@ */ +YAHOO.namespace('hippo'); + +if (!YAHOO.hippo.EditorManager) { + -/** - * Xinha globals - */ + /** + * Xinha globals + */ -var _editor_url = null; -var _editor_lang = null; -var _editor_skin = null; -var xinha_editors = []; + window._editor_url = null; + window._editor_lang = null; + window._editor_skin = null; + window.xinha_editors = []; -YAHOO.namespace('hippo'); - -if (!YAHOO.hippo.EditorManager) { (function() { var Dom = YAHOO.util.Dom, Lang = YAHOO.lang, HippoAjax = YAHOO.hippo.HippoAjax; var info = function(message) { + if(console && console.log) { + console.log(message); + } YAHOO.log(message, "info", "EditorManager"); }; var error = function(message) { + if(console && console.error) { + console.error(message) + } YAHOO.log(message, "error", "EditorManager"); }; @@ -65,6 +72,7 @@ * Xinha's that are currently in use. */ init : function(editorUrl, editorLang, editorSkin) { + info('Init editormanager[' + this.initialized + ']'); if (this.initialized) { return; } @@ -85,7 +93,6 @@ Wicket.Ajax.registerPreCallHandler(function() { me.saveEditors(); }); - }, /** @@ -119,8 +126,30 @@ context = this.contexts.get(form.id); } context.register(cfg); + + if(YAHOO.env.ua.ie > 0 && Lang.isUndefined(this.ieFocusWorkaroundElement)) { + var div = document.createElement('div'); + Dom.setStyle(div, 'position', 'absolute'); + document.body.appendChild(div); + Dom.setXY(div, [-2000, -2000]); + + var new_element = document.createElement('input'); + new_element.type = "text"; + Dom.generateId(new_element, 'ie-workaround'); + div.appendChild(new_element); + + this.ieFocusWorkaroundElement = new_element; + } + }, + unregisterContext : function(id) { + if (this.contexts.containsKey(id)) { + this.contexts.remove(id); + info('Context ' + id + ' removed') + } + }, + forEachContext: function(cb, obj) { this.contexts.forEach(this, function(k, v) { cb.apply(obj || this, [k, v]); @@ -232,6 +261,25 @@ this.newEditors.put(cfg.name, editor); }, + unregister: function(name) { + info('unregister editor ' + name); + + if (this.newEditors.containsKey((name))) { + this.newEditors.remove(name); + } + if (this.editors.containsKey(name)) { + this.editors.remove(name); + } + if (this.activeEditors.containsKey(name)) { + var editor = this.activeEditors.remove(name); + } + + //Context can be removed + if (this.editors.length == 0) { + YAHOO.hippo.EditorManager.unregisterContext(this.form.id); + } + }, + render: function() { this.newEditors.forEach(this, function(name, editor) { if (document.getElementById(editor.name)) { @@ -269,6 +317,7 @@ return editor; } } + return null; }, forEachActiveEditor : function(callback) { @@ -339,17 +388,23 @@ }, getContainer : function() { - if (this.container == null) { - this.container = Dom.getAncestorBy(Dom.get(this.name), function(element) { - return Dom.hasClass(element, 'hippo-editor-field-subfield'); - }); + //if (this.container == null) { + var name = this.name; + var test = document.getElementById(this.name); + var root = Dom.get(test ? test : name); + var check = function(el) { + return Dom.hasClass(el, 'hippo-editor-field-subfield'); + }; + if(root != null) { + this.container = Dom.getAncestorBy(root, check); - } + } + //} return this.container; }, info : function(msg) { YAHOO.log('Xinha[' + this.name + '] ' + msg, "info", "EditorManager"); - //console.log('Xinha[' + this.name + '] ' + msg); + info('Xinha[' + this.name + '] ' + msg); }, error : function(msg) { @@ -372,6 +427,12 @@ render : function() { var container = this.getContainer(); + if(container == null) { + //error('Container element not found for editor ' + this.name); + throw new Error('Container element not found for editor ' + this.name); + } + YAHOO.hippo.HippoAjax.registerDestroyFunction(container, this.destroy, this); + Dom.addClass(container, 'rte-preview-style'); var containerHeight = this.calculateHeight(); @@ -513,6 +574,7 @@ delegate.call(this, ev) } } catch(ignore) { + console.log('Error during _editorEvent: ' + ignore); } } } @@ -820,9 +882,15 @@ destroy : function() { this.destroyTooltip(); + if (this.xinha) { + xinha_editors.remove(this.name); + if (YAHOO.hippo.EditorManager.ieFocusWorkaroundElement) { + YAHOO.hippo.EditorManager.ieFocusWorkaroundElement.focus(); - } + } + } + this.context.unregister(this.name); - + } }); })(); Index: xinha-integration/src/main/java/org/hippoecm/frontend/plugins/xinha/AbstractXinhaPlugin.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- xinha-integration/src/main/java/org/hippoecm/frontend/plugins/xinha/AbstractXinhaPlugin.java (revision 35978) +++ xinha-integration/src/main/java/org/hippoecm/frontend/plugins/xinha/AbstractXinhaPlugin.java (revision ) @@ -1,12 +1,12 @@ /* * Copyright 2008 Hippo. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -64,9 +64,9 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public abstract class AbstractXinhaPlugin extends RenderPlugin { +public abstract class AbstractXinhaPlugin extends RenderPlugin { @SuppressWarnings("unused") - private final static String SVN_ID = "$Id: AbstractXinhaPlugin.java 33140 2012-02-23 12:20:32Z abogaart $"; + private final static String SVN_ID = "$Id: AbstractXinhaPlugin.java 33140 2012-02-23 12:20:28Z abogaart $"; private static final long serialVersionUID = 1L; @@ -257,6 +257,9 @@ super.onDetach(); } + /** + * + */ class EditorManagerBehavior extends AbstractYuiBehavior { private static final long serialVersionUID = 1L; @@ -297,17 +300,17 @@ } }); - context.addOnDomLoad("YAHOO.hippo.EditorManager.render();"); + context.addOnWinLoad("YAHOO.hippo.EditorManager.render();"); } } /** * Construct a Javascript object literal that represents the configuration of the Xinha editor. * An example of the returned object is - * { + * { * name: 'XinhaPlugin1', * textarea: 'xinha1', - * started: false, + * started: false, * focus: true, * properties: [{key: 'callbackUrl', value: '...'}]}, * plugins: ['AutoSave', 'table'], @@ -450,7 +453,7 @@ /** * Only after clicking the preview area, should this editor be auto-focused. All other cases, like switching editor-tabs * should be handled by state on the client instead of on the server. Because of this true is only returned once. - * + * * @return If the RTE should be auto-focused when created. */ public boolean getFocusAfterLoad() { @@ -520,8 +523,8 @@ public boolean getStatusBar() { return statusBar; } - - public boolean getOnly7BitPrintablesInURLs() { + + public boolean getOnly7BitPrintablesInURLs() { return only7BitPrintablesInURLs; }