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

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Mon Oct 30 23:49:01 EST 2006


Author: jesse
Date: Mon Oct 30 23:49:01 2006
New Revision: 2093

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

Log:
 r29625 at pinglin:  jesse | 2006-10-30 23:40:46 -0500
 * Switch our implementation of autofocus to use behavior, rather than a custom onload event
 


Modified: jifty/trunk/lib/Jifty/Web/Form/Field.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Web/Form/Field.pm	(original)
+++ jifty/trunk/lib/Jifty/Web/Form/Field.pm	Mon Oct 30 23:49:01 2006
@@ -494,6 +494,7 @@
                     ( $self->ajax_validates     ? ' ajaxvalidation' : '' ),
                     ( $self->ajax_canonicalizes ? ' ajaxcanonicalization' : '' ),
                     ( $self->autocompleter      ? ' ajaxautocompletes' : '' ),
+                    ( $self->focus              ? ' focus' : ''),
                     @_ );
 
     return qq! class="!. join(' ', at classes).  qq!"!
@@ -598,7 +599,9 @@
 
 sub focus_javascript {
     my $self = shift;
+    return undef;
     if($self->focus) {
+        return qq{document.getElementById("@{[$self->element_id]}").focus()};
         return qq{DOM.Events.addListener( window, "load", function(){document.getElementById("@{[$self->element_id]}").focus()})};
     }
 }

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	Mon Oct 30 23:49:01 2006
@@ -427,6 +427,17 @@
 
 JSAN.use("DOM.Events");
 
+
+// Form elements should focus if the CSS says so.
+Behaviour.register( { ".focus": function(e) {
+    /* Check to see if the element is already focused */
+    if ( !Element.hasClassName(e, "focused") ) {
+        e.focus();
+        Element.addClassName(e, "focused");
+    }
+    } });
+
+
 // Form elements should AJAX validate if the CSS says so
 Behaviour.register({
     'input.ajaxvalidation, textarea.ajaxvalidation, input.ajaxcanonicalization, textarea.ajaxcanonicalization': function(elt) {


More information about the Jifty-commit mailing list