1 angular.module('egCoreMod')
3 .directive('egNavbar', function() {
7 templateUrl : 'eg-navbar-template',
8 controller:['$scope','$window','$location','$timeout','hotkeys','$rootScope',
9 'egCore','$uibModal','ngToast','egOpChange','$element',
10 function($scope , $window , $location , $timeout , hotkeys , $rootScope ,
11 egCore , $uibModal , ngToast , egOpChange , $element) {
13 $scope.rs = $rootScope;
15 $scope.reprintLast = function (e) {
16 egCore.print.reprintLast();
17 return e.preventDefault();
20 function navTo(path) {
21 path = path.replace(/^\.\//,'');
22 $window.location.href = egCore.env.basePath + path;
25 // adds a keyboard shortcut
26 // http://chieffancypants.github.io/angular-hotkeys/
27 $scope.addHotkey = function(key, path, desc, elm) {
28 angular.forEach(key.split(' '), function (k) {
31 allowIn: ['INPUT','SELECT','TEXTAREA'],
33 callback: function(e) {
35 if (path) return navTo(path,route);
36 return $timeout(function(){$(elm).trigger('click')});
42 function inspect(elm) {
43 elm = angular.element(elm);
44 if (elm.attr('eg-accesskey')) {
46 elm.attr('eg-accesskey'),
48 elm.attr('eg-accesskey-desc'),
52 angular.forEach(elm.children(), inspect);
54 $timeout(function(){inspect($element)});
56 $scope.retrieveLastRecord = function() {
57 var last_record = egCore.hatch.getLocalItem("eg.cat.last_record_retrieved");
59 $window.location.href =
60 egCore.env.basePath + 'cat/catalog/record/' + last_record;
64 $scope.applyLocale = function(locale) {
65 // EGWeb.pm can change the locale for us w/ the right param
66 // Note: avoid using $location.search() to derive a new
67 // URL, since it creates an intermediate path change.
68 // Instead, use the ham-fisted approach of killing any
69 // search args and applying the args we want.
70 $window.location.href =
71 $window.location.href.replace(
73 '?set_eg_locale=' + encodeURIComponent(locale)
77 $scope.changeOperatorUndo = function() {
78 egOpChange.changeOperatorUndo().then(function() {
79 $scope.op_changed = false;
80 $scope.username = egCore.auth.user().usrname();
84 $scope.changeOperator = function() {
85 egOpChange.changeOperator().then(function() {
86 $scope.op_changed = egCore.auth.OCtoken() ? true : false;
87 $scope.username = egCore.auth.user().usrname();
91 $scope.currentToken = function () {
92 return egCore.auth.token();
95 // Returns true if the browser is connected to Hatch
96 $scope.hatchConnected = function() {
97 return egCore.hatch.hatchAvailable;
100 // tied to logout link
101 $scope.logout = function() {
102 egCore.auth.logout();
106 egCore.startup.go().then(
108 if (egCore.auth.user()) {
109 $scope.op_changed = egCore.auth.OCtoken() ? true : false;
110 $scope.username = egCore.auth.user().usrname();
111 $scope.workstation = egCore.auth.workstation();
113 egCore.org.settings('ui.staff.max_recent_patrons')
115 var val = s['ui.staff.max_recent_patrons'];
116 $scope.showRecentPatron = val > 0;
117 $scope.showRecentPatrons = val > 1;