if same id is used it replaces the current alerts contents

v1.18.x
Baris Usakli 12 years ago
parent 58d12c9c7c
commit 3c0b86689a

@ -55,7 +55,7 @@ var socket,
title: 'Disconnect', title: 'Disconnect',
message: 'You have disconnected from NodeBB, we will try to reconnect!', message: 'You have disconnected from NodeBB, we will try to reconnect!',
type: 'error', type: 'error',
timeout: 1000 timeout: 5000
}); });
}); });
@ -113,16 +113,27 @@ var socket,
// timeout default = permanent // timeout default = permanent
// location : notification_window (default) or content // location : notification_window (default) or content
app.alert = function(params) { app.alert = function(params) {
var alert_id = 'alert_button_' + ((params.alert_id) ? params.alert_id : new Date().getTime());
var alert = $('#'+alert_id);
if(alert.length > 0) {
alert.find('strong').html(params.title);
alert.find('p').html(params.message);
alert.attr('class', "alert toaster-alert " + ((params.type=='warning') ? '' : "alert-" + params.type));
}
else {
var div = document.createElement('div'), var div = document.createElement('div'),
button = document.createElement('button'), button = document.createElement('button'),
strong = document.createElement('strong'), strong = document.createElement('strong'),
p = document.createElement('p'); p = document.createElement('p');
var alert_id = 'alert_button_' + ((params.alert_id) ? params.alert_id : new Date().getTime()); /*jQuery('#'+alert_id).fadeOut(500, function() {
jQuery('#'+alert_id).fadeOut(500, function() {
this.remove(); this.remove();
}); });*/
p.innerHTML = params.message; p.innerHTML = params.message;
strong.innerHTML = params.title; strong.innerHTML = params.title;
@ -140,7 +151,8 @@ var socket,
div.parentNode.removeChild(div); div.parentNode.removeChild(div);
} }
if (params.location == null) params.location = 'notification_window'; if (params.location == null)
params.location = 'notification_window';
jQuery('#'+params.location).prepend(jQuery(div).fadeIn('100')); jQuery('#'+params.location).prepend(jQuery(div).fadeIn('100'));
@ -161,6 +173,7 @@ var socket,
} }
} }
} }
}
var post_window = null, var post_window = null,
submit_post_btn = null, submit_post_btn = null,

Loading…
Cancel
Save