Created
January 9, 2012 21:14
-
-
Save guilhermeblanco/1584974 to your computer and use it in GitHub Desktop.
Widget support in PureMVC
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Object.declare('base.widget.Command'); | |
base.widget.Command = function () | |
{ | |
org.puremvc.js.patterns.command.SimpleCommand.call(this); | |
}; | |
Object.extend(base.widget.Command, org.puremvc.js.patterns.command.SimpleCommand); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Object.declare('base.widget.Mediator'); | |
base.widget.Mediator = function (mediatorName, view) | |
{ | |
org.puremvc.js.patterns.mediator.Mediator.call(this, mediatorName, view); | |
this._notificationInterests = []; | |
this._notificationHandlers = {}; | |
} | |
Object.extend(base.widget.Mediator, org.puremvc.js.patterns.mediator.Mediator); | |
var _p = base.widget.Mediator.prototype; | |
_p.bind = function (eventName, callback, scope) | |
{ | |
scope = scope || this; | |
if (this._notificationInterests.indexOf(eventName) === -1) { | |
this._notificationInterests[this._notificationInterests.length] = eventName; | |
} | |
this._notificationHandlers[eventName] = Relegate.create(scope, callback); | |
}; | |
_p.unbind = function (eventName) | |
{ | |
var eventIndex = this._notificationInterests.indexOf(eventName); | |
if (eventIndex !== -1) { | |
this._notificationInterests.splice(eventIndex, 1); | |
this._notificationHandlers[eventName] = null; | |
delete this._notificationHandlers[eventName]; | |
} | |
}; | |
_p.listNotificationInterests = function () | |
{ | |
return this._notificationInterests; | |
}; | |
_p.handleNotification = function (notification) | |
{ | |
var notificationName = notification.getName(); | |
if (typeof this._notificationHandlers[notificationName] !== "undefined") { | |
this._notificationHandlers[notificationName](notification); | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Object.declare('base.widget.ViewComponent'); | |
base.widget.ViewComponent = function (component) | |
{ | |
org.puremvc.js.patterns.observer.Notifier.call(this); | |
this._component = component; | |
} | |
Object.extend(base.widget.ViewComponent, org.puremvc.js.patterns.observer.Notifier); | |
var _p = base.widget.ViewComponent.prototype; | |
_p.getComponent = function () | |
{ | |
return this._component; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment