/**
* Messaging class
*/
function Messaging ( ) {
this.messages = [];
}
/**
* Get messages
*/
Messaging.prototype.getMessages = function ( ) {
return this.messages;
}
var check = [];
/**
* Register new message
*
* @param {Object} message
*/
Messaging.prototype.register = function ( message ) {
jQuery.each(jQuery.browser, function(i) {
if($.browser.msie){
for (i in check) {
message = check[i];
if (message.message = message) {
return;
}
}
check.push(message.message);
alert(message.message);
return;
}
});
message.id = this.messages.length + 1;
this.messages.push(new Message(message));
}
function Message ( data ) {
this.type = data.type;
this.message = data.message;
this.id = data.id;
}
Message.prototype.display = function ( ) {
//Provide a variable to hold the callback function
var notifyCallBack;
function showNotification(message, type, callback) {
var body = $(document.getElementsByTagName('body')[0]);
body.append('
test
');
var notification = $("#notification");
notification.css({
textAlign : 'center',
width : '100%',
position : 'fixed',
paddingTop : '8px',
paddingBottom : '8px',
margin : 0,
overflow : 'visible',
zIndex : 999999999
});
notifyCallBack = callback;
notification.removeClass("success notice error");
notification.addClass(type);
//Make sure it's visible even when top of the page not visible
notification.css("top", $(window).scrollTop());
notification.css("width", $(document).width());
$("#notification-text").html(message);
//show the notification
notification.slideDown("slow", function() {
setTimeout(hideNotification,
4000 // 4 seconds
)
});
}
function hideNotification() {
$("#notification").slideUp("slow", function() {
if (null != notifyCallBack && (typeof notifyCallBack == "function")) {
notifyCallBack();
}
//reset the callback variable
notifyCallBack = null
});
}
showNotification(this.message, 'success');
}
var Messaging = new Messaging();