Code coverage report for scripts/services/aside.js

Statements: 93.33% (14 / 15)      Branches: 66.67% (4 / 6)      Functions: 100% (3 / 3)      Lines: 93.33% (14 / 15)      Ignored: none     

All files » scripts/services/ » aside.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 34 35 36 37 38 39 401 1                   1   1 3       3     2   2     2   2 2 2         3 3      
(function() {
    angular.module('ngAside')
    /**
     * @ngdoc service
     * @name ngAside.services:$aside
     * @description
     * Factory to create a modal instance to use it as aside. It simply wraps $modal by overriding open() method and sets a class on modal window.
     * @function
     */
        .factory('$aside', $aside);
 
    $aside.$inject = ['$modal'];
    /* @ngInject */
    function $aside($modal) {
        var defaults = this.defaults = {
            placement: 'left'
        };
 
        var asideFactory = {
            // override open method
            open: function(config) {
                var options = angular.extend({}, defaults, config);
                // check placement is set correct
                Iif(['left', 'right', 'bottom', 'top'].indexOf(options.placement) === -1) {
                    options.placement = defaults.placement;
                }
                var vertHoriz = ['left', 'right'].indexOf(options.placement) === -1 ? 'vertical' : 'horizontal';
                // set aside classes
                options.windowClass  = 'ng-aside ' + vertHoriz + ' ' + options.placement + (options.windowClass ? ' ' + options.windowClass : '');
                delete options.placement
                return $modal.open(options);
            }
        };
 
        // create $aside as extended $modal
        var $aside = angular.extend({}, $modal, asideFactory);
        return $aside;
    }
})();