[Rt-commit] rt branch, 4.2/message-box-type, created. rt-4.2.3-8-gc1c91d2
? sunnavy
sunnavy at bestpractical.com
Mon Mar 17 14:13:35 EDT 2014
The branch, 4.2/message-box-type has been created
at c1c91d2a1d65153a555a52698660f9db85670149 (commit)
- Log -----------------------------------------------------------------
commit 0161dbb0b818bfbe7619d1112afb3ed33479c4db
Author: sunnavy <sunnavy at bestpractical.com>
Date: Tue Mar 18 00:53:38 2014 +0800
allow to include js files from directories other than /static/js
this is initially for /static/RichText/ckeditor.js, which we want to include
in the default JSFiles so the rich messagebox could be always available.
diff --git a/lib/RT/Squish/JS.pm b/lib/RT/Squish/JS.pm
index 0c3bd3d..37b9088 100644
--- a/lib/RT/Squish/JS.pm
+++ b/lib/RT/Squish/JS.pm
@@ -76,7 +76,7 @@ sub Squish {
my $content = "";
for my $file ( RT::Interface::Web->JSFiles ) {
- my $uri = "/static/js/$file";
+ my $uri = $file =~ m{^/} ? $file : "/static/js/$file";
my $res = RT::Interface::Web::Handler->GetStatic($uri);
if ($res->is_success) {
diff --git a/share/html/Elements/HeaderJavascript b/share/html/Elements/HeaderJavascript
index 27dada4..4657dec 100644
--- a/share/html/Elements/HeaderJavascript
+++ b/share/html/Elements/HeaderJavascript
@@ -78,7 +78,7 @@ $RichText => 1
my @js_files;
if ( RT->Config->Get('DevelMode') ) {
- @js_files = map { "/static/js/$_" } RT::Interface::Web->JSFiles();
+ @js_files = map { $_ =~ m{^/} ? $_ : "/static/js/$_" } RT::Interface::Web->JSFiles();
}
else {
my $key = RT::Interface::Web::SquishedJS()->Key;
commit c1c91d2a1d65153a555a52698660f9db85670149
Author: sunnavy <sunnavy at bestpractical.com>
Date: Wed Feb 26 22:04:53 2014 +0800
add $Type to %ARGS so we can specify the type of the textarea in the caller
by default, the type is controlled by the system config($MessageBoxRichText)
and user preferences. however, sometimes we want to explicitly set the type no
matter what system config or the user preference is.
this is initially for the IPs and Addresses textareas in RTIR's ScriptedAction
tool page(/RTIR/Tools/ScriptedAction.html), where rich texts are not useful at
all(actually harmful as the backend doesn't handle the rich format).
diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index 8f690fe..df2e17c 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -105,7 +105,7 @@ sub SquishedJS {
=cut
sub JSFiles {
- return qw/
+ return qw{
jquery-1.9.1.min.js
jquery_noconflict.js
jquery-ui-1.10.0.custom.min.js
@@ -127,7 +127,8 @@ sub JSFiles {
forms.js
event-registration.js
late.js
- /, RT->Config->Get('JSFiles');
+ /static/RichText/ckeditor.js
+ }, RT->Config->Get('JSFiles');
}
=head2 ClearSquished
diff --git a/share/html/Elements/HeaderJavascript b/share/html/Elements/HeaderJavascript
index 4657dec..4b1abdb 100644
--- a/share/html/Elements/HeaderJavascript
+++ b/share/html/Elements/HeaderJavascript
@@ -55,9 +55,6 @@ $onload => undef
<script type="text/javascript" src="<%RT->Config->Get('WebPath')%><% $jsfile %>"></script>
% }
-% if ( $RichText and RT->Config->Get('MessageBoxRichText', $session{'CurrentUser'}) ) {
-<script type="text/javascript" src="<%RT->Config->Get('WebPath')%>/static/RichText/ckeditor.js"></script>
-% }
<script type="text/javascript"><!--
jQuery( loadTitleBoxStates );
% if ( $focus ) {
@@ -66,14 +63,7 @@ jQuery( loadTitleBoxStates );
% if ( $onload ) {
jQuery( <% $onload |n %> );
% }
-
-% if ( $RichText and RT->Config->Get('MessageBoxRichText', $session{'CurrentUser'})) {
- jQuery().ready(function () { ReplaceAllTextareas() });
-% }
--></script>
-<%ARGS>
-$RichText => 1
-</%ARGS>
<%INIT>
my @js_files;
diff --git a/share/html/Elements/MessageBox b/share/html/Elements/MessageBox
index 0749514..50fa56a 100644
--- a/share/html/Elements/MessageBox
+++ b/share/html/Elements/MessageBox
@@ -45,29 +45,28 @@
%# those contributions and any derivatives thereof.
%#
%# END BPS TAGGED BLOCK }}}
-<textarea autocomplete="off" class="messagebox" <% $width_attr %>="<% $Width %>" rows="<% $Height %>" <% $wrap_type |n %> name="<% $Name %>" id="<% $Name %>">\
+<textarea autocomplete="off" class="messagebox <% $Type eq 'text/html' ? 'richtext' : '' %>" <% $width_attr %>="<% $Width %>" rows="<% $Height %>" <% $wrap_type |n %> name="<% $Name %>" id="<% $Name %>">\
% $m->comp('/Articles/Elements/IncludeArticle', %ARGS) if $IncludeArticle;
% $m->callback( %ARGS, SignatureRef => \$signature );
<% $Default || '' %><% $message %><% $signature %></textarea>
% $m->callback( %ARGS, CallbackName => 'AfterTextArea' );
-% if ($type eq 'text/html') {
-<input type="text" style="display:none" name="<% $Name %>Type" id="<% $Name %>Type" value="<% $m->request_args->{$Name."Type"}||$type %>" />
+% if ($Type eq 'text/html') {
+<input type="text" style="display:none" name="<% $Name %>Type" id="<% $Name %>Type" value="<% $m->request_args->{$Name."Type"}||$Type %>" />
% }
<%INIT>
-my $type = RT->Config->Get('MessageBoxRichText', $session{'CurrentUser'}) ? 'text/html' : 'text/plain';
my $message = '';
if ( $QuoteTransaction ) {
my $transaction = RT::Transaction->new( $session{'CurrentUser'} );
$transaction->Load( $QuoteTransaction );
- $message = $transaction->Content( Quote => 1, Type => $type );
+ $message = $transaction->Content( Quote => 1, Type => $Type );
}
my $signature = '';
if ( $IncludeSignature and my $text = $session{'CurrentUser'}->UserObj->Signature ) {
$signature = "-- \n". $text;
- if ($type eq 'text/html') {
+ if ($Type eq 'text/html') {
$signature =~ s/&/&/g;
$signature =~ s/</</g;
$signature =~ s/>/>/g;
@@ -79,7 +78,7 @@ if ( $IncludeSignature and my $text = $session{'CurrentUser'}->UserObj->Signatur
}
# wrap="something" seems to really break IE + richtext
-my $wrap_type = $type eq 'text/html' ? '' : 'wrap="soft"';
+my $wrap_type = $Type eq 'text/html' ? '' : 'wrap="soft"';
# If there's no cols specified, we want to set the width to 100% in CSS
my $width_attr;
@@ -99,4 +98,5 @@ $Width => RT->Config->Get('MessageBoxWidth', $session{'CurrentUser'}
$Height => RT->Config->Get('MessageBoxHeight', $session{'CurrentUser'} ) || 15
$IncludeSignature => RT->Config->Get('MessageBoxIncludeSignature');
$IncludeArticle => 1;
+$Type => RT->Config->Get('MessageBoxRichText', $session{'CurrentUser'}) ? 'text/html' : 'text/plain';
</%ARGS>
diff --git a/share/static/js/util.js b/share/static/js/util.js
index d4a53c8..003109b 100644
--- a/share/static/js/util.js
+++ b/share/static/js/util.js
@@ -243,7 +243,7 @@ function ReplaceAllTextareas() {
for (var i=0; i < allTextAreas.length; i++) {
var textArea = allTextAreas[i];
- if (jQuery(textArea).hasClass("messagebox")) {
+ if (jQuery(textArea).hasClass("messagebox richtext")) {
// Turn the original plain text content into HTML
var type = jQuery("#"+textArea.name+"Type");
if (type.val() != "text/html")
@@ -341,4 +341,5 @@ jQuery(function() {
return true;
});
});
+ ReplaceAllTextareas();
});
-----------------------------------------------------------------------
More information about the rt-commit
mailing list