diff options
author | David Lawrence <dkl@mozilla.com> | 2014-10-28 04:01:01 +0100 |
---|---|---|
committer | David Lawrence <dkl@mozilla.com> | 2014-10-28 04:01:01 +0100 |
commit | 1f5404213d4b93ef573e99112536ed5af6643770 (patch) | |
tree | 754731f5b78b85a71a35b700bfb28ce020342c3d /js | |
parent | 2fbc1045f5b8e82d9a68328c35ba07d70d9d1877 (diff) | |
download | bugzilla-1f5404213d4b93ef573e99112536ed5af6643770.tar.gz bugzilla-1f5404213d4b93ef573e99112536ed5af6643770.tar.xz |
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.js | 28 |
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; } |