HTML-TagHelper
view release on metacpan or search on metacpan
lib/HTML/TagHelper.pm view on Meta::CPAN
$year_tag->attr( 'name', $year_name );
$year_tag->push_content($year_options);
$date_select .= $year_tag->as_HTML("");
return $date_select;
}
sub _convert_options_to_javascript {
my ( $self, $html_options, $url ) = @_;
my $confirm = delete $html_options->{confirm};
my $popup = delete $html_options->{popup};
my $method = delete $html_options->{method};
my $href = delete $html_options->{href};
$html_options->{onclick} =
( $popup && $method )
? return("You can't use :popup and :method in the same link\n")
: ( $confirm && $popup ) ? "if ("
. $self->_confirm_javascript_function($confirm) . ") { "
. $self->_popup_javascript_function($popup)
. " };return false;"
: ( $confirm && $method ) ? "if ("
. $self->_confirm_javascript_function($confirm) . ") { "
. $self->_method_javascript_function($method)
. " };return false;"
: ($confirm)
? "return " . $self->_confirm_javascript_function($confirm) . ";"
: ($method) ? $self->_method_javascript_function( $method, $url, $href )
. "return false;"
: ($popup) ? $self->_popup_javascript_function($popup) . ' return false;'
: $html_options->{onclick};
return $html_options;
}
sub _confirm_javascript_function {
my ( $self, $confirm ) = @_;
return "confirm('" . $self->_escape_javascript($confirm) . "')";
}
sub _popup_javascript_function {
my ( $self, $popup ) = @_;
return ( ref $popup eq 'ARRAY' )
? "window.open(this.href, '"
. shift(@$popup) . "', '"
. pop(@$popup) . "');"
: "window.open(this.href);";
}
sub _method_javascript_function {
my ( $self, $method, $url, $href ) = @_;
$url = "" unless defined $url;
$href = undef unless defined $href;
my $action = ( $href && length($url) > 0 ) ? "'" . $url . "'" : "this.href";
my $submit_function =
"var f = document.createElement('form'); f.style.display = 'none'; "
( run in 2.030 seconds using v1.01-cache-2.11-cpan-364913b4093 )