[Jifty-commit] r5141 - jifty/branches/jquery/share/web/static/js

Jifty commits jifty-commit at lists.jifty.org
Wed Feb 20 03:59:27 EST 2008


Author: gugod
Date: Wed Feb 20 03:59:26 2008
New Revision: 5141

Modified:
   jifty/branches/jquery/share/web/static/js/jifty.js

Log:
Re-arrange all <script> tags to the end of textContent.  This
approach easily deal with the uncertain amount of time we need to
wait before the region is ready for running some javascript.

This approach is introduced because YAHOO.util.Event.onAvailable
is only for the first time that region is reneder, but not working
for further region updates. This means that it's not quite
compatible with jQuery way of element update.


Modified: jifty/branches/jquery/share/web/static/js/jifty.js
==============================================================================
--- jifty/branches/jquery/share/web/static/js/jifty.js	(original)
+++ jifty/branches/jquery/share/web/static/js/jifty.js	Wed Feb 20 03:59:26 2008
@@ -1008,6 +1008,16 @@
                     textContent = fragment_bit.firstChild.nodeValue;
                 }
 
+                // Re-arrange all <script> tags to the end of textContent.
+                // This approach easily deal with the uncertain amount of
+                // time we need to wait before the region is ready for running
+                // some javascript.
+
+                var re = new RegExp('<script[^>]*>([\\S\\s]*?)<\/script>', 'img');
+                var scripts = (textContent.match(re) || []).join("");
+                var textContentWithoutScript = textContent.replace(re, '');
+                textContent = textContentWithoutScript + scripts;
+
                 // Once we find it, do the insertion
                 if (f['mode'] && (f['mode'] != 'Replace')) {
                     var method = ({


More information about the Jifty-commit mailing list