').addClass('remove')
);
var additionalComplete = args.complete;
// Get information for specified section path
$item.data('notification-section', args.section);
$item.data('notification-custom', _custom);
$popup.find('ul').append($item);
$total.html(newTotal);
$total.parent().addClass('pending');
$item.addClass('pending');
// Setup timer
var pollTimer = setInterval(function() {
args.poll({
_custom: _custom,
complete: function(args) {
clearInterval(pollTimer);
notifications.cornerAlert({ message: $item.html() });
notifications.activeTasks.pop(pollTimer);
$item.removeClass('pending');
if (additionalComplete) additionalComplete();
},
incomplete: function(args) {},
error: function(args) {
if (args.message) {
cloudStack.dialog.notice({ message: args.message });
}
clearInterval(pollTimer);
notifications.activeTasks.pop(pollTimer);
notifications.cornerAlert({ message: 'ERROR: ' + $item.html() });
$item.removeClass('pending').addClass('error');
if (additionalComplete) additionalComplete();
}
});
}, args.interval);
notifications.activeTasks.push(pollTimer);
return $total;
},
/**
* Set total to 0
*/
resetTotal: function($popup) {
var $total = $popup.data('notifications-attach-to').find('div.total span');
var $items = $popup.find('ul li');
var total = $items.size();
var completed = $items.filter(':not(.pending)').size();
var newTotal = total - completed;
if (newTotal < 0) newTotal = completed;
$total.html(newTotal);
if (!newTotal)
$total.parent().removeClass('pending');
},
/**
* Remove item from notification list
*/
removeItem: function($popup, $item) {
if ($item.closest('li').hasClass('pending')) return false;
$item.remove();
return true;
},
/**
* Remove all completed notifications
*/
clear: function($popup) {
$popup.find('ul li').each(function() {
var $item = $(this);
if (!$item.hasClass('pending')) {
notifications.removeItem($popup, $item);
}
});
},
popup: {
create: function($attachTo) {
var $popup = $('
')
.addClass('notification-box')
.append(
// Header
$('
').html('Notifications')
)
.append(
// Container
$('').addClass('container')
.append(
// Notification list
$('