diff --git a/apps/contacts/ajax/contactdetails.php b/apps/contacts/ajax/contactdetails.php
index 0cbd55258d..657dc5d586 100755
--- a/apps/contacts/ajax/contactdetails.php
+++ b/apps/contacts/ajax/contactdetails.php
@@ -43,7 +43,7 @@ if(is_null($vcard)) {
$details = OC_Contacts_VCard::structureContact($vcard);
// Some Google exported files have no FN field.
-if(!isset($details['FN'])) {
+/*if(!isset($details['FN'])) {
$fn = '';
if(isset($details['N'])) {
$details['FN'] = array(implode(' ', $details['N'][0]['value']));
@@ -52,7 +52,7 @@ if(!isset($details['FN'])) {
} else {
$details['FN'] = array('value' => OC_Contacts_App::$l10n->t('Unknown'));
}
-}
+}*/
// Make up for not supporting the 'N' field in earlier version.
if(!isset($details['N'])) {
diff --git a/apps/contacts/css/contacts.css b/apps/contacts/css/contacts.css
index 1dd6648c47..dfca0b37fa 100644
--- a/apps/contacts/css/contacts.css
+++ b/apps/contacts/css/contacts.css
@@ -4,10 +4,11 @@
#leftcontent { top: 3.5em !important; padding: 0; margin: 0; }
#rightcontent { top: 3.5em !important; padding-top: 5px; }
#contacts { background: #fff; width: 20em; left: 12.5em; top: 3.7em; bottom:3em; position: fixed; overflow: auto; padding: 0; margin: 0; }
+#contacts li { height: 28px; display: block; margin: 0 0 0 0; padding: 0 0 0 25px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; -webkit-transition:background-color 200ms; -moz-transition:background-color 200ms; -o-transition:background-color 200ms; transition:background-color 200ms; }
+#contacts li:hover { background-color: #eee }
#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;}
#contacts_newcontact { float: left; margin: 0.2em 0 0 1em; }
#chooseaddressbook { float: right; margin: 0.2em 1em 0 0; }
-#leftcontent a { height: 23px; display: block; margin: 0 0 0 0; padding: 0 0 0 25px; }
#actionbar { height: 30px; width: 60px; position: fixed; right: 0px; top: 4em; margin: 0 0 0 0; padding: 0 0 0 0; z-index: 1000; }
#contacts_deletecard {position:relative; float:left; background:url('%webroot%/core/img/actions/delete.svg') no-repeat center; }
#contacts_downloadcard {position:relative; float:left; background:url('%webroot%/core/img/actions/download.svg') no-repeat center; }
diff --git a/apps/contacts/js/contacts.js b/apps/contacts/js/contacts.js
index ee9fadfffb..2c9cb68b00 100644
--- a/apps/contacts/js/contacts.js
+++ b/apps/contacts/js/contacts.js
@@ -118,7 +118,7 @@ Contacts={
$('#fn_select').combobox({
'id': 'fn',
'name': 'value',
- 'classes': ['contacts_property', 'huge', 'tip', 'float'],
+ 'classes': ['contacts_property', 'nonempty', 'huge', 'tip', 'float'],
'attributes': {'placeholder': t('contacts', 'Enter name')},
'title': t('contacts', 'Format custom, Short name, Full name, Reverse or Reverse with comma')});
$('#bday').datepicker({
@@ -150,20 +150,12 @@ Contacts={
}
] );
- $('#fn').blur(function(){
- if($('#fn').val() == '') {
- OC.dialogs.alert(t('contacts','The name field cannot be empty. Please enter a name for this contact.'), t('contacts','Name is empty'), function() { $('#fn').focus(); });
- $('#fn').focus();
- return false;
- }
- });
-
// Name has changed. Update it and reorder.
$('#fn').change(function(){
var name = $('#fn').val();
var item = $('#contacts [data-id="'+Contacts.UI.Card.id+'"]').clone();
$('#contacts [data-id="'+Contacts.UI.Card.id+'"]').remove();
- $(item).find('a').html(name);
+ $(item).html(name);
var added = false;
$('#contacts li').each(function(){
if ($(this).text().toLowerCase() > name.toLowerCase()) {
@@ -177,6 +169,22 @@ Contacts={
}
});
+ $('#contacts_deletecard').click( function() { Contacts.UI.Card.doDelete();return false;} );
+ $('#contacts_deletecard').keydown( function(event) {
+ if(event.which == 13) {
+ Contacts.UI.Card.doDelete();
+ }
+ return false;
+ });
+
+ $('#contacts_downloadcard').click( function() { Contacts.UI.Card.doExport();return false;} );
+ $('#contacts_downloadcard').keydown( function(event) {
+ if(event.which == 13) {
+ Contacts.UI.Card.doExport();
+ }
+ return false;
+ });
+
$('#categories').multiple_autocomplete({source: categories});
$('#contacts_deletecard').tipsy({gravity: 'ne'});
$('#contacts_downloadcard').tipsy({gravity: 'ne'});
@@ -247,7 +255,7 @@ Contacts={
},
add:function(n, fn, aid, isnew){ // add a new contact
var card = $('#card')[0];
- if(!card) {
+ //if(!card) {
$.getJSON(OC.filePath('contacts', 'ajax', 'loadcard.php'),{},function(jsondata){
if(jsondata.status == 'success'){
$('#rightcontent').html(jsondata.data.page);
@@ -256,7 +264,7 @@ Contacts={
OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error'));
}
});
- }
+ //}
$.post(OC.filePath('contacts', 'ajax', 'addcontact.php'), { n: n, fn: fn, aid: aid, isnew: isnew },
function(jsondata) {
if (jsondata.status == 'success'){
@@ -266,7 +274,7 @@ Contacts={
if(jsondata.status == 'success'){
Contacts.UI.Card.loadContact(jsondata.data);
$('#leftcontent .active').removeClass('active');
- var item = '
'+Contacts.UI.Card.fn+'';
+ var item = $(''+Contacts.UI.Card.fn+'');
var added = false;
$('#leftcontent ul li').each(function(){
if ($(this).text().toLowerCase() > Contacts.UI.Card.fn.toLowerCase()) {
@@ -278,6 +286,7 @@ Contacts={
if(!added) {
$('#leftcontent ul').append(item);
}
+
if(isnew) { // add some default properties
Contacts.UI.Card.addProperty('EMAIL');
Contacts.UI.Card.addProperty('TEL');
@@ -425,10 +434,23 @@ Contacts={
}
},
populateNameFields:function() {
+ var props = ['FN', 'N'];
+ // Clear all elements
+ $('#ident .propertycontainer').each(function(){
+ if(props.indexOf($(this).data('element')) > -1) {
+ $(this).data('checksum', '');
+ $(this).find('input').val('');
+ }
+ });
this.fn = ''; this.fullname = ''; this.givname = ''; this.famname = ''; this.addname = ''; this.honpre = ''; this.honsuf = '';
var full = '';
var narray = undefined;
- this.fn = this.data.FN[0]['value'];
+ if(this.data.FN) {
+ this.fn = this.data.FN[0]['value'];
+ }
+ else {
+ this.fn = '';
+ }
if(this.data.N == undefined) {
narray = [this.fn,'','','','']; // Checking for non-existing 'N' property :-P
full = this.fn;
@@ -468,7 +490,9 @@ Contacts={
.text(value));
});
$('#contact_identity').find('*[data-element="N"]').data('checksum', this.data.N[0]['checksum']);
- $('#contact_identity').find('*[data-element="FN"]').data('checksum', this.data.FN[0]['checksum']);
+ if(this.data.FN) {
+ $('#contact_identity').find('*[data-element="FN"]').data('checksum', this.data.FN[0]['checksum']);
+ }
$('#contact_identity').show();
},
hasCategory:function(category) {
@@ -549,7 +573,7 @@ Contacts={
q = q + '&id=' + this.id + '&name=' + name;
if(checksum != undefined && checksum != '') { // save
q = q + '&checksum=' + checksum;
- //console.log('Saving: ' + q);
+ console.log('Saving: ' + q);
$(obj).attr('disabled', 'disabled');
$.post(OC.filePath('contacts', 'ajax', 'saveproperty.php'),q,function(jsondata){
if(jsondata.status == 'success'){
@@ -567,7 +591,7 @@ Contacts={
}
},'json');
} else { // add
- //console.log('Adding: ' + q);
+ console.log('Adding: ' + q);
$(obj).attr('disabled', 'disabled');
$.post(OC.filePath('contacts', 'ajax', 'addproperty.php'),q,function(jsondata){
if(jsondata.status == 'success'){
@@ -1426,13 +1450,13 @@ Contacts={
// Add thumbnails to the contact list as they become visible in the viewport.
lazyupdate:function(){
$('#contacts li').live('inview', function(){
- if (!$(this).find('a').attr('style')) {
- $(this).find('a').css('background','url('+OC.filePath('contacts', '', 'thumbnail.php')+'?id='+$(this).data('id')+') no-repeat');
+ if (!$(this).attr('style')) {
+ $(this).css('background','url('+OC.filePath('contacts', '', 'thumbnail.php')+'?id='+$(this).data('id')+') no-repeat');
}
});
},
refreshThumbnail:function(id){
- var item = $('#contacts [data-id="'+id+'"]').find('a');
+ var item = $('#contacts [data-id="'+id+'"]');
item.html(Contacts.UI.Card.fn);
item.css('background','url('+OC.filePath('contacts', '', 'thumbnail.php')+'?id='+id+'&refresh=1'+Math.random()+') no-repeat');
}
@@ -1454,38 +1478,30 @@ $(document).ready(function(){
$('#contacts_newcontact').click(Contacts.UI.Card.editNew);
$('#contacts_newcontact').keydown(Contacts.UI.Card.editNew);
- $('#contacts_deletecard').click( function() { Contacts.UI.Card.doDelete();return false;} );
- $('#contacts_deletecard').keydown( function(event) {
- if(event.which == 13) {
- Contacts.UI.Card.doDelete();
- }
- return false;
- });
-
- $('#contacts_downloadcard').click( function() { Contacts.UI.Card.doExport();return false;} );
- $('#contacts_downloadcard').keydown( function(event) {
- if(event.which == 13) {
- Contacts.UI.Card.doExport();
- }
- return false;
- });
-
// Load a contact.
- $('#leftcontent li').click(function(){
- var id = $(this).data('id');
- $(this).addClass('active');
- var oldid = $('#rightcontent').data('id');
- if(oldid != 0){
- $('#leftcontent li[data-id="'+oldid+'"]').removeClass('active');
+ $('#contacts').keydown(function(event) {
+ if(event.which == 13) {
+ $('#contacts').click();
}
- $.getJSON(OC.filePath('contacts', 'ajax', 'contactdetails.php'),{'id':id},function(jsondata){
- if(jsondata.status == 'success'){
- Contacts.UI.Card.loadContact(jsondata.data);
+ });
+ $('#contacts').click(function(event){
+ var $tgt = $(event.target);
+ if ($tgt.is('li')) {
+ var id = $($tgt).data('id');
+ $($tgt).addClass('active');
+ var oldid = $('#rightcontent').data('id');
+ if(oldid != 0){
+ $('#contacts li[data-id="'+oldid+'"]').removeClass('active');
}
- else{
- OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error'));
- }
- });
+ $.getJSON(OC.filePath('contacts', 'ajax', 'contactdetails.php'),{'id':id},function(jsondata){
+ if(jsondata.status == 'success'){
+ Contacts.UI.Card.loadContact(jsondata.data);
+ }
+ else{
+ OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error'));
+ }
+ });
+ }
return false;
});
@@ -1498,9 +1514,9 @@ $(document).ready(function(){
// bottom part of element is visible
} else {
// whole part of element is visible
- if (!$(this).find('a').attr('style')) {
+ if (!$(this).attr('style')) {
//alert($(this).data('id') + ' has background: ' + $(this).attr('style'));
- $(this).find('a').css('background','url('+OC.filePath('contacts', '', 'thumbnail.php')+'?id='+$(this).data('id')+') no-repeat');
+ $(this).css('background','url('+OC.filePath('contacts', '', 'thumbnail.php')+'?id='+$(this).data('id')+') no-repeat');
}/* else {
alert($(this).data('id') + ' has style ' + $(this).attr('style').match('url'));
}*/
diff --git a/apps/contacts/templates/part.contacts.php b/apps/contacts/templates/part.contacts.php
index a6ac0f1096..225a1ef0cf 100644
--- a/apps/contacts/templates/part.contacts.php
+++ b/apps/contacts/templates/part.contacts.php
@@ -8,5 +8,5 @@
}
}
?>
-
+