Bug 65772 - Rework comment preview, add comment preview to attachment forms

git-svn-id: svn://svn.office.custis.ru/3rdparty/bugzilla.org/trunk@814 6955db30-a419-402b-8a0d-67ecbb4d7f56
master
vfilippov 2010-06-28 11:28:20 +00:00
parent e0a5527882
commit de7e566ce6
8 changed files with 50 additions and 40 deletions

View File

@ -144,4 +144,4 @@ table.attachment_info td {
padding-top: 1em;
}
#comment { width: 50em; font-size: medium; font-family: monospace; }
#comment_textarea { width: 50em; font-size: medium; font-family: monospace; }

View File

@ -0,0 +1,22 @@
<div id="wrapcommentpreview" style="display: none">
<div id="commentpreviewhtml"></div>
<iframe name="commentpreviewframe" id="commentpreviewframe" style="display: none"></iframe>
<script>
/*<!--*/
if (!window.findPos)
{
window.findPos = function(obj) { var curtop = 0; if (obj.offsetParent) { do { curtop += obj.offsetTop; } while (obj = obj.offsetParent); return [curtop]; } }
window.scrollDocTo = function(obj) { window.scroll(0,findPos(obj)); }
window.scrTo = function(id) { scrollDocTo(document.getElementById(id)); }
window.hidepreview = function() { document.getElementById('wrapcommentpreview').style.display='none'; }
window.showcommentpreview = function() {
document.getElementById('wrapcommentpreview').style.display = '';
document.commentpreviewform.comment.value = document.getElementById('comment_textarea').value;
document.commentpreviewform.submit();
scrTo('wrapcommentpreview');
}
}
//-->
</script>
<p style="text-align: right; margin-top: 0"><a href="javascript:void(0)" onclick="hidepreview()">Hide preview</a></p>
</div>

View File

@ -0,0 +1,3 @@
<form name="commentpreviewform" style="display:none" target="commentpreviewframe" method="POST" action="page.cgi?id=previewcomment.html">
<input id="previewcommentvalue" type="hidden" name="comment" value="" />
</form>

View File

@ -10,16 +10,12 @@
.bz_st_CLOSED { text-decoration: line-through; border: 1px solid #2f6fab; background-color: #f9f9f9; line-height: 1.1em; }
</style>
</head>
<script type="text/javascript">
function resizeIframe()
{
parent.document.getElementById('commentpreview').style.height = (document.getElementById('cmt').scrollHeight+4) + "px";
parent.document.getElementById('commentpreview').style.width = document.getElementById('cmthtm').scrollWidth + "px";
}
</script>
<body onLoad="resizeIframe()" onResize="resizeIframe()" style="margin: 0; padding: 0; overflow: hidden">
<div id="cmt" class="bz_comment" style="border-style: dotted; border-width: 2px; border-color: #969696; background-color: #e8e8e8; padding: 5px">
<p><pre style="white-space: pre-wrap">[%- cgi.param("comment") FILTER wrap_comment FILTER quoteUrls FILTER links_targetblank -%]</pre></p>
<body style="margin: 0; padding: 0; overflow: hidden">
<div class="bz_comment" style="border-style: dotted; border-width: 2px; border-color: #969696; background-color: #e8e8e8; padding: 5px">
<pre style="white-space: pre-wrap">[%- cgi.param("comment") | wrap_comment | quoteUrls | links_targetblank -%]</pre>
</div>
</body>
<script type="text/javascript">
parent.document.getElementById('commentpreviewhtml').innerHTML = document.body.innerHTML;
</script>
</html>

View File

@ -38,6 +38,8 @@
doc_section = "attachments.html"
%]
[% PROCESS "bug/comment-preview-form.html.tmpl" %]
<form name="entryform" method="post" action="attachment.cgi"
enctype="multipart/form-data"
onsubmit="return validateAttachmentForm(this)">
@ -103,15 +105,17 @@
<td>
<em>(optional) Add a comment about this attachment to the [% terms.bug %].</em>
<input type="checkbox" name="commentsilent" value="1" /> <label for="commentsilent">Silent</label>
<br>
<br />
[% INCLUDE global/textarea.html.tmpl
name = 'comment'
id = 'comment'
id = 'comment_textarea'
minrows = 6
maxrows = 15
cols = constants.COMMENT_COLS
wrap = 'soft'
style = 'width: 100%'
%]
[% PROCESS "bug/comment-preview-div.html.tmpl" %]
</td>
</tr>
[% IF user.is_insider %]
@ -130,7 +134,7 @@
[% END %]
<tr>
<th>&nbsp;</th>
<td><input type="submit" id="create" value="Submit"></td>
<td><input type="submit" id="create" value="Submit"> <input type="button" value="Preview comment" onclick="showcommentpreview()" tabindex="-1" /></td>
</tr>
</table>

View File

@ -45,6 +45,8 @@
[% can_edit = attachment.validate_can_edit %]
[% editable_or_hide = can_edit ? "" : " bz_hidden_option" %]
[% PROCESS "bug/comment-preview-form.html.tmpl" %]
<form method="post" action="attachment.cgi" onsubmit="normalizeComments();">
<input type="hidden" name="id" value="[% attachment.id %]">
<input type="hidden" name="action" value="update">
@ -170,7 +172,7 @@
<label for="comment">Comment (on the [% terms.bug %]):</label>
<input type="checkbox" name="commentsilent" value="1" /> <label for="commentsilent">Silent</label></small><br />
[% INCLUDE global/textarea.html.tmpl
id = 'comment'
id = 'comment_textarea'
name = 'comment'
minrows = 5
cols = 25
@ -179,7 +181,11 @@
%]
</div>
<input type="submit" value="Submit" id="update"><br><br>
<input type="submit" value="Submit" id="update" />
<input type="button" value="Preview" onclick="showcommentpreview()" tabindex="-1" /><br><br>
[% PROCESS "bug/comment-preview-div.html.tmpl" %]
[% END %]
</td>

View File

@ -124,6 +124,8 @@
<table class="bz_comment_table" cellpadding="0" cellspacing="0"><tr>
<td>
[% PROCESS "bug/comment-preview-div.html.tmpl" %]
[% FOREACH comment = comments %]
[% IF count >= start_at;
PROCESS a_comment;

View File

@ -194,9 +194,7 @@
//-->
</script>
<form name="commentpreviewform" style="display:none" target="commentpreview" method="POST" action="page.cgi?id=previewcomment.html">
<input id="previewcommentvalue" type="hidden" name="comment" value="" />
</form>
[% PROCESS "bug/comment-preview-form.html.tmpl" %]
[%# CustIS Bug 57315 - Force Fucking Firefox to reset form on Reload %]
[% USE date %]
@ -1149,27 +1147,6 @@ document.changeform = document.[% cfname %];
</tr>
</table>
</td></tr></table>
<div id="wrapcommentpreview" style="display: none">
<iframe name="commentpreview" id="commentpreview" style="height: auto; border-width: 0; width: 100%; overflow: hidden">
</iframe>
<script>
/*<!--*/
function findPos(obj) { var curtop = 0; if (obj.offsetParent) { do { curtop += obj.offsetTop; } while (obj = obj.offsetParent); return [curtop]; } }
function scrollDocTo(obj) { window.scroll(0,findPos(obj)); }
function scrTo(id) { scrollDocTo(document.getElementById(id)); }
function hidepreview() { document.getElementById('wrapcommentpreview').style.display='none'; }
function showcommentpreview()
{
document.getElementById('wrapcommentpreview').style.width=document.getElementById('comments').scrollWidth+'px';
document.getElementById('wrapcommentpreview').style.display='inline-block';
document.commentpreviewform.comment.value = document.changeform.comment.value;
document.commentpreviewform.submit();
scrTo('commentpreview');
}
//-->
</script>
<p style="text-align: right"><a href="javascript:void hidepreview()">Hide preview</a></p>
</div>
[%# For logged-out users %]
[% ELSE %]