I don't consider this useful/tested enough to deliver to CPAN, but it works for my uses.
#--------------------------------------------------------------------- +---------------------- # B O O T S T R A P H E L P E R M O D U L E ("Twitter Bootst +rap" JS) #--------------------------------------------------------------------- +---------------------- package BootstrapHelper; # Helps create Bootstrap EventDetailHandler_E +numerate_Instances use CGI; #------------------------------- sub new{ my ($class, %atts) = @_; return bless ({ %atts } ,$class); } #------------------------------- sub panel{ # $bs->panel (heading=>"my title",content=>"important stuff +",class=>"panel-danger"); my ($self,%atts) = @_; $atts{class} ||= "panel-info"; $atts{heading} ||= "Info"; return CGI::div({-class => "panel $atts{class}"}, join "\n", CGI::div({-class=>"panel-heading"}, CGI::h3({-class=>"panel-title"},$atts{heading}) ), CGI::div({-class=>"panel-body"}, $atts{content}) ) . "\n"; } sub alert{ my ($self,%atts) = @_; $atts{class} ||= "alert-info"; $atts{dismiss} and $atts{class} .= " alert-dismissable"; $atts{heading} ||= ""; # Text to be highlighted return CGI::div({-class => "alert $atts{class}"}, join "\n", ($atts{dismiss} ? $self->button(dismiss=>1, class=>"clos +e") : ""), ($atts{heading} ? CGI::strong($atts{heading}) . " " : "" +), $atts{content} ) . "\n"; } sub button{ # Cannot use CGI::button, since that one produces an <inpu +t> tag my ($self,%atts) = @_; $atts{class} ||= "btn-info"; $atts{content} ||=""; $atts{dismiss} and $atts{content} .= "×"; return qq|<button type="button" class="btn $atts{class}" | . ($atts{dismiss} ? qq|data-dismiss="alert" aria-hidden="true" | +:"") . ($atts{onclick} ? qq|onclick="$atts{onclick}" | :"") . ">" . $atts{content} . qq|</button>\n|; } sub dropdown{ my ($self,%atts) = @_; $self->{DROPDOWN_COUNT}++; $self->{DROPDOWN_ID} = "dropdown_menu_$self->{DROPDOWN_COUNT}"; # Mo +st recent ID is here $atts{class} ||= "btn-info"; $atts{content} ||= $atts{selected_value} || "Button-name"; # Gets ov +erriden by default anyway $atts{values} ||= []; $atts{selected_value} ||= "***NONE***"; $atts{input} ||= ""; # Allow for optional <input> text tag (Whose ID + should be set to THIS control's data-target) my $target_txt = $atts{'data-target'} ? "data-target=\"$atts{'data-t +arget'}\" " : ""; return <<" __DROPDOWN__" <div class="dropdown"> <button class="btn $atts{class} dropdown-toggle" type="button" data +-toggle="dropdown" aria-haspopup="true" id="$self->{DROPDOWN_ID}" $target_txt aria-expanded="true"> $atts{content} <span class="caret"></span> </button> $atts{input} <ul class="dropdown-menu" aria-labelledby="$self->{DROPDOWN_ID}"> __DROPDOWN__ . join ("\n", map {"<li><a href='#' data-value='$_'>$_" . ($_ eq $atts{selected_value} ? "class='acti +ve'":"") ."</a></li>"} @{$atts{values}}) . "</ul></div>\n"; } 1; # End of BootstrapHelper class
"Think of how stupid the average person is, and realize half of them are stupider than that." - George Carlin
In reply to Re: How To Use Bootstrap Code in Perl Script?
by NetWallah
in thread How To Use Bootstrap Code in Perl Script?
by glennpm
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |