Skip to content

Commit

Permalink
Add support for applications to add support for custom events (like t…
Browse files Browse the repository at this point in the history
…hose in jQuery UI)
  • Loading branch information
tomhuda committed Jun 3, 2011
1 parent 9dcb681 commit 96b6756
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 7 additions & 1 deletion packages/sproutcore-views/lib/system/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ SC.Application = SC.Object.extend(
*/
eventDispatcher: null,

/**
@type Object
@default null
*/
customEvents: null,

/** @private */
init: function() {
var eventDispatcher,
Expand All @@ -63,7 +69,7 @@ SC.Application = SC.Object.extend(
set(this, 'eventDispatcher', eventDispatcher);

SC.$(document).ready(function() {
eventDispatcher.setup();
eventDispatcher.setup(this.get('customEvents'));
});
},

Expand Down
4 changes: 3 additions & 1 deletion packages/sproutcore-views/lib/system/event_dispatcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ SC.EventDispatcher = SC.Object.extend(
would like to register the listeners on different element, set the event
dispatcher's `root` property.
*/
setup: function() {
setup: function(addedEvents) {
var event, events = {
touchstart : 'touchStart',
touchmove : 'touchMove',
Expand All @@ -60,6 +60,8 @@ SC.EventDispatcher = SC.Object.extend(
change : 'change'
};

jQuery.extend(events, addedEvents || {})

for (event in events) {
if (events.hasOwnProperty(event)) {
this.setupHandler(event, events[event]);
Expand Down

0 comments on commit 96b6756

Please sign in to comment.