lib/html-interface.js
function initAll() {

    $$.ready(registerAllFromDataAttribtues);

    function registerAllFromDataAttribtues() {

        var _nextGroupId = 1;

        // es6 map would have been nice here, but this lib is intended to run on es5 browsers. integrating Babel might work.
        var groupIdToInputs = {};
        var groupIdToGroup = {};

        $$.getElementsByTagNames(validInputTagNames)
            .filter(function(el) {
                return $$.hasDataSet(el, 'vivalidTuples');
            })
            .forEach(function(el) {
                addGroupInputs($$.getClosestParentByAttribute(el, 'vivalidGroup'), el);
            });

        for (var groupId in groupIdToInputs) {
            var vivalidGroup = createGroupFromDataAttribtues(groupIdToGroup[groupId], groupIdToInputs[groupId]);
            addToGroupNameDictionairy(groupIdToGroup[groupId], vivalidGroup);
        }

        function addGroupInputs(group, input) {

            if (!group) {
                throw 'an input validation is missing a group, input id: ' + input.id;
            }

            if (!group._groupId) group._groupId = _nextGroupId++;

            if (!groupIdToInputs[group._groupId]) {
                groupIdToInputs[group._groupId] = [];
                groupIdToGroup[group._groupId] = group;
            }

            groupIdToInputs[group._groupId].push(input);
        }

    }

}
function initAll() {

    $$.ready(registerAllFromDataAttribtues);

    function registerAllFromDataAttribtues() {

        var _nextGroupId = 1;

        // es6 map would have been nice here, but this lib is intended to run on es5 browsers. integrating Babel might work.
        var groupIdToInputs = {};
        var groupIdToGroup = {};

        $$.getElementsByTagNames(validInputTagNames)
            .filter(function(el) {
                return $$.hasDataSet(el, 'vivalidTuples');
            })
            .forEach(function(el) {
                addGroupInputs($$.getClosestParentByAttribute(el, 'vivalidGroup'), el);
            });

        for (var groupId in groupIdToInputs) {
            var vivalidGroup = createGroupFromDataAttribtues(groupIdToGroup[groupId], groupIdToInputs[groupId]);
            addToGroupNameDictionairy(groupIdToGroup[groupId], vivalidGroup);
        }

        function addGroupInputs(group, input) {

            if (!group) {
                throw 'an input validation is missing a group, input id: ' + input.id;
            }

            if (!group._groupId) group._groupId = _nextGroupId++;

            if (!groupIdToInputs[group._groupId]) {
                groupIdToInputs[group._groupId] = [];
                groupIdToGroup[group._groupId] = group;
            }

            groupIdToInputs[group._groupId].push(input);
        }

    }

}
function initAll ( ) { $$ . ready ( registerAllFromDataAttribtues ) ; function registerAllFromDataAttribtues ( ) { var _nextGroupId = 1 ; // es6 map would have been nice here, but this lib is intended to run on es5 browsers. integrating Babel might work. var groupIdToInputs = { } ; var groupIdToGroup = { } ; $$ . getElementsByTagNames ( validInputTagNames ) . filter ( function ( el ) { return $$ . hasDataSet ( el , 'vivalidTuples' ) ; } ) . forEach ( function ( el ) { addGroupInputs ( $$ . getClosestParentByAttribute ( el , 'vivalidGroup' ) , el ) ; } ) ; for ( var groupId in groupIdToInputs ) { var vivalidGroup = createGroupFromDataAttribtues ( groupIdToGroup [ groupId ] , groupIdToInputs [ groupId ] ) ; addToGroupNameDictionairy ( groupIdToGroup [ groupId ] , vivalidGroup ) ; } function addGroupInputs ( group , input ) { if ( ! group ) { throw 'an input validation is missing a group, input id: ' + input . id ; } if ( ! group . _groupId ) group . _groupId = _nextGroupId ++ ; if ( ! groupIdToInputs [ group . _groupId ] ) { groupIdToInputs [ group . _groupId ] = [ ] ; groupIdToGroup [ group . _groupId ] = group ; } groupIdToInputs [ group . _groupId ] . push ( input ) ; } } }
Bootstraps all groups when using the html data attributes interface. Will work on all groups present at initial page load.
@memberof! vivalid.htmlInterface
@function
@example vivalid.htmlInterface.initAll();
Bootstraps all groups when using the html data attributes interface . Will work on all groups present at initial page load .