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:
psychobunny
2013-04-23 19:38:48 +00:00
parent 96a4cbd8d1
commit 67bf1b6041
6 changed files with 97 additions and 11 deletions

View File

@@ -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)
}
}
}());