[interchange-cvs] [SCM] Interchange branch, master, updated. cac6d8bcce20242cb4d2a7b9eb2c9787f41dc950

Jon Jensen interchange-cvs at icdevgroup.org
Tue Sep 15 20:14:01 UTC 2009


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Interchange".

The branch, master has been updated
       via  cac6d8bcce20242cb4d2a7b9eb2c9787f41dc950 (commit)
      from  9bf2577ee845c94efe121f22872b50a325195b24 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit cac6d8bcce20242cb4d2a7b9eb2c9787f41dc950
Author: Jon Jensen <jon at endpoint.com>
Date:   Tue Sep 15 14:09:21 2009 -0600

    Allow passing custom JavaScript to country_select.widget
    
    Add country_js and state_js options. It will rewrite "this.form" with the
    correct form name at runtime. By Josh Lavin <josh at perusion.com>.
    
    Squashed commit of the following:
    
    commit bf765f1821aec2b9e39b69d8b0e992f7d56054b8
    Author: Josh Lavin <josh at perusion.com>
    Date:   Mon Sep 14 16:31:27 2009 -0500
    
        Added javascript option for country in country_select.widget
    
        Now country select box can have javascript passed for onChange event.
    
    commit 24630e9aeebafcdf2c43de4b6cadb920ab964145
    Author: Josh Lavin <josh at perusion.com>
    Date:   Mon Sep 14 14:51:11 2009 -0500
    
        Changed country_select to enable ID; minor tweaks
    
        Now a state or a country select box can have an id. Other minor tweaks made to last commit.
    
    commit 76eda3c78f384bf36108e0a39fa1729ddc3d53b6
    Author: Josh Lavin <josh at perusion.com>
    Date:   Mon Sep 14 11:39:46 2009 -0500
    
        Allow passing of Javascript for onChange event
    
        Adds state_js option, so Javascript can be passed to the onChange event. Rewrites "this.form" with "$v_formv" so it will work when passed. Useful for calling check_tax like so: state_js="check_tax(this.form)".

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

Summary of changes and diff:
 WHATSNEW-5.7                      |    6 ++++++
 code/Widget/country_select.widget |   17 ++++++++++++-----
 2 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/WHATSNEW-5.7 b/WHATSNEW-5.7
index a112cbc..0d8cdc8 100755
--- a/WHATSNEW-5.7
+++ b/WHATSNEW-5.7
@@ -739,6 +739,12 @@ Widgets
 * Prevent cross-site scripting problem in the country-select widget. Found and
   fixed by Josh Lavin of Perusion.
 
+* Allow passing custom JavaScript to country_select.widget by adding country_js
+  and state_js options. It will rewrite "this.form" with the correct form name
+  at runtime. By Josh Lavin. Useful e.g. for calling check_tax like this:
+
+  state_js="check_tax(this.form)"
+
 Admin UI
 --------
 
diff --git a/code/Widget/country_select.widget b/code/Widget/country_select.widget
index 2608b83..f2a7518 100644
--- a/code/Widget/country_select.widget
+++ b/code/Widget/country_select.widget
@@ -1,11 +1,9 @@
-# Copyright 2005-2007 Interchange Development Group and others
+# Copyright 2005-2009 Interchange Development Group and others
 # 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
 # the Free Software Foundation; either version 2 of the License, or
 # (at your option) any later version.  See the LICENSE file for details.
-# 
-# $Id: country_select.widget,v 1.11 2008-07-18 20:58:35 mheins Exp $
 
 CodeDef state_select  Widget  1
 CodeDef state_select  Description State (needs country_select)
@@ -197,6 +195,9 @@ EOF
 	$cvar =~ s/\W+/_/g;
 
 	my $extra = $opt->{state_extra} ? " $opt->{state_extra}" : '';
+	my $state_js = $opt->{state_js} ? "; $opt->{state_js}" : '';
+	my $country_js = $opt->{country_js} ? "; $opt->{country_js}" : '';
+	for ($state_js, $country_js) { s|\bthis\.form\b|$v_formv|g }
 
 	push @pre, <<EOF;
 	function ${cvar}_widget_adjust_state (cel,sval) {
@@ -229,7 +230,7 @@ EOF
 		}
 		var stary = $v_state_tary\[country];
 
-		var str = '<select name="$svar_in" onChange="$v_formv.$svar.value = this.value">';
+		var str = '<select name="$svar_in" onChange="$v_formv.$svar.value = this.value$state_js"$extra>';
 		for(var i = 0; i < svary.length; i++) {
 			str += '<option value="' + svary[i] + '"';
 			if(svary[i] == sval)
@@ -295,7 +296,7 @@ EOF
 		$opt->{append} .= $append;
 	}
 
-	$opt->{js} = qq{ onLoad="${cvar}_widget_adjust_state(this)" onChange="${cvar}_widget_adjust_state(this)"};
+	$opt->{js} = qq{ onLoad="${cvar}_widget_adjust_state(this)" onChange="${cvar}_widget_adjust_state(this)$country_js"};
 	my @out;
 	#push @out, '<xmp>';
 	#push @out, ::uneval(\%states);
@@ -321,6 +322,7 @@ CodeDef country_select ExtraMeta <<EOM
 			country_table
 			state_table
 			state_element
+			state_js
 		/],
 	state_var => {
 		label => 'State variable',
@@ -374,5 +376,10 @@ CodeDef country_select ExtraMeta <<EOM
 		help => 'The CSS ID of the span containing the dynamic widget. The default is usually good (state_widget_container or b_state_widget_container)',
 		widget => 'text_30',
 	},
+	state_js => {
+		label => 'State javascript',
+		help => 'Runs specified javascript under onChange. E.g. "state_js=check_tax(this.form)"',
+		widget => 'text_20',
+	},
 }
 EOM


hooks/post-receive
-- 
Interchange



More information about the interchange-cvs mailing list