{"size": 1994, "ext": "js", "max_stars_repo_path": "src/js/directives/dagNavBar/dagNavBar.directive.js", "max_stars_repo_name": "m42cx/TravelFlexWallet", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/js/directives/dagNavBar/dagNavBar.directive.js", "max_issues_repo_name": "m42cx/TravelFlexWallet", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/js/directives/dagNavBar/dagNavBar.directive.js", "max_forks_repo_name": "m42cx/TravelFlexWallet", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 31.15625, "max_line_length": 121, "alphanum_fraction": 0.5591775326}
(() => {
  'use strict';

  /**
   * @name DagCoin Navigation Bar
   * @desc Navigation bar located at the top of each page
   * @example <dag-nav-bar title="Language" invert goBack="preferencesSystem"></dag-nav-bar>
   */
  angular
    .module('copayApp.directives')
    .directive('dagNavBar', dagNavBar);

  dagNavBar.$inject = ['$state', '$rootScope', '$stateParams', 'notification'];

  function dagNavBar($state, $rootScope, $stateParams, notification) {
    return {
      restrict: 'E',
      templateUrl: 'directives/dagNavBar/dagNavBar.template.html',
      transclude: true,
      replace: true,
      scope: {
        title: '@',
        goBack: '@',
        goBackParams: '@',
        goBackTransition: '@',
        invert: '&'
      },
      link: ($scope, elem, attr) => {
        $scope.invert = ('invert' in attr);
        $scope.showBack = (!!$stateParams.backTo || !!$scope.goBack);
        $scope.goStateBack = () => {
          if ($scope.goBackParams) {
            $state.go($stateParams.backTo || $scope.goBack || 'wallet', JSON.parse($scope.goBackParams));
          } else {
            $state.go($stateParams.backTo || $scope.goBack || 'wallet');
          }
        };

        const eventBus = require('core/event_bus.js');

        $scope.showNotificationIcon = () => (!$stateParams.backTo || !$scope.goBack) && $rootScope.tab === 'wallet.home';

        $scope.checkUnreadNotifications = () => {
          notification.unreadNotifications((notifications) => {
            $scope.hasUnreadNotifications = notifications.length > 0;
          });
        };

        $scope.openMenu = () => $rootScope.openMenu();
        $scope.openNotifications = () => $rootScope.openNotifications();

        eventBus.on('notifications_updated', () => {
          $scope.checkUnreadNotifications();
        });

        $scope.checkUnreadNotifications();
        /* document.addEventListener('backbutton', () => {
          back();
        }, false); */
      }
    };
  }
})();
