nl_tokens: @file events . js . An Event System ( John Resig - Secrets of a JS Ninja http : // jsninja . com / ) ( Original book version wasn t completely usable so fixed some things and made Closure Compiler compatible ) This should work very similarly to jQuery s events however it s based off the book version which isn t as robust as jquery s so there s probably some differences .
pl_tokens: function _cleanUpEvents ( elem , type ) { var data = getData ( elem ) ; // Remove the events of a particular type if there are none left if ( data . handlers [ type ] . length === 0 ) { delete <mask> . handlers [ type ] ; // data.handlers[type] = null; // Setting to null was causing an error with data.handlers // Remove the meta-handler from the element if ( elem . removeEventListener ) { elem . removeEventListener ( type , data . dispatcher , false ) ; } else if ( elem . detachEvent ) { elem . detachEvent ( 'on' + type , data . dispatcher ) ; } } // Remove the events object if there are no types left if ( Object . getOwnPropertyNames ( data . handlers ) . length <= 0 ) { delete data . handlers ; delete data . dispatcher ; delete data . disabled ; } // Finally remove the element data if there is no data left if ( Object . getOwnPropertyNames ( data ) . length === 0 ) { removeData ( elem ) ; } }