aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Bugzilla/Constants.pm2
-rw-r--r--js/comments.js48
-rw-r--r--skins/standard/IE-fixes.css2
-rw-r--r--skins/standard/attachment.css3
-rw-r--r--skins/standard/global.css5
-rw-r--r--template/en/default/attachment/midair.html.tmpl2
-rw-r--r--template/en/default/bug/comments.html.tmpl2
-rw-r--r--template/en/default/bug/edit.html.tmpl12
-rw-r--r--template/en/default/bug/field.html.tmpl3
-rw-r--r--template/en/default/bug/process/midair.html.tmpl2
-rw-r--r--template/en/default/global/header.html.tmpl4
-rw-r--r--template/en/default/pages/linked.html.tmpl4
12 files changed, 62 insertions, 27 deletions
diff --git a/Bugzilla/Constants.pm b/Bugzilla/Constants.pm
index 9ce2c9f94..f4ed56608 100644
--- a/Bugzilla/Constants.pm
+++ b/Bugzilla/Constants.pm
@@ -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;
diff --git a/js/comments.js b/js/comments.js
index 2f1a14406..d9c0f5033 100644
--- a/js/comments.js
+++ b/js/comments.js
@@ -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 */
diff --git a/skins/standard/IE-fixes.css b/skins/standard/IE-fixes.css
index fc2225398..9a7856aba 100644
--- a/skins/standard/IE-fixes.css
+++ b/skins/standard/IE-fixes.css
@@ -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;
}
diff --git a/skins/standard/attachment.css b/skins/standard/attachment.css
index c05cfe2da..b42b2224c 100644
--- a/skins/standard/attachment.css
+++ b/skins/standard/attachment.css
@@ -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;
}
diff --git a/skins/standard/global.css b/skins/standard/global.css
index db874de29..0deb4b94a 100644
--- a/skins/standard/global.css
+++ b/skins/standard/global.css
@@ -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. */
diff --git a/template/en/default/attachment/midair.html.tmpl b/template/en/default/attachment/midair.html.tmpl
index f0883b55b..f7f40fdcb 100644
--- a/template/en/default/attachment/midair.html.tmpl
+++ b/template/en/default/attachment/midair.html.tmpl
@@ -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 %]
diff --git a/template/en/default/bug/comments.html.tmpl b/template/en/default/bug/comments.html.tmpl
index 580ba6b5e..208ea092a 100644
--- a/template/en/default/bug/comments.html.tmpl
+++ b/template/en/default/bug/comments.html.tmpl
@@ -102,7 +102,7 @@
[% 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 %]
diff --git a/template/en/default/bug/edit.html.tmpl b/template/en/default/bug/edit.html.tmpl
index 9c951fb2e..2a9a0776e 100644
--- a/template/en/default/bug/edit.html.tmpl
+++ b/template/en/default/bug/edit.html.tmpl
@@ -52,17 +52,7 @@
/* 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 %]
diff --git a/template/en/default/bug/field.html.tmpl b/template/en/default/bug/field.html.tmpl
index 4065b3af0..1eb4574bf 100644
--- a/template/en/default/bug/field.html.tmpl
+++ b/template/en/default/bug/field.html.tmpl
@@ -206,8 +206,7 @@
</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 %]
diff --git a/template/en/default/bug/process/midair.html.tmpl b/template/en/default/bug/process/midair.html.tmpl
index 8a49f7cdc..157cb44b4 100644
--- a/template/en/default/bug/process/midair.html.tmpl
+++ b/template/en/default/bug/process/midair.html.tmpl
@@ -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 %]
diff --git a/template/en/default/global/header.html.tmpl b/template/en/default/global/header.html.tmpl
index aa6604d2c..e5e5a08fb 100644
--- a/template/en/default/global/header.html.tmpl
+++ b/template/en/default/global/header.html.tmpl
@@ -189,7 +189,9 @@
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. %]
diff --git a/template/en/default/pages/linked.html.tmpl b/template/en/default/pages/linked.html.tmpl
index 52b1735f6..b5d850627 100644
--- a/template/en/default/pages/linked.html.tmpl
+++ b/template/en/default/pages/linked.html.tmpl
@@ -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>