Author: richter Date: Fri Apr 13 20:26:56 2012 New Revision: 1325935 URL: http://svn.apache.org/viewvc?rev=1325935&view=rev Log: Support for checkbox state changes
Modified: perl/embperl/trunk/Embperl/Form/Control.pm perl/embperl/trunk/Embperl/Form/Control/checkbox.pm perl/embperl/trunk/Embperl/Form/Control/grid.pm perl/embperl/trunk/Embperl/Form/Control/radio.pm Modified: perl/embperl/trunk/Embperl/Form/Control.pm URL: http://svn.apache.org/viewvc/perl/embperl/trunk/Embperl/Form/Control.pm?rev=1325935&r1=1325934&r2=1325935&view=diff ============================================================================== --- perl/embperl/trunk/Embperl/Form/Control.pm (original) +++ perl/embperl/trunk/Embperl/Form/Control.pm Fri Apr 13 20:26:56 2012 @@ -295,8 +295,9 @@ sub get_std_control_attr my $width = $self -> {width_percent} ; my $events = $self -> {eventattrs} ; $type ||= $self -> {type} ; + my $state = $self -> {state} ; - return qq{class="ef-control ef-control-width-$width ef-control-$type ef-control-$type-width-$width $addclass $class" id="$ctrlid" $events} ; + return qq{class="ef-control ef-control-width-$width ef-control-$type ef-control-$type-width-$width $addclass $class $state" id="$ctrlid" $events} ; } @@ -320,7 +321,7 @@ __EMBPERL__ $fdat{$self -> {name}} = $self -> {default} if ($fdat{$self -> {name}} eq '' && exists ($self -> {default})) ; my $span = 0 ; -$]<table class="ef-element ef-element-width-[+ $self -> {width_percent} +] ef-element-[+ $self -> {type} +]"> +$]<table class="ef-element ef-element-width-[+ $self -> {width_percent} +] ef-element-[+ $self -> {type} +] [+ $self -> {state} +]"> <tr> [- $span += $self -> show_label_cell ($req, $span); @@ -613,6 +614,38 @@ Default value of the control Basepath where to find images, in case the control uses images. Default value is /images +=head2 trigger + +When set will trigger state changes of other controls. See "state". + +=head2 state + +Can be used to hide/show disable/enable the control trigger by +other controls. + +Checkbox define the following states: + +=over + +=item * <id-of-checkbox>-show + +Show control if checkbox checked + +=item * <id-of-checkbox>-hide + +Hide control if checkbox checked + +=item * <id-of-checkbox>-enable + +Enable control if checkbox checked + +=item * <id-of-checkbox>-disable + +Disable control if checkbox checked + +=back + + =head1 AUTHOR Modified: perl/embperl/trunk/Embperl/Form/Control/checkbox.pm URL: http://svn.apache.org/viewvc/perl/embperl/trunk/Embperl/Form/Control/checkbox.pm?rev=1325935&r1=1325934&r2=1325935&view=diff ============================================================================== --- perl/embperl/trunk/Embperl/Form/Control/checkbox.pm (original) +++ perl/embperl/trunk/Embperl/Form/Control/checkbox.pm Fri Apr 13 20:26:56 2012 @@ -83,7 +83,6 @@ __EMBPERL__ my $name = $self -> {name} ; my $val = $self -> {value} || 1 ; my $nsprefix = $self -> form -> {jsnamespace} ; - my $class = $self -> {class} ||= '' ; $val =~ s/%%%name%%%/$fdat{$name}/g ; $val =~ s/%%(.+?)%%/$fdat{$1}/g ; @@ -92,7 +91,7 @@ __EMBPERL__ $] <input type="checkbox" name="[+ $self -> {force_name} || $self -> {name} +]" [+ do { local $escmode = 0 ; $self -> get_std_control_attr() } +] value="[+ $val +]" [$if ($self -> {sublines} || $self -> {subobjects}) $] OnClick="[+ $nsprefix +]show_checked(document, this)" [$endif$] -> +>[$if ($self -> {trigger}) $]<script >$('#[+ $self -> {name} +]').ef_checkbox ()</script>[$endif$] [$endsub$] __END__ Modified: perl/embperl/trunk/Embperl/Form/Control/grid.pm URL: http://svn.apache.org/viewvc/perl/embperl/trunk/Embperl/Form/Control/grid.pm?rev=1325935&r1=1325934&r2=1325935&view=diff ============================================================================== --- perl/embperl/trunk/Embperl/Form/Control/grid.pm (original) +++ perl/embperl/trunk/Embperl/Form/Control/grid.pm Fri Apr 13 20:26:56 2012 @@ -260,7 +260,7 @@ __EMBPERL__ my $max = $fdat{"__${name}_max"} ; my $on_grid_change = $self -> {on_grid_change} ; $self -> {fullid} = $self -> form -> {unique_id} . '_' . $self -> {id} ; -$]<table class="ef-element ef-element-width-[+ $self -> {width_percent} +]"> +$]<table class="ef-element ef-element-width-[+ $self -> {width_percent} +][+ ' ' +][+ $self -> {state} +]"> <tr> <td class="ui-label-box" colspan="[+ $span +]"> [- @@ -269,13 +269,13 @@ $]<table class="ef-element ef-element-wi $self -> show_grid_title ($req); -] <input type="hidden" name="__[+ $self -> {name} +]_max" id="__[+ $self -> {fullid} +]_max"> - <table class="cGridTable cBase" id="[+ $self -> {fullid} +]"> + <table class="cGridTable cBase [+ $self -> {state} +]" id="[+ $self -> {fullid} +]"> [- $self -> show_grid_header ($req); -] [- $self -> show_grid_table ($req) ; -] </table> [- $self -> show_grid_title ($req) if ($max > $self -> {header_bottom} && !$self -> {disable_controls}) -] - <table id="__[+ $self -> {fullid} +]_newrow" style="display: none"> + <table id="__[+ $self -> {fullid} +]_newrow" style="display: none" class="[+ $self -> {state} +]"> [- local $req -> {epf_no_script} = 1 ; $self -> show_grid_table_row ($req, '%row%') ; @@ -297,7 +297,7 @@ $]<table class="ef-element ef-element-wi [$ sub show_grid_title ($self, $req) $] -<table class="cBase cGridTitle"> +<table class="cBase cGridTitle [+ $self -> {state} +]"> <tr class="cTableRow"> <td class="cBase cGridLabelBox">[+ $self -> form -> convert_label ($self) +]</td> [$if !($self -> is_readonly ($req)) && !$self -> {disable_controls} $] @@ -351,7 +351,8 @@ $] [$ foreach my $field (@$fields) $] [* next if ($field -> is_hidden ) ; *] <td class="cGridFooter cGridCellReadonly">[- - local $field -> {name} = "__${name}_${j}_$i" ; + local $field -> {name} = "__${name}_${j}_$i" ; + local $field -> {state} = $self -> {state} ; $field -> show_control_readonly ($req) if (!$field -> {nofooter}) ; $j++ ; -]</td> @@ -380,13 +381,15 @@ $] <tr class="cGridRow [+ $self -> {rowclasses}[$i] +]" id="[+ "$id-row-$i" +]"> [$foreach $field (@$fields)$] [$if $field -> is_hidden $][- - local $field -> {name} = "__${name}_${j}_$i" ; + local $field -> {name} = "__${name}_${j}_$i" ; + local $field -> {state} = $self -> {state} ; $field -> show_control ($req) ; $j++ ; -][$else$] [- $ro = $gridro || $field -> is_readonly () ; -] <td class="[+ $ro?'cGridCellReadonly':'cGridCell' +]" [$if $field->{width}$]style="width: [+ $field->{width} +]"[$endif$]>[$if $n++ == 0$]<input type="hidden" name="[+ "__${name}_#row#_$i" +]" value="[+ $i +]">[$endif$][- - local $field -> {name} = "__${name}_${j}_$i" ; + local $field -> {name} = "__${name}_${j}_$i" ; + local $field -> {state} = $self -> {state} ; if ($ro) { $field -> show_control_readonly ($req) @@ -406,7 +409,8 @@ $] <tr class="cGridRow2" id="[+ "$id-row2-$i" +]"> <td colspan="[+ scalar(@$fields) +]" class="[+ $ro?'cGridCellReadonly':'cGridCell' +]">[$if $n++ == 0$]<input type="hidden" name="[+ "__${name}_#row#_$i" +]" value="[+ $i +]">[$endif$][- - local $line2 -> {name} = "__${name}_${j}_$i" ; + local $line2 -> {name} = "__${name}_${j}_$i" ; + local $line2 -> {state} = $self -> {state} ; if ($ro) { $line2 -> show_control_readonly ($req) Modified: perl/embperl/trunk/Embperl/Form/Control/radio.pm URL: http://svn.apache.org/viewvc/perl/embperl/trunk/Embperl/Form/Control/radio.pm?rev=1325935&r1=1325934&r2=1325935&view=diff ============================================================================== --- perl/embperl/trunk/Embperl/Form/Control/radio.pm (original) +++ perl/embperl/trunk/Embperl/Form/Control/radio.pm Fri Apr 13 20:26:56 2012 @@ -68,7 +68,7 @@ else } $] -<table class="ef-control-radiotab">[+ do { local $escmode = 0 ; $trglob }+] +<table class="ef-control-radiotab [+ $self -> {state} +]">[+ do { local $escmode = 0 ; $trglob }+] [$ foreach $val (@$values) $][- $x = ($val =~ /$filter/i) -] [- $fdat{$name} = $val, $set = 0 if ($set) ; $fdat{$name} = $val if ($ignorecase && lc($fdat{$name}) eq lc($val)) ; -] --------------------------------------------------------------------- To unsubscribe, e-mail: embperl-cvs-unsubscr...@perl.apache.org For additional commands, e-mail: embperl-cvs-h...@perl.apache.org