]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 460754: Move JS code out of attachment/diff-header.html.tmpl - Patch by FrédÃ...
authorlpsolit%gmail.com <>
Tue, 21 Oct 2008 21:41:02 +0000 (21:41 +0000)
committerlpsolit%gmail.com <>
Tue, 21 Oct 2008 21:41:02 +0000 (21:41 +0000)
js/attachment.js
template/en/default/attachment/diff-header.html.tmpl
template/en/default/filterexceptions.pl

index eb42ba49208f296b792e9c5851c400f3caa1d955..c05d1d3ea609e9c30fad02f212e80eb5356f41d6 100644 (file)
@@ -104,3 +104,102 @@ function clearAttachmentFields() {
     if ((element = document.getElementById('isprivate')))
         element.checked = '';
 }
+
+/* Functions used when viewing patches in Diff mode. */
+
+function collapse_all() {
+  var elem = document.checkboxform.firstChild;
+  while (elem != null) {
+    if (elem.firstChild != null) {
+      var tbody = elem.firstChild.nextSibling;
+      if (tbody.className == 'file') {
+        tbody.className = 'file_collapse';
+        twisty = get_twisty_from_tbody(tbody);
+        twisty.firstChild.nodeValue = '(+)';
+        twisty.nextSibling.checked = false;
+      }
+    }
+    elem = elem.nextSibling;
+  }
+  return false;
+}
+
+function expand_all() {
+  var elem = document.checkboxform.firstChild;
+  while (elem != null) {
+    if (elem.firstChild != null) {
+      var tbody = elem.firstChild.nextSibling;
+      if (tbody.className == 'file_collapse') {
+        tbody.className = 'file';
+        twisty = get_twisty_from_tbody(tbody);
+        twisty.firstChild.nodeValue = '(-)';
+        twisty.nextSibling.checked = true;
+      }
+    }
+    elem = elem.nextSibling;
+  }
+  return false;
+}
+
+var current_restore_elem;
+
+function restore_all() {
+  current_restore_elem = null;
+  incremental_restore();
+}
+
+function incremental_restore() {
+  if (!document.checkboxform.restore_indicator.checked) {
+    return;
+  }
+  var next_restore_elem;
+  if (current_restore_elem) {
+    next_restore_elem = current_restore_elem.nextSibling;
+  } else {
+    next_restore_elem = document.checkboxform.firstChild;
+  }
+  while (next_restore_elem != null) {
+    current_restore_elem = next_restore_elem;
+    if (current_restore_elem.firstChild != null) {
+      restore_elem(current_restore_elem.firstChild.nextSibling);
+    }
+    next_restore_elem = current_restore_elem.nextSibling;
+  }
+}
+
+function restore_elem(elem, alertme) {
+  if (elem.className == 'file_collapse') {
+    twisty = get_twisty_from_tbody(elem);
+    if (twisty.nextSibling.checked) {
+      elem.className = 'file';
+      twisty.firstChild.nodeValue = '(-)';
+    }
+  } else if (elem.className == 'file') {
+    twisty = get_twisty_from_tbody(elem);
+    if (!twisty.nextSibling.checked) {
+      elem.className = 'file_collapse';
+      twisty.firstChild.nodeValue = '(+)';
+    }
+  }
+}
+
+function twisty_click(twisty) {
+  tbody = get_tbody_from_twisty(twisty);
+  if (tbody.className == 'file') {
+    tbody.className = 'file_collapse';
+    twisty.firstChild.nodeValue = '(+)';
+    twisty.nextSibling.checked = false;
+  } else {
+    tbody.className = 'file';
+    twisty.firstChild.nodeValue = '(-)';
+    twisty.nextSibling.checked = true;
+  }
+  return false;
+}
+
+function get_tbody_from_twisty(twisty) {
+  return twisty.parentNode.parentNode.parentNode.nextSibling;
+}
+function get_twisty_from_tbody(tbody) {
+  return tbody.previousSibling.firstChild.nextSibling.firstChild.firstChild;
+}
index c6b14d9a062123e0b4c24466b6b413cc5f5afc75..0bf88d3d9753f189d11b0f29b35374f229e0e00d 100644 (file)
@@ -100,106 +100,6 @@ tbody.file pre:empty {
 }
 [% END %]
 
-[%# SCRIPT FUNCTIONS %]
-[% javascript = BLOCK %]
-  function collapse_all() {
-    var elem = document.checkboxform.firstChild;
-    while (elem != null) {
-      if (elem.firstChild != null) {
-        var tbody = elem.firstChild.nextSibling;
-        if (tbody.className == 'file') {
-          tbody.className = 'file_collapse';
-          twisty = get_twisty_from_tbody(tbody);
-          twisty.firstChild.nodeValue = '(+)';
-          twisty.nextSibling.checked = false;
-        }
-      }
-      elem = elem.nextSibling;
-    }
-    return false;
-  }
-
-  function expand_all() {
-    var elem = document.checkboxform.firstChild;
-    while (elem != null) {
-      if (elem.firstChild != null) {
-        var tbody = elem.firstChild.nextSibling;
-        if (tbody.className == 'file_collapse') {
-          tbody.className = 'file';
-          twisty = get_twisty_from_tbody(tbody);
-          twisty.firstChild.nodeValue = '(-)';
-          twisty.nextSibling.checked = true;
-        }
-      }
-      elem = elem.nextSibling;
-    }
-    return false;
-  }
-
-  var current_restore_elem;
-
-  function restore_all() {
-    current_restore_elem = null;
-    incremental_restore();
-  }
-
-  function incremental_restore() {
-    if (!document.checkboxform.restore_indicator.checked) {
-      return;
-    }
-    var next_restore_elem;
-    if (current_restore_elem) {
-      next_restore_elem = current_restore_elem.nextSibling;
-    } else {
-      next_restore_elem = document.checkboxform.firstChild;
-    }
-    while (next_restore_elem != null) {
-      current_restore_elem = next_restore_elem;
-      if (current_restore_elem.firstChild != null) {
-        restore_elem(current_restore_elem.firstChild.nextSibling);
-      }
-      next_restore_elem = current_restore_elem.nextSibling;
-    }
-  }
-
-  function restore_elem(elem, alertme) {
-    if (elem.className == 'file_collapse') {
-      twisty = get_twisty_from_tbody(elem);
-      if (twisty.nextSibling.checked) {
-        elem.className = 'file';
-        twisty.firstChild.nodeValue = '(-)';
-      }
-    } else if (elem.className == 'file') {
-      twisty = get_twisty_from_tbody(elem);
-      if (!twisty.nextSibling.checked) {
-        elem.className = 'file_collapse';
-        twisty.firstChild.nodeValue = '(+)';
-      }
-    }
-  }
-
-  function twisty_click(twisty) {
-    tbody = get_tbody_from_twisty(twisty);
-    if (tbody.className == 'file') {
-      tbody.className = 'file_collapse';
-      twisty.firstChild.nodeValue = '(+)';
-      twisty.nextSibling.checked = false;
-    } else {
-      tbody.className = 'file';
-      twisty.firstChild.nodeValue = '(-)';
-      twisty.nextSibling.checked = true;
-    }
-    return false;
-  }
-
-  function get_tbody_from_twisty(twisty) {
-    return twisty.parentNode.parentNode.parentNode.nextSibling;
-  }
-  function get_twisty_from_tbody(tbody) {
-    return tbody.previousSibling.firstChild.nextSibling.firstChild.firstChild;
-  }
-[% END %]
-
 [% onload = 'restore_all(); document.checkboxform.restore_indicator.checked = true' %]
 
 [% BLOCK viewurl %]attachment.cgi?id=[% id %][% END %]
@@ -221,18 +121,15 @@ tbody.file pre:empty {
   [% subheader = BLOCK %]
     [% bugsummary FILTER html %]
   [% END %]
-  [% PROCESS global/header.html.tmpl doc_section = "attachments.html#patchviewer" %]
+  [% PROCESS global/header.html.tmpl doc_section = "attachments.html#patchviewer"
+                                     javascript_urls = "js/attachment.js" %]
 [% ELSE %]
   <html>
   <head>
   <style type="text/css">
   [% style %]
   </style>
-  <script type="text/javascript">
-  <!--
-  [% javascript %]
-  -->
-  </script>
+  <script src="js/attachment.js" type="text/javascript"></script>
   </head>
   <body onload="[% onload FILTER html %]">
 [% END %]
index 2509ff5c2d8e130dce10ffe81f9d2f4e3208198b..2929bbf22f056742ca688c8c5d9024dfadbc06b6 100644 (file)
   'oldid',
   'newid',
   'style',
-  'javascript',
   'patch.id',
 ],