Created
January 14, 2015 21:46
-
-
Save dshook/4ee5f052d3c608bebd6f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| window.WEBLINC = window.WEBLINC || {}; | |
| window.WEBLINC.modules = (function () { | |
| 'use strict'; | |
| var $document = $(document), | |
| validateArgs = function (args) { | |
| _.forEach(args, function (arg) { | |
| if (typeof arg !== 'function') { | |
| throw new Error('WEBLINC.modules: Arguments must be functions'); | |
| } | |
| }); | |
| }, | |
| addToQueue = function (queue) { | |
| return function () { | |
| validateArgs(arguments); | |
| [].push.apply(queue, arguments); | |
| }; | |
| }, | |
| initQueue = function (queue) { | |
| return function ($scope) { | |
| $scope = $scope || $document; | |
| _.forEach(queue, function (func) { | |
| func($scope); | |
| }); | |
| }; | |
| }, | |
| domReadyQueue = [], | |
| domUpdateQueue = [], | |
| onDomReady = addToQueue(domReadyQueue), | |
| onDomUpdate = addToQueue(domUpdateQueue), | |
| domReady = initQueue(domReadyQueue), | |
| domUpdate = initQueue(domUpdateQueue); | |
| return { | |
| onDomReady: onDomReady, | |
| onDomUpdate: onDomUpdate, | |
| domReady: domReady, | |
| domUpdate: domUpdate | |
| }; | |
| }()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment