nl_tokens: / * wrapper for event implementations - includes on / off methods
pl_tokens: function createHandler ( event , callback , context , dontWrapCallback ) { if ( ! dontWrapCallback ) { var _callback = callback , noArg ; if ( typeof callback === 'object' ) { // use the "callback" attribute to get the callback function.  useful if you need to reference the component as "this" /*jshint validthis:true */ _callback = callback . callback . call ( this ) ; } if ( typeof callback === 'string' ) { noArg = ( noArgMethods . indexOf ( callback ) >= 0 ) ; _callback = context [ callback ] ; } if ( ! _callback ) { throw 'no callback function exists for "' + callback + '"' ; } callback = function ( ) { return _callback . apply ( context , noArg ? [ ] : arguments ) ; } ; } // check for special wrapper function var match = event . match ( specialWrapper ) ; if ( match ) { var specialMethodName = match [ 1 ] , /*jshint evil: true */ args = eval ( '[' + match [ 2 ] + ']' ) , rest = match [ 3 ] , specialHandler = eventManager . specials [ specialMethodName ] ; if ( specialHandler ) { if ( args . length === 1 && args [ 0 ] === '' ) { args = [ ] ; } callback = specialHandler . call ( context , callback , args ) ; return createHandler ( rest , callback , context , true ) ; } else { throw new Error ( 'invalid special event handler "' + specialMethodName + "'" ) ; } } var parts = <mask> . match ( splitter ) , handlerName = parts [ 1 ] , path = parts [ 2 ] , handler = handlers [ handlerName ] ; // check pattern handlers if no match for ( var i = 0 ; ! handler && i < patternHandlers . length ; i ++ ) { if ( handlerName . match ( patternHandlers [ i ] . pattern ) ) { handler = patternHandlers [ i ] . handler ; } } if ( ! handler ) { throw new Error ( 'no handler registered for "' + event + '"' ) ; } return handler . call ( context , { key : handlerName , path : path } , callback ) ; }