
richter at apache
Aug 4, 2013, 8:36 PM
Post #1 of 1
(11 views)
Permalink
|
|
svn commit: r1510368 - in /perl/embperl/trunk/Embperl: ./ Form/ Form/Control/ Form/Validate/
|
|
Author: richter Date: Mon Aug 5 03:36:14 2013 New Revision: 1510368 URL: http://svn.apache.org/r1510368 Log: Adapat controls to new htmÃl layout Added: perl/embperl/trunk/Embperl/Form/Validate/FQDN.pm Removed: perl/embperl/trunk/Embperl/Form/Control/cell.pm Modified: perl/embperl/trunk/Embperl/Form.pm perl/embperl/trunk/Embperl/Form/Control/addremove.pm perl/embperl/trunk/Embperl/Form/Control/blank.pm perl/embperl/trunk/Embperl/Form/Control/button.pm perl/embperl/trunk/Embperl/Form/Control/label.pm perl/embperl/trunk/Embperl/Form/Control/line.pm perl/embperl/trunk/Embperl/Form/Control/select.pm perl/embperl/trunk/Embperl/Form/ControlMultValue.pm Modified: perl/embperl/trunk/Embperl/Form.pm URL: http://svn.apache.org/viewvc/perl/embperl/trunk/Embperl/Form.pm?rev=1510368&r1=1510367&r2=1510368&view=diff ============================================================================== --- perl/embperl/trunk/Embperl/Form.pm (original) +++ perl/embperl/trunk/Embperl/Form.pm Mon Aug 5 03:36:14 2013 @@ -284,7 +284,8 @@ sub new_controls } my $name = $control -> {name} ; - $control -> {type} =~ s/sf_select.+/select/ ; + $control -> {type} =~ s/sf_select.+/select/ ; + $control -> {type} ||= ($control -> {name}?'input':'blank') ; $control -> {parentid} = $id if ($id) ; $control -> {id} ||= $ctlid ; $control -> {basename} = $control->{name} ; @@ -312,7 +313,7 @@ sub new_controls if (ref $control eq 'HASH') { - my $type = $control -> {type} || ($control -> {name}?'input':'blank') ; + my $type = $control -> {type} ; $control = $self -> new_object ($packages, $type, $control) ; if (!$no_init) { @@ -417,7 +418,8 @@ sub layout my $line = [] ; my @lines ; my $max_num = 0 ; - my $num = 0 ; + my $num = 0 ; + my $last_state ; foreach my $control (@$controls) { next if ($control -> is_disabled ()) ; @@ -428,33 +430,33 @@ sub layout next ; } my $width = ($control -> {width} eq 'expand')?100:$control -> {width_percent} || int($max_x / ($control -> {width} || 2)) ; - $width = 21 if ($x == 0 && $width < 21) ; + #$width = 21 if ($x == 0 && $width < 21) ; if ($x + $width > $max_x || $control -> {newline} > 0 || (($control -> {sublines} || $control -> {subobjects}) && @$line)) { # new line if ($x < $max_x) { push @$line, Embperl::Form::Control::blank -> new ( - {width_percent => int($max_x - $x), level => $level, x_percent => int($x), state => $control -> {state} }) ; + {width_percent => int($max_x - $x), level => $level, x_percent => int($x), state => $last_state }) ; } push @lines, $line ; $line = [] ; $x = 0 ; $num = 0 ; } - push @$line, $control ; + push @$line, $control ; + $last_state = $control -> {state} ; $control -> {width_percent} = $control -> {width} eq 'expand'?'expand':int($width) ; $control -> {x_percent} = int($x) ; $control -> {level} = $level ; $x += $width ; $num++ ; $max_num = $num if ($num > $max_num) ; - if ($control -> {subobjects} || $control -> {sublines} || $control -> {newline} < 0) { # new line if ($x < $max_x) { push @$line, Embperl::Form::Control::blank -> new ( - {width_percent => int($max_x - $x), level => $level, x_percent => int($x), state => $control -> {state} }) ; + {width_percent => int($max_x - $x), level => $level, x_percent => int($x), state => $last_state }) ; $num++ ; $max_num = $num if ($num > $max_num) ; } @@ -487,9 +489,9 @@ sub layout } if ($x > 0 && $x < $max_x) - { + { push @$line, Embperl::Form::Control::blank -> new ( - {width_percent => int($max_x - $x), level => $level, x_percent => int($x) }) ; + {width_percent => int($max_x - $x), level => $level, x_percent => int($x), state => $last_state }) ; $num++ ; $max_num = $num if ($num > $max_num) ; } @@ -846,11 +848,16 @@ sub add_sublines my $obj = Execute ({object => "$fn"} ) ; $subfields = $obj -> fields ($epreq, $file) ; } - push @forms, $subfields || []; + $subfields ||= [] ; + foreach (@$subfields) + { + $_ -> {state} = $object_data -> {name} . '-show-' . ($file->{value} || $file->{name}) ; + } + push @forms, $subfields ; push @values, $file->{value} || $file->{name}; push @options, $file -> {text} || $file->{value} || $file->{name}; } - + $object_data -> {trigger} = 1 ; return { %$object_data, type => $type || 'select', values => \@values, options => \@options, sublines => \@forms, }; @@ -903,9 +910,19 @@ sub add_checkbox_subform my $obj = Execute ({object => "./$fn"} ) ; #$subfield = [.eval {$obj -> fields ($r, { %$file, %$args} ) || undef}]; } - - - return {type => 'checkbox' , section => $section, width => $width, name => $name, text => $text, value => $value, sublines => $subfield} + + my $subfields = $subfield -> [0] ; + foreach (@$subfields) + { + $_ -> {state} = $subform -> {name} . '-show' ; + } + $subfields = $subfield -> [1] ; + foreach (@$subfields) + { + $_ -> {state} = $subform -> {name} . '-hide'; + } + + return {type => 'checkbox' , trigger => 1, section => $section, width => $width, name => $name, text => $text, value => $value, sublines => $subfield} } Modified: perl/embperl/trunk/Embperl/Form/Control/addremove.pm URL: http://svn.apache.org/viewvc/perl/embperl/trunk/Embperl/Form/Control/addremove.pm?rev=1510368&r1=1510367&r2=1510368&view=diff ============================================================================== --- perl/embperl/trunk/Embperl/Form/Control/addremove.pm (original) +++ perl/embperl/trunk/Embperl/Form/Control/addremove.pm Mon Aug 5 03:36:14 2013 @@ -38,7 +38,7 @@ sub new bless $self, $class ; $self -> {removesource} ||= 0 ; - $self -> form -> add_code_at_bottom("addremoveInitOptions (document.getElementById('$self->{src}'), document.getElementById('$self->{dest}'), document.getElementById('$self->{name}'), $self->{removesource})") ; + $self -> form -> add_code_at_bottom("ef_addremoveInitOptions (document, document.getElementsByName('$self->{src}')[0], document.getElementsByName('$self->{dest}')[0], document.getElementsByName('$self->{name}')[0], $self->{removesource})") ; return $self ; } @@ -48,29 +48,26 @@ sub new __EMBPERL__ + [# --------------------------------------------------------------------------- # # show - output the control #] -[.$ sub show ($self) - - my $span = $self->{width_percent} ; - my $name = $self->{name} ; - my $nsprefix = $self -> form -> {jsnamespace} ; +[$ sub show ($self, $req) -$] +my $name = $self -> {name} ; -<td class="cBase cControlBox cControlAddRemoveBox" colspan="[+ $span +]"> +$]<table class="ef-element ef-element-width-[+ $self -> {width_percent} +] ef-element-[+ $self -> {type} +] [+ ' ' . $self -> {state} +]"> + <tr> + <td class="cBase cControlBox cControlAddRemoveBox"> <input type="hidden" id="[+ $name +]" name="[+ $name +]"> -<img src="[+ $self -> {imagedir} +]/toleft.gif" title="Hinzufügen" onClick="[+ $nsprefix +]addremoveAddOption (document, document.getElementById('[+ $self->{src} +]'), document.getElementById('[+ $self->{dest} +]'), document.getElementById('[+ $name +]'), [+ $self->{removesource} +])"> -<img src="[+ $self -> {imagedir} +]/toright.gif" title="Entfernen" onClick="[+ $nsprefix +]addremoveRemoveOption (document, document.getElementById('[+ $self->{src} +]'), document.getElementById('[+ $self->{dest} +]'), document.getElementById('[+ $name +]'), [+ $self->{removesource} +])"> +<img src="[+ $self -> {imagedir} +]/toleft.gif" title="Hinzufügen" onClick="ef_addremoveAddOption (document, document.getElementsByName('[+ $self->{src} +]')[0], document.getElementsByName('[+ $self->{dest} +]')[0], document.getElementsByName('[+ $name +]')[0], [+ $self->{removesource} +])"> +<img src="[+ $self -> {imagedir} +]/toright.gif" title="Entfernen" onClick="ef_addremoveRemoveOption (document, document.getElementsByName('[+ $self->{src} +]')[0], document.getElementsByName('[+ $self->{dest} +]')[0], document.getElementsByName('[+ $name +]')[0], [+ $self->{removesource} +])"> -[# - print "<input class="cStandardButton" type=button value="Hinzufügen" onClick="[+ $nsprefix +]addremoveAddOption (document, this.form.elements['$self->{src}'], this.form.elements['$self->{dest}'], this.form.elements['$self->{name}'], $self->{removesource})">\n" ; - print "<input class="cStandardButton" type=button value="Entfernen" onClick="[+ $nsprefix +]addremoveRemoveOption (document, this.form.elements['$self->{src}'], this.form.elements['$self->{dest}'], this.form.elements['$self->{name}'], $self->{removesource})">\n" ; -#] </td> +</tr> +</table> [$endsub$] __END__ Modified: perl/embperl/trunk/Embperl/Form/Control/blank.pm URL: http://svn.apache.org/viewvc/perl/embperl/trunk/Embperl/Form/Control/blank.pm?rev=1510368&r1=1510367&r2=1510368&view=diff ============================================================================== --- perl/embperl/trunk/Embperl/Form/Control/blank.pm (original) +++ perl/embperl/trunk/Embperl/Form/Control/blank.pm Mon Aug 5 03:36:14 2013 @@ -31,15 +31,15 @@ __EMBPERL__ # show - output the control #] -[.$ sub show ($self, $data) +[.$ sub show ($self, $req) -my $state = $self -> {state} ; - -$]<table class="[+ $state +] ef-element ef-element-width-[+ $self -> {width_percent} +]"> +$]<table class="ef-element ef-element-width-[+ $self -> {width_percent} +] ef-element-[+ $self -> {type} || 'blank' +] [+ ' ' . $self -> {state} +]"> <tr> - <td class="ef-label-box">[+ $self->{text} +]</td> + [#<td class="ef-label-box ef-label-box-width-100">[+ $self->{text} +]</td>#] + <td class="ef-control-box ef-control-box-width-100">[+ $self->{text} +]</td> </tr> - </table>[$endsub$] +</table>[$endsub$] + __END__ Modified: perl/embperl/trunk/Embperl/Form/Control/button.pm URL: http://svn.apache.org/viewvc/perl/embperl/trunk/Embperl/Form/Control/button.pm?rev=1510368&r1=1510367&r2=1510368&view=diff ============================================================================== --- perl/embperl/trunk/Embperl/Form/Control/button.pm (original) +++ perl/embperl/trunk/Embperl/Form/Control/button.pm Mon Aug 5 03:36:14 2013 @@ -36,8 +36,8 @@ __EMBPERL__ my $span = ($self->{width_percent}) ; $self->{button} ||= [{}] ; my $state = $self -> {state} ; -$] -<td class="cBase cControlBox cControlButtonBox" colspan="[+ $span +] [+ $state +]"> +$]<table class="ef-element ef-element-width-[+ $self -> {width_percent} +] ef-element-[+ $self -> {type} +] [+ $self -> {state} +]"> + <tr> <td class="ui-label-box" > [$ foreach my $button (@{$self->{button}}) $] [$if $self -> {symbol} $] <div class="cControlButtonDiv" @@ -71,8 +71,8 @@ $] [$endif$] [$ endforeach $] -</td> -[$endsub$] + </td></tr> + </table>[$endsub$] __END__ Modified: perl/embperl/trunk/Embperl/Form/Control/label.pm URL: http://svn.apache.org/viewvc/perl/embperl/trunk/Embperl/Form/Control/label.pm?rev=1510368&r1=1510367&r2=1510368&view=diff ============================================================================== --- perl/embperl/trunk/Embperl/Form/Control/label.pm (original) +++ perl/embperl/trunk/Embperl/Form/Control/label.pm Mon Aug 5 03:36:14 2013 @@ -31,13 +31,15 @@ __EMBPERL__ # show - output the control #] -[.$ sub show ($self, $data) +[$ sub show ($self, $req) + +$]<table class="ef-element ef-element-width-[+ $self -> {width_percent} +] ef-element-[+ $self -> {type} || 'blank' +] [+ ' ' . $self -> {state} +]"> + <tr> + <td class="ef-label-box ef-label-box-width-100">[$ if $self -> {controlclass} $]<span class="[+$self->{controlclass}+]">[+ $self->{text} +]</span>[$else$][+ $self->{text} +][$endif$]</td> + [#<td class="ef-control-box ef-control-box-width-100">[+ $self->{text} +]</td>#] + </tr> +</table>[$endsub$] -my $span = ($self->{width_percent}) ; -my $state = $self -> {state} ; -$] -<td class="cBase cLabelBox" colspan="[+ $span +] [+ $state +]">[+ $self->{text} +]</td> -[$endsub$] __END__ Modified: perl/embperl/trunk/Embperl/Form/Control/line.pm URL: http://svn.apache.org/viewvc/perl/embperl/trunk/Embperl/Form/Control/line.pm?rev=1510368&r1=1510367&r2=1510368&view=diff ============================================================================== --- perl/embperl/trunk/Embperl/Form/Control/line.pm (original) +++ perl/embperl/trunk/Embperl/Form/Control/line.pm Mon Aug 5 03:36:14 2013 @@ -36,7 +36,9 @@ __EMBPERL__ my $span = ($self->{width_percent}) ; my $state = $self -> {state} ; $] -<td class="cBase cTransparentBox" colspan="[+ $span +] [+ $state +]"><hr class="cControlLine"></td> +<table class="ef-element ef-element-width-[+ $self -> {width_percent} +] ef-element-[+ $self -> {type} +] [+ $self -> {state} +]"> + <tr> <td class="cBase cTransparentBox" colspan="[+ $span +] [+ $state +]"><hr class="cControlLine"></td> + </tr></table> [$endsub$] Modified: perl/embperl/trunk/Embperl/Form/Control/select.pm URL: http://svn.apache.org/viewvc/perl/embperl/trunk/Embperl/Form/Control/select.pm?rev=1510368&r1=1510367&r2=1510368&view=diff ============================================================================== --- perl/embperl/trunk/Embperl/Form/Control/select.pm (original) +++ perl/embperl/trunk/Embperl/Form/Control/select.pm Mon Aug 5 03:36:14 2013 @@ -52,7 +52,7 @@ __EMBPERL__ my $i = 0 ; my ($values, $options) = $self -> get_all_values ($req) ; my ($ctlattrs, $ctlid, $ctlname) = $self -> get_std_control_attr($req) ; - + $values ||= [] ; $] <select name="[+ $ctlname +]" [+ $self->{multiple}?'multiple':''+] [.+ do { local $escmode = 0 ; $ctlattrs } +] [$if ($self -> {rows}) $] size="[+ $self->{rows} +]" [$endif$] Modified: perl/embperl/trunk/Embperl/Form/ControlMultValue.pm URL: http://svn.apache.org/viewvc/perl/embperl/trunk/Embperl/Form/ControlMultValue.pm?rev=1510368&r1=1510367&r2=1510368&view=diff ============================================================================== --- perl/embperl/trunk/Embperl/Form/ControlMultValue.pm (original) +++ perl/embperl/trunk/Embperl/Form/ControlMultValue.pm Mon Aug 5 03:36:14 2013 @@ -92,7 +92,7 @@ sub get_all_values $options = $self -> form -> convert_options ($self, $self -> {values}, $options) if (!$self -> {showoptions}) ; } - + if (!$addtop && !$addbottom) { $req -> {$key} = [$values, $options] ; Added: perl/embperl/trunk/Embperl/Form/Validate/FQDN.pm URL: http://svn.apache.org/viewvc/perl/embperl/trunk/Embperl/Form/Validate/FQDN.pm?rev=1510368&view=auto ============================================================================== --- perl/embperl/trunk/Embperl/Form/Validate/FQDN.pm (added) +++ perl/embperl/trunk/Embperl/Form/Validate/FQDN.pm Mon Aug 5 03:36:14 2013 @@ -0,0 +1,66 @@ + +################################################################################### +# +# Embperl - Copyright (c) 1997-2004 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: FQDN_IPAddr.pm,v 1.2 2004/01/23 06:50:57 richter Exp $ +# +################################################################################### + + +package Embperl::Form::Validate::FQDN ; + +use base qw(Embperl::Form::Validate::Default); + +my %error_messages = +( + de => + { + validate_fqdn => 'Feld %0: "%1" ist keine gültiger Hostname.', + }, + en => + { + validate_fqdn => 'Field %0: "%1" isn\\\'t a valid hostname.', + } + ); + +# -------------------------------------------------------------- + +sub getmsg + { + my ($self, $id, $language, $default_language) = @_ ; + + return $error_messages{$language}{$id} || + $error_messages{$default_language}{$id} || + $self -> SUPER::getmsg ($id, $language, $default_language) ; + } + + +# -------------------------------------------------------------- + +sub validate + { + my ($self, $key, $value, $fdat, $pref) = @_ ; + + return undef if ($value =~ /^[-.a-zA-Z0-9]+$/) ; + return ['validate_fqdn', $value] ; + } + +# -------------------------------------------------------------- + +sub getscript_validate + { + my ($self, $arg, $pref) = @_ ; + + return ('obj.value.search(/^[-.a-zA-Z0-9]+$/) >= 0 ', ['validate_fqdn', "'+obj.value+'"]) ; + } + + +1; --------------------------------------------------------------------- To unsubscribe, e-mail: embperl-cvs-unsubscribe [at] perl For additional commands, e-mail: embperl-cvs-help [at] perl
|