projects
/
HTML-Widgets-SelectLayers.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
8a716df
)
add support from select-multiple
author
jeff
<jeff>
Thu, 8 Feb 2007 01:39:01 +0000
(
01:39
+0000)
committer
jeff
<jeff>
Thu, 8 Feb 2007 01:39:01 +0000
(
01:39
+0000)
Changes
patch
|
blob
|
history
META.yml
patch
|
blob
|
history
SelectLayers.pm
patch
|
blob
|
history
diff --git
a/Changes
b/Changes
index
677c656
..
9387d09
100644
(file)
--- a/
Changes
+++ b/
Changes
@@
-1,5
+1,12
@@
Revision history for Perl extension HTML::Widgets::SelectLayers.
Revision history for Perl extension HTML::Widgets::SelectLayers.
+0.07 Wed Feb 07 05:33:00 PST 2007
+ - Also overdue: add support for select-multiple
+ "form_elements" instead of the old form_* options.
+ - eliminate dubious fchanged javascript function
+ - check the type against undefined rather than the object itself
+ in copyelement
+
0.06 Wed Dec 20 01:50:00 PST 2006
- Also long overdue: add auto-sensing of form field types, pass
"form_elements" instead of the old form_* options.
0.06 Wed Dec 20 01:50:00 PST 2006
- Also long overdue: add auto-sensing of form field types, pass
"form_elements" instead of the old form_* options.
diff --git
a/META.yml
b/META.yml
index
3bc1223
..
34ac425
100644
(file)
--- a/
META.yml
+++ b/
META.yml
@@
-1,7
+1,7
@@
# http://module-build.sourceforge.net/META-spec.html
#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
name: HTML-Widgets-SelectLayers
# http://module-build.sourceforge.net/META-spec.html
#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
name: HTML-Widgets-SelectLayers
-version: 0.0
6
+version: 0.0
7
version_from: SelectLayers.pm
installdirs: site
requires:
version_from: SelectLayers.pm
installdirs: site
requires:
diff --git
a/SelectLayers.pm
b/SelectLayers.pm
index
63887c6
..
5444071
100644
(file)
--- a/
SelectLayers.pm
+++ b/
SelectLayers.pm
@@
-3,7
+3,7
@@
package HTML::Widgets::SelectLayers;
use strict;
use vars qw($VERSION);
use strict;
use vars qw($VERSION);
-$VERSION = '0.0
6
';
+$VERSION = '0.0
7
';
=head1 NAME
=head1 NAME
@@
-93,9
+93,8
@@
form_action - Form action
form_elements - (optional) Array reference of form fields to copy from the
B<form_name> form. Field type is autodetected; currently
form_elements - (optional) Array reference of form fields to copy from the
B<form_name> form. Field type is autodetected; currently
- text, hidden, checkbox, and select (single) fiels are
- supported. Select (multiple) and radio fields are not yet
- supported.
+ text, hidden, checkbox, and select fields are
+ supported. Radio fields are not yet supported.
form_text - (optional) Array reference of text (or hidden) form fields to copy
from the B<form_name> form.
form_text - (optional) Array reference of text (or hidden) form fields to copy
from the B<form_name> form.
@@
-106,8
+105,8
@@
form_checkbox - (optional) Array reference of checkbox form fields to copy from
form_radio - (optional) Array reference of radio form fields to copy from the
B<form_name> form.
form_radio - (optional) Array reference of radio form fields to copy from the
B<form_name> form.
-form_select - (optional) Array reference of select
(not select multiple) for
m
-
fields to copy from
the B<form_name> form.
+form_select - (optional) Array reference of select
form fields to copy fro
m
+ the B<form_name> form.
fixup_callback - (optional) subroutine reference, returns supplimentary
JavaScript for the function described above under FORMS.
fixup_callback - (optional) subroutine reference, returns supplimentary
JavaScript for the function described above under FORMS.
@@
-184,7
+183,7
@@
END
#form fields
$html .= <<END;
#form fields
$html .= <<END;
- <FORM NAME="${key}$layer" ACTION="$form_action" METHOD=POST on
S
ubmit="${key}fixup(this)" STYLE="margin-top: 0; margin-bottom: 0">
+ <FORM NAME="${key}$layer" ACTION="$form_action" METHOD=POST on
s
ubmit="${key}fixup(this)" STYLE="margin-top: 0; margin-bottom: 0">
END
foreach my $f ( @$form_elements, @$form_text, @$form_checkbox, @$form_radio, @$form_select )
{
END
foreach my $f ( @$form_elements, @$form_text, @$form_checkbox, @$form_radio, @$form_select )
{
@@
-239,11
+238,30
@@
sub _fixup {
<SCRIPT>
function copyelement(from, to) {
<SCRIPT>
function copyelement(from, to) {
- if ( from == undefined ) {
+ if ( from
.type
== undefined ) {
to.value = '';
} else if ( from.type == 'select-one' ) {
to.value = from.options[from.selectedIndex].value;
//alert(from + " (" + from.type + "): " + to.name + " => (" + from.selectedIndex + ") " + to.value);
to.value = '';
} else if ( from.type == 'select-one' ) {
to.value = from.options[from.selectedIndex].value;
//alert(from + " (" + from.type + "): " + to.name + " => (" + from.selectedIndex + ") " + to.value);
+ } else if ( from.type == 'select-multiple' ) {
+ var i = 0;
+ var count = 0;
+ var values = new Array();
+ for (i=0;i<from.length;i++) {
+ if (from.options[i].selected){
+ values[count++] = from.options[i].value;
+ }
+ }
+ for (i=0;i<values.length-1;i++) {
+ var clone = to.cloneNode(true);
+ clone.value = values[i];
+ to.form.appendChild(clone);
+ }
+ if (count > 0) {
+ to.value = values[values.length-1];
+ }else{
+ to.value = '';
+ }
} else if ( from.type == 'checkbox' ) {
if ( from.checked ) {
to.value = from.value;
} else if ( from.type == 'checkbox' ) {
if ( from.checked ) {
to.value = from.value;
@@
-263,9
+281,9
@@
function copyelement(from, to) {
END
$html .= "
END
$html .= "
- function ${key}fchanged(what) {
- ${key}fixup(what.form);
- }
+
//
function ${key}fchanged(what) {
+
//
${key}fixup(what.form);
+
//
}
function ${key}fixup(what) {\n";
foreach my $f ( @$form_elements ) {
function ${key}fixup(what) {\n";
foreach my $f ( @$form_elements ) {