[kupu-checkins] r34311 - in kupu/trunk/kupu: common plone plone/kupu_plone_layer

duncan at codespeak.net duncan at codespeak.net
Tue Nov 7 12:18:26 CET 2006


Author: duncan
Date: Tue Nov  7 12:18:23 2006
New Revision: 34311

Modified:
   kupu/trunk/kupu/common/kupubasetools.js
   kupu/trunk/kupu/common/kupudrawers.js
   kupu/trunk/kupu/common/kupueditor.js
   kupu/trunk/kupu/common/kupusourceedit.js
   kupu/trunk/kupu/common/sarissa.js
   kupu/trunk/kupu/plone/body.kupu
   kupu/trunk/kupu/plone/kupu_plone_layer/kupu_wysiwyg_support.html
   kupu/trunk/kupu/plone/plonedrawers.py
Log:
Fixes for IE7 compatibility.

Modified: kupu/trunk/kupu/common/kupubasetools.js
==============================================================================
--- kupu/trunk/kupu/common/kupubasetools.js	(original)
+++ kupu/trunk/kupu/common/kupubasetools.js	Tue Nov  7 12:18:23 2006
@@ -2707,17 +2707,19 @@
         var width = window.innerWidth;
         var height = window.innerHeight;
     } else if (document.documentElement) {
-        var width = document.documentElement.offsetWidth-5;
-        var height = document.documentElement.offsetHeight-5;
+        if (!window._IE_VERSION) {
+            _IE_VERSION = /MSIE\s*([0-9.]*)/.exec(navigator.appVersion);
+        };
+        var kludge = (_IE_VERSION[1]<7)?5:0;
+        var width = document.documentElement.offsetWidth-kludge;
+        var height = document.documentElement.offsetHeight-kludge;
     } else {
         var width = document.body.offsetWidth-5;
         var height = document.body.offsetHeight-5;
     }
     width = width + 'px';
-    var offset = iframe.offsetTop;
-    if (sourceArea && sourceArea.offsetTop) offset = sourceArea.offsetTop-1;
-    var nheight = Math.max(height - offset -1/*top border*/, 10);
-    nheight = nheight + 'px';
+    var offset = iframe.parentNode.offsetTop;
+    var nheight = Math.max(height - offset -1/*top border*/, 10) + 'px';
     fulleditor.style.width = width; /*IE needs this*/
     iframe.style.width = width;
     iframe.style.height = nheight;

Modified: kupu/trunk/kupu/common/kupudrawers.js
==============================================================================
--- kupu/trunk/kupu/common/kupudrawers.js	(original)
+++ kupu/trunk/kupu/common/kupudrawers.js	Tue Nov  7 12:18:23 2006
@@ -674,7 +674,6 @@
         var targetnode = document.getElementById(id);
         if (!sourcenode || !targetnode) return;
 
-        sourcenode = document.importNode(sourcenode, true);
         Sarissa.copyChildNodes(sourcenode, targetnode);
         if (!this.focussed) {
             this.focusElement();

Modified: kupu/trunk/kupu/common/kupueditor.js
==============================================================================
--- kupu/trunk/kupu/common/kupueditor.js	(original)
+++ kupu/trunk/kupu/common/kupueditor.js	Tue Nov  7 12:18:23 2006
@@ -627,7 +627,7 @@
         for (var i = 0; i < bodies.length; i++) {
             data += this.serializer.serializeToString(bodies[i]);
         }
-        return this.escapeEntities(data);
+        return this.layoutsource(this.escapeEntities(data));
     };
 
     this.getHTMLBody = function() {
@@ -638,7 +638,7 @@
         for (var i = 0; i < bodies.length; i++) {
             data += bodies[i].innerHTML;
         }
-        return this.escapeEntities(data);
+        return this.layoutsource(this.escapeEntities(data));
     };
 
     // If we have multiple bodies this needs to remove the extras.
@@ -765,6 +765,13 @@
         
         return contents;
     };
+    this.layoutsource = function(data) {
+        data = data.replace(
+            /\s*(<(p|div|h.|ul|ol|dl|menu|dir|pre|blockquote|address|center|table|thead|tbody|tfoot|tr|th|td))\b/ig, '\n$1');
+        data = data.replace(
+            /\s*(<\/(p|div|h.|ul|ol|dl|menu|dir|pre|blockquote|address|center|table|thead|tbody|tfoot|tr|th|td)>)\s*/ig, '$1\n');
+        return data.strip();
+    }
     this.escapeEntities = function(xml) {
         // XXX: temporarily disabled
         return xml;

Modified: kupu/trunk/kupu/common/kupusourceedit.js
==============================================================================
--- kupu/trunk/kupu/common/kupusourceedit.js	(original)
+++ kupu/trunk/kupu/common/kupusourceedit.js	Tue Nov  7 12:18:23 2006
@@ -75,9 +75,7 @@
         } else {
             data = kupu.getHTMLBody();
         }
-        data = data.replace(
-            /\s*(<(p|div|h.|ul|ol|dl|menu|dir|pre|blockquote|address|center|table|thead|tbody|tfoot|tr|th|td))\b/g, '\n$1').strip();
-        sourcearea.value = data;
+        sourcearea.value = data.strip();
         kupu.setClass(sourceClass);
         editorframe.style.display = 'none';
         sourcearea.style.display = 'block';

Modified: kupu/trunk/kupu/common/sarissa.js
==============================================================================
--- kupu/trunk/kupu/common/sarissa.js	(original)
+++ kupu/trunk/kupu/common/sarissa.js	Tue Nov  7 12:18:23 2006
@@ -428,9 +428,9 @@
         document.importNode = function(oNode, bChildren){
             var tmp = document.createElement("div");
             if(bChildren){
-                tmp.innerHTML = oNode.xml ? oNode.xml : oNode.innerHTML;
+                tmp.innerHTML = oNode.xml ? oNode.xml : oNode.outerHTML;
             }else{
-                tmp.innerHTML = oNode.xml ? oNode.cloneNode(false).xml : oNode.cloneNode(false).innerHTML;
+                tmp.innerHTML = oNode.xml ? oNode.cloneNode(false).xml : oNode.cloneNode(false).outerHTML;
             };
             return tmp.getElementsByTagName("*")[0];
         };

Modified: kupu/trunk/kupu/plone/body.kupu
==============================================================================
--- kupu/trunk/kupu/plone/body.kupu	(original)
+++ kupu/trunk/kupu/plone/body.kupu	Tue Nov  7 12:18:23 2006
@@ -7,6 +7,7 @@
     xmlns:i18n="http://xml.zope.org/namespaces/i18n">
   <kupu:id>$Id$</kupu:id>
   <kupu:part name="editorframe"><script type="text/javascript">var focuscount = 0;</script>
+    <div>
     <iframe class="kupu-editor-iframe"
         frameborder="0"
         src="emptypage"
@@ -60,6 +61,7 @@
                         rows rows|default;
                         cols cols|default;">
     </textarea>
+    </div>
   </kupu:part>
 
   <kupu:part name="suppress-kupu">

Modified: kupu/trunk/kupu/plone/kupu_plone_layer/kupu_wysiwyg_support.html
==============================================================================
--- kupu/trunk/kupu/plone/kupu_plone_layer/kupu_wysiwyg_support.html	(original)
+++ kupu/trunk/kupu/plone/kupu_plone_layer/kupu_wysiwyg_support.html	Tue Nov  7 12:18:23 2006
@@ -416,6 +416,7 @@
   
     </div>
   <script type="text/javascript">var focuscount = 0;</script>
+    <div>
     <iframe class="kupu-editor-iframe" frameborder="0" src="emptypage" onfocus="this.contentWindow.focus();" tal:define="base python:here.kupu_library_tool.getBaseUrl(here, True);                     base kupu_base_override|base;" tal:attributes="src string:${base}/emptypage;                         tabindex tabindex/next|nothing;">
     </iframe>
      <input type="hidden" name="text_format:default" value="text/html" tal:define="fieldName fieldName|inputname|nothing;                 val python:fieldName and 'text/html' or 'html';                 fieldName python:test(fieldName, fieldName+'_', '') + 'text_format:default';" tal:attributes="name fieldName;value val;"/>
@@ -425,6 +426,7 @@
 </tal:test>
     <textarea cols="80" rows="25" tabindex="" class="kupu-editor-textarea" name="description" id="kupu-editor-textarea" tal:define="pss modules/Products/PythonScripts/standard;                 text_format python: getattr(here,'text_format','html');                 is_stx python:text_format=='structured-text';                 is_ptx python:text_format=='plain';" tal:condition="not:fieldName|nothing" tal:content="python:(is_stx and pss.structured_text(inputvalue))                                     or (is_ptx and pss.newline_to_br(inputvalue))                                     or inputvalue" tal:attributes="name inputname;                         onfocus onfocus|nothing;                         onblur onblur|nothing;                         tabindex tabindex|nothing;                         rows rows|default;                         cols cols|default;">
     </textarea>
+    </div>
   
     <div class="kupuoverride" tal:condition="python:exists('kupu_content') and len(kupu_content)==0" tal:define="floated widget/allow_file_upload | python:1;" tal:attributes="style python:test(floated, 'float:left;;', '');"><span class="discreet"><a class="forcekupu" href="#" i18n:translate="suppress-kupu" tal:attributes="href string:${request/URL0}?kupu.suppress=${fieldName};" title="reload current page without kupu">
          Edit without visual editor

Modified: kupu/trunk/kupu/plone/plonedrawers.py
==============================================================================
--- kupu/trunk/kupu/plone/plonedrawers.py	(original)
+++ kupu/trunk/kupu/plone/plonedrawers.py	Tue Nov  7 12:18:23 2006
@@ -232,7 +232,11 @@
             if not callable(obj.getId):
                 if getattr(obj, 'getObject', None) is None:
                     return
-                obj = obj.getObject()
+                try:
+                    obj = obj.getObject()
+                except:
+                    return 
+                
             if getattr(obj, 'getField', None) is None:
                 return
             image_field = obj.getWrappedField(imagefield)


More information about the kupu-checkins mailing list