@ -65,7 +65,7 @@ Contacts={
propertyTypeFor : function ( obj ) {
return $ ( obj ) . parents ( '.propertycontainer' ) . first ( ) . data ( 'element' ) ;
} ,
showHideContactInfo : function ( ) {
/ * s h o w H i d e C o n t a c t I n f o : f u n c t i o n ( ) {
var show = ( $ ( '#emaillist li.propertycontainer' ) . length > 0 || $ ( '#phonelist li.propertycontainer' ) . length > 0 || $ ( '#addressdisplay dl.propertycontainer' ) . length > 0 ) ;
console . log ( 'showHideContactInfo: ' + show ) ;
if ( show ) {
@ -73,8 +73,8 @@ Contacts={
} else {
$ ( '#contact_communication' ) . hide ( ) ;
}
} ,
checkListFor : function ( obj ) {
} , * /
/ * c h e c k L i s t F o r : f u n c t i o n ( o b j ) {
var type = $ ( obj ) . parents ( '.propertycontainer' ) . first ( ) . data ( 'element' ) ;
console . log ( 'checkListFor: ' + type ) ;
switch ( type ) {
@ -101,7 +101,7 @@ Contacts={
case 'BDAY' :
break ;
}
} ,
} , * /
loading : function ( obj , state ) {
if ( state ) {
$ ( obj ) . addClass ( 'loading' ) ;
@ -137,18 +137,14 @@ Contacts={
$ ( this ) . find ( '.add' ) . fadeOut ( 500 ) ;
}
) ; * /
$ ( '.button,.action' ) . tipsy ( ) ;
$ ( '#contacts_deletecard' ) . tipsy ( { gravity : 'ne' } ) ;
$ ( '#contacts_downloadcard' ) . tipsy ( { gravity : 'ne' } ) ;
//$('#fn').jec();
$ ( '#fn_select' ) . combobox ( {
'id' : 'fn' ,
'name' : 'value' ,
'classes' : [ 'contacts_property' ] ,
'classes' : [ 'contacts_property' , 'huge' , 'tip' , 'float' ] ,
'attributes' : { 'placeholder' : t ( 'contacts' , 'Enter name' ) } ,
'title' : t ( 'contacts' , 'Format custom, Short name, Full name, Reverse or Reverse with comma' ) } ) ;
//$('.jecEditableOption').attr('title', t('contacts','Custom'));
$ ( '#fn' ) . tipsy ( ) ;
$ ( '#contacts_details_photo_wrapper' ) . tipsy ( ) ;
$ ( '#bday' ) . datepicker ( {
dateFormat : 'dd-mm-yy'
} ) ;
@ -200,6 +196,9 @@ Contacts={
}
] ) ;
$ ( '#categories' ) . multiple _autocomplete ( { source : categories } ) ;
$ ( '.button,.action,.tip' ) . tipsy ( ) ;
$ ( '#contacts_deletecard' ) . tipsy ( { gravity : 'ne' } ) ;
$ ( '#contacts_downloadcard' ) . tipsy ( { gravity : 'ne' } ) ;
Contacts . UI . loadListHandlers ( ) ;
} ,
Card : {
@ -267,7 +266,7 @@ Contacts={
import : function ( ) {
Contacts . UI . notImplemented ( ) ;
} ,
add : function ( n , fn , aid ) { // add a new contact
add : function ( n , fn , aid , isnew ) { // add a new contact
console . log ( 'Add contact: ' + n + ', ' + fn + ' ' + aid ) ;
$ . post ( OC . filePath ( 'contacts' , 'ajax' , 'addcontact.php' ) , { n : n , fn : fn , aid : aid } ,
function ( jsondata ) {
@ -291,7 +290,15 @@ Contacts={
if ( ! added ) {
$ ( '#leftcontent ul' ) . append ( item ) ;
}
if ( isnew ) {
Contacts . UI . Card . addProperty ( 'EMAIL' ) ;
Contacts . UI . Card . addProperty ( 'TEL' ) ;
Contacts . UI . Card . addProperty ( 'BDAY' ) ;
Contacts . UI . Card . addProperty ( 'NICKNAME' ) ;
Contacts . UI . Card . addProperty ( 'ORG' ) ;
Contacts . UI . Card . addProperty ( 'CATEGORIES' ) ;
$ ( '#fn' ) . focus ( ) ;
}
}
else {
OC . dialogs . alert ( jsondata . data . message , t ( 'contacts' , 'Error' ) ) ;
@ -356,7 +363,7 @@ Contacts={
return false ;
} ,
loadContact : function ( jsondata ) {
$ ( '#contact_communication' ) . hide ( ) ;
//$('#contact_communication').hide();
this . data = jsondata ;
this . id = this . data . id ;
$ ( '#rightcontent' ) . data ( 'id' , this . id ) ;
@ -368,7 +375,6 @@ Contacts={
this . loadPhones ( ) ;
this . loadAddresses ( ) ;
this . loadSingleProperties ( ) ;
// TODO: load NOTE ;-)
if ( this . data . NOTE ) {
$ ( '#note' ) . data ( 'checksum' , this . data . NOTE [ 0 ] [ 'checksum' ] ) ;
$ ( '#note' ) . find ( 'textarea' ) . val ( this . data . NOTE [ 0 ] [ 'value' ] ) ;
@ -376,7 +382,7 @@ Contacts={
} else {
$ ( '#note' ) . data ( 'checksum' , '' ) ;
$ ( '#note' ) . find ( 'textarea' ) . val ( '' ) ;
$ ( '#note' ) . hide ( ) ;
//$('#note').hide();
}
} ,
loadSingleProperties : function ( ) {
@ -521,17 +527,18 @@ Contacts={
} , * /
editNew : function ( ) { // add a new contact
this . id = '' ; this . fn = '' ; this . fullname = '' ; this . givname = '' ; this . famname = '' ; this . addname = '' ; this . honpre = '' ; this . honsuf = '' ;
$ . getJSON ( OC . filePath ( 'contacts' , 'ajax' , 'newcontact.php' ) , { } , function ( jsondata ) {
Contacts . UI . Card . add ( ';;;;' , '' , '' , true ) ;
/ * $ . g e t J S O N ( O C . f i l e P a t h ( ' c o n t a c t s ' , ' a j a x ' , ' n e w c o n t a c t . p h p ' ) , { } , f u n c t i o n ( j s o n d a t a ) {
if ( jsondata . status == 'success' ) {
id = '' ;
$ ( '#rightcontent' ) . data ( 'id' , '' ) ;
$ ( '#rightcontent' ) . html ( jsondata . data . page ) ;
Contacts . UI . Card . editName ( ) ;
//Contacts.UI.Card.editName();
} else {
OC . dialogs . alert ( jsondata . data . message , t ( 'contacts' , 'Error' ) ) ;
//alert(jsondata.data.message);
}
} ) ;
} ) ; * /
} ,
savePropertyInternal : function ( name , fields , oldchecksum , checksum ) {
// TODO: Add functionality for new fields.
@ -627,8 +634,8 @@ Contacts={
} , 'json' ) ;
}
} ,
addProperty : function ( obj ) {
var type = $ ( obj ) . data ( 'type' ) ;
addProperty : function ( type ) {
//var type = $(obj).data('type');
console . log ( 'addProperty:' + type ) ;
switch ( type ) {
case 'PHOTO' :
@ -647,21 +654,21 @@ Contacts={
$ ( '#emails' ) . show ( ) ;
}
Contacts . UI . Card . addMail ( ) ;
Contacts . UI . showHideContactInfo ( ) ;
//Contacts.UI.showHideContactInfo();
break ;
case 'TEL' :
if ( $ ( '#phonelist>li' ) . length == 1 ) {
$ ( '#phones' ) . show ( ) ;
}
Contacts . UI . Card . addPhone ( ) ;
Contacts . UI . showHideContactInfo ( ) ;
//Contacts.UI.showHideContactInfo();
break ;
case 'ADR' :
if ( $ ( '#addressdisplay>dl' ) . length == 1 ) {
$ ( '#addresses' ) . show ( ) ;
}
Contacts . UI . Card . editAddress ( 'new' , true ) ;
Contacts . UI . showHideContactInfo ( ) ;
//Contacts.UI.showHideContactInfo();
break ;
case 'NICKNAME' :
case 'ORG' :
@ -682,8 +689,8 @@ Contacts={
if ( jsondata . status == 'success' ) {
if ( type == 'list' ) {
Contacts . UI . propertyContainerFor ( obj ) . remove ( ) ;
Contacts . UI . showHideContactInfo ( ) ;
Contacts . UI . checkListFor ( obj ) ;
//Contacts.UI.showHideContactInfo();
//Contacts.UI.checkListFor(obj);
} else if ( type == 'single' ) {
var proptype = Contacts . UI . propertyTypeFor ( obj ) ;
console . log ( 'deleteProperty, hiding: ' + proptype ) ;
@ -718,8 +725,8 @@ Contacts={
} else { // Property hasn't been saved so there's nothing to delete.
if ( type == 'list' ) {
Contacts . UI . propertyContainerFor ( obj ) . remove ( ) ;
Contacts . UI . showHideContactInfo ( ) ;
Contacts . UI . checkListFor ( obj ) ;
//Contacts.UI.showHideContactInfo();
//Contacts.UI.checkListFor(obj);
} else if ( type == 'single' ) {
var proptype = Contacts . UI . propertyTypeFor ( obj ) ;
console . log ( 'deleteProperty, hiding: ' + proptype ) ;
@ -891,7 +898,7 @@ Contacts={
if ( isnew ) {
container . remove ( ) ;
}
Contacts . UI . showHideContactInfo ( ) ;
//Contacts.UI.showHideContactInfo();
}
} ,
close : function ( event , ui ) {
@ -900,7 +907,7 @@ Contacts={
if ( isnew ) {
container . remove ( ) ;
}
Contacts . UI . showHideContactInfo ( ) ;
//Contacts.UI.showHideContactInfo();
} / * ,
open : function ( event , ui ) {
// load 'ADR' property - maybe :-P
@ -973,7 +980,7 @@ Contacts={
}
} ,
loadPhoto : function ( force ) {
if ( this . data . PHOTO || force == true ) {
//if(this.data.PHOTO||force==true) {
$ . getJSON ( 'ajax/loadphoto.php' , { 'id' : this . id } , function ( jsondata ) {
if ( jsondata . status == 'success' ) {
//alert(jsondata.data.page);
@ -986,11 +993,11 @@ Contacts={
} ) ;
$ ( '#file_upload_form' ) . show ( ) ;
$ ( '#contacts_propertymenu a[data-type="PHOTO"]' ) . parent ( ) . hide ( ) ;
} else {
/ * } e l s e {
$ ( '#contacts_details_photo_wrapper' ) . empty ( ) ;
$ ( '#file_upload_form' ) . hide ( ) ;
$ ( '#contacts_propertymenu a[data-type="PHOTO"]' ) . parent ( ) . show ( ) ;
}
} * /
} ,
editPhoto : function ( id , tmp _path ) {
//alert('editPhoto: ' + tmp_path);
@ -1430,7 +1437,8 @@ $(document).ready(function(){
}
} ) ;
$ ( '#contacts_propertymenu a' ) . live ( 'click' , function ( ) {
Contacts . UI . Card . addProperty ( this ) ;
var type = $ ( this ) . data ( 'type' ) ;
Contacts . UI . Card . addProperty ( type ) ;
$ ( '#contacts_propertymenu' ) . hide ( ) ;
} ) ;
} ) ;