summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorDavid Lawrence <dkl@mozilla.com>2014-10-28 03:03:39 +0000
committerDavid Lawrence <dkl@mozilla.com>2014-10-28 03:03:39 +0000
commit3eb1f9f9c91fb630090420a8c726091f23c29263 (patch)
treec0d1aa40f6424eaf3c8020ea6805ea6c5d66a2c5 /js
parentBug 1083081 - javascript concatenation should insert a semicolon between files (diff)
downloadbugzilla-3eb1f9f9c91fb630090420a8c726091f23c29263.tar.gz
bugzilla-3eb1f9f9c91fb630090420a8c726091f23c29263.tar.bz2
bugzilla-3eb1f9f9c91fb630090420a8c726091f23c29263.zip
Bug 1059684 - markdown text should not be rendered within a <pre> tag
r=glob,a=glob
Diffstat (limited to 'js')
-rw-r--r--js/field.js28
1 files changed, 24 insertions, 4 deletions
diff --git a/js/field.js b/js/field.js
index 1cd58a69a..c24603988 100644
--- a/js/field.js
+++ b/js/field.js
@@ -984,18 +984,32 @@ function initDirtyFieldTracking() {
var last_comment_text = '';
var last_markdown_cb_value = null;
+var comment_textarea_width = null;
+var comment_textarea_height = null;
-function show_comment_preview(bug_id) {
+function refresh_markdown_preview (bug_id) {
+ if (!YAHOO.util.Dom.hasClass('comment_preview_tab', 'active_comment_tab'))
+ return;
+ show_comment_preview(bug_id, 1);
+}
+
+function show_comment_preview(bug_id, refresh) {
var Dom = YAHOO.util.Dom;
var comment = document.getElementById('comment');
var preview = document.getElementById('comment_preview');
var markdown_cb = document.getElementById('use_markdown');
if (!comment || !preview) return;
- if (Dom.hasClass('comment_preview_tab', 'active_comment_tab')) return;
+ if (Dom.hasClass('comment_preview_tab', 'active_comment_tab') && !refresh)
+ return;
- preview.style.width = (comment.clientWidth - 4) + 'px';
- preview.style.height = comment.offsetHeight + 'px';
+ if (!comment_textarea_width) {
+ comment_textarea_width = (comment.clientWidth - 4) + 'px';
+ comment_textarea_height = comment.offsetHeight + 'px';
+ }
+
+ preview.style.width = comment_textarea_width;
+ preview.style.height = comment_textarea_height;
var comment_tab = document.getElementById('comment_tab');
Dom.addClass(comment, 'bz_default_hidden');
@@ -1029,6 +1043,12 @@ function show_comment_preview(bug_id) {
document.getElementById('comment_preview_text').innerHTML = data.result.html;
Dom.addClass('comment_preview_loading', 'bz_default_hidden');
Dom.removeClass('comment_preview_text', 'bz_default_hidden');
+ if (markdown_cb.checked) {
+ Dom.removeClass('comment_preview_text', 'comment_preview_pre');
+ }
+ else {
+ Dom.addClass('comment_preview_text', 'comment_preview_pre');
+ }
last_comment_text = comment.value;
last_markdown_cb_value = markdown_cb.checked;
}