~ubuntu-branches/ubuntu/intrepid/bugzilla/intrepid

« back to all changes in this revision

Viewing changes to template/en/default/attachment/edit.html.tmpl

  • Committer: Bazaar Package Importer
  • Author(s): Raphael Bossek
  • Date: 2008-06-27 22:34:34 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20080627223434-0ib57vstn43bb4a3
Tags: 3.0.4.1-1
* Update of French, Russian and German translations. (closes: #488251)
* Added Bulgarian and Belarusian translations.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
[%# 1.0@bugzilla.org %]
2
 
[%# The contents of this file are subject to the Mozilla Public
3
 
  # License Version 1.1 (the "License"); you may not use this file
4
 
  # except in compliance with the License. You may obtain a copy of
5
 
  # the License at http://www.mozilla.org/MPL/
6
 
  #
7
 
  # Software distributed under the License is distributed on an "AS
8
 
  # IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
9
 
  # implied. See the License for the specific language governing
10
 
  # rights and limitations under the License.
11
 
  #
12
 
  # The Original Code is the Bugzilla Bug Tracking System.
13
 
  #
14
 
  # The Initial Developer of the Original Code is Netscape Communications
15
 
  # Corporation. Portions created by Netscape are
16
 
  # Copyright (C) 1998 Netscape Communications Corporation. All
17
 
  # Rights Reserved.
18
 
  #
19
 
  # Contributor(s): Myk Melez <myk@mozilla.org>
20
 
  #                 Frédéric Buclin <LpSolit@gmail.com>
21
 
  #%]
22
 
 
23
 
[% PROCESS global/variables.none.tmpl %]
24
 
 
25
 
[%# Define strings that will serve as the title and header of this page %]
26
 
[% title = BLOCK %]
27
 
  Attachment [% attachment.id %] Details for [% terms.Bug %] [%+ attachment.bug_id %]
28
 
[% END %]
29
 
[% header = BLOCK %]
30
 
  Attachment [% attachment.id %] Details for
31
 
  [%+ "$terms.Bug ${attachment.bug_id}" FILTER bug_link(attachment.bug_id) FILTER none %]
32
 
[% END %]
33
 
[% subheader = BLOCK %][% bugsummary FILTER html %][% END %]
34
 
 
35
 
[% PROCESS global/header.html.tmpl
36
 
  title = title
37
 
  header = header
38
 
  subheader = subheader
39
 
%]
40
 
 
41
 
<script type="text/javascript">
42
 
  <!--
43
 
  var prev_mode = 'raw';
44
 
  var current_mode = 'raw';
45
 
  var has_edited = 0;
46
 
  var has_viewed_as_diff = 0;
47
 
  function editAsComment()
48
 
    {
49
 
      // Get the content of the document as a string.
50
 
      var viewFrame = document.getElementById('viewFrame');
51
 
      var aSerializer = new XMLSerializer();
52
 
      var contentDocument = viewFrame.contentDocument;
53
 
      var theContent = aSerializer.serializeToString(contentDocument);
54
 
 
55
 
      // If this is a plaintext document, remove cruft that Mozilla adds
56
 
      // because it treats it as an HTML document with a big PRE section.
57
 
      // http://bugzilla.mozilla.org/show_bug.cgi?id=86012
58
 
      var contentType = '[% attachment.contenttype FILTER js %]';
59
 
      if ( contentType == 'text/plain' )
60
 
        {
61
 
          theContent = theContent.replace( /^<html><head\/?><body><pre>/i , "" );
62
 
          theContent = theContent.replace( /<\/pre><\/body><\/html>$/i , "" );
63
 
          theContent = theContent.replace( /&lt;/gi , "<" );
64
 
          theContent = theContent.replace( /&gt;/gi , ">" );
65
 
          theContent = theContent.replace( /&amp;/gi , "&" );
66
 
        }
67
 
 
68
 
      // Add mail-style quote indicators (>) to the beginning of each line.
69
 
      // ".*\n" matches lines that end with a newline, while ".+" matches
70
 
      // the rare situation in which the last line of a file does not end
71
 
      // with a newline.
72
 
      theContent = theContent.replace( /(.*\n|.+)/g , ">$1" );
73
 
 
74
 
      switchToMode('edit');
75
 
 
76
 
      // Copy the contents of the diff into the textarea
77
 
      var editFrame = document.getElementById('editFrame');
78
 
      editFrame.value = theContent + "\n\n";
79
 
 
80
 
      has_edited = 1;
81
 
    }
82
 
  function undoEditAsComment()
83
 
    {
84
 
      switchToMode(prev_mode);
85
 
    }
86
 
  function redoEditAsComment()
87
 
    {
88
 
      switchToMode('edit');
89
 
    }
90
 
[% IF patchviewerinstalled %]
91
 
  function viewDiff()
92
 
    {
93
 
      switchToMode('diff');
94
 
 
95
 
      // If we have not viewed as diff before, set the view diff frame URL
96
 
      if (!has_viewed_as_diff) {
97
 
        var viewDiffFrame = document.getElementById('viewDiffFrame');
98
 
        viewDiffFrame.src =
99
 
            'attachment.cgi?id=[% attachment.id %]&action=diff&headers=0';
100
 
        has_viewed_as_diff = 1;
101
 
      }
102
 
    }
103
 
[% END %]
104
 
  function viewRaw()
105
 
    {
106
 
      switchToMode('raw');
107
 
    }
108
 
 
109
 
  function switchToMode(mode)
110
 
    {
111
 
      if (mode == current_mode) {
112
 
        alert('switched to same mode!  This should not happen.');
113
 
        return;
114
 
      }
115
 
 
116
 
      // Switch out of current mode
117
 
      if (current_mode == 'edit') {
118
 
        hideElementById('editFrame');
119
 
        hideElementById('undoEditButton');
120
 
      } else if (current_mode == 'raw') {
121
 
        hideElementById('viewFrame');
122
 
[% IF patchviewerinstalled %]
123
 
        hideElementById('viewDiffButton');
124
 
[% END %]
125
 
        hideElementById(has_edited ? 'redoEditButton' : 'editButton');
126
 
        hideElementById('smallCommentFrame');
127
 
      } else if (current_mode == 'diff') {
128
 
[% IF patchviewerinstalled %]
129
 
        hideElementById('viewDiffFrame');
130
 
[% END %]
131
 
        hideElementById('viewRawButton');
132
 
        hideElementById(has_edited ? 'redoEditButton' : 'editButton');
133
 
        hideElementById('smallCommentFrame');
134
 
      }
135
 
 
136
 
      // Switch into new mode
137
 
      if (mode == 'edit') {
138
 
        showElementById('editFrame');
139
 
        showElementById('undoEditButton');
140
 
      } else if (mode == 'raw') {
141
 
        showElementById('viewFrame');
142
 
[% IF patchviewerinstalled %]
143
 
        showElementById('viewDiffButton');
144
 
[% END %]
145
 
        showElementById(has_edited ? 'redoEditButton' : 'editButton');
146
 
        showElementById('smallCommentFrame');
147
 
      } else if (mode == 'diff') {
148
 
[% IF patchviewerinstalled %]
149
 
        showElementById('viewDiffFrame');
150
 
[% END %]
151
 
        showElementById('viewRawButton');
152
 
        showElementById(has_edited ? 'redoEditButton' : 'editButton');
153
 
        showElementById('smallCommentFrame');
154
 
      }
155
 
 
156
 
      prev_mode = current_mode;
157
 
      current_mode = mode;
158
 
    }
159
 
 
160
 
  function hideElementById(id)
161
 
  {
162
 
    var elm = document.getElementById(id);
163
 
    if (elm) {
164
 
      elm.style.display = 'none';
165
 
    }
166
 
  }
167
 
 
168
 
  function showElementById(id, val)
169
 
  {
170
 
    var elm = document.getElementById(id);
171
 
    if (elm) {
172
 
      if (!val) val = 'inline';
173
 
      elm.style.display = val;
174
 
    }
175
 
  }
176
 
 
177
 
  function normalizeComments()
178
 
  {
179
 
    // Remove the unused comment field from the document so its contents
180
 
    // do not get transmitted back to the server.
181
 
 
182
 
    var small = document.getElementById('smallCommentFrame');
183
 
    var big = document.getElementById('editFrame');
184
 
    if ( (small) && (small.style.display == 'none') )
185
 
    {
186
 
      small.parentNode.removeChild(small);
187
 
    }
188
 
    if ( (big) && (big.style.display == 'none') )
189
 
    {
190
 
      big.parentNode.removeChild(big);
191
 
    }
192
 
  }
193
 
  //-->
194
 
</script>
195
 
 
196
 
<form method="post" action="attachment.cgi" onsubmit="normalizeComments();">
197
 
  <input type="hidden" name="id" value="[% attachment.id %]">
198
 
  <input type="hidden" name="action" value="update">
199
 
  <input type="hidden" name="contenttypemethod" value="manual">
200
 
 
201
 
  <table class="attachment_info" width="100%">
202
 
 
203
 
    <tr>
204
 
      <td width="25%">
205
 
        <small>
206
 
        <b><label for="description">Description</label>:</b><br>
207
 
          [% INCLUDE global/textarea.html.tmpl
208
 
            id             = 'description'
209
 
            name           = 'description'
210
 
            minrows        = 3
211
 
            cols           = 25
212
 
            wrap           = 'soft'
213
 
            defaultcontent = attachment.description
214
 
          %]<br>
215
 
 
216
 
        [% IF attachment.isurl %]
217
 
            <input type="hidden" name="filename"
218
 
                   value="[% attachment.filename FILTER html %]">
219
 
            <input type="hidden" name="contenttypeentry"
220
 
                   value="[% attachment.contenttype FILTER html %]">
221
 
        [% ELSE %]
222
 
          <b><label for="filename">Filename</label>:</b><br>
223
 
            <input type="text" size="20" id="filename" name="filename"
224
 
                   value="[% attachment.filename FILTER html %]"><br>
225
 
          <b>Size:</b>
226
 
          [% IF attachment.datasize %]
227
 
            [%+ attachment.datasize FILTER unitconvert %]
228
 
          [% ELSE %]
229
 
            <em>deleted</em>
230
 
          [% END %]<br>
231
 
 
232
 
          <b><label for="contenttypeentry">MIME Type</label>:</b><br>
233
 
            <input type="text" size="20"
234
 
                   id="contenttypeentry" name="contenttypeentry"
235
 
                   value="[% attachment.contenttype FILTER html %]"><br>
236
 
 
237
 
          <input type="checkbox" id="ispatch" name="ispatch" value="1"
238
 
                 [% 'checked="checked"' IF attachment.ispatch %]>
239
 
          <label for="ispatch">patch</label>
240
 
        [% END %]
241
 
          <input type="checkbox" id="isobsolete" name="isobsolete" value="1"
242
 
                 [% 'checked="checked"' IF attachment.isobsolete %]>
243
 
          <label for="isobsolete">obsolete</label>
244
 
          [% IF (Param("insidergroup") && user.in_group(Param("insidergroup"))) %]
245
 
            <input type="checkbox" id="isprivate" name="isprivate" value="1"
246
 
                   [% " checked" IF attachment.isprivate %]>
247
 
            <label for="isprivate">private</label><br>
248
 
          [% END %]
249
 
          <br>
250
 
        </small>
251
 
 
252
 
        [% IF flag_types.size > 0 %]
253
 
          [% PROCESS "flag/list.html.tmpl" bug_id = attachment.bug_id
254
 
                                           attach_id = attachment.id %]<br>
255
 
        [% END %]
256
 
 
257
 
        <div id="smallCommentFrame">
258
 
          <b><small><label for="comment">Comment</label> (on the
259
 
          [%+ terms.bug %]):</small></b><br>
260
 
            [% INCLUDE global/textarea.html.tmpl
261
 
              id      = 'comment'
262
 
              name    = 'comment'
263
 
              minrows = 5
264
 
              cols    = 25
265
 
              wrap    = 'soft'
266
 
            %]<br>
267
 
        </div>
268
 
 
269
 
        <input type="submit" value="Submit" id="update"><br><br>
270
 
        <strong>Actions:</strong>
271
 
        <a href="attachment.cgi?id=[% attachment.id %]">View</a>
272
 
        [% IF attachment.ispatch && patchviewerinstalled %]
273
 
         | <a href="attachment.cgi?id=[% attachment.id %]&amp;action=diff">Diff</a>
274
 
        [% END %]
275
 
        [% IF Param("allow_attachment_deletion")
276
 
              && user.groups.admin
277
 
              && attachment.datasize > 0 %]
278
 
          | <a href="attachment.cgi?id=[% attachment.id %]&amp;action=delete">Delete</a>
279
 
        [% END %]
280
 
      </td>
281
 
 
282
 
      [% IF !attachment.datasize %]
283
 
        <td width="75%"><b>The content of this attachment has been deleted.</b></td>
284
 
      [% ELSIF isviewable %]
285
 
        <td width="75%">
286
 
          [% INCLUDE global/textarea.html.tmpl
287
 
            id      = 'editFrame'
288
 
            name    = 'comment'
289
 
            style   = 'height: 400px; width: 100%; display: none'
290
 
            minrows = 10
291
 
            cols    = 80
292
 
            wrap    = 'soft'
293
 
          %]
294
 
          <iframe id="viewFrame" src="attachment.cgi?id=[% attachment.id %]" style="height: 400px; width: 100%;">
295
 
            <b>You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
296
 
            <a href="attachment.cgi?id=[% attachment.id %]">View the attachment on a separate page</a>.</b>
297
 
          </iframe>
298
 
          <script type="text/javascript">
299
 
            <!--
300
 
            if (typeof document.getElementById == "function") {
301
 
[% IF patchviewerinstalled %]
302
 
              document.write('<iframe id="viewDiffFrame" style="height: 400px; width: 100%; display: none;"><\/iframe>');
303
 
[% END %]
304
 
              document.write('<button type="button" id="editButton" onclick="editAsComment();">Edit Attachment As Comment<\/button>');
305
 
              document.write('<button type="button" id="undoEditButton" onclick="undoEditAsComment();" style="display: none;">Undo Edit As Comment<\/button>');
306
 
              document.write('<button type="button" id="redoEditButton" onclick="redoEditAsComment();" style="display: none;">Redo Edit As Comment<\/button>');
307
 
[% IF patchviewerinstalled %]
308
 
              document.write('<button type="button" id="viewDiffButton" onclick="viewDiff();">View Attachment As Diff<\/button>');
309
 
[% END %]
310
 
              document.write('<button type="button" id="viewRawButton" onclick="viewRaw();" style="display: none;">View Attachment As Raw<\/button>');
311
 
            }
312
 
            //-->
313
 
          </script>
314
 
        </td>
315
 
      [% ELSIF attachment.isurl %]
316
 
        <td width="75%">
317
 
          <a href="[% attachment.data FILTER html %]">
318
 
            [% IF attachment.datasize < 120 %]
319
 
              [% attachment.data FILTER html %]
320
 
            [% ELSE %]
321
 
              [% attachment.data FILTER truncate(80) FILTER html %]
322
 
              &nbsp;...
323
 
              [% attachment.data.match(".*(.{20})$").0 FILTER html %]
324
 
            [% END %]
325
 
          </a>
326
 
        </td>
327
 
      [% ELSE %]
328
 
        <td id="noview" width="50%">
329
 
          <p><b>
330
 
            Attachment is not viewable in your browser because its MIME type 
331
 
            ([% attachment.contenttype FILTER html %]) is not one that your browser is 
332
 
            able to display.
333
 
          </b></p>
334
 
          <p><b>
335
 
            <a href="attachment.cgi?id=[% attachment.id %]">Download the attachment</a>.
336
 
          </b></p>
337
 
        </td>
338
 
      [% END %]
339
 
 
340
 
    </tr>
341
 
 
342
 
  </table>
343
 
 
344
 
  Attachments on this [% terms.Bug %]:
345
 
  [% FOREACH a = attachments %]
346
 
    [% IF a == attachment.id %]
347
 
      [%+ a %]
348
 
    [% ELSE %]
349
 
      <a href="attachment.cgi?id=[% a %]&amp;action=edit">[% a %]</a>
350
 
    [% END %]
351
 
    [% " |" UNLESS loop.last() %]
352
 
  [% END %]
353
 
 
354
 
</form>
355
 
 
356
 
<br>
357
 
 
358
 
[% PROCESS global/footer.html.tmpl %]