[Rt-commit] rt branch, 4.2/message-box-type, created. rt-4.2.3-7-g9648bd7

? sunnavy sunnavy at bestpractical.com
Wed Feb 26 09:49:34 EST 2014


The branch, 4.2/message-box-type has been created
        at  9648bd7d3ce552db26389d3ca2f8820fe41e18ca (commit)

- Log -----------------------------------------------------------------
commit 9648bd7d3ce552db26389d3ca2f8820fe41e18ca
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 perferences. however, sometimes we want to explicitly set the type no
    matter what system config or the user perference 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/share/html/Elements/HeaderJavascript b/share/html/Elements/HeaderJavascript
index 27dada4..cd711ec 100644
--- a/share/html/Elements/HeaderJavascript
+++ b/share/html/Elements/HeaderJavascript
@@ -55,9 +55,7 @@ $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 ) {
@@ -67,9 +65,7 @@ jQuery( loadTitleBoxStates );
     jQuery( <% $onload |n %> );
 % }
 
-% if ( $RichText and RT->Config->Get('MessageBoxRichText',  $session{'CurrentUser'})) {
     jQuery().ready(function ()  { ReplaceAllTextareas() });
-% }
 --></script>
 <%ARGS>
 $RichText => 1
diff --git a/share/html/Elements/MessageBox b/share/html/Elements/MessageBox
index 0749514..3bf390b 100644
--- a/share/html/Elements/MessageBox
+++ b/share/html/Elements/MessageBox
@@ -45,29 +45,29 @@
 %# 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';
+$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 +79,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 +99,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..5fb1fc3 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")

-----------------------------------------------------------------------


More information about the rt-commit mailing list