]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 551468: Stop word-wrapping comments on the server
authorMax Kanat-Alexander <mkanat@bugzilla.org>
Tue, 26 Oct 2010 22:48:33 +0000 (15:48 -0700)
committerMax Kanat-Alexander <mkanat@bugzilla.org>
Tue, 26 Oct 2010 22:48:33 +0000 (15:48 -0700)
r=glob, a=mkanat

12 files changed:
Bugzilla/Constants.pm
js/comments.js
skins/standard/IE-fixes.css
skins/standard/attachment.css
skins/standard/global.css
template/en/default/attachment/midair.html.tmpl
template/en/default/bug/comments.html.tmpl
template/en/default/bug/edit.html.tmpl
template/en/default/bug/field.html.tmpl
template/en/default/bug/process/midair.html.tmpl
template/en/default/global/header.html.tmpl
template/en/default/pages/linked.html.tmpl

index 9ce2c9f94e3607c91b5cd9352c84bd6c438c9a17..f4ed5660834ecae1d27b5786f31677c0c5e156fe 100644 (file)
@@ -295,7 +295,7 @@ use constant LIST_OF_BUGS => 1;
 # How many of the user's most recent searches to save.
 use constant SAVE_NUM_SEARCHES => 10;
 
-# The column length for displayed (and wrapped) bug comments.
+# The column width for comment textareas and comments in bugmails.
 use constant COMMENT_COLS => 80;
 # Used in _check_comment(). Gives the max length allowed for a comment.
 use constant MAX_COMMENT_LENGTH => 65535;
index 2f1a14406d260a230969c982fc1b263d09dd0ed3..d9c0f5033ab2ccaf2e4b6feea0facd311f62a2f4 100644 (file)
@@ -18,6 +18,7 @@
  * Contributor(s): Frédéric Buclin <LpSolit@gmail.com>
  *                 Max Kanat-Alexander <mkanat@bugzilla.org>
  *                 Edmund Wong <ewong@pw-wspx.org>
+ *                 Anthony Pipkin <a.pipkin@yahoo.com>
  */
 
 function updateCommentPrivacy(checkbox, id) {
@@ -76,6 +77,53 @@ function expand_comment(link, comment) {
     YAHOO.util.Dom.removeClass(comment, 'collapsed');
 }
 
+function wrapReplyText(text) {
+    // This is -3 to account for "\n> "
+    var maxCol = BUGZILLA.constant.COMMENT_COLS - 3;
+    var text_lines = text.split("\n");
+    var wrapped_lines = new Array();
+
+    for (var i = 0; i < text_lines.length; i++) {
+        var paragraph = text_lines[i];
+        // Don't wrap already-quoted text.
+        if (paragraph.indexOf('>') == 0) {
+            wrapped_lines.push('> ' + paragraph);
+            continue;
+        }
+
+        var replace_lines = new Array();
+        while (paragraph.length > maxCol) {
+            var testLine = paragraph.substring(0, maxCol);
+            var pos = testLine.search(/\s\S*$/);
+
+            if (pos < 1) {
+                // Try to find some ASCII punctuation that's reasonable
+                // to break on.
+                var punct = '\\-\\./,!;:';
+                var punctRe = new RegExp('[' + punct + '][^' + punct + ']+$');
+                pos = testLine.search(punctRe) + 1;
+                // Try to find some CJK Punctuation that's reasonable
+                // to break on.
+                if (pos == 0)
+                    pos = testLine.search(/[\u3000\u3001\u3002\u303E\u303F]/) + 1;
+                // If we can't find any break point, we simply break long
+                // words. This makes long, punctuation-less CJK text wrap,
+                // even if it wraps incorrectly.
+                if (pos == 0) pos = maxCol;
+            }
+
+            var wrapped_line = paragraph.substring(0, pos);
+            replace_lines.push(wrapped_line);
+            paragraph = paragraph.substring(pos);
+            // Strip whitespace from the start of the line
+            paragraph = paragraph.replace(/^\s+/, '');
+        }
+        replace_lines.push(paragraph);
+        wrapped_lines.push("> " + replace_lines.join("\n> "));
+    }
+    return wrapped_lines.join("\n");
+}
+
 /* This way, we are sure that browsers which do not support JS
    * won't display this link  */
 
index fc2225398512d997e913cfcb315a36d9a16a4794..9a7856abac0311e6386355073ce42accaa6cfcf8 100644 (file)
@@ -13,7 +13,7 @@
   * Contributor(s): Marc Schumann <wurblzap@gmail.com>
   */
 
-.bz_comment_text, .uneditable_textarea {
+.bz_comment_text, .uneditable_textarea, tbody.file pre {
      white-space: pre;
      word-wrap: break-word;
 }
index c05cfe2dacebf712f25a606d4bb8c058f91fef62..b42b2224cfc31ef0a30208cc71edb55cc53a0955 100644 (file)
@@ -73,9 +73,6 @@ table.file_table {
 
 tbody.file pre {
   display: inline;
-  white-space: pre-wrap; /* CSS 3 & CSS 2.1 */
-  white-space: -moz-pre-wrap; /* Gecko < 1.9.1 */
-  white-space: -o-pre-wrap; /* Opera 7 */
   font-size: 0.9em;
 }
 
index db874de291a686f52430f8885b8aab45c0590057..0deb4b94a1a4fe08cc8fbee0b778ad8a181db3f3 100644 (file)
@@ -293,9 +293,8 @@ div#docslinks {
     margin-bottom: 2em;
 }
 
-/* The rules for these classes make international text wrap correctly,
-   even for languages like Japanese that have no spaces. */
-.bz_comment_text, .uneditable_textarea {
+/* tbody.file pre is for the Diff view of attachments. */
+.bz_comment_text, .uneditable_textarea, tbody.file pre {
      font-family: monospace;
     /* Note that these must all be on separate lines or they stop
        working in Konqueror. */
index f0883b55b9f2da9b325e7c96512732ff9bf3c06c..f7f40fdcb99d8e82a7c7620a5ea44a7d3ef9d03b 100644 (file)
@@ -51,7 +51,7 @@
 <p>
   Your comment was:<br>
   <blockquote><pre class="bz_comment_text">
-    [% cgi.param("comment") FILTER wrap_comment FILTER html %]
+    [% cgi.param("comment") FILTER html %]
   </pre></blockquote>
 </p>
 [% END %]
index 580ba6b5e33e0b020de30e40d31c5c3e3614eff1..208ea092a3bdab7c38a8adbb90c4b0f4a3fc9738 100644 (file)
 
 [% BLOCK a_comment %]
   [% RETURN IF comment.is_private AND ! user.is_insider %]
-  [% comment_text = comment.body_full({ wrap => 1 }) %]
+  [% comment_text = comment.body_full %]
   [% RETURN IF comment_text == '' AND (comment.work_time - 0) != 0 AND !user.is_timetracker %]
 
     <div id="c[% count %]" class="bz_comment[% " bz_private" IF comment.is_private %]
index 9c951fb2ea71f888504081b44b6a1c255eb28534..2a9a0776e4efd105bc88450a324581efb52319e9 100644 (file)
         /* pre id="comment_name_N" */
         var text_elem = document.getElementById('comment_text_'+id);
         var text = getText(text_elem);
-
-        /* make sure we split on all newlines -- IE or Moz use \r and \n
-         * respectively.
-         */
-        text = text.split(/\r|\n/);
-
-        for (var i=0; i < text.length; i++) {
-            replytext += "> " + text[i] + "\n"; 
-        }
-
-        replytext = prefix + replytext + "\n";
+        replytext = prefix + wrapReplyText(text);
       [% ELSIF user.settings.quote_replies.value == 'simple_reply' %]
         replytext = prefix;
       [% END %]
index 4065b3af0cf07e4088d637acccf46530f7c8c751..1eb4574bfce6aece1d7499ac697649040065a072 100644 (file)
        </script>
   [% END %]
 [% ELSIF field.type == constants.FIELD_TYPE_TEXTAREA %]
-  <div class="uneditable_textarea">[% value FILTER wrap_comment(60)
-                                            FILTER html %]</div>
+  <div class="uneditable_textarea">[% value FILTER html %]</div>
 [% ELSIF field.type == constants.FIELD_TYPE_BUG_ID %]
     [% IF value %]  
         [% value FILTER bug_link(value, use_alias => 1) FILTER none %]
index 8a49f7cdc1643342ef1c558d1306671d09c02046..157cb44b421f4e5490ddf77a66ce433fcb588ce1 100644 (file)
@@ -67,7 +67,7 @@
 <p>
   Your comment was:<br>
   <blockquote><pre class="bz_comment_text">
-    [% cgi.param("comment") FILTER wrap_comment FILTER html %]
+    [% cgi.param("comment") FILTER html %]
   </pre></blockquote>
 </p>
 [% END %]
index aa6604d2cd02de7961be6ed31053f80348dbfd29..e5e5a08fbfcc738fe3cab69f616ae06a0dc1ff3b 100644 (file)
                 cookiepath: '[% Param('cookiepath') FILTER js %]',
                 maxusermatches: [% Param('maxusermatches') FILTER js %]
             },
-
+            constant: {
+                COMMENT_COLS: [% constants.COMMENT_COLS FILTER js %]
+            },
             string: {
                 [%# Please keep these in alphabetical order. %]
 
index 52b1735f60afbff3d0fd446359ceb7f89f501570..b5d850627e7b639af03173b913d457e1db1ee325 100644 (file)
@@ -31,7 +31,7 @@
 
 <p>
 <pre class="bz_comment_text">
-[%- cgi.param("text") FILTER wrap_comment FILTER quoteUrls FILTER html -%]
+[%- cgi.param("text") FILTER quoteUrls FILTER html -%]
 </pre>
 </p>
 
@@ -46,7 +46,7 @@
 
 <p>
 <pre class="bz_comment_text">
-[%- cgi.param("text") FILTER wrap_comment FILTER quoteUrls -%]
+[%- cgi.param("text") FILTER quoteUrls -%]
 </pre>
 </p>