2012-09-16 16:41:47 +04:00
|
|
|
(function () {
|
|
|
|
var ns = $.namespace("pskl.controller");
|
2012-09-03 03:24:55 +04:00
|
|
|
|
2012-09-16 16:41:47 +04:00
|
|
|
ns.NotificationController = function () {};
|
2012-09-03 03:24:55 +04:00
|
|
|
|
2013-09-22 23:02:43 +04:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
ns.NotificationController.prototype.init = function() {
|
|
|
|
$.subscribe(Events.SHOW_NOTIFICATION, $.proxy(this.displayMessage_, this));
|
|
|
|
$.subscribe(Events.HIDE_NOTIFICATION, $.proxy(this.removeMessage_, this));
|
|
|
|
};
|
|
|
|
|
2012-09-16 16:41:47 +04:00
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
ns.NotificationController.prototype.displayMessage_ = function (evt, messageInfo) {
|
|
|
|
var message = document.createElement('div');
|
|
|
|
message.id = "user-message";
|
|
|
|
message.className = "user-message";
|
|
|
|
message.innerHTML = messageInfo.content;
|
|
|
|
message.innerHTML = message.innerHTML + "<div title='Close message' class='close'>x</div>";
|
|
|
|
document.body.appendChild(message);
|
|
|
|
$(message).find(".close").click($.proxy(this.removeMessage_, this));
|
|
|
|
if(messageInfo.behavior) {
|
|
|
|
messageInfo.behavior(message);
|
|
|
|
}
|
|
|
|
};
|
2012-09-03 03:24:55 +04:00
|
|
|
|
2012-09-16 16:41:47 +04:00
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
ns.NotificationController.prototype.removeMessage_ = function (evt) {
|
|
|
|
var message = $("#user-message");
|
|
|
|
if (message.length) {
|
|
|
|
message.remove();
|
|
|
|
}
|
|
|
|
};
|
2012-09-03 03:24:55 +04:00
|
|
|
})();
|