[Jifty-commit] r4762 - in jifty/branches/jquery: . lib/Jifty share/web/static/js t/TestApp-JiftyJS/share/web/static/js-test

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Sat Dec 22 05:22:15 EST 2007


Author: clkao
Date: Sat Dec 22 05:22:12 2007
New Revision: 4762

Modified:
   jifty/branches/jquery/   (props changed)
   jifty/branches/jquery/lib/Jifty/Config.pm
   jifty/branches/jquery/lib/Jifty/Plugin/CSSQuery.pm
   jifty/branches/jquery/lib/Jifty/Web.pm
   jifty/branches/jquery/share/web/static/js/behaviour.js
   jifty/branches/jquery/share/web/static/js/cssQuery-jquery.js
   jifty/branches/jquery/t/TestApp-JiftyJS/share/web/static/js-test/01.behaviour.html

Log:
merge down for jquery branch.

Modified: jifty/branches/jquery/lib/Jifty/Config.pm
==============================================================================
--- jifty/branches/jquery/lib/Jifty/Config.pm	(original)
+++ jifty/branches/jquery/lib/Jifty/Config.pm	Sat Dec 22 05:22:12 2007
@@ -346,7 +346,7 @@
 sub initial_config {
     my $self = shift;
     my $guess = $self->guess(@_);
-    $guess->{'framework'}->{'ConfigFileVersion'} = 2;
+    $guess->{'framework'}->{'ConfigFileVersion'} = 3;
 
     # These are the plugins which new apps will get by default
     $guess->{'framework'}->{'Plugins'} = [
@@ -390,6 +390,12 @@
         );
     }
 
+    if ( $config->{'framework'}->{'ConfigFileVersion'} < 3) {
+        unshift (@{$config->{'framework'}->{'Plugins'}}, 
+            { CSSQuery           => {}, }
+        );
+    }
+
     return $config;
 }
 

Modified: jifty/branches/jquery/lib/Jifty/Plugin/CSSQuery.pm
==============================================================================
--- jifty/branches/jquery/lib/Jifty/Plugin/CSSQuery.pm	(original)
+++ jifty/branches/jquery/lib/Jifty/Plugin/CSSQuery.pm	Sat Dec 22 05:22:12 2007
@@ -27,6 +27,9 @@
 time, for Jifty use it internally. Now it's been replaced with jQuery.
 It's now a plugin for backward compatibility.
 
+It is disabled by default, unless your C<ConfigFileVersion> is smaller
+or equal then 2.
+
 For more information about cssQuery, see L<http://dean.edwards.name/my/cssQuery/>.
 
 =head1 METHODS

Modified: jifty/branches/jquery/lib/Jifty/Web.pm
==============================================================================
--- jifty/branches/jquery/lib/Jifty/Web.pm	(original)
+++ jifty/branches/jquery/lib/Jifty/Web.pm	Sat Dec 22 05:22:12 2007
@@ -41,7 +41,6 @@
     prototype.js
     jquery-1.2.1.js
     jquery_noconflict.js
-    cssQuery-jquery.js
     behaviour.js
     scriptaculous/builder.js
     scriptaculous/effects.js

Modified: jifty/branches/jquery/share/web/static/js/behaviour.js
==============================================================================
--- jifty/branches/jquery/share/web/static/js/behaviour.js	(original)
+++ jifty/branches/jquery/share/web/static/js/behaviour.js	Sat Dec 22 05:22:12 2007
@@ -1,6 +1,5 @@
 /*
-   Modified to fix some bugs, use a different css query engine, and to
-   to use JSAN classes.
+   Modified version. Use jQuery as css query engine.
    
    Based on Behaviour v1.1 by Ben Nolan, June 2005, which was based
    largely on the work of Simon Willison.
@@ -27,33 +26,27 @@
 
 */   
 
-JSAN.use("DOM.Events");
-JSAN.use("Upgrade.Array.push");
-
 var Behaviour = {
     list: [],
-    
+
     register: function(sheet) {
         Behaviour.list.push(sheet);
     },
     
     apply: function() {
-	var root = arguments[0];
-	if(root) root = $(root);
-
+        var root = arguments[0];
         for (var h = 0; sheet = Behaviour.list[h]; h++) {
             for (var selector in sheet) {
-		var start = new Date();
-                var elements = cssQuery(selector, root);
-
-                if ( !elements ) continue;
-
-                for (var i = 0; element = elements[i]; i++) {
-                    sheet[selector](element);
-		}
+                jQuery(selector, root).each(function() {
+                     sheet[selector](this);
+                });
             }
         }
     }
-}    
+};
 
-DOM.Events.addListener( window, "load", function() { Behaviour.apply() } );
+(function($) {
+    $(document).ready(function(){
+        Behaviour.apply();
+    });
+})(jQuery);

Modified: jifty/branches/jquery/share/web/static/js/cssQuery-jquery.js
==============================================================================
--- jifty/branches/jquery/share/web/static/js/cssQuery-jquery.js	(original)
+++ jifty/branches/jquery/share/web/static/js/cssQuery-jquery.js	Sat Dec 22 05:22:12 2007
@@ -5,8 +5,13 @@
 
     // All public interfaces are showing alert instead of doing the realthing.
     // Deep compatibiliy isn't going to be implemented.
-    cssQuery.toString = cssQuery.clearCache = cssQuery.addModule = cssQuery.valueOf = function() {
-        var msg = "This implementation of cssQuery is really a wrapper to jQuery. No compatibility is ensured. Please use jQuery instead.";
+    var msg = "This implementation of cssQuery is really a wrapper to jQuery. No compatibility is ensured. Please use jQuery instead.";
+
+    cssQuery.toString = function() {
+        return "function() { [" + msg +  "] }";
+    };
+
+     cssQuery.clearCache = cssQuery.addModule = cssQuery.valueOf = function() {
         alert(msg);
     };
 

Modified: jifty/branches/jquery/t/TestApp-JiftyJS/share/web/static/js-test/01.behaviour.html
==============================================================================
--- jifty/branches/jquery/t/TestApp-JiftyJS/share/web/static/js-test/01.behaviour.html	(original)
+++ jifty/branches/jquery/t/TestApp-JiftyJS/share/web/static/js-test/01.behaviour.html	Sat Dec 22 05:22:12 2007
@@ -8,10 +8,10 @@
 
 <script type="text/javascript" src="/static/js/jquery-1.2.1.js" charset="UTF-8"></script>
 <script type="text/javascript" src="/static/js/jquery_noconflict.js" charset="UTF-8"></script>
-<script type="text/javascript" src="/static/js/cssQuery-jquery.js" charset="UTF-8"></script>
-
 <script type="text/javascript" src="/static/js/behaviour.js" charset="UTF-8"></script>
 <script type="text/javascript">
+var nonexists_applied = false;
+
 Behaviour.register({
     '#foo': function(element) {
         element.innerHTML = "FOO is HERE";
@@ -19,6 +19,12 @@
 
     '#bar': function(element) {
         element.innerHTML = "BAR is HERE";
+    },
+    '.nonexists': function(element) {
+        nonexists_applied = true;
+        document.body.appendChild(
+            document.createTextNode("Foo")
+        );
     }
 });
 
@@ -34,11 +40,12 @@
 
 <body>
     <div id="foo"></div>
+    <div id="foo2"></div>
     <pre id="test"></pre>
 
     <script type="text/javascript"><!--
     JSAN.use('Test.More');
-    plan({ tests: 2 });
+    plan({ tests: 4 });
     async_id = beginAsync();
     
     setTimeout(function() {
@@ -46,9 +53,13 @@
         
         add_bar();
         
+        Behaviour.apply("#foo2");
+        is( document.getElementById("bar").innerHTML, "", "#bar rule is not applied because that's not under #foo2");
+
         Behaviour.apply();
-        
         is( document.getElementById("bar").innerHTML, "BAR is HERE", "#bar rule is applied manually");
+
+        is (nonexists_applied, false, ".nonexists rule never applied.");
         endAsync(async_id);
     }, 1000);
     //--></script>


More information about the Jifty-commit mailing list