From 4a211fb5f7aab55aab4511c2d65751d4b296ca8e Mon Sep 17 00:00:00 2001
From: deuce <>
Date: Sun, 16 Nov 2008 08:36:20 +0000
Subject: [PATCH] Make quotes in HTML view collapsible and default to
 collapsed.

---
 web/root/sajax-forum/body.xjs             | 17 ++++++++++-------
 web/root/sajax-forum/client_functions.xjs | 19 +++++++++++++++++++
 web/root/sajax-forum/style.css            | 17 ++++++++++++++++-
 3 files changed, 45 insertions(+), 8 deletions(-)

diff --git a/web/root/sajax-forum/body.xjs b/web/root/sajax-forum/body.xjs
index d6b7394072..e1dfedda20 100644
--- a/web/root/sajax-forum/body.xjs
+++ b/web/root/sajax-forum/body.xjs
@@ -52,6 +52,9 @@ if(ANSI_formatted) {
 	}
 }
 else {
+	var blockquote_start='<div class="quote"><a href="#" onclick="toggle_quote(this);return false">Show quote</a><blockquote style="display: none">';
+	var blockquote_end='</blockquote></div>';
+
 	writeln("<div class=\"ansi_toggle\"><a href=\"#\" onclick=\"load_ansi(this.parentNode.parentNode, "+html_sub_code_string+");return false\">ANSI Mode</a></div>");
 	// Strip CTRL-A
 	body=body.replace(/\1./g,'');
@@ -87,7 +90,7 @@ else {
 			// If the new length is smaller than the old one, close the extras
 			for(p=new_prefixes.length; p<prefixes.length; p++) {
 				if(quote_depth > 0) {
-					line_prefix = line_prefix + '</blockquote>';
+					line_prefix = line_prefix + blockquote_end;
 					quote_depth--;
 				}
 				else {
@@ -100,11 +103,11 @@ else {
 
 				if(prefixes[p]==undefined) {
 					/* New depth */
-					line_prefix = line_prefix + '<blockquote>';
+					line_prefix = line_prefix + blockquote_start;
 					quote_depth++;
 				}
 				else if(broken) {
-					line_prefix = line_prefix + '<blockquote>';
+					line_prefix = line_prefix + blockquote_start;
 					quote_depth++;
 				}
 				else if(prefixes[p].replace(/^\s*(.*?)\s*$/,"$1") != new_prefixes[p].replace(/^\s*(.*?)\s*$/,"$1")) {
@@ -112,14 +115,14 @@ else {
 					var o;
 					for(o=p; o<prefixes.length && o<new_prefixes.length; o++) {
 						if(quote_depth > 0) {
-							line_prefix = '</blockquote>'+line_prefix;
+							line_prefix = blockquote_end+line_prefix;
 							quote_depth--;
 						}
 						else {
 							log("BODY: Depth problem 2");
 						}
 					}
-					line_prefix = '<blockquote>'+line_prefix;
+					line_prefix = blockquote_start+line_prefix;
 					quote_depth++;
 					broken=true;
 				}
@@ -130,7 +133,7 @@ else {
 		else {
 			for(p=0; p<prefixes.length; p++) {
 				if(quote_depth > 0) {
-					line_prefix = line_prefix + '</blockquote>';
+					line_prefix = line_prefix + blockquote_end;
 					quote_depth--;
 				}
 				else {
@@ -145,7 +148,7 @@ else {
 	if(quote_depth != 0) {
 		log("BODY: Depth problem 4");
 		for(;quote_depth > 0; quote_depth--) {
-			body += "</blockquote>";
+			body += blockquote_end;
 		}
 	}
 
diff --git a/web/root/sajax-forum/client_functions.xjs b/web/root/sajax-forum/client_functions.xjs
index 3db9d339b1..3b727b8d0d 100644
--- a/web/root/sajax-forum/client_functions.xjs
+++ b/web/root/sajax-forum/client_functions.xjs
@@ -91,6 +91,25 @@ function toggle_replies(sub_code, message_number)
 	}
 }
 
+function toggle_quote(container)
+{
+	for(child in container.parentNode.childNodes) {
+		if(container.parentNode.childNodes[child].nodeName=='BLOCKQUOTE') {
+			switch(container.parentNode.childNodes[child].style.display) {
+			case 'none':
+				container.parentNode.childNodes[child].style.display='block';
+				container.innerHTML="Hide quote";
+				break;
+			default:
+				container.parentNode.childNodes[child].style.display='none';
+				container.innerHTML="Show quote";
+				break;
+			}
+			break;
+		}
+	}
+}
+
 function load_ansi(container, sub_code)
 {
 	var message=container.parentNode.parentNode;
diff --git a/web/root/sajax-forum/style.css b/web/root/sajax-forum/style.css
index 6b3d73d842..aa5ee45821 100644
--- a/web/root/sajax-forum/style.css
+++ b/web/root/sajax-forum/style.css
@@ -93,8 +93,23 @@ body {
 	background-color: #999;
 }
 
-blockquote {
+.ansi_toggle {
+}
+
+.quote {
+}
+
+.quote a {
+	font-size: 25%;
+	margin: 0px;
+	margin-left: 20px;
+}
+
+.quote blockquote {
 	border-width: 1px;
 	border-color: black;
 	border-style: dashed;
+	margin: 5px;
+	margin-left: 20px;
+	margin-top: 0px;
 }
-- 
GitLab