From 4c4fb8f3a2759d17dc3ac62056f8cce532e10cc8 Mon Sep 17 00:00:00 2001 From: Martin Kamerbeek Date: Thu, 30 Jul 2009 09:30:53 +0000 Subject: [PATCH] Fixed a bug where the textarea based formplugins would put multiple style tags in head if invoked mor than once per request. One case in which this happens is when you provide multiple form controls for the same form param through a template, like in eg. the post form of the cs. Anyway thes multiple tags confuse IE somehow borking javascript execution in the process. --- docs/changelog/7.x.x.txt | 3 +++ lib/WebGUI/Form/Textarea.pm | 15 ++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 0d1634296..915f192f2 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -14,6 +14,9 @@ - fixed #10706: FriendManager Style/Layout template options - fixed #10707: i18n Account_FriendManager::manageUrl - fixed #9962: gallery thumbnail view: JS problem in IE7 + - fixed a bug where the textarea (based) form plugins would put multiple + identical style tags in head in some cases, which caused javascript errors + in IE. ( Martin Kamerbeek / Oqapi ) 7.7.16 - fixed #10590: Session::DateTime->secondsToInterval doesn't allow 7 weeks diff --git a/lib/WebGUI/Form/Textarea.pm b/lib/WebGUI/Form/Textarea.pm index ded05ad35..5b9b647ee 100644 --- a/lib/WebGUI/Form/Textarea.pm +++ b/lib/WebGUI/Form/Textarea.pm @@ -142,9 +142,7 @@ sub toHtml { my $value = $self->fixMacros($self->fixTags($self->fixSpecialCharacters(scalar $self->getOriginalValue))); my $width = $self->get('width') || 400; my $height = $self->get('height') || 150; - my ($style, $url) = $self->session->quick(qw(style url)); - my $styleAttribute = "width: ".$width."px; height: ".$height."px; ".$self->get("style"); - $style->setRawHeadTags(qq||); + my ($style, $url, $stow) = $self->session->quick(qw(style url stow)); my $out = '' @@ -160,14 +158,21 @@ sub toHtml { { type => 'text/javascript' }, ); - unless ( $self->session->stow->get( 'texareaHeadTagsLoaded' ) ) { + # Make sure we load the css for this plugin only once per id. + unless ( $stow->get( 'textareaStyleLoaded_' . $self->get('id') ) ) { + my $styleAttribute = "width: ".$width."px; height: ".$height."px; ".$self->get("style"); + $style->setRawHeadTags(qq||); + $stow->set( 'textareaStyleLoaded_' . $self->get('id'), 1 ); + } + # Make sure we add the max length js only once for all texatareas. + unless ( $stow->get( 'texareaHeadTagsLoaded' ) ) { $style->setRawHeadTags( q| | ); - $self->session->stow->set( 'texareaHeadTagsLoaded', 1 ) + $stow->set( 'texareaHeadTagsLoaded', 1 ); } if ($self->get("resizable")) {