mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-10 07:55:46 +01:00
updated ajaxify to do a callback after page change, added toaster style notifications (app.alert), changes to webserver to update automatically
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
var socket,
|
||||
config;
|
||||
config,
|
||||
app = {};
|
||||
|
||||
(function() {
|
||||
|
||||
@@ -18,5 +19,47 @@ var socket,
|
||||
|
||||
});
|
||||
|
||||
|
||||
// use unique alert_id to have multiple alerts visible at a time, use the same alert_id to fade out the current instance
|
||||
// type : error, success, info, warning/notify
|
||||
// timeout default = permanent
|
||||
// location : notification_window (default) or content
|
||||
app.alert = function(params) {
|
||||
var div = document.createElement('div'),
|
||||
button = document.createElement('button'),
|
||||
strong = document.createElement('strong'),
|
||||
p = document.createElement('p');
|
||||
|
||||
var alert_id = 'alert_button_' + ((alert_id) ? alert_id : new Date().getTime());
|
||||
|
||||
jQuery('#'+alert_id).fadeOut(500, function() {
|
||||
this.remove();
|
||||
});
|
||||
|
||||
p.innerHTML = params.message;
|
||||
strong.innerHTML = params.title;
|
||||
|
||||
div.className = "alert " + ((params.type=='warning') ? '' : "alert-" + params.type);
|
||||
|
||||
div.setAttribute('id', alert_id);
|
||||
div.appendChild(button);
|
||||
div.appendChild(strong);
|
||||
div.appendChild(p);
|
||||
|
||||
button.className = 'close';
|
||||
button.innerHTML = '×';
|
||||
button.onclick = function(ev) {
|
||||
div.parentNode.removeChild(div);
|
||||
}
|
||||
|
||||
if (params.location == null) params.location = 'notification_window';
|
||||
|
||||
jQuery('#'+params.location).prepend(jQuery(div).fadeIn('100'));
|
||||
|
||||
if (params.timeout) {
|
||||
setTimeout(function() {
|
||||
jQuery(div).fadeOut('1000');
|
||||
}, params.timeout)
|
||||
}
|
||||
}
|
||||
|
||||
}());
|
||||
|
||||
Reference in New Issue
Block a user