[Jifty-commit] r5243 - in jifty/trunk: lib/Jifty/Web share/web/static/js

Jifty commits jifty-commit at lists.jifty.org
Thu Mar 27 19:25:55 EDT 2008


Author: alexmv
Date: Thu Mar 27 19:25:54 2008
New Revision: 5243

Modified:
   jifty/trunk/   (props changed)
   jifty/trunk/lib/Jifty/Web/PageRegion.pm
   jifty/trunk/share/web/static/js/jifty.js

Log:
 r28914 at kohr-ah:  chmrr | 2008-03-27 19:25:42 -0400
  * Lazy pageregions can't be done using behavior, as the JS which
    defined the region might not have been run yet if it itself came
    from a region load (for fragments responses, behavior is applied
    immediately, scripts are run after some settle time).
    Thus, put the region-updating code into the page directly.


Modified: jifty/trunk/lib/Jifty/Web/PageRegion.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Web/PageRegion.pm	(original)
+++ jifty/trunk/lib/Jifty/Web/PageRegion.pm	Thu Mar 27 19:25:54 2008
@@ -290,9 +290,12 @@
             . qq|);\n|
             . qq|</script>|;
         if ($self->lazy) {
-            return $result .  qq|<div id="region-| . $self->qualified_name . qq|" class="jifty-region-lazy"></div>|;
+            $result .= qq|<script type="text/javascript">|
+              . qq|Jifty.update( { 'fragments': [{'region': '|.$self->qualified_name.qq|', 'mode': 'Replace'}], 'actions': {}}, document.getElementById('region-|.$self->qualified_name.qq|'))|
+              . qq|</script>|;
         }
         $result .= qq|<div id="region-| . $self->qualified_name . qq|" class="jifty-region">|;
+        return $result . qq|</div>| if $self->lazy;
     }
 
     $self->render_as_subrequest(\$result, \%arguments);

Modified: jifty/trunk/share/web/static/js/jifty.js
==============================================================================
--- jifty/trunk/share/web/static/js/jifty.js	(original)
+++ jifty/trunk/share/web/static/js/jifty.js	Thu Mar 27 19:25:54 2008
@@ -834,10 +834,6 @@
     },
     '.form_field .error, .form_field .warning, .form_field .canonicalization_note': function(e) {
         if ( e.innerHTML == "" ) Element.hide(e);
-    },
-    '.jifty-region-lazy': function(e) {
-        var region = e.getAttribute("id").replace(/^region-/,"");
-        Jifty.update( { 'fragments': [{'region': region, 'mode': 'Replace'}]}, e);
     }
 });
 
@@ -1081,10 +1077,10 @@
             }
             // We need to give the browser some "settle" time before
             // we eval scripts in the body
-        YAHOO.util.Event.onAvailable(element.id, function() {
-            (function() { this.evalScripts() }).bind(textContent)();
-        });
-        Behaviour.apply(element);
+            YAHOO.util.Event.onAvailable(element.id, function() {
+                (function() { this.evalScripts() }).bind(textContent)();
+            });
+            Behaviour.apply(element);
         }
     });
     dom_fragment.setArgs(new_dom_args);


More information about the Jifty-commit mailing list