You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl-cvs@perl.apache.org by ri...@apache.org on 2006/09/26 15:01:52 UTC
svn commit: r450038 - in /perl/embperl/trunk/Embperl/Form: Control.pm
Control/button.pm Control/displaylink.pm Control/input.pm
Control/selectdyn.pm
Author: richter
Date: Tue Sep 26 06:01:51 2006
New Revision: 450038
URL: http://svn.apache.org/viewvc?view=rev&rev=450038
Log:
new controls for Embperl::Form
Added:
perl/embperl/trunk/Embperl/Form/Control/displaylink.pm (with props)
perl/embperl/trunk/Embperl/Form/Control/selectdyn.pm (with props)
Modified:
perl/embperl/trunk/Embperl/Form/Control.pm
perl/embperl/trunk/Embperl/Form/Control/button.pm
perl/embperl/trunk/Embperl/Form/Control/input.pm
Modified: perl/embperl/trunk/Embperl/Form/Control.pm
URL: http://svn.apache.org/viewvc/perl/embperl/trunk/Embperl/Form/Control.pm?view=diff&rev=450038&r1=450037&r2=450038
==============================================================================
--- perl/embperl/trunk/Embperl/Form/Control.pm (original)
+++ perl/embperl/trunk/Embperl/Form/Control.pm Tue Sep 26 06:01:51 2006
@@ -250,7 +250,7 @@
# show_controll_cell - output the table cell for the control
#]
-[$ sub show_control_cell ($self, , $req, $x)
+[$ sub show_control_cell ($self, $req, $x)
my $span = $self->{width_percent} - $x ;
$]
Modified: perl/embperl/trunk/Embperl/Form/Control/button.pm
URL: http://svn.apache.org/viewvc/perl/embperl/trunk/Embperl/Form/Control/button.pm?view=diff&rev=450038&r1=450037&r2=450038
==============================================================================
--- perl/embperl/trunk/Embperl/Form/Control/button.pm (original)
+++ perl/embperl/trunk/Embperl/Form/Control/button.pm Tue Sep 26 06:01:51 2006
@@ -32,18 +32,24 @@
[$ sub show ($self, $data)
-my $span = ($self->{width_percent});
-my $section = $self->{section};
+my $span = ($self->{width_percent}) ;
+$self->{button} ||= [{}] ;
$]
-<td class="cBase cInfoBox" colspan="[+ $span +]"
- style="[+ $self->{style} || 'text-align: center;' +]">
-
+<td class="cBase cControlBox cControlButtonBox" colspan="[+ $span +]">
[$ foreach my $button (@{$self->{button}}) $]
- [- $button->{class} ||= "cStandardButton"; -]
[# Workaround around segfault in Embperl 2.1.1-dev *grmpf* #]
<[# #]input
- type="button"
- onMouseOver="buttonover(this);" onMouseOut="buttonout(this);"
+ class="cBase cControl cControlButton" name="[+ $self->{name} +]"
+ value="[+ $self->{value} || $self->{text} +]"
+ title="[+ $self->{text} +]"
+ [$if $self -> {onclick} $] onClick="[+ $self -> {onclick} +]" [$endif$]
+ [$if $self -> {image} $]
+ type="image" src="[+ $self -> {image} +]"
+ [$else$]
+ type="button"
+ [$endif$]
+ style="[+ $self->{style} || 'text-align: center;' +]"
+ [# onMouseOver="buttonover(this);" onMouseOut="buttonout(this);" #]
[$ foreach my $attr (keys %$button) $]
[$ if exists $button->{"__$attr".'_escmode'} $]
[+ $attr +]="[+ do { local $escmode = int $button->{"__${attr}_escmode"}; $button->{$attr}; } +]"
@@ -52,9 +58,9 @@
[$ endif $]
[$ endforeach $]>
[$ endforeach $]
-</td>
-[$ endsub $]
+</td>
+[$endsub$]
__END__
@@ -62,18 +68,21 @@
=head1 NAME
-Embperl::Form::Control::button - A fully configurable button inside an Embperl Form
+Embperl::Form::Control::submit - A button inside an Embperl Form
=head1 SYNOPSIS
{
- type => 'button',
- width => 1,
+ type => 'submit',
+ text => 'send',
+ name => 'foo',
+ value => 'xxx',
+ image => 'xxx',
+ onclick => 'window.open (...)',
+
button => [
{
- name => 'blafasel',
- value => 'Click here',
onclick => 'do_something()',
style => 'border: 1px solid black;',
},
@@ -86,11 +95,13 @@
onmouseout => 'do(that)';
}
]
+
}
=head1 DESCRIPTION
-Used to create a click button inside an Embperl Form.
+Used to create an submit control inside an Embperl Form.
+If an image is given it will create an image button.
See Embperl::Form on how to specify parameters.
=head2 PARAMETER
@@ -98,6 +109,28 @@
=head3 type
Needs to be 'button'
+
+=head3 name
+
+Name of the button
+
+=head3 text
+
+Will be used as label for the submit button or tool tip
+in case of an image button
+
+=head3 value
+
+Gives the value to send
+
+=head3 image
+
+URL of an image. If given an image button will be created,
+if absent, an normal submit button will be created.
+
+=head3 onclick
+
+Javascript that should be executed when the users clicks on the button.
=head3 button
Added: perl/embperl/trunk/Embperl/Form/Control/displaylink.pm
URL: http://svn.apache.org/viewvc/perl/embperl/trunk/Embperl/Form/Control/displaylink.pm?view=auto&rev=450038
==============================================================================
--- perl/embperl/trunk/Embperl/Form/Control/displaylink.pm (added)
+++ perl/embperl/trunk/Embperl/Form/Control/displaylink.pm Tue Sep 26 06:01:51 2006
@@ -0,0 +1,118 @@
+
+###################################################################################
+#
+# Embperl - Copyright (c) 1997-2005 Gerald Richter / ecos gmbh www.ecos.de
+#
+# You may distribute under the terms of either the GNU General Public
+# License or the Artistic License, as specified in the Perl README file.
+#
+# THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+# WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+#
+# $Id$
+#
+###################################################################################
+
+package Embperl::Form::Control::displaylink ;
+
+use strict ;
+use base 'Embperl::Form::Control' ;
+
+use Embperl::Inline ;
+
+1 ;
+
+__EMBPERL__
+
+[# ---------------------------------------------------------------------------
+#
+# show_control - output the control
+#]
+
+[$ sub show_control ($self)
+
+my $name = $self->{name};
+my $hrefs = $self -> {href} ;
+my $targets = $self -> {target} ;
+my $opens = $self -> {open} ;
+my $displays = $self -> {link} || $self -> {value} ;
+
+$hrefs = [$hrefs] if (!ref $hrefs) ;
+$targets = [$targets] if ($targets && !ref $targets) ;
+$opens = [$opens] if ($opens && !ref $opens) ;
+$displays = [$displays] if (!ref $displays) ;
+
+my $dispn = 0 ;
+$]
+
+[$ foreach $display (@$displays) $]
+ [$if $opens -> [$dispn] $]
+ <a href="#" onclick="[+ $opens -> [$dispn] +]('[+ $hrefs -> [$dispn] +]')">
+ [$else$]
+ <a href="[+ do {local $escmode=0;$hrefs -> [$dispn]} +]"
+ [$if $targets -> [$dispn] $]target="[+ $targets -> [$dispn] +]"[$endif$]>
+ [$endif$][+ $display +]</a>
+ [- $dispn++ -]
+[$endforeach$]
+
+__END__
+
+=pod
+
+=head1 NAME
+
+Embperl::Form::Control::displaylink - A control to display links inside an Embperl Form
+
+
+=head1 SYNOPSIS
+
+ {
+ type => 'displaylink',
+ text => 'blabla',
+ link => ['ecos', 'bb5000'],
+ href => ['http://www.ecos.de', 'http://www.bb5000.info']
+ }
+
+=head1 DESCRIPTION
+
+Used to create a control which displays links inside an Embperl Form.
+See Embperl::Form on how to specify parameters.
+
+=head2 PARAMETER
+
+=head3 type
+
+Needs to be set to 'displaylink'.
+
+=head3 text
+
+Will be used as label for the text display control.
+
+=head3 link
+
+Arrayref with texts for the links that should be shown to the user
+
+=head3 href
+
+Arrayref with hrefs
+
+=head3 open
+
+Arrayref, if a value is given for the link, the value will be used as
+javascript function which is executed onclick. href will be pass as
+argument.
+
+=gead3 target
+
+Arrayref with targets
+
+=head1 Author
+
+G. Richter (richter@dev.ecos.de)
+
+=head1 See Also
+
+perl(1), Embperl, Embperl::Form
+
+
Propchange: perl/embperl/trunk/Embperl/Form/Control/displaylink.pm
------------------------------------------------------------------------------
svn:executable = *
Modified: perl/embperl/trunk/Embperl/Form/Control/input.pm
URL: http://svn.apache.org/viewvc/perl/embperl/trunk/Embperl/Form/Control/input.pm?view=diff&rev=450038&r1=450037&r2=450038
==============================================================================
--- perl/embperl/trunk/Embperl/Form/Control/input.pm (original)
+++ perl/embperl/trunk/Embperl/Form/Control/input.pm Tue Sep 26 06:01:51 2006
@@ -34,10 +34,9 @@
$self -> {size} ||= 80 / ($self -> {width} || 2) ;
$]
-<input type="text" class="cBase cControl" name="[+ $self->{name} +]"
- style="width: [+ $self->{css_width} || '100%' +];"
- [$ if $self->{size} $]size="[+ $self->{size} +]"[$ endif $]
- [$ if $self->{maxlength} $]maxlength="[+ $self->{maxlength} +]"[$ endif $]
+<input type="text" class="cBase cControl" name="[+ $self->{name} +]" id="[+ $self->{name} +]"
+[$if $self -> {size} $]size="[+ $self->{size} +]"[$endif$]
+[$if $self -> {maxlength} $]maxlength="[+ $self->{maxlength} +]"[$endif$]
>
[$endsub$]
@@ -58,7 +57,6 @@
name => 'foo',
size => 10,
maxlength => 50,
- css_width => '50px',
}
=head1 DESCRIPTION
@@ -87,10 +85,6 @@
=head3 maxlength
Gives the maximum possible input length in characters
-
-=head3 css_width
-
-width style of the input field. Defaults to "100%".
=head1 Author
Added: perl/embperl/trunk/Embperl/Form/Control/selectdyn.pm
URL: http://svn.apache.org/viewvc/perl/embperl/trunk/Embperl/Form/Control/selectdyn.pm?view=auto&rev=450038
==============================================================================
--- perl/embperl/trunk/Embperl/Form/Control/selectdyn.pm (added)
+++ perl/embperl/trunk/Embperl/Form/Control/selectdyn.pm Tue Sep 26 06:01:51 2006
@@ -0,0 +1,211 @@
+
+###################################################################################
+#
+# Embperl - Copyright (c) 1997-2005 Gerald Richter / ecos gmbh www.ecos.de
+#
+# You may distribute under the terms of either the GNU General Public
+# License or the Artistic License, as specified in the Perl README file.
+#
+# THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+# WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+#
+# $Id$
+#
+###################################################################################
+
+package Embperl::Form::Control::selectdyn ;
+
+use strict ;
+use vars qw{%fdat} ;
+use base 'Embperl::Form::ControlMultValue' ;
+
+use Embperl::Inline ;
+
+# ---------------------------------------------------------------------------
+#
+# show_control_readonly - output readonly control
+#
+
+sub show_control_readonly
+ {
+ my ($self, $req) = @_ ;
+
+ my $name = $self -> {name} ;
+ $self -> show_control ($req, "^\Q$fdat{$name}\\E\$") ;
+ }
+
+
+
+1 ;
+
+__EMBPERL__
+
+[# ---------------------------------------------------------------------------
+#
+# show_control - output the control
+#]
+
+[$ sub show_control ($self, $req, $filter)
+
+ my ($values, $options) = $self -> get_values ($req) ;
+ my $name = $self -> {name} ;
+ $filter ||= $self -> {filter} ;
+ my $addtop = $self -> {addtop} || [] ;
+ my $addbottom= $self -> {addbottom} || [] ;
+ my $val ;
+ my $i = 0 ;
+ my $jsname = $name ;
+ $jsname =~ s/[^a-zA-Z0-9]/_/g ;
+ $self -> {size} ||= 75 / ($self -> {width} || 2) ;
+ my $initval ;
+$]
+<script type="text/javascript" src="/js/prototype.js"></script>
+<script type="text/javascript" src="/js/effects.js"></script>
+<script type="text/javascript" src="/js/controls.js"></script>
+
+<div class="cAutoCompDiv">
+<div class="cAutoCompContainer" id="_cont_[+ $jsname +]" style="display:none">
+[$ foreach $val (@$values) $]
+ <li id='[+ $val +]'>[+ $options->[$i] || $val +]</li>
+ [*
+ $initval = $options->[$i] if ($val eq $fdat{$name}) ;
+ $i++ ;
+ *]
+[$endforeach$]
+</div>
+<input class="cBase cControl cAutoCompInput" id="_inp_[+ $jsname +]" type="text"
+[$if $self -> {size} $]size="[+ $self->{size} +]"[$endif$]
+value="[+ $initval +]"
+>
+<div class="cAutoCompArrow" onclick="[+ $jsname +]onClickArrow()"> </div>
+<input type="hidden" name="[+ $name +]" id="[+ $name +]" >
+</div>
+
+ <script type="text/javascript">
+ function [+ $jsname +]onClickArrow(id,obj)
+ {
+ i = document.getElementById ('_inp_[+ $jsname +]') ;
+ if (i.value == '')
+ i.value = '*' ;
+ c = document.getElementById ('_cont_[+ $jsname +]') ;
+ if (c.style.display == 'none')
+ {
+ [+ $jsname +]AutoComp.render();
+ }
+ else
+ [+ $jsname +]AutoComp.hide();
+ i.focus() ;
+ }
+ function [+ $jsname +]savevalue(inputelem, lielem) {
+ f = document.getElementById ('[+ $name +]') ;
+ //alert (inputelem.value + ' , ' + lielem.value) ;
+ if (!lielem || inputelem.value == '' || lielem.value == '')
+ {
+ f.value = '' ;
+ inputelem.value = '' ;
+ }
+ else
+ f.value = lielem.id ;
+ //alert (lielem.value + ' = ' + lielem.id) ;
+ }
+
+ [+ $jsname +]AutoComp = new Ajax.Autocompleter('_inp_[+ $jsname +]','_cont_[+ $jsname +]',
+ '/ebos/datasrc.exml', {paramName: "query", parameters: "datasrc=[+ $self -> {datasrc} +]", frequency: 0.3, afterUpdateElement: [+ $jsname +]savevalue}) ;
+ [+ $jsname +]AutoComp.updateChoices ;
+
+ </script>
+
+
+
+
+[$endsub$]
+
+__END__
+
+=pod
+
+=head1 NAME
+
+Embperl::Form::Control::select - A select control inside an Embperl Form
+
+
+=head1 SYNOPSIS
+
+ {
+ type => 'select',
+ text => 'blabla',
+ name => 'foo',
+ values => [1,2,3],
+ options => ['foo', 'bar', 'none'],
+ rows => 5
+ }
+
+=head1 DESCRIPTION
+
+Used to create an select control inside an Embperl Form.
+See Embperl::Form on how to specify parameters.
+
+=head2 PARAMETER
+
+=head3 type
+
+Needs to be 'select'
+
+=head3 name
+
+Specifies the name of the select control
+
+=head3 text
+
+Will be used as label for the select control
+
+=head3 values
+
+Gives the values as an array ref of the select control.
+
+=head3 options
+
+Gives the options as an array ref that should be displayed to the user.
+If no options are given, the values from values are used.
+
+=head3 rows
+
+If specified a select box is display with the given number of lines.
+If not specified or undef, a drop down list is shown.
+
+=head3 addtop
+
+Array ref which contains items that should be added at the top
+of the select box. Each item consists of an array ref with two
+entries, the first is the value and the second is the option
+that is displayed on the page. If the second is missing the
+value (first entry)is displayed. Example:
+
+ addtop => [ [1 => 'first item'], [2 => 'second item']]
+
+=head3 addbottom
+
+Array ref which contains items that should be added at the bottom
+of the select box. Each item consists of an array ref with two
+entries, the first is the value and the second is the option
+that is displayed on the page. If the second is missing the
+value (first entry)is displayed. Example:
+
+ addbottom => [ [9999 => 'last item'], [9999 => 'very last item']]
+
+=head3 filter
+
+If given, only items where the value matches the regex given in
+C<filter> are displayed.
+
+
+=head1 Author
+
+G. Richter (richter@dev.ecos.de)
+
+=head1 See Also
+
+perl(1), Embperl, Embperl::Form
+
+
Propchange: perl/embperl/trunk/Embperl/Form/Control/selectdyn.pm
------------------------------------------------------------------------------
svn:executable = *
---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-cvs-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-cvs-help@perl.apache.org