dist/jbone.js
function(el, types, handler, data, selector) {
        jBone.setId(el);

        var eventHandler = function(e) {
                jBone.event.dispatch.call(el, e);
            },
            events = jBone.getData(el).events,
            eventType, t, event;

        types = types.split(" ");
        t = types.length;
        while (t--) {
            event = types[t];

            eventType = event.split(".")[0];
            events[eventType] = events[eventType] || [];

            if (events[eventType].length) {
                // override with previous event handler
                eventHandler = events[eventType][0].fn;
            } else {
                el.addEventListener && el.addEventListener(eventType, eventHandler, false);
            }

            events[eventType].push({
                namespace: event.split(".").splice(1).join("."),
                fn: eventHandler,
                selector: selector,
                data: data,
                originfn: handler
            });
        }
    }
function(el, types, handler, data, selector) {
        jBone.setId(el);

        var eventHandler = function(e) {
                jBone.event.dispatch.call(el, e);
            },
            events = jBone.getData(el).events,
            eventType, t, event;

        types = types.split(" ");
        t = types.length;
        while (t--) {
            event = types[t];

            eventType = event.split(".")[0];
            events[eventType] = events[eventType] || [];

            if (events[eventType].length) {
                // override with previous event handler
                eventHandler = events[eventType][0].fn;
            } else {
                el.addEventListener && el.addEventListener(eventType, eventHandler, false);
            }

            events[eventType].push({
                namespace: event.split(".").splice(1).join("."),
                fn: eventHandler,
                selector: selector,
                data: data,
                originfn: handler
            });
        }
    }
function ( el , types , handler , data , selector ) { jBone . setId ( el ) ; var eventHandler = function ( e ) { jBone . event . dispatch . call ( el , e ) ; } , events = jBone . getData ( el ) . events , eventType , t , event ; types = types . split ( " " ) ; t = types . length ; while ( t -- ) { event = types [ t ] ; eventType = event . split ( "." ) [ 0 ] ; events [ eventType ] = events [ eventType ] || [ ] ; if ( events [ eventType ] . length ) { // override with previous event handler eventHandler = events [ eventType ] [ 0 ] . fn ; } else { el . addEventListener && el . addEventListener ( eventType , eventHandler , false ) ; } events [ eventType ] . push ( { namespace : event . split ( "." ) . splice ( 1 ) . join ( "." ) , fn : eventHandler , selector : selector , data : data , originfn : handler } ) ; } }
Attach a handler to an event for the elements
@param {Node}        el         - Events will be attached to this DOM Node
@param {String}      types      - One or more space-separated event types and optional namespaces
@param {Function}    handler    - A function to execute when the event is triggered
@param {Object}      [data]     - Data to be passed to the handler in event.data
@param {String}      [selector] - A selector string to filter the descendants of the selected elements
Attach a handler to an event for the elements