]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 647158: The Error Console in Firefox reports
authorFrédéric Buclin <LpSolit@gmail.com>
Tue, 26 Jul 2011 09:08:44 +0000 (11:08 +0200)
committerFrédéric Buclin <LpSolit@gmail.com>
Tue, 26 Jul 2011 09:08:44 +0000 (11:08 +0200)
"unbalanced tree was written using document.write()"
when reporting a new bug or when visiting the "User Authentication" panel in the Parameters page
r=glob a=LpSolit

js/attachment.js
template/en/default/admin/params/common.html.tmpl
template/en/default/admin/params/editparams.html.tmpl
template/en/default/bug/create/create.html.tmpl

index d759248cdfef5743477f1a82f961b99e2c468bde..9251a9b541ff16e5a3a716f5ec5e12cc2dc4c0d6 100644 (file)
@@ -312,7 +312,7 @@ function hideElementById(id)
   }
 }
 
-function showElementById(id, val)
+function showElementById(id)
 {
   var elm = document.getElementById(id);
   if (elm) {
@@ -348,3 +348,16 @@ function toggle_attachment_details_visibility ( )
     }
 }
 
+/* Used in bug/create.html.tmpl to show/hide the attachment field. */
+
+function handleWantsAttachment(wants_attachment) {
+    if (wants_attachment) {
+        hideElementById('attachment_false');
+        showElementById('attachment_true');
+    }
+    else {
+        showElementById('attachment_false');
+        hideElementById('attachment_true');
+        clearAttachmentFields();
+    }
+}
index 3ec38ca56de0df365b6efb158dd9b2e81f461255..d86da0dcdcb6cf9fc1adb73231aae793ee693dfd 100644 (file)
           [% END %]
         </select>
       [% ELSIF param.type == "o" %]
-        <script type="text/javascript"><!--
-          document.write("<span style=\"display: none\">");
-        // -->
-        </script>
         <input id="input_[% param.name FILTER html %]" size="80"
                name="[% param.name FILTER html %]"
                value="[% Param(param.name) FILTER html %]"><br>
-        <script type="text/javascript"><!--
-          document.write("<\/span>");
-        // -->
-        </script>
         [% boxSize = 7 %]
         [% boxSize = 3 + param.choices.size IF param.choices.size < 7 %]
         [% plist = Param(param.name).split(',') %]
 
-        <script type="text/javascript"><!--
-          document.write(
-            '<table>' +
-            '  <tr>' +
-            '    <td rowspan="2">' +
-            '      <select id="select_[% param.name FILTER html %]"' +
-            '              size="[% boxSize FILTER html %]"' +
-            '              name="select_[% param.name FILTER html %]">' +
-                     [% FOREACH item = plist %]
-            '          <option value="[% item FILTER html %]">[% item FILTER html %]<\/option>' +
-                     [% END %]
-            '        <option class="sortlist_separator"' +
-            '                disabled="disabled"' +
-            '                value="[% sortlist_separator %]">active&uarr;&nbsp;&darr;inactive<\/option>' +
-                     [% FOREACH item = param.choices %]
-                       [% IF lsearch(plist, item) == -1 %]
-            '            <option value="[% item FILTER html %]">[% item FILTER html %]<\/option>' +
-                       [% END %]
-                     [% END %]
-            '      <\/select>' +
-            '    <\/td>' +
-            '    <td style="vertical-align: bottom">' +
-            '      <button type="button"' +
-            '              onClick="sortedList_moveItem(\'[% param.name FILTER html %]\', -1, \'[% sortlist_separator %]\');">&uarr;<\/button>' +
-            '    <\/td>' +
-            '  <\/tr>' +
-            '  <tr>' +
-            '    <td style="vertical-align: top">' +
-            '      <button type="button"' +
-            '              onClick="sortedList_moveItem(\'[% param.name FILTER html %]\', +1, \'[% sortlist_separator %]\');">&darr;<\/button>' +
-            '    <\/td>' +
-            '  <\/tr>' +
-            '<\/table>');
-        // -->
+        <table id="table_[% param.name FILTER html %]" class="bz_default_hidden">
+          <tr>
+            <td rowspan="2">
+              <select id="select_[% param.name FILTER html %]"
+                      name="select_[% param.name FILTER html %]"
+                      size="[% boxSize FILTER html %]">
+                [% FOREACH item = plist %]
+                  <option value="[% item FILTER html %]">[% item FILTER html %]</option>
+                [% END %]
+                <option class="sortlist_separator" disabled="disabled"
+                        value="[% sortlist_separator %]">active&uarr;&nbsp;&darr;inactive</option>
+                [% FOREACH item = param.choices %]
+                  [% IF lsearch(plist, item) == -1 %]
+                    <option value="[% item FILTER html %]">[% item FILTER html %]</option>
+                  [% END %]
+                [% END %]
+              </select>
+            </td>
+            <td style="vertical-align: bottom">
+              <button type="button"
+                      onClick="sortedList_moveItem('[% param.name FILTER html %]', -1, '[% sortlist_separator %]');">&uarr;</button>
+            </td>
+          </tr>
+
+          <tr>
+            <td style="vertical-align: top">
+              <button type="button"
+                      onClick="sortedList_moveItem('[% param.name FILTER html %]', +1, '[% sortlist_separator %]');">&darr;</button>
+            </td>
+          </tr>
+        </table>
+
+        <script type="text/javascript">
+            bz_toggleClass("input_[% param.name FILTER html %]", "bz_default_hidden");
+            bz_toggleClass("table_[% param.name FILTER html %]", "bz_default_hidden");
         </script>
       [% ELSIF param.type == "s" %]
         <select name="[% param.name FILTER html %]" id="[% param.name FILTER html %]">
index 21fa9fa416b6728134f0daada546ed31ceeec4a7..8d6a98741dc69c5337f7df3dfe4dee04a16a7953 100644 (file)
@@ -56,7 +56,7 @@
    title = title
    message = message
    style_urls = ['skins/standard/params.css']
-   javascript_urls = ['js/params.js']
+   javascript_urls = ['js/params.js', 'js/util.js']
    doc_section = "parameters.html"
 %]
 
index 26e37a2d0e8bd61258b0ad7d1d22895eca59feb7..8e01e927510754839df22ca90050817909334b39 100644 (file)
@@ -35,7 +35,8 @@
                  'skins/standard/enter_bug.css' ]
   javascript_urls = [ "js/attachment.js", "js/util.js",
                       "js/field.js", "js/TUI.js", "js/bug.js" ]
-  onload = 'set_assign_to();'
+  onload = "set_assign_to(); hideElementById('attachment_true');
+            showElementById('attachment_false'); showElementById('btn_no_attachment');"
 %]
 
 <script type="text/javascript">
@@ -149,18 +150,6 @@ function set_assign_to() {
     }
 }
 
-function handleWantsAttachment(wants_attachment) {
-    if (wants_attachment) {
-        document.getElementById('attachment_false').style.display = 'none';
-        document.getElementById('attachment_true').style.display = 'block';
-    }
-    else {
-        document.getElementById('attachment_false').style.display = 'block';
-        document.getElementById('attachment_true').style.display = 'none';
-        clearAttachmentFields();
-    }
-}
-
 var status_comment_required = new Array();
 [% FOREACH status = bug_status %]
   status_comment_required['[% status.name FILTER js %]'] = 
@@ -601,21 +590,13 @@ TUI_hide_default('expert_fields');
   <tr>
     <th>Attachment:</th>
     <td colspan="3">
-      <script type="text/javascript">
-        <!--
-        document.write( '<div id="attachment_false">'
-                      +   '<input type="button" value="Add an attachment" '
-                      +          'onClick="handleWantsAttachment(true)"> '
-                      +   '<em style="display: none">This button has no '
-                      +   'functionality for you because your browser does '
-                      +   'not support CSS or does not use it.<\/em>'
-                      + '<\/div>'
-                      + '<div id="attachment_true" style="display: none">'
-                      +   '<input type="button" '
-                      +          'value="Don\'t add an attachment " '
-                      +          'onClick="handleWantsAttachment(false)">');
-        //-->
-      </script>
+      <div id="attachment_false" class="bz_default_hidden">
+        <input type="button" value="Add an attachment" onClick="handleWantsAttachment(true)">
+      </div>
+
+      <div id="attachment_true">
+        <input type="button" id="btn_no_attachment" value="Don't add an attachment"
+               class="bz_default_hidden"  onClick="handleWantsAttachment(false)">
         <fieldset>
           <legend>Add an attachment</legend>
           <table class="attachment_entry">
@@ -625,11 +606,7 @@ TUI_hide_default('expert_fields');
                        flag_table_id ="attachment_flags" %]
           </table>
         </fieldset>
-      <script type="text/javascript">
-        <!--
-        document.write('<\/div>');
-        //-->
-      </script>
+      </div>
     </td>
   </tr>
   [% END %]