From 5393c0cfedf9ab07276e43e02fbe75e397671df0 Mon Sep 17 00:00:00 2001
From: Thomas Tanghus <thomas@tanghus.net>
Date: Sun, 24 Jun 2012 16:03:10 +0200
Subject: [PATCH] Click to select which address book to add to.

---
 apps/contacts/css/contacts.css | 2 +-
 apps/contacts/js/contacts.js   | 5 ++++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/apps/contacts/css/contacts.css b/apps/contacts/css/contacts.css
index 6c65db2b77..fb5bcb2b70 100644
--- a/apps/contacts/css/contacts.css
+++ b/apps/contacts/css/contacts.css
@@ -5,7 +5,7 @@
 #leftcontent a { padding: 0 0 0 25px; }
 #rightcontent { top: 3.5em !important; padding-top: 5px; }
 #leftcontent h3 { cursor: pointer; -moz-transition: background 300ms ease 0s; background: none no-repeat scroll 1em center #eee; border-bottom: 1px solid #ddd; border-top: 1px solid #fff; display: block; max-width: 100%; padding: 0.5em 0.8em; color: #666; text-shadow: 0 1px 0 #f8f8f8; font-size: 1.2em; }
-#leftcontent h3:hover { background-color: #DBDBDB; border-bottom: 1px solid #CCCCCC; border-top: 1px solid #D4D4D4; color: #333333; }
+#leftcontent h3:hover,#leftcontent h3:active,#leftcontent h3.active { background-color: #DBDBDB; border-bottom: 1px solid #CCCCCC; border-top: 1px solid #D4D4D4; color: #333333; }
 #contacts { position: fixed; background: #fff; max-width: 100%; width: 20em; left: 12.5em; top: 3.7em; bottom: 3em; overflow: auto; padding: 0; margin: 0; }
 .contacts a { height: 23px; display: block; left: 12.5em; margin: 0 0 0 0; padding: 0 0 0 25px; }
 #bottomcontrols { padding: 0; bottom:0px; height:2.8em; width: 20em; margin:0; background:#eee; border-top:1px solid #ccc; position:fixed; -moz-box-shadow: 0 -3px 3px -3px #000; -webkit-box-shadow: 0 -3px 3px -3px #000; box-shadow: 0 -3px 3px -3px #000;}
diff --git a/apps/contacts/js/contacts.js b/apps/contacts/js/contacts.js
index 0654976a6d..0325b2cec2 100644
--- a/apps/contacts/js/contacts.js
+++ b/apps/contacts/js/contacts.js
@@ -310,10 +310,11 @@ Contacts={
 			editNew:function(){ // add a new contact
 				this.id = ''; this.fn = ''; this.fullname = ''; this.givname = ''; this.famname = ''; this.addname = ''; this.honpre = ''; this.honsuf = '';
 				//Contacts.UI.Card.add(t('contacts', 'Contact')+';'+t('contacts', 'New')+';;;', t('contacts', 'New Contact'), '', true);
-				Contacts.UI.Card.add(';;;;;', '', '', true);
+				Contacts.UI.Card.add(';;;;;', '', this.bookid, true);
 				return false;
 			},
 			add:function(n, fn, aid, isnew){ // add a new contact
+				aid = aid?aid:$('#contacts h3.active').first().data('id');
 				var localAddcontact = function(n, fn, aid, isnew) {
 					$.post(OC.filePath('contacts', 'ajax', 'addcontact.php'), { n: n, fn: fn, aid: aid, isnew: isnew },
 					function(jsondata) {
@@ -1605,6 +1606,8 @@ $(document).ready(function(){
 	});
 
 	$(document).on('click', '.addressbook', function(event){
+		$('#contacts h3').removeClass('active');
+		$(this).addClass('active');
 		$(this).next().slideToggle(300);
 		return false;
 	});
-- 
GitLab