(function () {
    'use strict';

    angular
        .module('setoresApp')
        .directive('sidebarOuter', sidebarOuter);

    sidebarOuter.$inject = ['$timeout', '__env', '$q'];

    /* @ngInject */
    function sidebarOuter($timeout, __env, $q) {
        let directive = {
            restrict: 'E',
            replace: true,
            templateUrl: __env.appPath + 'scripts/components/sidebar-outer/sidebar-outer.directive.html',
            link: link,
            scope: false
        };

        return directive;

        function link(scope, element, attrs) {
            //exports
            angular.extend(scope.vm, {
                openSidebarOuter: openSidebarOuter,
                closeSidebarOuter: closeSidebarOuter
            });

            scope.vm.sidebarOuterOpen = false;
            scope.vm.sidebarOuterComponent = {};

            function openSidebarOuter(headerText, innerContent, closeAction) {
                scope.vm.sidebarOuterComponent.headerText = headerText;
                scope.vm.sidebarOuterComponent.innerContent = innerContent;
                scope.vm.sidebarOuterComponent.closeAction = closeAction;
                return $timeout(() => { return $q.resolve() }, 400);
            }

            function closeSidebarOuter() {
                return $timeout(() => {
                    scope.vm.sidebarOuterComponent.headerText = null;
                    scope.vm.sidebarOuterComponent.innerContent = null;
                    return $q.resolve()
                }, 400);
            }

        }
    }
})();

