(function () { "use strict"; var name = 'adToolbar'; angular.module('app.directive') .directive('adToolbar', ['$window', '$state', 'navigation', 'user', 'cfg', 'indicator', 'staticData', function ($window, $state, navigation, user, cfg, indicator, staticData) { return { replace: true, templateUrl: 'directive/' + name + '/' + name + '.html', scope: {}, link: function (scope, element, attributes) { cfg.debug && console.log(name); var scopeListeners = []; scope.language = staticData.languageJs2Db[cfg.lang]; scope.indicator = indicator; scope.$state = $state; scope.user = user; scope.navOpened = false; scope.navigation = navigation; scope.staticData = staticData; scope.logout = function () { if (!indicator.has('user.logout')) { user.logout(); } }; scope.switchLanguage = function (language) { user.switchLanguage(language).then(function () { $window.location.reload(); }); }; scope.$on('$destroy', function () { angular.forEach(scopeListeners, function (unbindMethod) { unbindMethod(); }); }); } }; }]); })();