diff options
author | Thomas Tanghus <thomas@tanghus.net> | 2012-08-21 00:10:31 +0200 |
---|---|---|
committer | Thomas Tanghus <thomas@tanghus.net> | 2012-08-21 00:20:18 +0200 |
commit | 1e42cd162e70b6c9498c806a05c5c52402035c65 (patch) | |
tree | 45f8ec7969fc2fa144c52f608ee3f8bf3faeb6f1 /apps/contacts/js | |
parent | 719ae155db3c0d4a97250fdf00a34ae2d83aaf3e (diff) | |
download | nextcloud-server-1e42cd162e70b6c9498c806a05c5c52402035c65.tar.gz nextcloud-server-1e42cd162e70b6c9498c806a05c5c52402035c65.zip |
Added types to emails. Support for custom types. Partial fix for oc-1508.
Diffstat (limited to 'apps/contacts/js')
-rw-r--r-- | apps/contacts/js/contacts.js | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/apps/contacts/js/contacts.js b/apps/contacts/js/contacts.js index fda47665c90..8f52ec88733 100644 --- a/apps/contacts/js/contacts.js +++ b/apps/contacts/js/contacts.js @@ -1301,26 +1301,39 @@ OC.Contacts={ loadMails:function() { $('#emails').hide(); $('#emaillist li.propertycontainer').remove(); + var emaillist = $('#emaillist'); for(var mail in this.data.EMAIL) { this.addMail(); //$('#emaillist li:first-child').clone().appendTo($('#emaillist')).show(); - $('#emaillist li:last-child').data('checksum', this.data.EMAIL[mail]['checksum']) - $('#emaillist li:last-child').find('input[type="email"]').val(this.data.EMAIL[mail]['value']); + var curemail = emaillist.find('li:last-child'); + curemail.data('checksum', this.data.EMAIL[mail]['checksum']) + curemail.find('input[type="email"]').val(this.data.EMAIL[mail]['value']); for(var param in this.data.EMAIL[mail]['parameters']) { if(param.toUpperCase() == 'PREF') { - $('#emaillist li:last-child').find('input[type="checkbox"]').attr('checked', 'checked') + curemail.find('input[type="checkbox"]').attr('checked', 'checked') } else if(param.toUpperCase() == 'TYPE') { for(etype in this.data.EMAIL[mail]['parameters'][param]) { + var found = false; var et = this.data.EMAIL[mail]['parameters'][param][etype]; - $('#emaillist li:last-child').find('select option').each(function(){ + curemail.find('select option').each(function(){ if($.inArray($(this).val().toUpperCase(), et.toUpperCase().split(',')) > -1) { $(this).attr('selected', 'selected'); + found = true; } }); + if(!found) { + curemail.find('select option:last-child').after('<option value="'+et+'" selected="selected">'+et+'</option>'); + } } } } + curemail.find('select').multiselect({ + noneSelectedText: t('contacts', 'Select type'), + header: false, + selectedList: 4, + classes: 'typelist' + }); } if($('#emaillist li').length > 1) { $('#emails').show(); @@ -1359,13 +1372,18 @@ OC.Contacts={ } else if(param.toUpperCase() == 'TYPE') { for(ptype in this.data.TEL[phone]['parameters'][param]) { + var found = false; var pt = this.data.TEL[phone]['parameters'][param][ptype]; - phonelist.find('li:last-child').find('select option').each(function(){ + phonelist.find('li:last-child').find('select option').each(function() { //if ($(this).val().toUpperCase() == pt.toUpperCase()) { if ($.inArray($(this).val().toUpperCase(), pt.toUpperCase().split(',')) > -1) { $(this).attr('selected', 'selected'); + found = true; } }); + if(!found) { + phonelist.find('li:last-child').find('select option:last-child').after('<option class="custom" value="'+pt+'" selected="selected">'+pt+'</option>'); + } } } } |