summaryrefslogtreecommitdiffstats
path: root/js
diff options
context:
space:
mode:
authorlpsolit%gmail.com <>2008-10-21 23:41:02 +0200
committerlpsolit%gmail.com <>2008-10-21 23:41:02 +0200
commitafa6ca704ab8002ec12ff5ae8b5d20b4ad64046a (patch)
tree2b08bb42188727b5a843f833951c05c2d841a19b /js
parent06d09afdbf093d8ea2bee1bd7b0c13647651bf58 (diff)
downloadbugzilla-afa6ca704ab8002ec12ff5ae8b5d20b4ad64046a.tar.gz
bugzilla-afa6ca704ab8002ec12ff5ae8b5d20b4ad64046a.tar.xz
Bug 460754: Move JS code out of attachment/diff-header.html.tmpl - Patch by Frédéric Buclin <LpSolit@gmail.com> r=wicked a=LpSolit
Diffstat (limited to 'js')
-rw-r--r--js/attachment.js99
1 files changed, 99 insertions, 0 deletions
diff --git a/js/attachment.js b/js/attachment.js
index eb42ba492..c05d1d3ea 100644
--- a/js/attachment.js
+++ b/js/attachment.js
@@ -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;
+}