From 0175abdfc531365c6f71b51526154cac1bcca43a Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Fri, 7 Aug 2009 20:42:58 +0000 Subject: [PATCH] Forward porting TinyMCE ask user fix for FF browsers on Windows. --- docs/changelog/7.x.x.txt | 1 + lib/WebGUI/Asset/RichEdit.pm | 30 ++++++++++++++++++++--- lib/WebGUI/i18n/English/Asset_RichEdit.pm | 6 +++++ 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 3c517b91c..e86bab914 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -2,6 +2,7 @@ - fixed #10724: gotcha.txt for 7.7.17 enhanced - fixed #10316: Cannot view pending version tags - fixed #10710: testEnvironment 7.6.33 + - fixed #9777: Cursor disappears in non-Rich Editor window - fixed #10667: cannot change size of template editor - fixed #10654: Story Archive: Search not working properly - fixed #10692: Unprivileged users can stop spectre diff --git a/lib/WebGUI/Asset/RichEdit.pm b/lib/WebGUI/Asset/RichEdit.pm index 3258fa377..56b086cb9 100644 --- a/lib/WebGUI/Asset/RichEdit.pm +++ b/lib/WebGUI/Asset/RichEdit.pm @@ -489,7 +489,8 @@ sub getRichEditor { theme_advanced_resizing => JSON::true(), (map { "theme_advanced_buttons".($_+1) => (join ',', @{$toolbarRows[$_]}) } (0..$#toolbarRows)), - ask => $self->getValue("askAboutRichEdit") ? JSON::true() : JSON::false(), + #ask => $self->getValue("askAboutRichEdit") ? JSON::true() : JSON::false(), + ask => JSON::false(), preformatted => $self->getValue("preformatted") ? JSON::true() : JSON::false(), force_br_newlines => $self->getValue("useBr") ? JSON::true() : JSON::false(), force_p_newlines => $self->getValue("useBr") ? JSON::false() : JSON::true(), @@ -502,6 +503,10 @@ sub getRichEditor { valid_elements => $self->getValue("validElements"), wg_userIsVisitor => $self->session->user->isVisitor ? JSON::true() : JSON::false(), ); + my $ask = $self->getValue("askAboutRichEdit"); + if ($ask) { + $config{oninit} = 'turnOffTinyMCE_'.$nameId; + } foreach my $button (@toolbarButtons) { if ($button eq "spellchecker" && $self->session->config->get('availableDictionaries')) { push(@plugins,"-wgspellchecker"); @@ -569,12 +574,29 @@ sub getRichEditor { $self->session->style->setScript($self->session->url->extras('tinymce/jscripts/tiny_mce/tiny_mce.js'),{type=>"text/javascript"}); $self->session->style->setScript($self->session->url->extras("tinymce-webgui/callbacks.js"),{type=>"text/javascript"}); - my $out = ""; + $out .= "\ttinyMCE.init(" . JSON->new->pretty->encode(\%config) . " );\n"; + if ($ask) { + $out .= <<"EOHTML1"; +function toggleEditor(id) { + if (!tinyMCE.get(id)) + tinyMCE.execCommand('mceAddControl', false, id); + else + tinyMCE.execCommand('mceRemoveControl', false, id); +} +function turnOffTinyMCE_$nameId () { + tinyMCE.execCommand( 'mceRemoveControl', false, '$nameId'); +} +EOHTML1 + } + $out .= ""; } diff --git a/lib/WebGUI/i18n/English/Asset_RichEdit.pm b/lib/WebGUI/i18n/English/Asset_RichEdit.pm index 49ee2128a..ab59a7b5b 100644 --- a/lib/WebGUI/i18n/English/Asset_RichEdit.pm +++ b/lib/WebGUI/i18n/English/Asset_RichEdit.pm @@ -457,6 +457,12 @@ option is set to Yes, then all whitespace entered into the form will be preserve lastUpdated => 1206653834, }, + 'Toggle editor' => { + message => q{Toggle editor}, + lastUpdated => 0, + context => q{Toggle, to switch between on and off}, + }, + 'editForm allowMedia label' => { message => q{Allow Media}, lastUpdated => 0,