nl_tokens: Works just like jQuery . fn . bind () with a couple noteable differences . * It binds all events to the application element * All events are bound within the eventNamespace () * Events are not actually bound until the application is started with run () * callbacks are evaluated within the context of a Sammy . EventContext See http : // code . quirkey . com / sammy / docs / events . html for more info .
pl_tokens: function ( name , data , callback ) { var app = this ; // build the callback // if the arity is 2, callback is the second argument if ( typeof callback == 'undefined' ) { callback = data ; } var listener_callback = function ( ) { // pull off the context from the arguments to the callback var e , context , data ; e = arguments [ 0 ] ; data = arguments [ 1 ] ; if ( data && data . context ) { context = data . context ; delete <mask> . context ; } else { context = new app . context_prototype ( app , 'bind' , e . type , data , e . target ) ; } e . cleaned_type = e . type . replace ( app . eventNamespace ( ) , '' ) ; callback . apply ( context , [ e , data ] ) ; } ; // it could be that the app element doesnt exist yet // so attach to the listeners array and then run() // will actually bind the event. if ( ! this . listeners [ name ] ) { this . listeners [ name ] = [ ] ; } this . listeners [ name ] . push ( listener_callback ) ; if ( this . isRunning ( ) ) { // if the app is running // *actually* bind the event to the app element this . _listen ( name , listener_callback ) ; } return this ; }