[Rt-commit] rt branch, 4.0/ckeditor-back-button, created. rt-4.0.18rc1-10-g1940eba

Alex Vandiver alexmv at bestpractical.com
Wed Oct 9 10:29:40 EDT 2013


The branch, 4.0/ckeditor-back-button has been created
        at  1940ebaf4e50eafc20c2bd149d63a627bfe80ecf (commit)

- Log -----------------------------------------------------------------
commit 1940ebaf4e50eafc20c2bd149d63a627bfe80ecf
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Tue Jan 25 21:29:58 2011 -0500

    Make CKeditor work with the back button
    
    Using the back button caused the html-filled output of the submission
    to appear in the textarea, then be encoded _again_ by the
    ckeditor-creation code.  We work around this by inserting a
    <input type="text" style="display:none"> element into the form, which
    we update when we upgrade the field.  This serves dual purposes: it
    notifies the perl side of the content type of the field, but it also
    serves as a storage of if the text->html encoding has already happened
    in javascript.
    
    This needs to be a type="text" because, unlike text="hidden", values
    in those fields are restored to their submit-time values when the back
    button is pressed.  Thus, the only way to back this system safe from
    the back button is to store that information in a non-hidden text
    area, and hide it using CSS.

diff --git a/share/html/Elements/HeaderJavascript b/share/html/Elements/HeaderJavascript
index bfb4a8c..693e219 100644
--- a/share/html/Elements/HeaderJavascript
+++ b/share/html/Elements/HeaderJavascript
@@ -67,7 +67,7 @@ $onload => undef
 % }
 
 % if ( $RichText and RT->Config->Get('MessageBoxRichText',  $session{'CurrentUser'})) {
-    jQuery().ready(function ()  { ReplaceAllTextareas(<%$DECODED_ARGS->{'CKeditorEncoded'} || 0 |n,j%>) });
+    jQuery().ready(function ()  { ReplaceAllTextareas() });
 % }
 --></script>
 <%ARGS>
diff --git a/share/html/Elements/MessageBox b/share/html/Elements/MessageBox
index 6f55b27..0a15530 100644
--- a/share/html/Elements/MessageBox
+++ b/share/html/Elements/MessageBox
@@ -50,6 +50,9 @@
 % $m->callback( %ARGS, SignatureRef => \$signature );
 <% $Default || '' %><% $message %><% $signature %></textarea>
 % $m->callback( %ARGS, CallbackName => 'AfterTextArea' );
+% if (RT->Config->Get('MessageBoxRichText',  $session{'CurrentUser'})) {
+<input type="text" style="display:none" name="<% $Name %>Type" id="<% $Name %>Type" value="<% $m->request_args->{$Name."Type"}||'' %>" />
+% }
 <%INIT>
 
 my $message = '';
diff --git a/share/html/NoAuth/js/util.js b/share/html/NoAuth/js/util.js
index 77a211e..a403d2e 100644
--- a/share/html/NoAuth/js/util.js
+++ b/share/html/NoAuth/js/util.js
@@ -273,7 +273,7 @@ function textToHTML(value) {
                 .replace(/\n/g,   "\n<br />");
 };
 
-function ReplaceAllTextareas(encoded) {
+function ReplaceAllTextareas() {
     var sAgent = navigator.userAgent.toLowerCase();
     if (!CKEDITOR.env.isCompatible ||
         sAgent.indexOf('iphone') != -1 ||
@@ -288,23 +288,12 @@ function ReplaceAllTextareas(encoded) {
         var textArea = allTextAreas[i];
         if (jQuery(textArea).hasClass("messagebox")) {
             // Turn the original plain text content into HTML
-            if (encoded == 0) {
+            var type = jQuery("#"+textArea.name+"Type");
+            if (type.val() != "text/html")
                 textArea.value = textToHTML(textArea.value);
-            }
-            // For this javascript
-            var CKeditorEncoded = document.createElement('input');
-            CKeditorEncoded.setAttribute('type', 'hidden');
-            CKeditorEncoded.setAttribute('name', 'CKeditorEncoded');
-            CKeditorEncoded.setAttribute('value', '1');
-            textArea.parentNode.appendChild(CKeditorEncoded);
-
-            // For fckeditor
-            var typeField = document.createElement('input');
-            typeField.setAttribute('type', 'hidden');
-            typeField.setAttribute('name', textArea.name + 'Type');
-            typeField.setAttribute('value', 'text/html');
-            textArea.parentNode.appendChild(typeField);
 
+            // Set the type
+            type.val("text/html");
 
             CKEDITOR.replace(textArea.name,{width:'100%',height:<% RT->Config->Get('MessageBoxRichTextHeight') |n,j%>});
             CKEDITOR.basePath = <%RT->Config->Get('WebPath')|n,j%>+"/NoAuth/RichText/";

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


More information about the Rt-commit mailing list