mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
6528c7724b
!! NOT STABLE !! Initial implementation. No UI update yet. Check js/model/Piskel.js and js/model/Layer.js for an overview of the new API. Piskels can be saved on the existing service. Previous piskels cannot be loaded. This should be fixed soon.
40 lines
1.1 KiB
JavaScript
40 lines
1.1 KiB
JavaScript
(function () {
|
|
var ns = $.namespace("pskl.controller");
|
|
|
|
ns.NotificationController = function () {};
|
|
|
|
/**
|
|
* @public
|
|
*/
|
|
ns.NotificationController.prototype.init = function() {
|
|
$.subscribe(Events.SHOW_NOTIFICATION, $.proxy(this.displayMessage_, this));
|
|
$.subscribe(Events.HIDE_NOTIFICATION, $.proxy(this.removeMessage_, this));
|
|
};
|
|
|
|
/**
|
|
* @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);
|
|
}
|
|
};
|
|
|
|
/**
|
|
* @private
|
|
*/
|
|
ns.NotificationController.prototype.removeMessage_ = function (evt) {
|
|
var message = $("#user-message");
|
|
if (message.length) {
|
|
message.remove();
|
|
}
|
|
};
|
|
})();
|