Made notifications more flexible.

remotes/origin/stable45
Thomas Tanghus 13 years ago
parent d71da67bee
commit 48521fcfaa
  1. 21
      apps/contacts/js/contacts.js

@ -12,13 +12,10 @@ String.prototype.strip_tags = function(){
Contacts={ Contacts={
UI:{ UI:{
notify:function(msg, ndata) { notify:function(params) {
$('#notification').text(msg); $('#notification').text(params.message);
if(data) {
$('#notification').data(ndata[0],ndata[1]);
}
$('#notification').fadeIn(); $('#notification').fadeIn();
setTimeout($('#notification').fadeOut(), 10000); setTimeout(function() {$('#notification').fadeOut();}, 10000);
}, },
notImplemented:function() { notImplemented:function() {
OC.dialogs.alert(t('contacts', 'Sorry, this functionality has not been implemented yet'), t('contacts', 'Not implemented')); OC.dialogs.alert(t('contacts', 'Sorry, this functionality has not been implemented yet'), t('contacts', 'Not implemented'));
@ -1421,7 +1418,7 @@ Contacts={
$.post(OC.filePath('contacts', '', 'import.php'), { id: aid, file: file, fstype: 'OC_FilesystemView' }, $.post(OC.filePath('contacts', '', 'import.php'), { id: aid, file: file, fstype: 'OC_FilesystemView' },
function(jsondata){ function(jsondata){
if(jsondata.status != 'success'){ if(jsondata.status != 'success'){
Contacts.UI.notify(jsondata.data.message); Contacts.UI.notify({message:jsondata.data.message});
} }
}); });
return false; return false;
@ -1757,12 +1754,12 @@ $(document).ready(function(){
// import the file // import the file
uploadedfiles += 1; uploadedfiles += 1;
} else { } else {
Contacts.UI.notify(jsondata.data.message); Contacts.UI.notify({message:jsondata.data.message});
} }
return false; return false;
}) })
.error(function(jqXHR, textStatus, errorThrown) { .error(function(jqXHR, textStatus, errorThrown) {
Contacts.UI.notify(errorThrown + ': ' + textStatus); Contacts.UI.notify({message:errorThrown + ': ' + textStatus,});
}); });
uploadingFiles[fileName] = jqXHR; uploadingFiles[fileName] = jqXHR;
} }
@ -1779,7 +1776,7 @@ $(document).ready(function(){
} }
FileList.loadingDone(file.name); FileList.loadingDone(file.name);
} else { } else {
Contacts.UI.notify(response.data.message); Contacts.UI.notify({message:response.data.message});
} }
}); });
} }
@ -1787,7 +1784,7 @@ $(document).ready(function(){
}, },
fail: function(e, data) { fail: function(e, data) {
console.log('fail'); console.log('fail');
Contacts.UI.notify(data.errorThrown + ': ' + data.textStatus); Contacts.UI.notify({message:data.errorThrown + ': ' + data.textStatus});
// TODO: Remove file from upload queue. // TODO: Remove file from upload queue.
}, },
progressall: function(e, data) { progressall: function(e, data) {
@ -1806,7 +1803,7 @@ $(document).ready(function(){
var importFiles = function(aid, fileList) { var importFiles = function(aid, fileList) {
// Create a closure that can be called from different places. // Create a closure that can be called from different places.
if(numfiles != uploadedfiles) { if(numfiles != uploadedfiles) {
Contacts.UI.notify('Not all files uploaded. Retrying...'); Contacts.UI.notify({message:t('contacts', 'Not all files uploaded. Retrying...')});
retries += 1; retries += 1;
if(retries > 0) { if(retries > 0) {
numfiles = uploadedfiles = retries = aid = 0; numfiles = uploadedfiles = retries = aid = 0;

Loading…
Cancel
Save