<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- TODO: remote hosted CSS should be hosted locally instead -->
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" />
+ <link rel="stylesheet" href="[% ctx.media_prefix %]/js/ui/default/staff/build/hotkeys.min.css" />
<link rel="stylesheet" href="[% ctx.base_path %]/staff/css/style.css" />
<link rel="stylesheet" href="[% ctx.base_path %]/staff/css/print.css" type="text/css" media="print" />
</head>
<body>
- [% INCLUDE "staff/t_navbar.tt2" %]
+ <!-- load the navbar template inline since it's used on every page -->
+ <script type="text/ng-template" id="eg-navbar-template">
+ [% INCLUDE "staff/t_navbar.tt2" %]
+ </script>
+ <!-- instantiate the navbar by invoking it's name -->
+ <eg-navbar></eg-navbar>
+
<div id="top-content-container" class="container">[% content %]</div>
[%
# status bar along bottom of page
-<!-- TODO: remotely hosted JS should be hosted locally -->
-<!-- TODO: combine and minify JS -->
-
[%
- EG_VERSION = '0.0.1'; # FIXME: build optoin
+ EG_VERSION = '0.0.1'; # FIXME: build option
EXPAND_JS_IMPORTS = 1; # FIXME: env option?
%]
<script src="[% ctx.media_prefix %]/js/ui/default/staff/services/startup.js"></script>
<script src="[% ctx.media_prefix %]/js/ui/default/staff/services/hatch.js"></script>
<script src="[% ctx.media_prefix %]/js/ui/default/staff/services/coresvc.js"></script>
-<script src="[% ctx.media_prefix %]/js/ui/default/staff/navbar.js"></script>
+<script src="[% ctx.media_prefix %]/js/ui/default/staff/services/navbar.js"></script>
<script src="[% ctx.media_prefix %]/js/ui/default/staff/services/statusbar.js"></script>
<script src="[% ctx.media_prefix %]/js/ui/default/staff/services/ui.js"></script>
<div class="navbar-header">
<button type="button" class="navbar-toggle"
ng-init="navCollapsed = true" ng-click="navCollapsed = !navCollapsed">
- <span class="sr-only">Toggle navigation</span>
+ <span class="sr-only">[% l('Toggle navigation') %]</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<ul class="nav navbar-nav">
<li><a href='./' title="[% l('Home') %]" target="_self"
class="glyphicon glyphicon-home"></a><li>
- <!-- " vim -->
<!-- circulation -->
<li class="dropdown">
</a>
</li>
<li>
- <a href="./circ/patron/search" target="_self">
+ <a href="./circ/patron/search" target="_self"
+ eg-accesskey="[% l('alt+s') %]"
+ eg-accesskey-desc="[% l('Patron search by name, address, etc.') %]">
<span class="glyphicon glyphicon-search"></span>
- [% l('Patron Search') %]
+ <span eg-accesskey-label>[% l('Patron Search') %]</span>
</a>
</li>
<li>
+++ /dev/null
-/**
- * Free-floating controller which can be used by any app.
- */
-function NavCtrl($scope, $window, $location, egCore) {
-
- $scope.applyLocale = function(locale) {
- // EGWeb.pm can change the locale for us w/ the right param
- $window.location.href =
- $location.search('set_eg_locale', locale).absUrl();
- }
-
- // tied to logout link
- $scope.logout = function() {
- egCore.auth.logout();
- return true;
- };
-
- /**
- * Two important things happening here.
- *
- * 1. Since this is a standalone controller, which may execute at
- * any time during page load, we have no gaurantee that needed
- * startup actions, session retrieval being the main one, have taken
- * place yet. So we kick off the startup chain ourselves and run
- * actions when it's done. Note this does not mean startup runs
- * multiple times. If it's already started, we just pick up the
- * existing startup promise.
- *
- * 2. We are updating the $scope asynchronously, but since it's
- * done inside a promise resolver, another $digest() loop will
- * run and pick up our changes. No $scope.$apply() needed.
- */
- if ($location.path() != '/login') {
- // avoiding rending user info on the login page
-
- egCore.startup.go().then(
- function() {
- $scope.username = egCore.auth.user().usrname();
- $scope.workstation = egCore.auth.workstation();
- }
- );
- }
-}
-
-// minify-safe dependency injection
-NavCtrl.$inject = ['$scope', '$window', '$location', 'egCore'];
-
* egCoreMod houses all of the services, etc. required by all pages
* for basic functionality.
*/
-angular.module('egCoreMod', []);
+angular.module('egCoreMod', ['cfp.hotkeys']);
--- /dev/null
+angular.module('egCoreMod')
+
+.directive('egNavbar', function() {
+ return {
+ restrict : 'AE',
+ transclude : true,
+ templateUrl : 'eg-navbar-template',
+ link : function(scope, element, attrs) {
+
+ // Find all eg-accesskey entries within the menu and attach
+ // hotkey handlers for each.
+ // jqlite doesn't support selectors, so we have to
+ // manually navigate to the elements we're interested in.
+ function inspect(elm) {
+ elm = angular.element(elm);
+ if (elm.attr('eg-accesskey')) {
+ scope.addHotkey(
+ elm.attr('eg-accesskey'),
+ elm.attr('href'),
+ elm.attr('eg-accesskey-desc')
+ );
+ }
+ angular.forEach(elm.children(), inspect);
+ }
+ inspect(element);
+ },
+
+ controller:['$scope','$window','$location','hotkeys','egCore',
+ function($scope , $window , $location , hotkeys , egCore) {
+
+ function navTo(path) {
+ // $location.path() does not want a leading ".",
+ // which <a>'s will have
+ path = path.replace(/^\./,'');
+
+ // navigates to the requested path as a new page
+ $window.location.href = $location.path(path).absUrl();
+ }
+
+ // adds a keyboard shortcut
+ // http://chieffancypants.github.io/angular-hotkeys/
+ $scope.addHotkey = function(key, path, desc) {
+ hotkeys.add(key, desc, function() { navTo(path) });
+ };
+
+ $scope.applyLocale = function(locale) {
+ // EGWeb.pm can change the locale for us w/ the right param
+ $window.location.href =
+ $location.search('set_eg_locale', locale).absUrl();
+ }
+
+ // tied to logout link
+ $scope.logout = function() {
+ egCore.auth.logout();
+ return true;
+ };
+
+ // display the username and workstation after startup completes
+ if ($location.path() != '/login') {
+ // avoiding rending user info on the login page
+
+ egCore.startup.go().then(
+ function() {
+ $scope.username = egCore.auth.user().usrname();
+ $scope.workstation = egCore.auth.workstation();
+ }
+ );
+ }
+ }
+ ]
+ }
+});
+