mocks/domready.js

Summary

Maintainability
A
0 mins
Test Coverage
'use strict';


var mockDomIsReady = false
    , messenger = new milo.Messenger;


milo.util.domReady = domReady;
function domReady(func) { // , arguments
    var self = this
        , args = _.slice(arguments, 1);
    if (mockDomIsReady) callFunc();
    messenger.on('domready', callFunc);

    function callFunc() {
        func.apply(self, args);
    }
}


_.extend(domReady, {
    isReady: isReady,
    trigger: trigger
});


function trigger() {
    mockDomIsReady = true;
    messenger.postMessage('domready');
}


function isReady() {
    return mockDomIsReady;
}