Skip to content

Commit

Permalink
Made Notification Bubbles 'undo' actually undo action (currently Tag …
Browse files Browse the repository at this point in the history
…only) #34
  • Loading branch information
bnvk committed Aug 30, 2014
1 parent f46bfb0 commit 863af3d
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions static/default/html/jsapi/app/notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,13 @@ Mailpile.notification = function(result, complete, complete_action) {
result.message = default_messages[result.status];
}

if (result.undo == undefined) {
if (result.command === 'tag') {
result['undo'] = true;
var hide_notification = 20000;
}
else {
result['undo'] = false;
var hide_notification = 8000;
}

var notification_data = _.extend(result, {
Expand All @@ -41,29 +46,40 @@ Mailpile.notification = function(result, complete, complete_action) {
$('#event-' + result.event_id).fadeOut(function() {
$(this).remove();
});
}, 8000);
}, hide_notification);
} else if (complete == 'hide') {
message.delay(5000).fadeOut('normal', function() {
message.find('span.message-text').empty();
});
} else if (complete == 'redirect') {
setTimeout(function() {
window.location.href = complete_action
}, 5000);
}, 4000);
}

return function() { message.fadeOut('normal'); };
};


/* Message Close */
/* Notification - Close */
$(document).on('click', '.notification-close', function() {
$(this).parent().fadeOut(function() {
$(this).remove();
});
});


/* Notification - Undo */
$(document).on('click', '.notification-undo', function() {
var event_id = $(this).data('event_id').split('-').join('.');
Mailpile.API.eventlog_undo_post({ event_id: event_id }, function(result) {
if (result.status === 'success') {
window.location.reload(true);
}
});
});


/* Connection Down - Hide */
$(document).on('click', '#connection-down-hide', function() {
$('#connection-down').fadeOut().remove();
Expand Down

0 comments on commit 863af3d

Please sign in to comment.