Author: julien(a)jboss.com
Date: 2007-04-08 06:31:41 -0400 (Sun, 08 Apr 2007)
New Revision: 6953
Modified:
trunk/theme/src/bin/portal-ajax-war/dyna/dyna.js
Log:
make async portlet markup update don't mess up with the DnD
Modified: trunk/theme/src/bin/portal-ajax-war/dyna/dyna.js
===================================================================
--- trunk/theme/src/bin/portal-ajax-war/dyna/dyna.js 2007-04-08 09:46:44 UTC (rev 6952)
+++ trunk/theme/src/bin/portal-ajax-war/dyna/dyna.js 2007-04-08 10:31:41 UTC (rev 6953)
@@ -159,8 +159,19 @@
markup = markup.substring(25, markup.length - 7);
var markupContainer = Element.up(matchingElt);
- markupContainer.innerHTML = markup;
+
+ // Create a temporary element and paste the innerHTML in it
+ var tmpElt = document.createElement("toto");
+ tmpElt.innerHTML = markup;
+
+ //
+ copyInnerHTML(tmpElt, container, "dyna-portlet")
+ copyInnerHTML(tmpElt, container, "dyna-handle")
}
+ else
+ {
+ // Should log that somewhere
+ }
}
// update view state
@@ -184,7 +195,38 @@
}
+/*
+ * Copy the inner content of two zones of the provided containers.
+ * The zone are found using the css class names. The operation
+ * will succeed only if there is exactly one zone in each container.
+ */
+function copyInnerHTML(srcContainer, dstContainer, className)
+{
+ var srcs = Element.getElementsByClassName(srcContainer, className);
+ if (srcs.length == 1)
+ {
+ var src = srcs[0];
+ //
+ var dsts = Element.getElementsByClassName(dstContainer, className)
+ if (dsts.length == 1)
+ {
+ var dst = dsts[0];
+
+ // Copy markup
+ dst.innerHTML = src.innerHTML;
+ }
+ else
+ {
+ // Should log that somewhere but
+ }
+ }
+ else
+ {
+ // Should log that somewhere
+ }
+}
+
function footer()
{
//
@@ -228,12 +270,15 @@
//
Draggables.addObserver(new WindowMoveObserver());
+
+ //
snapshot();
// Find the dyna portlets
var portlets_on_page = document.getElementsByClassName("async-window");
- // Add listener for the dyna windows
+ // Add listener for the dyna windows on the dyna-window element
+ // and not async-window as this one will have its markup replaced
for(var i = 0;i < portlets_on_page.length;i++) {
var portlet = Element.up(portlets_on_page[i]);
Event.observe(portlet, "click", bilto);
Show replies by date