X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=SelectLayers.pm;h=54440719de65c43afa40a5092c9f2d1e74056665;hb=c596647a05d29ca82878b47dbc78112916c19950;hp=e7cca4c637d0a481e9fe2de0662b853d140aa172;hpb=be6e0143d36cf2834bb122255ae41b89e5c8049c;p=HTML-Widgets-SelectLayers.git
diff --git a/SelectLayers.pm b/SelectLayers.pm
index e7cca4c..5444071 100644
--- a/SelectLayers.pm
+++ b/SelectLayers.pm
@@ -3,7 +3,7 @@ package HTML::Widgets::SelectLayers;
use strict;
use vars qw($VERSION);
-$VERSION = '0.04';
+$VERSION = '0.07';
=head1 NAME
@@ -23,10 +23,17 @@ HTML::Widgets::SelectLayers - Perl extension for selectable HTML layers
'options' => \%options,
'form_name' => 'dummy',
'form_action' => 'process.cgi',
- 'form_text' => [ qw( textfield1 textfield2 ) ],
- 'form_checkbox' => [ qw( checkbox1 ) ],
- 'form_radio' => [ qw( radio1 ) ],
- 'form_select' => [ qw( select1 ) ],
+
+ #new code auto-detects form types (radio not yet supported)
+ #'form_elements' => [ qw( textfield1 textfield2 checkbox1 radio1 select1 ) ],
+ 'form_elements' => [ qw( textfield1 textfield2 checkbox1 radio1 select1 ) ],
+
+ #deprecated style still works for now
+ #'form_text' => [ qw( textfield1 textfield2 ) ],
+ #'form_checkbox' => [ qw( checkbox1 ) ],
+ #'form_radio' => [ qw( radio1 ) ],
+ #'form_select' => [ qw( select1 ) ],
+
'layer_callback' => sub {
my $layer = shift;
my $html = qq!!;
@@ -35,7 +42,7 @@ HTML::Widgets::SelectLayers - Perl extension for selectable HTML layers
},
);
- print '
';
+ $self->_select. $between. ''.
+ "";
#foreach my $layer ( 'konq_kludge', keys %$options ) {
foreach my $layer ( keys %$options ) {
#start layer
- my $visibility = "hidden";
+
$html .= <
- if (document.getElementById) {
- document.write("");
- } else {
-END
- $visibility="show" if $visibility eq "visible";
- $html .= <
");
- }
-
+
END
#form fields
$html .= <
+
END
}
+ if ( $under_position eq 'absolute' ) {
+ $html .= <
+ //var max = ${key}maxHeight;
+ document.write("");
+
+END
+ }
+
$html;
}
@@ -198,6 +223,9 @@ sub _fixup {
my $self = shift;
my $key = exists($self->{unique_key}) ? $self->{unique_key} : '';
my $form_name = $self->{form_name} or return '';
+
+ my $form_elements =
+ exists($self->{form_elements}) ? $self->{form_elements} : [];
my $form_text =
exists($self->{form_text}) ? $self->{form_text} : [];
my $form_checkbox =
@@ -206,13 +234,64 @@ sub _fixup {
exists($self->{form_radio}) ? $self->{form_radio} : [];
my $form_select =
exists($self->{form_select}) ? $self->{form_select} : [];
- my $html = "
+ my $html = <
- function ${key}fchanged(what) {
- ${key}fixup(what.form);
+
+function copyelement(from, to) {
+ 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);
+ } else if ( from.type == 'select-multiple' ) {
+ var i = 0;
+ var count = 0;
+ var values = new Array();
+ for (i=0;i 0) {
+ to.value = values[values.length-1];
+ }else{
+ to.value = '';
+ }
+ } else if ( from.type == 'checkbox' ) {
+ if ( from.checked ) {
+ to.value = from.value;
+ } else {
+ to.value = '';
}
+// } else if ( from.type == 'radio' ) {
+ } else {
+ if ( from.value == undefined ) {
+ to.value = '';
+ } else {
+ to.value = from.value;
+ }
+ }
+ //alert(from + " (" + from.type + "): " + to.name + " => " + to.value);
+}
+END
+
+ $html .= "
+ //function ${key}fchanged(what) {
+ // ${key}fixup(what.form);
+ //}
function ${key}fixup(what) {\n";
+ foreach my $f ( @$form_elements ) {
+ $html .= "copyelement( document.$form_name.elements['$f'],
+ what.elements['$f']
+ )\n";
+ }
+
foreach my $f ( @$form_text ) {
$html .= "what.$f.value = document.$form_name.$f.value;\n";
}
@@ -253,7 +332,7 @@ sub _select {