aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Tanghus <thomas@tanghus.net>2012-05-14 11:05:50 +0200
committerThomas Tanghus <thomas@tanghus.net>2012-05-14 11:08:00 +0200
commit1f2b37c08bf3ef42f26ef596127dba4e251be3aa (patch)
tree10e175d09e0dd4b0e7fb9c6fdf1fc54a3fecc306
parent3514ec5947c4f7ee4545eee261c6a79e98722575 (diff)
downloadnextcloud-server-1f2b37c08bf3ef42f26ef596127dba4e251be3aa.tar.gz
nextcloud-server-1f2b37c08bf3ef42f26ef596127dba4e251be3aa.zip
Contacts: Photo upload handlers wern't being loaded for new contacts.
Name conflict with two FileUploads :-P
-rw-r--r--apps/contacts/js/contacts.js65
1 files changed, 39 insertions, 26 deletions
diff --git a/apps/contacts/js/contacts.js b/apps/contacts/js/contacts.js
index b20fec54c32..44f1c220f91 100644
--- a/apps/contacts/js/contacts.js
+++ b/apps/contacts/js/contacts.js
@@ -148,7 +148,15 @@ Contacts={
click: function() { $(this).dialog('close'); }
}
] );
-
+
+ $('#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();
@@ -166,6 +174,7 @@ Contacts={
if(!added) {
$('#leftcontent ul').append(item);
}
+ Contacts.UI.Contacts.scrollTo(Contacts.UI.Card.id);
});
$('#contacts_deletecard').click( function() { Contacts.UI.Card.doDelete();return false;} );
@@ -184,6 +193,28 @@ Contacts={
return false;
});
+ // Profile picture upload handling
+ // New profile picture selected
+ $('#file_upload_start').change(function(){
+ Contacts.UI.Card.uploadPhoto(this.files);
+ });
+ $('#contacts_details_photo_wrapper').bind('dragover',function(event){
+ $(event.target).addClass('droppable');
+ event.stopPropagation();
+ event.preventDefault();
+ });
+ $('#contacts_details_photo_wrapper').bind('dragleave',function(event){
+ $(event.target).removeClass('droppable');
+ //event.stopPropagation();
+ //event.preventDefault();
+ });
+ $('#contacts_details_photo_wrapper').bind('drop',function(event){
+ event.stopPropagation();
+ event.preventDefault();
+ $(event.target).removeClass('droppable');
+ $.fileUpload(event.originalEvent.dataTransfer.files);
+ });
+
$('#categories').multiple_autocomplete({source: categories});
$('#contacts_deletecard').tipsy({gravity: 'ne'});
$('#contacts_downloadcard').tipsy({gravity: 'ne'});
@@ -1324,10 +1355,10 @@ Contacts={
$(event.target).removeClass('droppable');
$(event.target).html(t('contacts', 'Uploading...'));
Contacts.UI.loading(event.target, true);
- $.fileUpload(event.originalEvent.dataTransfer.files);
+ $.importUpload(event.originalEvent.dataTransfer.files);
});
- $.fileUpload = function(files){
+ $.importUpload = function(files){
var file = files[0];
if(file.size > $('#max_upload').val()){
OC.dialogs.alert(t('contacts','The file you are trying to upload exceed the maximum size for file uploads on this server.'), t('contacts','Upload too large'));
@@ -1346,7 +1377,7 @@ Contacts={
if (!xhr.upload) {
OC.dialogs.alert(t('contacts', 'Your browser doesn\'t support AJAX upload. Please upload the contacts file to ownCloud and import that way.'), t('contacts', 'Error'))
}
- fileUpload = xhr.upload,
+ importUpload = xhr.upload,
xhr.onreadystatechange = function() {
if (xhr.readyState == 4){
response = $.parseJSON(xhr.responseText);
@@ -1486,6 +1517,10 @@ Contacts={
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');
+ },
+ scrollTo:function(id){
+ $('#contacts').animate({
+ scrollTop: $('#leftcontent li[data-id="'+id+'"]').offset().top}, 'slow','swing');
}
}
}
@@ -1557,28 +1592,6 @@ $(document).ready(function(){
Contacts.UI.Card.saveProperty(this);
});
- // Profile picture upload handling
- // New profile picture selected
- $('#file_upload_start').change(function(){
- Contacts.UI.Card.uploadPhoto(this.files);
- });
- $('#contacts_details_photo_wrapper').bind('dragover',function(event){
- $(event.target).addClass('droppable');
- event.stopPropagation();
- event.preventDefault();
- });
- $('#contacts_details_photo_wrapper').bind('dragleave',function(event){
- $(event.target).removeClass('droppable');
- //event.stopPropagation();
- //event.preventDefault();
- });
- $('#contacts_details_photo_wrapper').bind('drop',function(event){
- event.stopPropagation();
- event.preventDefault();
- $(event.target).removeClass('droppable');
- $.fileUpload(event.originalEvent.dataTransfer.files);
- });
-
/**
* Upload function for dropped files. Should go in the Contacts class/object.
*/