[Zope-CVS] CVS: Products/CompositePage/common - editstyles.css:1.5 pdlib.js:1.3

Shane Hathaway shane at zope.com
Fri Dec 26 14:00:34 EST 2003


Update of /cvs-repository/Products/CompositePage/common
In directory cvs.zope.org:/tmp/cvs-serv28907/common

Modified Files:
	editstyles.css pdlib.js 
Log Message:
Fixed the two Internet Explorer bugs.

First, IE failed to produce events for some blocks in table cells that
had no text content.  Adding a floating, empty <div> in each slot
seems to have cleared up the problem for now, since the floating divs
affect the layout algorithm in some inexplicable way.  (I could only
fix this for real if I had access to the IE source code.)

Second, drag and drop didn't work when dragging an image.  Fixed by
using Microsoft's Javascript API for drag and drop.  I'm actually pretty
happy with this API--it's too bad other browsers don't use it.



=== Products/CompositePage/common/editstyles.css 1.4 => 1.5 ===
--- Products/CompositePage/common/editstyles.css:1.4	Mon Dec 22 15:21:14 2003
+++ Products/CompositePage/common/editstyles.css	Fri Dec 26 14:00:33 2003
@@ -1,5 +1,13 @@
 /* Composite editing styles */
 
+div.slot_header {
+  /* This is an IE6 hack.  The presence of a floating element in a
+  slot changes the layout algorithm somehow so that empty block elements
+  in table cells can generate events like onmouseover.  Otherwise, IE
+  simply doesn't generate the events. */
+  float: right;
+}
+
 div.slot_target {
   padding: 4px;
   border: 1px outset #cccccc;


=== Products/CompositePage/common/pdlib.js 1.2 => 1.3 ===
--- Products/CompositePage/common/pdlib.js:1.2	Mon Dec 22 12:28:10 2003
+++ Products/CompositePage/common/pdlib.js	Fri Dec 26 14:00:33 2003
@@ -440,27 +440,39 @@
   }
 }
 
+function pd_ie_ondragstart() {
+  event.dataTransfer.effectAllowed = "move";
+}
+
+function pd_ie_ondragend() {
+  if (pd_drag_event) {
+    pd_drag_event.target = null;
+    pd_finishDrag();
+  }
+}
+
 function pd_setupDragUI(mo, move_func, checkmove_func, box) {
   // Adds selection and drag and drop functionality to an element
-  function call_onmousedown(e) {
+  mo.onmousedown = function(e) {
     return pd_itemOnMousedown(mo, e, move_func, checkmove_func, box);
-  }
-  function call_onmouseover(e) {
+  };
+  mo.onmouseover = function(e) {
     return pd_itemOnMouseover(mo, e, box);
-  }
-  mo.onmousedown = call_onmousedown;
-  mo.onmouseover = call_onmouseover;
+  };
   mo.onselectstart = pd_stopEvent;  // IE: Don't start a selection.
+  // IE: drag and drop
+  mo.ondragstart = pd_ie_ondragstart;
+  mo.ondrag = pd_dragging;
+  mo.ondragend = pd_ie_ondragend;
 }
 
 function pd_setupContextMenu(mo, contextMenuId, box, onclick) {
   // Adds context menu functionality to an element
-  function oncontextmenu(e) {
+  mo.oncontextmenu = function(e) {
     return pd_itemOnContextMenu(mo, e, contextMenuId, box);
-  }
-  mo.oncontextmenu = oncontextmenu;
+  };
   if (onclick)
-    mo.onclick = oncontextmenu;
+    mo.onclick = mo.oncontextmenu;
 }
 
 function pd_documentOnMouseDown() {
@@ -493,14 +505,25 @@
   pd_setupNodeAndDescendants(node);
 }
 
+function pd_ie_ondrag() {
+  event.returnValue = false;
+  event.dataTransfer.dropEffect = "move";
+}
+
 function pd_setupDropTarget(node, selectable) {
-  function call_highlight() {
+  node.onmouseover = function() {
     return pd_setHighlightedTarget(node);
-  }
-  node.onmouseover = call_highlight;
+  };
   node.onmouseout = pd_unhighlightTarget;
   if (!selectable)
     node.onmousedown = pd_stopEvent; // Prevent accidental selection
+  // IE: drag and drop
+  node.ondrop = function() {
+    pd_setHighlightedTarget(node);
+    pd_finishDrag();
+  };
+  node.ondragenter = pd_ie_ondrag;
+  node.ondragover = pd_ie_ondrag;
 }
 
 function pd_setupContextMenuDefinition(node) {
@@ -509,14 +532,12 @@
 }
 
 function pd_setupContextMenuItem(node) {
-  function call_highlight() {
+  node.onmouseover = function() {
     pd_highlight(node, "hover");
-  }
-  function call_unhighlight() {
+  };
+  node.onmouseout = function() {
     pd_highlight(node, "");
-  }
-  node.onmouseover = call_highlight;
-  node.onmouseout = call_unhighlight;
+  };
 }
 
 pd_node_setup['drop-target'] = pd_setupDropTarget;




More information about the Zope-CVS mailing list