################################################################################### # # 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' ; $]
| #]
[$endif$]
[$endsub$]
[# ---------------------------------------------------------------------------
#
# show_controls_end - output end of form controls area
#]
[$sub show_subform_controls_end ($self, $form, $req)
$]
[# [$ if (!$form -> {noframe}) $] |
[+ $options ->[$j] || $val +]
|
[* $i++ ;
$j++ ;
if ($i - $start_i >= $tabs && @$values > $j)
{
$more = 1 ;
$start_i = $i ;
last ;
}
*]
[$endwhile $]
[$if ($j == @$values) $][$endif$] |