r1077 - trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte
Author: vjrj Date: 2009-03-15 19:00:13 +0100 (Sun, 15 Mar 2009) New Revision: 1077 Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/WrappedRichTextAreaImplIE6.java trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/WrappedRichTextAreaImplMozilla.java trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/WrappedRichTextAreaImplOpera.java trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/WrappedRichTextAreaImplSafari.java Log: Complete - RTE styling issue in non-mozilla browsers Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/WrappedRichTextAreaImplIE6.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/WrappedRichTextAreaImplIE6.java 2009-03-15 17:29:41 UTC (rev 1076) +++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/WrappedRichTextAreaImplIE6.java 2009-03-15 18:00:13 UTC (rev 1077) @@ -35,33 +35,33 @@ @Override public native void initElement() /*-{ - var _this = this; - _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplStandard::initializing = true; + var _this = this; + _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplStandard::initializing = true; - setTimeout(function() { - if (_this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplStandard::initializing == false) { - return; - } + setTimeout(function() { + if (_this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplStandard::initializing == false) { + return; + } - // Attempt to set the iframe document's body to 'contentEditable' mode. - // There's no way to know when the body will actually be available, so - // keep trying every so often until it is. - // Note: The body seems to be missing only rarely, so please don't remove - // this retry loop just because it's hard to reproduce. - var elem = _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImpl::elem; - var doc = elem.contentWindow.document; - if (!doc.body) { - // Retry in 50 ms. Faster would run the risk of pegging the CPU. Slower - // would increase the probability of a user-visible delay. - setTimeout(arguments.callee, 50); - return; - } - var ct = "<html><head><style>@import url('" + $wnd.location.protocol + $wnd.location.host + $wnd.location.pathname + "css/richtext.css" + "');</style></head><body CONTENTEDITABLE='true'></body></html>" ; - doc.write( ct ); - doc.body.contentEditable = true; + // Attempt to set the iframe document's body to 'contentEditable' mode. + // There's no way to know when the body will actually be available, so + // keep trying every so often until it is. + // Note: The body seems to be missing only rarely, so please don't remove + // this retry loop just because it's hard to reproduce. + var elem = _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImpl::elem; + var doc = elem.contentWindow.document; + if (!doc.body) { + // Retry in 50 ms. Faster would run the risk of pegging the CPU. Slower + // would increase the probability of a user-visible delay. + setTimeout(arguments.callee, 50); + return; + } + var ct = "<html><head><style>@import url('" + $wnd.location.protocol + "//" + $wnd.location.host + $wnd.location.pathname + "css/richtext.css" + "');</style></head><body CONTENTEDITABLE='true'></body></html>" ; + doc.write( ct ); + doc.body.contentEditable = true; - // Send notification that the iframe has reached design mode. - _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplStandard::onElementInitialized()(); - }, 1); - }-*/; + // Send notification that the iframe has reached design mode. + _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplStandard::onElementInitialized()(); + }, 1); + }-*/; } Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/WrappedRichTextAreaImplMozilla.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/WrappedRichTextAreaImplMozilla.java 2009-03-15 17:29:41 UTC (rev 1076) +++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/WrappedRichTextAreaImplMozilla.java 2009-03-15 18:00:13 UTC (rev 1077) @@ -35,42 +35,42 @@ @Override public native void initElement() /*-{ - // Mozilla doesn't allow designMode to be set reliably until the iframe is - // fully loaded. - var _this = this; - var iframe = _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImpl::elem; - _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplStandard::initializing = true; + // Mozilla doesn't allow designMode to be set reliably until the iframe is + // fully loaded. + var _this = this; + var iframe = _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImpl::elem; + _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplStandard::initializing = true; - iframe.onload = function() { - // Some Mozillae have the nasty habit of calling onload again when you set - // designMode, so let's avoid doing it more than once. - iframe.onload = null; + iframe.onload = function() { + // Some Mozillae have the nasty habit of calling onload again when you set + // designMode, so let's avoid doing it more than once. + iframe.onload = null; - // patch ccs inject: + // patch ccs inject: - var doc = _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImpl::elem.contentWindow.document; - head=doc.getElementsByTagName('head')[0]; - link=document.createElement('link'); - link.setAttribute('rel',"stylesheet"); - link.setAttribute('type',"text/css"); - link.setAttribute('href',$wnd.location.protocol + $wnd.location.host + $wnd.location.pathname + "css/richtext.css" ); - head.appendChild(link); + var doc = _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImpl::elem.contentWindow.document; + head=doc.getElementsByTagName('head')[0]; + link=document.createElement('link'); + link.setAttribute('rel',"stylesheet"); + link.setAttribute('type',"text/css"); + link.setAttribute('href',$wnd.location.protocol + "//" + $wnd.location.host + $wnd.location.pathname + "css/richtext.css" ); + head.appendChild(link); - // -- patch + // -- patch - // Send notification that the iframe has finished loading. - _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplStandard::onElementInitialized()(); + // Send notification that the iframe has finished loading. + _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplStandard::onElementInitialized()(); - // Don't set designMode until the RTA actually gets focused. This is - // necessary because editing won't work on Mozilla if the iframe is - // *hidden, but attached*. Waiting for focus gets around this issue. - // - // Note: This onfocus will not conflict with the addEventListener('focus', - // ...) // in RichTextAreaImplStandard. - iframe.contentWindow.onfocus = function() { - iframe.contentWindow.onfocus = null; - iframe.contentWindow.document.designMode = 'On'; - }; - }; - }-*/; + // Don't set designMode until the RTA actually gets focused. This is + // necessary because editing won't work on Mozilla if the iframe is + // *hidden, but attached*. Waiting for focus gets around this issue. + // + // Note: This onfocus will not conflict with the addEventListener('focus', + // ...) // in RichTextAreaImplStandard. + iframe.contentWindow.onfocus = function() { + iframe.contentWindow.onfocus = null; + iframe.contentWindow.document.designMode = 'On'; + }; + }; + }-*/; } Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/WrappedRichTextAreaImplOpera.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/WrappedRichTextAreaImplOpera.java 2009-03-15 17:29:41 UTC (rev 1076) +++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/WrappedRichTextAreaImplOpera.java 2009-03-15 18:00:13 UTC (rev 1077) @@ -25,24 +25,24 @@ @Override public native void initElement() /*-{ - // Most browsers don't like setting designMode until slightly _after_ - // the iframe becomes attached to the DOM. Any non-zero timeout will do - // just fine. - var _this = this; - _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplStandard::initializing = true; - setTimeout(function() { - // Turn on design mode. - _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImpl::elem.contentWindow.document.designMode = 'On'; - // patch css inject: - var elem = _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImpl::elem; - var doc = elem.contentWindow.document; - var ct = "<html><head><style>@import url('" +$wnd.location.protocol + $wnd.location.host + $wnd.location.pathname + "css/richtext.css" + "');</style></head><body CONTENTEDITABLE='true'></body></html>" ; - doc.write( ct ); - // -- patch + // Most browsers don't like setting designMode until slightly _after_ + // the iframe becomes attached to the DOM. Any non-zero timeout will do + // just fine. + var _this = this; + _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplStandard::initializing = true; + setTimeout(function() { + // Turn on design mode. + _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImpl::elem.contentWindow.document.designMode = 'On'; + // patch css inject: + var elem = _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImpl::elem; + var doc = elem.contentWindow.document; + var ct = "<html><head><style>@import url('" + $wnd.location.protocol + "//" + $wnd.location.host + $wnd.location.pathname + "css/richtext.css" + "');</style></head><body CONTENTEDITABLE='true'></body></html>" ; + doc.write( ct ); + // -- patch - // Send notification that the iframe has reached design mode. - _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplStandard::onElementInitialized()(); - }, 1); - }-*/; + // Send notification that the iframe has reached design mode. + _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplStandard::onElementInitialized()(); + }, 1); + }-*/; } Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/WrappedRichTextAreaImplSafari.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/WrappedRichTextAreaImplSafari.java 2009-03-15 17:29:41 UTC (rev 1076) +++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/WrappedRichTextAreaImplSafari.java 2009-03-15 18:00:13 UTC (rev 1077) @@ -25,25 +25,25 @@ @Override public native void initElement() /*-{ - // Most browsers don't like setting designMode until slightly _after_ - // the iframe becomes attached to the DOM. Any non-zero timeout will do - // just fine. - var _this = this; - _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplStandard::initializing = true; - setTimeout(function() { - // Turn on design mode. - _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImpl::elem.contentWindow.document.designMode = 'On'; + // Most browsers don't like setting designMode until slightly _after_ + // the iframe becomes attached to the DOM. Any non-zero timeout will do + // just fine. + var _this = this; + _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplStandard::initializing = true; + setTimeout(function() { + // Turn on design mode. + _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImpl::elem.contentWindow.document.designMode = 'On'; - // patch css inject: - var elem = _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImpl::elem; - var doc = elem.contentWindow.document; - var ct = "<html><head><style>@import url('" +$wnd.location.protocol + $wnd.location.host + $wnd.location.pathname + "css/richtext.css" + "');</style></head><body CONTENTEDITABLE='true'></body></html>" ; - doc.write( ct ); - // -- patch + // patch css inject: + var elem = _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImpl::elem; + var doc = elem.contentWindow.document; + var ct = "<html><head><style>@import url('" +$wnd.location.protocol+ "//" + $wnd.location.host + $wnd.location.pathname + "css/richtext.css" + "');</style></head><body CONTENTEDITABLE='true'></body></html>" ; + doc.write( ct ); + // -- patch - // Send notification that the iframe has reached design mode. - _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplStandard::onElementInitialized()(); - }, 1); - }-*/; + // Send notification that the iframe has reached design mode. + _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplStandard::onElementInitialized()(); + }, 1); + }-*/; }
participants (1)
-
vjrj