<!-- 1.0@bugzilla.org --> [%# The contents of this file are subject to the Mozilla Public # License Version 1.1 (the "License"); you may not use this file # except in compliance with the License. You may obtain a copy of # the License at http://www.mozilla.org/MPL/ # # Software distributed under the License is distributed on an "AS # IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or # implied. See the License for the specific language governing # rights and limitations under the License. # # The Original Code is the Bugzilla Bug Tracking System. # # The Initial Developer of the Original Code is Netscape Communications # Corporation. Portions created by Netscape are # Copyright (C) 1998 Netscape Communications Corporation. All # Rights Reserved. # # Contributor(s): Myk Melez <myk@mozilla.org> #%] [%# Define strings that will serve as the title and header of this page %] [% title = BLOCK %]Edit Attachment #[% attachid %] for Bug #[% bugid %][% END %] [% h1 = BLOCK %]Edit Attachment #[% attachid %] for <a href="show_bug.cgi?id=[% bugid %]">Bug #[% bugid %]</a>[% END %] [% h2 = BLOCK %][% bugsummary FILTER html %][% END %] [% PROCESS global/header.html.tmpl title = title h1 = h1 h2 = h2 style = " table.attachment_info th { text-align: right; vertical-align: top; } table.attachment_info td { text-align: left; vertical-align: top; } #noview { text-align: left; vertical-align: center; } " %] <script type="application/x-javascript" language="JavaScript"> <!-- function editAsComment() { // Get the content of the document as a string. var viewFrame = document.getElementById('viewFrame'); var aSerializer = new XMLSerializer(); var contentDocument = viewFrame.contentDocument; var theContent = aSerializer.serializeToString(contentDocument); // If this is a plaintext document, remove cruft that Mozilla adds // because it treats it as an HTML document with a big PRE section. // http://bugzilla.mozilla.org/show_bug.cgi?id=86012 var contentType = '[% contenttype %]'; if ( contentType == 'text/plain' ) { theContent = theContent.replace( /^<html><head\/?><body><pre>/i , "" ); theContent = theContent.replace( /<\/pre><\/body><\/html>$/i , "" ); theContent = theContent.replace( /</gi , "<" ); theContent = theContent.replace( />/gi , ">" ); theContent = theContent.replace( /&/gi , "&" ); } // Add mail-style quote indicators (>) to the beginning of each line. // ".*\n" matches lines that end with a newline, while ".+" matches // the rare situation in which the last line of a file does not end // with a newline. theContent = theContent.replace( /(.*\n|.+)/g , ">$1" ); hideElementById('viewFrame'); hideElementById('editButton'); hideElementById('smallCommentFrame'); showElementById('undoEditButton'); // Show the TEXTAREA that will contain the editable attachment // and copy the content of the attachment into it. showElementById('editFrame'); var editFrame = document.getElementById('editFrame'); editFrame.value = theContent; editFrame.value += "\n\n"; } function undoEditAsComment() { // Hide the "edit attachment as comment" TEXTAREA and the "undo" button. hideElementById('undoEditButton'); hideElementById('editFrame'); // Show the "view attachment" IFRAME, the "redo" button that allows the user // to go back to editing the attachment as a comment, and the small comment field. showElementById('viewFrame'); showElementById('redoEditButton'); showElementById('smallCommentFrame'); } function redoEditAsComment() { // Hide the "view attachment" IFRAME, the "redo" button that allows the user // to go back to editing the attachment as a comment, and the small comment field. hideElementById('viewFrame'); hideElementById('redoEditButton'); hideElementById('smallCommentFrame'); // Show the "edit attachment as comment" TEXTAREA and the "undo" button. showElementById('undoEditButton'); showElementById('editFrame'); } function hideElementById(id) { var elm = document.getElementById(id); if (elm) { elm.style.display = 'none'; } } function showElementById(id, val) { var elm = document.getElementById(id); if (elm) { if (!val) val = 'inline'; elm.style.display = val; } } function normalizeComments() { // Remove the unused comment field from the document so its contents // do not get transmitted back to the server. var small = document.getElementById('smallCommentFrame'); var big = document.getElementById('editFrame'); if ( small.style.display == 'none' ) { small.parentNode.removeChild(small); } if ( big.style.display == 'none' ) { big.parentNode.removeChild(big); } } //--> </script> <form method="post" action="attachment.cgi" onsubmit="normalizeComments();"> <input type="hidden" name="id" value="[% attachid %]"> <input type="hidden" name="action" value="update"> <input type="hidden" name="contenttypemethod" value="manual"> <table class="attachment_info" width="100%"> <tr> <td width="25%"> <small> <b>Description:</b><br> <textarea rows="3" cols="25" name="description" wrap="soft">[% description FILTER html %]</textarea><br> <b>Filename:</b><br> <input type="text" size="20" name="filename" value="[% filename FILTER html %]"><br> <b>MIME Type:</b><br> <input type="text" size="20" name="contenttypeentry" value="[% contenttype FILTER html %]"><br> <b>Flags:</b><br> <input type="checkbox" id="ispatch" name="ispatch" value="1" [% 'checked="checked"' IF ispatch %]> <label for="ispatch">patch</label> <input type="checkbox" id="isobsolete" name="isobsolete" value="1" [% 'checked="checked"' IF isobsolete %]> <label for="isobsolete">obsolete</label><br> [% IF (Param("insidergroup") && UserInGroup(Param("insidergroup"))) %] <input type="checkbox" name="isprivate" value="1"[% " checked" IF isprivate %]> private<br><br> [% END %] [% IF statusdefs.size %] <b>Status:</b><br> [% FOREACH def = statusdefs %] <input type="checkbox" id="status-[% def.id %]" name="status" value="[% def.id %]" [% 'checked="checked"' IF statuses.${def.id} %]> <label for="status-[% def.id %]"> [% def.name FILTER html %] </label><br> [% END %] [% END %] <div id="smallCommentFrame"> <b>Comment (on the bug):</b><br> <textarea name="comment" rows="5" cols="25" wrap="soft"></textarea><br> </div> <input type="submit" value="Submit"> </small> </td> [% IF isviewable %] <td width="75%"> <textarea id="editFrame" name="comment" style="height: 400px; width: 100%; display: none;" cols="80" wrap="soft"></textarea> <iframe id="viewFrame" src="attachment.cgi?id=[% attachid %]&action=view" style="height: 400px; width: 100%;"> <b>You cannot view the attachment while editing it because your browser does not support IFRAMEs. <a href="attachment.cgi?id=[% attachid %]&action=view">View the attachment on a separate page</a>.</b> </iframe> <script type="application/x-javascript" language="JavaScript"> <!-- if (typeof document.getElementById == "function") { document.write('<button type="button" id="editButton" onclick="editAsComment();">Edit Attachment As Comment</button>'); document.write('<button type="button" id="undoEditButton" onclick="undoEditAsComment();" style="display: none;">Undo Edit As Comment</button>'); document.write('<button type="button" id="redoEditButton" onclick="redoEditAsComment();" style="display: none;">Redo Edit As Comment</button>'); } //--> </script> </td> [% ELSE %] <td id="noview" width="50%"> <p><b> Attachment cannot be viewed because its MIME type is not either text/*, image/*, or application/vnd.mozilla.*. <a href="attachment.cgi?id=[% attachid %]&action=view">Download the attachment instead</a>. </b></p> </td> [% END %] </tr> </table> Attachments on this Bug: [% FOREACH a = attachments %] [% IF a == attachid %] #[% a %] [% ELSE %] <a href="attachment.cgi?id=[% a %]&action=edit">#[% a %]</a> [% END %] [% " |" UNLESS loop.last() %] [% END %] </form> <br> [% PROCESS global/footer.html.tmpl %]