Contacts: Photo upload handlers wern't being loaded for new contacts.
Name conflict with two FileUploads :-P
This commit is contained in:
parent
3514ec5947
commit
1f2b37c08b
|
@ -149,6 +149,14 @@ 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.
|
// Name has changed. Update it and reorder.
|
||||||
$('#fn').change(function(){
|
$('#fn').change(function(){
|
||||||
var name = $('#fn').val();
|
var name = $('#fn').val();
|
||||||
|
@ -166,6 +174,7 @@ Contacts={
|
||||||
if(!added) {
|
if(!added) {
|
||||||
$('#leftcontent ul').append(item);
|
$('#leftcontent ul').append(item);
|
||||||
}
|
}
|
||||||
|
Contacts.UI.Contacts.scrollTo(Contacts.UI.Card.id);
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#contacts_deletecard').click( function() { Contacts.UI.Card.doDelete();return false;} );
|
$('#contacts_deletecard').click( function() { Contacts.UI.Card.doDelete();return false;} );
|
||||||
|
@ -184,6 +193,28 @@ Contacts={
|
||||||
return false;
|
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});
|
$('#categories').multiple_autocomplete({source: categories});
|
||||||
$('#contacts_deletecard').tipsy({gravity: 'ne'});
|
$('#contacts_deletecard').tipsy({gravity: 'ne'});
|
||||||
$('#contacts_downloadcard').tipsy({gravity: 'ne'});
|
$('#contacts_downloadcard').tipsy({gravity: 'ne'});
|
||||||
|
@ -1324,10 +1355,10 @@ Contacts={
|
||||||
$(event.target).removeClass('droppable');
|
$(event.target).removeClass('droppable');
|
||||||
$(event.target).html(t('contacts', 'Uploading...'));
|
$(event.target).html(t('contacts', 'Uploading...'));
|
||||||
Contacts.UI.loading(event.target, true);
|
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];
|
var file = files[0];
|
||||||
if(file.size > $('#max_upload').val()){
|
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'));
|
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) {
|
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'))
|
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() {
|
xhr.onreadystatechange = function() {
|
||||||
if (xhr.readyState == 4){
|
if (xhr.readyState == 4){
|
||||||
response = $.parseJSON(xhr.responseText);
|
response = $.parseJSON(xhr.responseText);
|
||||||
|
@ -1486,6 +1517,10 @@ Contacts={
|
||||||
var item = $('#contacts [data-id="'+id+'"]');
|
var item = $('#contacts [data-id="'+id+'"]');
|
||||||
item.html(Contacts.UI.Card.fn);
|
item.html(Contacts.UI.Card.fn);
|
||||||
item.css('background','url('+OC.filePath('contacts', '', 'thumbnail.php')+'?id='+id+'&refresh=1'+Math.random()+') no-repeat');
|
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);
|
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.
|
* Upload function for dropped files. Should go in the Contacts class/object.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue