[Bps-public-commit] rt-extension-formtools branch, enabled-by, updated. 0.07_03-4-g9d20423

Ruslan Zakirov ruz at bestpractical.com
Mon May 2 06:22:41 EDT 2011


The branch, enabled-by has been updated
       via  9d20423fffe0c6efa6ec0efc3ac47ff221908cf1 (commit)
       via  bc8eca9e7f89d09e90ffd08852fcede8f8ff58de (commit)
      from  6bd1dd1b33eacec750c2f80335afaf5d32d09b70 (commit)

Summary of changes:
 html/FormTools/Field         |    4 ++--
 html/NoAuth/js/form_tools.js |   14 +++++++++++---
 2 files changed, 13 insertions(+), 5 deletions(-)

- Log -----------------------------------------------------------------
commit bc8eca9e7f89d09e90ffd08852fcede8f8ff58de
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Mon May 2 14:21:36 2011 +0400

    name readonly span/li elements, so we can find them in JS

diff --git a/html/FormTools/Field b/html/FormTools/Field
index d528484..7c24610 100644
--- a/html/FormTools/Field
+++ b/html/FormTools/Field
@@ -234,7 +234,7 @@ unless ( $default ) {
 % if (@values > 1) {
     <ul>
 % for (@values) {
-    <li class="readonly"><% $_ %></li>
+    <li name="<% $input_name %>" class="readonly"><% $_ %></li>
 % }
     </ul>
     <script>
@@ -244,7 +244,7 @@ unless ( $default ) {
     </script>
 
 % } else {
-    <span class="readonly"><% $default %></span>
+    <span name="<% $input_name %>" class="readonly"><% $default %></span>
 % if ( my $disable = $disables->{ $default } ) {
     <script>
         jQuery(function() { disable_form_field(true, '<% $disable %>') } );

commit 9d20423fffe0c6efa6ec0efc3ac47ff221908cf1
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Mon May 2 14:22:10 2011 +0400

    support readonly fields in enabled-by feature

diff --git a/html/NoAuth/js/form_tools.js b/html/NoAuth/js/form_tools.js
index b10c57a..79a264f 100644
--- a/html/NoAuth/js/form_tools.js
+++ b/html/NoAuth/js/form_tools.js
@@ -13,10 +13,18 @@ function disable_form_field(disable, selector) {
 function should_disable_form_field( fields, values ) {
     for ( var i = 0; i<fields.length; i++ ) {
         var field = fields[i];
-        var active = jQuery('input:enabled[name="'+ field +'"], input:enabled[name="'+ field +'s"]').filter(function() {
-            var value = this.value;
-            if ( this.type == 'radio' || this.type == 'checkbox' ) {
+        var selector = 'input:enabled[name="'+ field +'"]'
+            +', input:enabled[name="'+ field +'s"]'
+            +', span.readonly[name="'+ field +'"]'
+            +', li.readonly[name="'+ field +'"]'
+        ;
+        var active = jQuery( selector ).filter(function() {
+            var value;
+            if ( this.tagName == 'SPAN' || this.tagName == 'LI' ) {
+                value = jQuery(this).text();
+            } else if ( this.type == 'radio' || this.type == 'checkbox' ) {
                 if ( !jQuery(this).is(':checked') ) return 0;
+                value = this.value;
             }
             for ( var i = 0; i < values[field].length; i++ ) {
                 if ( value == values[field][i] ) { return 1 }

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list