Code coverage report for ./src/ocLazyLoad.loaders.jsLoader.js

Statements: 100% (12 / 12)      Branches: 100% (0 / 0)      Functions: 100% (7 / 7)      Lines: 100% (12 / 12)      Ignored: none     

All files » ./src/ » ocLazyLoad.loaders.jsLoader.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33    1     1 29                 28 13 13 13   13 12   1     28   28        
'use strict';
 
(function (angular) {
    'use strict';
 
    angular.module('oc.lazyLoad').config(function ($provide) {
        $provide.decorator('$ocLazyLoad', function ($delegate, $q) {
            /**
             * jsLoader function
             * @type Function
             * @param paths array list of js files to load
             * @param callback to call when everything is loaded. We use a callback and not a promise
             * @param params object config parameters
             * because the user can overwrite jsLoader and it will probably not use promises :(
             */
            $delegate.jsLoader = function (paths, callback, params) {
                var promises = [];
                angular.forEach(paths, function (path) {
                    promises.push($delegate.buildElement('js', path, params));
                });
                $q.all(promises).then(function () {
                    callback();
                }, function (err) {
                    callback(err);
                });
            };
            $delegate.jsLoader.ocLazyLoadLoader = true;
 
            return $delegate;
        });
    });
})(angular);
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkM6L3d3dy9vY0xhenlMb2FkL3NyYy9vY0xhenlMb2FkLmxvYWRlcnMuanNMb2FkZXIuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSxDQUFDLFVBQUEsT0FBTyxFQUFJO0FBQ1IsZ0JBQVksQ0FBQzs7QUFFYixXQUFPLENBQUMsTUFBTSxDQUFDLGFBQWEsQ0FBQyxDQUFDLE1BQU0sQ0FBQyxVQUFTLFFBQVEsRUFBRTtBQUNwRCxnQkFBUSxDQUFDLFNBQVMsQ0FBQyxhQUFhLEVBQUUsVUFBVSxTQUFTLEVBQUUsRUFBRSxFQUFFOzs7Ozs7Ozs7QUFTdkQscUJBQVMsQ0FBQyxRQUFRLEdBQUcsVUFBUyxLQUFLLEVBQ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ICAgICAgKiBqc0xvYWRlciBmdW5jdGlvblxyXG4gICAgICAgICAgICAgKiBAdHlwZSBGdW5jdGlvblxyXG4gICAgICAgICAgICAgKiBAcGFyYW0gcGF0aHMgYXJyYXkgbGlzdCBvZiBqcyBmaWxlcyB0byBsb2FkXHJcbiAgICAgICAgICAgICAqIEBwYXJhbSBjYWxsYmFjayB0byBjYWxsIHdoZW4gZXZlcnl0aGluZyBpcyBsb2FkZWQuIFdlIHVzZSBhIGNhbGxiYWNrIGFuZCBub3QgYSBwcm9taXNlXHJcbiAgICAgICAgICAgICAqIEBwYXJhbSBwYXJhbXMgb2JqZWN0IGNvbmZpZyBwYXJhbWV0ZXJzXHJcbiAgICAgICAgICAgICAqIGJlY2F1c2UgdGhlIHVzZXIgY2FuIG92ZXJ3cml0ZSBqc0xvYWRlciBhbmQgaXQgd2lsbCBwcm9iYWJseSBub3QgdXNlIHByb21pc2VzIDooXHJcbiAgICAgICAgICAgICAqL1xyXG4gICAgICAgICAgICAkZGVsZWdhdGUuanNMb2FkZXIgPSBmdW5jdGlvbihwYXRocywgY2FsbGJhY2ssIHBhcmFtcykge1xyXG4gICAgICAgICAgICAgICAgdmFyIHByb21pc2VzID0gW107XHJcbiAgICAgICAgICAgICAgICBhbmd1bGFyLmZvckVhY2gocGF0aHMsIHBhdGggPT4ge1xyXG4gICAgICAgICAgICAgICAgICAgIHByb21pc2VzLnB1c2goJGRlbGVnYXRlLmJ1aWxkRWxlbWVudCgnanMnLCBwYXRoLCBwYXJhbXMpKTtcclxuICAgICAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICAgICAgJHEuYWxsKHByb21pc2VzKS50aGVuKCgpID0+IHtcclxuICAgICAgICAgICAgICAgICAgICBjYWxsYmFjaygpO1xyXG4gICAgICAgICAgICAgICAgfSwgZXJyID0+IHtcclxuICAgICAgICAgICAgICAgICAgICBjYWxsYmFjayhlcnIpO1xyXG4gICAgICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgICAgIH07XHJcbiAgICAgICAgICAgICRkZWxlZ2F0ZS5qc0xvYWRlci5vY0xhenlMb2FkTG9hZGVyID0gdHJ1ZTtcclxuXHJcbiAgICAgICAgICAgIHJldHVybiAkZGVsZWdhdGU7XHJcbiAgICAgICAgfSlcclxuICAgIH0pO1xyXG5cclxufSkoYW5ndWxhcik7XHJcbiJdfQ==