dist/toolkit.js
function(type) {
        var self = this,
            event,
            context,
            func,
            selector,
            win = $(window),
            doc = $(document);

        $.each(this.__events, function(i, value) {
            event = value[0];
            context = value[1];
            func = value[2];
            selector = value[3];

            // Determine the correct context
            if (self[context]) {
                context = self[context];

            } else if (context === 'window') {
                context = win;

            } else if (context === 'document') {
                context = doc;
            }

            // Ready events
            if (event === 'ready') {
                doc.ready(func);

            // Delegated events
            } else if (selector) {
                $(context)[type](event, selector, func);

            // Regular events
            } else {
                $(context)[type](event, func);
            }
        });
    }
function(type) {
        var self = this,
            event,
            context,
            func,
            selector,
            win = $(window),
            doc = $(document);

        $.each(this.__events, function(i, value) {
            event = value[0];
            context = value[1];
            func = value[2];
            selector = value[3];

            // Determine the correct context
            if (self[context]) {
                context = self[context];

            } else if (context === 'window') {
                context = win;

            } else if (context === 'document') {
                context = doc;
            }

            // Ready events
            if (event === 'ready') {
                doc.ready(func);

            // Delegated events
            } else if (selector) {
                $(context)[type](event, selector, func);

            // Regular events
            } else {
                $(context)[type](event, func);
            }
        });
    }
function ( type ) { var self = this , event , context , func , selector , win = $ ( window ) , doc = $ ( document ) ; $ . each ( this . __events , function ( i , value ) { event = value [ 0 ] ; context = value [ 1 ] ; func = value [ 2 ] ; selector = value [ 3 ] ; // Determine the correct context if ( self [ context ] ) { context = self [ context ] ; } else if ( context === 'window' ) { context = win ; } else if ( context === 'document' ) { context = doc ; } // Ready events if ( event === 'ready' ) { doc . ready ( func ) ; // Delegated events } else if ( selector ) { $ ( context ) [ type ] ( event , selector , func ) ; // Regular events } else { $ ( context ) [ type ] ( event , func ) ; } } ) ; }
Loop through the events object and attach events to the specified selector in the correct context.
Take into account window, document, and delegation.

@param {String} type
Loop through the events object and attach events to the specified selector in the correct context . Take into account window document and delegation .