(function () {
    'use strict';

    angular
        .module('contestacaoApp')
        .directive('overlay', overlay);

    overlay.$inject = ['$q'];

    /* @ngInject */
    function overlay($q) {
        return {
            restrict: 'E',
            replace: true,
            templateUrl: __env.appPath + 'scripts/components/overlay/overlay.directive.html',
            link: link,
            scope: false
        };

        function link(scope) {
            //exports
            angular.extend(scope.vm, {
                showOverlay: showOverlay,
                hideOverlay: hideOverlay
            });

            scope.vm.overlayVisible = false;

            function hideOverlay() {
                scope.vm.overlayVisible = false;

                if (!scope.$$phase) {
                    scope.$apply();
                }
            }

            function showOverlay() {
                scope.vm.overlayVisible = true;

                if (!scope.$$phase) {
                    scope.$apply();
                }
            }
        }
    }
})();

