diff --git a/js/controller/NotificationController.js b/js/controller/NotificationController.js index 2ff6908f..15c106cf 100644 --- a/js/controller/NotificationController.js +++ b/js/controller/NotificationController.js @@ -1,39 +1,39 @@ -/* - * @provide pskl.NotificationService - * - */ -$.namespace("pskl"); +(function () { + var ns = $.namespace("pskl.controller"); -pskl.NotificationService = (function() { + ns.NotificationController = function () {}; - /** - * @private - */ - var 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 + "
x
"; - document.body.appendChild(message); - $(message).find(".close").click(removeMessage_); - if(messageInfo.behavior) messageInfo.behavior(message); - }; + /** + * @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 + "
x
"; + document.body.appendChild(message); + $(message).find(".close").click($.proxy(this.removeMessage_, this)); + if(messageInfo.behavior) { + messageInfo.behavior(message); + } + }; - /** - * @private - */ - var removeMessage_ = function (evt) { - var message = $("#user-message"); - if (message.length) { - message.remove(); - } - }; + /** + * @private + */ + ns.NotificationController.prototype.removeMessage_ = function (evt) { + var message = $("#user-message"); + if (message.length) { + message.remove(); + } + }; - return { - init: function() { - $.subscribe(Events.SHOW_NOTIFICATION, displayMessage_); - $.subscribe(Events.HIDE_NOTIFICATION, removeMessage_); - } - }; + /** + * @public + */ + ns.NotificationController.prototype.init = function() { + $.subscribe(Events.SHOW_NOTIFICATION, $.proxy(this.displayMessage_, this)); + $.subscribe(Events.HIDE_NOTIFICATION, $.proxy(this.removeMessage_, this)); + }; })(); diff --git a/js/piskel.js b/js/piskel.js index 1a38d314..8b62d505 100644 --- a/js/piskel.js +++ b/js/piskel.js @@ -69,10 +69,12 @@ $.namespace("pskl"); this.historyService = new pskl.service.HistoryService(frameSheet); this.historyService.init(); - this.KeyboardEventService = new pskl.service.KeyboardEventService(); - this.KeyboardEventService.init(); + this.keyboardEventService = new pskl.service.KeyboardEventService(); + this.keyboardEventService.init(); + + this.notificationController = new pskl.controller.NotificationController(); + this.notificationController.init(); - pskl.NotificationService.init(); this.localStorageService = new pskl.service.LocalStorageService(frameSheet); this.localStorageService.init();