[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb:[2505] trunk/UI/payments



Revision: 2505
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=2505&view=rev
Author:   einhverfr
Date:     2009-03-17 02:35:41 +0000 (Tue, 17 Mar 2009)

Log Message:
-----------
Hide/show vendor invoice details via javascript.

Modified Paths:
--------------
    trunk/UI/payments/payments_detail.html

Added Paths:
-----------
    trunk/UI/payments/payments_detail.js

Modified: trunk/UI/payments/payments_detail.html
===================================================================
--- trunk/UI/payments/payments_detail.html	2009-03-16 20:22:38 UTC (rev 2504)
+++ trunk/UI/payments/payments_detail.html	2009-03-17 02:35:41 UTC (rev 2505)
@@ -4,6 +4,7 @@
 			'css/global.css' 
 			'UI/payments/payments.css'
 		]
+	include_script = ['UI/payments/payments_detail.js']
 ?>
 <?lsmb BLOCK format_money ?><?lsmb number 
 ?><?lsmb END # block ?>
@@ -12,7 +13,7 @@
 ?>
 <?lsmb payment_type = (account_class == 1) ? text('Payments') : text('Receipts') 
 ?>
-<body id="payment_2_body">
+<body id="payment_2_body" onLoad="init()">
 <!-- CT:  This template produces invalid XHTML due to the use of nested tables.
     Because nested tables are widely used (perhaps improperly) for layout,
     most browsers should have no issues with them.  Furthermore, I cannot find
@@ -200,10 +201,13 @@
 		?>"><?lsmb r.contact_name ?></span></td>
 	<td class="invoice"><?lsmb r.total_due ?> 
 		<?lsmb currency ?></td>
-        <td class="payment" class="details_select">
+        <td>
+		<span class="details_select">
 		<?lsmb INCLUDE input element_data = {
 		name = "paid_$r.contact_id"
 		value = "some"
+		class = "paid_some"
+		id = "paid_some_$r.contact_id"
 		label = text('Some')
 		checked = (${"paid_$r.contact_id"} == 'some') ? "checked" : ""
 		type = "radio"
@@ -211,10 +215,12 @@
 		<?lsmb INCLUDE input element_data = {
 		name = "paid_$r.contact_id"
 		value = "all"
+		class = "paid_all"
+		id = "paid_all_$r.contact_id"
 		label = text('All')
 		checked = (${"paid_$r.contact_id"} != 'some') ? "checked" : ""
 		type = "radio"
-	 }	?>
+	 }	?></span>
 	</td>
 	<td rowspan = 2><?lsmb INCLUDE input element_data = {
 		name = "source_$r.contact_id"

Added: trunk/UI/payments/payments_detail.js
===================================================================
--- trunk/UI/payments/payments_detail.js	                        (rev 0)
+++ trunk/UI/payments/payments_detail.js	2009-03-17 02:35:41 UTC (rev 2505)
@@ -0,0 +1,68 @@
+
+function init() {
+	var spans = document.getElementsByTagName('span');
+	var tables = document.getElementsByTagName('table');
+	for (var i=0, il=tables.length; i<il; i++){
+		var table = tables.item(i);
+		if (table.getAttribute('class') == 'detail_table_visible'){
+			var tid = table.getAttribute('id');
+			var cid = tid.slice(19, tid.length);
+			var rg = document.getElementsByName('paid_' + cid);
+			for (var i=0, il=rg.length; i<il; i++){
+				var button = rg.item(i);
+				if ((button.value == 'all') && 
+						(button.checked == true)){
+					table.className = 'detail_table_hidden';
+				}
+			}
+		}
+	}
+	for (var i=0, il=spans.length; i<il; i++){
+		var span = spans.item(i);
+		if (span.getAttribute('class') != 'details_select'){
+			continue;
+		}
+		var inputs = span.getElementsByTagName('input');
+		for (var i=0, il=inputs.length; i<il; i++){
+			var input = inputs.item(i);
+			if (input.getAttribute('class') == 'paid_some'){
+				input.addEventListener('click', 
+					function(e){
+						var my_id = 
+							this.getAttribute('id');
+						var contact_id = 
+							my_id.slice(10, 
+								my_id.length);
+						show_details(contact_id);
+						return true;
+					}, false);
+			}
+			else if (input.getAttribute('class') == 'paid_all'){
+				input.addEventListener('click', 
+					function(e){
+						var my_id = 
+							this.getAttribute('id');
+						var contact_id = 
+							my_id.slice(9, 
+								my_id.length);
+						hide_details(contact_id);
+						return true;
+					}, false);
+			}
+		}
+	}
+}
+
+function show_details(contact_id){
+	var e_id = "invoice_data_table_" + contact_id;
+	var e = document.getElementById(e_id);
+	e.className = "detail_table_visible";
+	return true;
+}
+
+function hide_details(contact_id){
+	var e_id = "invoice_data_table_" + contact_id;
+	var e = document.getElementById(e_id);
+	e.className = "detail_table_hidden";
+	return true;
+}


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.