/usr/lib/x86_64-linux-gnu/perl5/5.22/Embperl/Form/Control/tabs.pm is in libembperl-perl 2.5.0-6.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 | ###################################################################################
#
# Embperl - Copyright (c) 1997-2008 Gerald Richter / ecos gmbh www.ecos.de
# Embperl - Copyright (c) 2008-2014 Gerald Richter
#
# 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::tabs ;
use strict ;
use vars qw{%fdat} ;
use Embperl::Form::ControlMultValue ;
use base 'Embperl::Form::ControlMultValue' ;
use Embperl::Inline ;
# ---------------------------------------------------------------------------
#
# new - create a new control
#
sub new
{
my ($class, $args) = @_ ;
my $self = Embperl::Form::ControlMultValue -> new($args) ;
bless $self, $class ;
$self -> {width} = 1 ;
$self -> {nameprefix} ||= 'tab:' ;
return $self ;
}
# ---------------------------------------------------------------------------
#
# noframe - do not draw frame border if this is the first control
#
sub noframe
{
return 1 ;
}
# ---------------------------------------------------------------------------
#
# get_active_id - get the id of the value which is currently active
#
sub get_active_id
{
my ($self, $req) = @_ ;
my $key = "active_id:$self" ;
my $id ;
return $id if ($id = $req -> {$key}) ;
my ($values, $options) = $self -> get_values ($req) ;
my $name = $self -> {name} ;
my $dataval = $fdat{$name} || $req -> {query}{$name} || $values -> [0] ;
my $activeid ;
my $i = 0 ;
foreach my $val (@$values)
{
if ($val eq $dataval || $self -> {subids}[$i] eq $dataval)
{
$activeid = $self -> {subids}[$i] ;
last ;
}
$i++ ;
}
return $req -> {$key} = $activeid || $self -> {subids}[0];
}
1 ;
__EMBPERL__
[$ syntax EmbperlBlocks $]
[ ---------------------------------------------------------------------------
#
# show_controls_begin - output begin of form controls area
#]
[$ sub show_subform_controls_begin ($self, $form, $req, $activeid)
my $parent = $form -> parent_form ;
my $class = $parent -> {noframe}?'ef-tabs-border-u':'ef-tabs-border' ;
$]
<div _ef_name="[+ $form->{id} +]" class="ef-tabs-content"
[$if ($activeid && $form->{id} ne $activeid) $] style="display: none" [$endif$]
>
[$if (!$form -> {noframe}) $]
<div class="ef-tabs-separator ui-accordion-header ui-helper-reset ui-state-default ui-accordion-icons ui-corner-top"><span class="ui-accordion-header-icon ui-icon ui-icon-triangle-1-s ef-icon" title="Verstecken/Anzeigen"></span><span class="ef-tabs-separator-header-text">[+ $form -> {text} +]</span></div>
[#<table class="ef-tabs-border-cell [+ $class +]"><tr><td class="ef-tabs-content-cell"> #]
<div class="ef-tabs-border-cell [+ $class +]"><div class="ef-tabs-content-cell">
[$endif$]
[$endsub$]
[# ---------------------------------------------------------------------------
#
# show_controls_end - output end of form controls area
#]
[$sub show_subform_controls_end ($self, $form, $req)
$]
[# [$ if (!$form -> {noframe}) $]</td></tr></table> [$endif$] #]
[$ if (!$form -> {noframe}) $]</div></div> [$endif$]
</div>
[$endsub$]
[# ---------------------------------------------------------------------------
#
# show - output the control
#]
[$ sub show ($self, $req)
my ($values, $options) = $self -> get_values ($req) ;
my $span = ($self->{width_percent}) ;
my $name = $self -> {name} ;
my $dataval = $fdat{$name} || $values -> [0] ;
my $activeid = $self -> get_active_id ($req) ;
my $form = $self -> form ;
my $nsprefix = $form -> {jsnamespace} ;
my $tabs_per_line = $self -> {'tabs_per_line'} || 99;
$tabs_per_line = [$tabs_per_line, $tabs_per_line, $tabs_per_line, $tabs_per_line]
if (!ref $tabs_per_line) ;
my $val ;
my $i = 0 ;
my $j = 0 ;
my $more = 1 ;
my $start_i = 0 ;
my $line = 0 ;
$]
<div class="ef-tabs-content-cell" colspan="[+ $span +]" _ef_attach="ef_tabs">
[$ while ($more) $]
<table class="ef-tabs-selector" ><tr class="ef-tabs-selector-row">
[*
$more = 0 ;
my $tabs = $tabs_per_line -> [$line++] ;
*]
[$ while ($j < @$values) $]
[*
if ($self -> {subobjects}[ $j ] -> is_disabled ($req))
{
$j++ ;
next ;
}
$val = $values -> [$j] ;
my $id = $self -> {subids}[$j] ;
my $cellclass = $id eq $activeid?'ef-tabs-cell-on':'ef-tabs-cell-off' ;
my $divclass = $id eq $activeid?'ef-tabs-div-on':'ef-tabs-div-off' ;
my @switch_code ;
foreach my $sub (@{$form -> {controls}})
{
my $code = $sub -> get_on_show_code ;
push @switch_code, $code if ($code) ;
}
my $js = join (';', @switch_code) ;
*]
<td class="[+ $cellclass +]"><div class="ef-tabs-div [+ $divclass +]"
[$ if $i - $start_i == 0 $]style="border-left: black 1px solid" [$endif$]
>[+ $options ->[$j] || $val +]
</div></td>
[* $i++ ;
$j++ ;
if ($i - $start_i >= $tabs && @$values > $j)
{
$more = 1 ;
$start_i = $i ;
last ;
}
*]
[$endwhile $]
[$if ($j == @$values) $]<td class="ef-tabs-cell-blank ef-tabs-view-all"> </td>[$endif$]
</tr></table>
[$endwhile$]
[#<input type="hidden" name="[+ $name +]" id="[+ $fullname +]" class="ef-field-tab_select" value="[+ $uid +]_[+ $activeid +]">#]
</div>
[$endsub$]
__END__
=pod
=head1 NAME
Embperl::Form::Control::tabs - A tab control inside an Embperl Form
=head1 SYNOPSIS
Embperl::Form -> add_tabs (
[
{
text => 'First Tab',
fields => [
...
]
},
{
text => 'Second Tab',
fields => [
...
]
}
])
=head1 DESCRIPTION
Control to display tabs at the top of the form and control the switching between sub forms.
The switching is done by Javascript, so it can only be used in environment where
Javascript is available.
You can use the method Embperl::Form -> add_tabs
to setup a tabbed form.
See Embperl::Form on how to specify parameters.
=head2 PARAMETER
=head3 text
Text that will be displayed on the tab
=head3 fields
List of fields that should be displayed in this subform.
Given in the same form as form Embperl::Form.
=head1 Author
G. Richter (richter at embperl dot org)
=head1 See Also
perl(1), Embperl, Embperl::Form
|