From 445dbff297ecd4cbbffa9f75473fed78ba30e4e8 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Tue, 14 Sep 2010 13:39:59 -0700 Subject: [PATCH] Covert File, CheckList over to headTags --- lib/WebGUI/Form/CheckList.pm | 16 ++++++++++++++-- lib/WebGUI/Form/File.pm | 17 +++++++++++++++-- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/lib/WebGUI/Form/CheckList.pm b/lib/WebGUI/Form/CheckList.pm index e2daaa57e..83fe6ee08 100644 --- a/lib/WebGUI/Form/CheckList.pm +++ b/lib/WebGUI/Form/CheckList.pm @@ -100,8 +100,6 @@ sub getSelectAllButton { my $formName = $self->get('name'); my $i18n = WebGUI::International->new($self->session, "Form_CheckList"); - $self->session->style->setScript( $self->session->url->extras("yui-webgui/build/form/form.js")); - return WebGUI::Form::Button->new($self->session, { name => $self->privateName('selectAllButton'), value => $i18n->get("selectAll label"), @@ -116,6 +114,19 @@ sub getSelectAllButton { #------------------------------------------------------------------- +=head2 headTags ( ) + +Set the head tags for this form plugin + +=cut + +sub headTags { + my $self = shift; + $self->session->style->setScript( $self->session->url->extras("yui-webgui/build/form/form.js")); +} + +#------------------------------------------------------------------- + =head2 isDynamicCompatible ( ) A class method that returns a boolean indicating whether this control is compatible with the DynamicField control. @@ -148,6 +159,7 @@ Renders a series of checkboxes. sub toHtml { my $self = shift; + $self->headTags; my $session = $self->session; my $output = '
'; $output .= WebGUI::Form::Hidden($session, { name => $self->privateName('isIn'), value => 1, }); diff --git a/lib/WebGUI/Form/File.pm b/lib/WebGUI/Form/File.pm index 1564aa6fb..0ac019f3d 100644 --- a/lib/WebGUI/Form/File.pm +++ b/lib/WebGUI/Form/File.pm @@ -237,6 +237,20 @@ sub getValueAsHtml { #------------------------------------------------------------------- +=head2 headTags ( ) + +Set the head tags for this form plugin + +=cut + +sub headTags { + my $self = shift; + $self->session->style->setScript($self->session->url->extras('FileUploadControl.js'),{type=>"text/javascript"}); + $self->session->style->setScript($self->session->url->extras('fileIcons.js'),{type=>"text/javascript"}); +} + +#------------------------------------------------------------------- + =head2 isDynamicCompatible ( ) A class method that returns a boolean indicating whether this control is compatible with the DynamicField control. @@ -272,14 +286,13 @@ Renders a file upload control. sub toHtml { my $self = shift; + $self->headTags; my $i18n = WebGUI::International->new($self->session); my $uploadControl = ''; my $storage = $self->getStorageLocation; my @files = @{ $storage->getFiles } if (defined $storage); my $maxFiles = $self->get('maxAttachments') - scalar(@files); if ($maxFiles > 0) { - $self->session->style->setScript($self->session->url->extras('FileUploadControl.js')); - $self->session->style->setScript($self->session->url->extras('fileIcons.js')); $uploadControl = '