[Jifty-commit] r2508 - in jifty/branches/template-declare: . doc lib/Jifty/Web/Form share/web/static/js

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Tue Jan 16 17:35:53 EST 2007


Author: trs
Date: Tue Jan 16 17:35:52 2007
New Revision: 2508

Modified:
   jifty/branches/template-declare/   (props changed)
   jifty/branches/template-declare/doc/declarative-test-design
   jifty/branches/template-declare/lib/Jifty/Manual/Tutorial_de.pod
   jifty/branches/template-declare/lib/Jifty/Web/Form/Element.pm
   jifty/branches/template-declare/lib/Jifty/Web/Form/Field.pm
   jifty/branches/template-declare/share/web/static/js/jifty_utils.js

Log:
Mergedown from trunk

 r18816 at zot (orig r2492):  trs | 2007-01-11 14:50:33 -0500
  r18814 at zot:  tom | 2007-01-11 14:50:11 -0500
  Add a key_binding_label attribute so that key binding labels can be set independently of the normal label
 
 r18884 at zot (orig r2504):  jesse | 2007-01-15 23:53:29 -0500
  r21003 at hualien:  jesse | 2007-01-15 23:52:34 -0500
  * a syntax idea for declarative test design
 
 r18885 at zot (orig r2505):  jesse | 2007-01-16 11:45:36 -0500
  r21005 at hualien:  jesse | 2007-01-16 11:45:26 -0500
  * Tutorial_de retitled to not conflict with the english one.
 
 r18892 at zot (orig r2507):  trs | 2007-01-16 17:34:39 -0500
  r18891 at zot:  tom | 2007-01-16 17:32:21 -0500
  Add browser detection from BTDT to Jifty (where it should have been)
 


Modified: jifty/branches/template-declare/doc/declarative-test-design
==============================================================================
--- jifty/branches/template-declare/doc/declarative-test-design	(original)
+++ jifty/branches/template-declare/doc/declarative-test-design	Tue Jan 16 17:35:52 2007
@@ -103,3 +103,26 @@
 
 
 run_all;
+
+
+# A syntax idea from jesse:
+
+flow "Check to see if the user can login" => test {
+    get '/';
+    element '//body' matches /You're not logged in/;
+
+    follow link 'Login';
+
+    my $login_form = element id 'login-form'
+
+    fill $login_form  =>  { 
+        email => 'jesse at fsck.com',
+        password => 'I hate you'
+    }
+
+    click button 'Login!';
+
+}
+
+
+

Modified: jifty/branches/template-declare/lib/Jifty/Manual/Tutorial_de.pod
==============================================================================
--- jifty/branches/template-declare/lib/Jifty/Manual/Tutorial_de.pod	(original)
+++ jifty/branches/template-declare/lib/Jifty/Manual/Tutorial_de.pod	Tue Jan 16 17:35:52 2007
@@ -1,6 +1,6 @@
 =head1 NAME
 
-Jifty::Manual::Tutorial - Einführung in Jifty
+Jifty::Manual::Tutorial_de - Einführung in Jifty
 
 =head1 BESCHREIBUNG
 

Modified: jifty/branches/template-declare/lib/Jifty/Web/Form/Element.pm
==============================================================================
--- jifty/branches/template-declare/lib/Jifty/Web/Form/Element.pm	(original)
+++ jifty/branches/template-declare/lib/Jifty/Web/Form/Element.pm	Tue Jan 16 17:35:52 2007
@@ -144,8 +144,8 @@
 
 =cut
 
-sub accessors { shift->handlers, qw(class key_binding id label tooltip) }
-__PACKAGE__->mk_accessors(qw(_onclick class key_binding id label tooltip));
+sub accessors { shift->handlers, qw(class key_binding key_binding_label id label tooltip) }
+__PACKAGE__->mk_accessors(qw(_onclick class key_binding key_binding_label id label tooltip));
 
 =head2 new PARAMHASH OVERRIDE
 
@@ -336,7 +336,12 @@
 
 =head2 key_binding
 
-Sets the key binding associated with this elements
+Sets the key binding associated with this element
+
+=head2 key_binding_label
+
+Sets the key binding label associated with this element (if none is specified,
+the normal label is used instead)
 
 =head2 id
 
@@ -345,7 +350,7 @@
 =head2 label
 
 Sets the label of the element.  This will be used for the key binding
-legend, at very least.
+legend if key_binding_label is not set.
 
 =head2 key_binding_javascript
 
@@ -355,14 +360,17 @@
 =cut
 
 sub key_binding_javascript {
-    my $self = shift;
-    my $key  = $self->key_binding;
+    my $self  = shift;
+    my $key   = $self->key_binding;
+    my $label = defined $self->key_binding_label
+                    ? $self->key_binding_label
+                    : $self->label;
     if ($key) {
         return "Jifty.KeyBindings.add("
                 . Jifty::JSON::objToJson( uc($key), { singlequote => 1 } ).","
                 . "'click', "
                 . Jifty::JSON::objToJson( $self->id, { singlequote => 1 } ).","
-                . Jifty::JSON::objToJson( $self->label, { singlequote => 1 } )
+                . Jifty::JSON::objToJson( $label, { singlequote => 1 } )
                 . ");";
     }
 }

Modified: jifty/branches/template-declare/lib/Jifty/Web/Form/Field.pm
==============================================================================
--- jifty/branches/template-declare/lib/Jifty/Web/Form/Field.pm	(original)
+++ jifty/branches/template-declare/lib/Jifty/Web/Form/Field.pm	Tue Jan 16 17:35:52 2007
@@ -129,6 +129,11 @@
 
 Sets this form field's "submit" key binding to VALUE. 
 
+=head2 key_binding_label VALUE
+
+Sets this form field's key binding label to VALUE.  If none is specified
+the normal label is used.
+
 =head2 default_value [VALUE]
 
 Gets or sets the default value for the form.

Modified: jifty/branches/template-declare/share/web/static/js/jifty_utils.js
==============================================================================
--- jifty/branches/template-declare/share/web/static/js/jifty_utils.js	(original)
+++ jifty/branches/template-declare/share/web/static/js/jifty_utils.js	Tue Jan 16 17:35:52 2007
@@ -73,6 +73,35 @@
 
     isMSIE: false,
 
+    _browser: null,
+    browser: function() {
+        if ( Jifty.Utils._browser ) return Jifty.Utils._browser;
+
+        if ( Jifty.Utils.isMSIE ) {
+            Jifty.Utils._browser = "msie";
+            return "msie";
+        }
+
+        var browser = "unknown";
+        
+        if      ( Jifty.Utils._checkUAFor("konqueror"))   browser = "konqueror";
+        else if ( Jifty.Utils._checkUAFor("safari"))      browser = "safari";
+        else if ( Jifty.Utils._checkUAFor("omniweb"))     browser = "omniweb";
+        else if ( Jifty.Utils._checkUAFor("opera"))       browser = "opera";
+        else if ( Jifty.Utils._checkUAFor("webtv"))       browser = "webtv";
+        else if ( Jifty.Utils._checkUAFor("icab"))        browser = "icab";
+        else if ( Jifty.Utils._checkUAFor("msie"))        browser = "msie";
+        else if ( !Jifty.Utils._checkUAFor("compatible")) browser = "mozilla";
+        
+        Jifty.Utils._browser = browser;
+        return browser;
+    },
+
+    _ua: navigator.userAgent.toLowerCase(),
+    _checkUAFor: function(str) {
+        return Jifty.Utils._ua.indexOf( str ) + 1;
+    },
+
     findScreenHeight: function() {
         if ( window.innerHeight ) {
             return window.innerHeight;


More information about the Jifty-commit mailing list