function bindBehaviours(elBindAt = document)
{
    // 1. start binding
    elBindAt.querySelectorAll('[data-behaviour]').forEach(function(elNode)
    {
        elNode.dataset.behaviour.trim().split(/\s+/).forEach(function(sBehaviour)
        {
            // a. if we don’t know about that behaviour
            if (oRegisteredBehaviours[sBehaviour] === undefined)
            {
                console.warn(`Attempting to bind unknown behaviour ‘${sBehaviour}’`);
                return false;
            }

            // b. if we’ve already bound that behaviour
            elNode.boundBehaviours = elNode.boundBehaviours || {};
            if (elNode.boundBehaviours[sBehaviour] !== undefined)
            {
                console.warn(`Attempting to rebind behaviour ’${sBehaviour}‘: ignoring`);
                return false;
            }

            // b. get some options
            let oBehaviour = oRegisteredBehaviours[sBehaviour];
            let oOptions   = getOptionsFor(elNode, oBehaviour.namespace, oBehaviour.defaults);

            // c. debug
            console.group(`Binding behaviour ‘${sBehaviour}’`);
            console.debug('Options:', oOptions);
            console.groupEnd();

            // d. fire the behaviour and store it
            try
            {
                elNode.boundBehaviours[sBehaviour] = oBehaviour.init.call(elNode, oOptions);
            }
            catch (ex)
            {
                console.error(ex);
            }
        });
    });
}
/**
 * Binds behaviours on a specific element.
 *
 * @param   {HTMLElement} elBindAt - the root HTML element at which we should start binding
 */
Binds behaviours on a specific element.
@param   {HTMLElement} elBindAt - the root HTML element at which we should start binding
Binds behaviours on a specific element . @param { HTMLElement } elBindAt - the root HTML element at which we should start binding
function bindBehaviours(elBindAt = document)
{
    elBindAt.querySelectorAll('[data-behaviour]').forEach(function(elNode)
    {
        elNode.dataset.behaviour.trim().split(/\s+/).forEach(function(sBehaviour)
        {
            if (oRegisteredBehaviours[sBehaviour] === undefined)
            {
                console.warn(`Attempting to bind unknown behaviour ‘${sBehaviour}’`);
                return false;
            }
            elNode.boundBehaviours = elNode.boundBehaviours || {};
            if (elNode.boundBehaviours[sBehaviour] !== undefined)
            {
                console.warn(`Attempting to rebind behaviour ’${sBehaviour}‘: ignoring`);
                return false;
            }
            let oBehaviour = oRegisteredBehaviours[sBehaviour];
            let oOptions   = getOptionsFor(elNode, oBehaviour.namespace, oBehaviour.defaults);
            console.group(`Binding behaviour ‘${sBehaviour}’`);
            console.debug('Options:', oOptions);
            console.groupEnd();
            try
            {
                elNode.boundBehaviours[sBehaviour] = oBehaviour.init.call(elNode, oOptions);
            }
            catch (ex)
            {
                console.error(ex);
            }
        });
    });
}
function bindBehaviours ( elBindAt = document ) { elBindAt . querySelectorAll ( '[data-behaviour]' ) . forEach ( function ( elNode ) { elNode . dataset . behaviour . trim ( ) . split ( / \s+ / ) . forEach ( function ( sBehaviour ) { if ( oRegisteredBehaviours [ sBehaviour ] === undefined ) { console . warn ( ` sB ehaviour}’ ` return false ; } elNode . boundBehaviours = elNode . boundBehaviours || { } ; if ( elNode . boundBehaviours [ sBehaviour ] !== undefined ) { console . warn ( ` sB ehaviour}‘ : return false ; } let oBehaviour = oRegisteredBehaviours [ sBehaviour ] ; let oOptions = getOptionsFor ( elNode , oBehaviour . namespace , oBehaviour . defaults ) ; console . group ( ` sB ehaviour}’ ` console . debug ( 'Options:' , oOptions ) ; console . groupEnd ( ) ; try { elNode . boundBehaviours [ sBehaviour ] = oBehaviour . init . call ( elNode , oOptions ) ; } catch ( ex ) { console . error ( ex ) ; } } ) ; } ) ; }
Binds behaviours on a specific element.
Binds behaviours on a specific element .
// 1. start binding // a. if we don’t know about that behaviour // b. if we’ve already bound that behaviour // b. get some options // c. debug // d. fire the behaviour and store it