From 0a07e5fdaabfc5652ec96b4179e2c9433ab42002 Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Tue, 27 Mar 2012 01:09:28 +0200 Subject: [PATCH 1/4] Added some documentation. --- core/js/oc-vcategories.txt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/core/js/oc-vcategories.txt b/core/js/oc-vcategories.txt index 76d4245f5e..31216f80bd 100644 --- a/core/js/oc-vcategories.txt +++ b/core/js/oc-vcategories.txt @@ -17,7 +17,7 @@ Set the app specific values in your javascript file. This is what I've used for OCCategories.app = 'contacts'; OCCategories.changed = Contacts.UI.Card.categoriesChanged; -If OCCategories.changed point is set that function will be called each time the categories have been changed +If OCCategories.changed is set that function will be called each time the categories have been changed in the editor (add/delete/rescan) to allow the app to update the UI accordingly. The only argument to the function is an array of the updated categories e.g.: @@ -25,4 +25,9 @@ OCCategories.changed = function(categories) { for(var category in categories) { console.log(categories[category]); } -} \ No newline at end of file +} + +To show the categories editor call: + + OCCategories.edit() + From ff038f8766d49b2a4913ef5ae0a206758f2cdaaa Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Tue, 27 Mar 2012 10:12:30 +0200 Subject: [PATCH 2/4] Contacts: Update contact list thumbnail when deleting PHOTO. --- apps/contacts/js/contacts.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/apps/contacts/js/contacts.js b/apps/contacts/js/contacts.js index 18214cb1cc..82aadb54b8 100644 --- a/apps/contacts/js/contacts.js +++ b/apps/contacts/js/contacts.js @@ -667,6 +667,10 @@ Contacts={ console.log('NOTE or PHOTO'); Contacts.UI.propertyContainerFor(obj).hide(); Contacts.UI.propertyContainerFor(obj).data('checksum', ''); + if(proptype == 'PHOTO') { + console.log('Delete PHOTO'); + Contacts.UI.Contacts.refreshThumbnail(Contacts.UI.Card.id); + } } else { $('dl dt[data-element="'+proptype+'"],dd[data-element="'+proptype+'"]').hide(); $('dl dd[data-element="'+proptype+'"]').data('checksum', ''); @@ -990,7 +994,7 @@ Contacts={ OC.dialogs.alert(response.data.message, t('contacts', 'Error')); } }); - $('#contacts [data-id="'+this.id+'"]').find('a').css('background','url(thumbnail.php?id='+this.id+'&refresh=1'+Math.random()+') no-repeat'); + Contacts.UI.Contacts.refreshThumbnail(this.id); }, addMail:function() { //alert('addMail'); @@ -1192,6 +1196,9 @@ Contacts={ $(this).find('a').css('background','url(thumbnail.php?id='+$(this).data('id')+') no-repeat'); } }); + }, + refreshThumbnail:function(id){ + $('#contacts [data-id="'+id+'"]').find('a').css('background','url(thumbnail.php?id='+id+'&refresh=1'+Math.random()+') no-repeat'); } } } From fa165498ccfe2becbdaf997b4e36336e794cce50 Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Tue, 27 Mar 2012 12:26:59 +0200 Subject: [PATCH 3/4] Improvements in adding/deleting properties. --- apps/contacts/js/contacts.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/apps/contacts/js/contacts.js b/apps/contacts/js/contacts.js index 82aadb54b8..e182702745 100644 --- a/apps/contacts/js/contacts.js +++ b/apps/contacts/js/contacts.js @@ -613,10 +613,12 @@ Contacts={ this.loadPhoto(true); $('#file_upload_form').show(); $('#contacts_propertymenu a[data-type="'+type+'"]').parent().hide(); + $('#file_upload_start').trigger('click'); break; case 'NOTE': $('#note').show(); $('#contacts_propertymenu a[data-type="'+type+'"]').parent().hide(); + $('#note').find('textarea').focus(); break; case 'EMAIL': if($('#emaillist>li').length == 1) { @@ -644,6 +646,7 @@ Contacts={ case 'BDAY': case 'CATEGORIES': $('dl dt[data-element="'+type+'"],dd[data-element="'+type+'"]').show(); + $('dd[data-element="'+type+'"]').find('input').focus(); $('#contacts_propertymenu a[data-type="'+type+'"]').parent().hide(); break; } @@ -670,10 +673,13 @@ Contacts={ if(proptype == 'PHOTO') { console.log('Delete PHOTO'); Contacts.UI.Contacts.refreshThumbnail(Contacts.UI.Card.id); + } else if(proptype == 'NOTE') { + $('#note').find('textarea').val(''); } } else { $('dl dt[data-element="'+proptype+'"],dd[data-element="'+proptype+'"]').hide(); $('dl dd[data-element="'+proptype+'"]').data('checksum', ''); + $('dl dd[data-element="'+proptype+'"]').find('input').val(''); } $('#contacts_propertymenu a[data-type="'+proptype+'"]').parent().show(); Contacts.UI.loading(obj, false); From cb2dd97509ffd039fbd321aea4a8d631e3effcc7 Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Tue, 27 Mar 2012 12:29:19 +0200 Subject: [PATCH 4/4] Trigger autocomplete wo button. --- apps/contacts/js/jquery.multi-autocomplete.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/apps/contacts/js/jquery.multi-autocomplete.js b/apps/contacts/js/jquery.multi-autocomplete.js index 1c923a2543..7607de3f91 100644 --- a/apps/contacts/js/jquery.multi-autocomplete.js +++ b/apps/contacts/js/jquery.multi-autocomplete.js @@ -5,14 +5,25 @@ (function( $ ) { $.widget('ui.multiple_autocomplete', { _create: function() { + var self = this; function split( val ) { return val.split( /,\s*/ ); } function extractLast( term ) { return split( term ).pop(); } + function showOptions() { + if(!self.element.autocomplete('widget').is(':visible') && self.element.val().trim() == '') { + self.element.autocomplete('search', ''); + } + } //console.log('_create: ' + this.options['id']); - var self = this; + this.element.bind('click', function( event ) { + showOptions(); + }); + this.element.bind('input', function( event ) { + showOptions(); + }); this.element.bind('blur', function( event ) { var tmp = self.element.val().trim(); if(tmp[tmp.length-1] == ',') {