diff --git a/brewman/static/base.html b/brewman/static/base.html
index 5bd9fc54..c3f87578 100644
--- a/brewman/static/base.html
+++ b/brewman/static/base.html
@@ -26,6 +26,7 @@
+
diff --git a/brewman/static/js/mousetrap-brewman.js b/brewman/static/js/mousetrap-brewman.js
new file mode 100644
index 00000000..ff2851ff
--- /dev/null
+++ b/brewman/static/js/mousetrap-brewman.js
@@ -0,0 +1,50 @@
+Mousetrap = (function (Mousetrap) {
+ 'use strict';
+ var self = Mousetrap,
+ _oldBind = self.bind,
+ _oldUnbind = self.unbind,
+ args;
+
+ self.stopCallback = function (e, element) {
+
+ // if the element has the class "mousetrap" then no need to stop
+ if ((' ' + element.className + ' ').indexOf(' mousetrap ') > -1) {
+ return false;
+ }
+
+ // stop for input, select, and textarea
+ return ['INPUT', 'SELECT', 'TEXTAREA', 'BUTTON'].indexOf(element.tagName) > -1 || element.isContentEditable;
+ };
+
+ self.bind = function () {
+ args = arguments;
+
+ // normal call
+ if (typeof args[0] === 'string' || args[0] instanceof Array) {
+ return _oldBind.apply(this, args);
+ }
+
+ // object passed in
+ for (var key in args[0]) {
+ if (args[0].hasOwnProperty(key)) {
+ _oldBind(key, args[0][key], args[1]);
+ }
+ }
+ };
+ self.unbind = function () {
+ args = arguments;
+
+ // normal call
+ if (typeof args[0] === 'string' || args[0] instanceof Array) {
+ return _oldUnbind.apply(this, args);
+ }
+
+ // object passed in
+ for (var key in args[0]) {
+ if (args[0].hasOwnProperty(key)) {
+ _oldUnbind(key, args[1]);
+ }
+ }
+ };
+ return Mousetrap;
+})(Mousetrap);
\ No newline at end of file
diff --git a/brewman/static/partial/ledger.html b/brewman/static/partial/ledger.html
index 5169e449..99172794 100644
--- a/brewman/static/partial/ledger.html
+++ b/brewman/static/partial/ledger.html
@@ -54,7 +54,8 @@
{{item.Date}} |
- {{item.Name}} |
+ {{item.Name}} |
+ {{item.Name}} |
{{item.Type}} |
{{item.Narration}} |
{{item.Debit | currency | clr}} |
diff --git a/brewman/static/scripts/angular_directive.js b/brewman/static/scripts/angular_directive.js
index 6782e94c..0406118c 100644
--- a/brewman/static/scripts/angular_directive.js
+++ b/brewman/static/scripts/angular_directive.js
@@ -125,21 +125,9 @@ overlordDirective.directive('chosen', ['$parse', function ($parse) {
overlordDirective.directive('keypress', [function () {
return function (scope, element, attrs) {
var keypress = scope.$eval(attrs.keypress || '{}');
- for (var k in keypress) {
- if (keypress.hasOwnProperty(k)) {
- (function (k, val) {
- Mousetrap.bind(k, val);
- })(k, keypress[k]);
- }
- }
+ Mousetrap.bind(keypress);
element.on('$destroy', function () {
- for (var k in keypress) {
- if (keypress.hasOwnProperty(k)) {
- (function (k) {
- Mousetrap.unbind(k);
- })(k);
- }
- }
+ Mousetrap.unbind(keypress);
});
};
diff --git a/brewman/static/scripts/ledger.js b/brewman/static/scripts/ledger.js
index 02f57ac5..3e791df6 100644
--- a/brewman/static/scripts/ledger.js
+++ b/brewman/static/scripts/ledger.js
@@ -35,12 +35,20 @@ var LedgerCtrl = ['$scope', '$routeParams', '$location', 'asDateFilter', 'ledger
$scope.selected = index;
};
+
+ // Replace with $watchGroup in AngularJS 1.3+
$scope.$watch('hidden', function () {
var filtered = $scope.doFilter($scope.hidden, $scope.info.Body);
$scope.ledger = filtered.Body;
$scope.footer = filtered.Footer;
}, true);
+ $scope.$watch('info', function () {
+ var filtered = $scope.doFilter($scope.hidden, $scope.info.Body);
+ $scope.ledger = filtered.Body;
+ $scope.footer = filtered.Footer;
+ }, true);
+
$scope.doFilter = _.memoize(function (hidden, input) {
var data = angular.copy(input),
debit = 0, credit = 0, running = 0;
diff --git a/brewman/static/scripts/reconcile.js b/brewman/static/scripts/reconcile.js
index 700c7b87..c399e99f 100644
--- a/brewman/static/scripts/reconcile.js
+++ b/brewman/static/scripts/reconcile.js
@@ -2,14 +2,12 @@
var ReconcileCtrl = ['$scope', '$routeParams', '$location', 'asDateFilter', 'reconcile', 'Reconcile', 'Account', function ($scope, $routeParams, $location, asDate, reconcile, Reconcile, Account) {
$scope.info = reconcile;
- $scope.hidden = [];
$scope.show = function () {
var id = $scope.info.Account.LedgerID,
startDate = asDate($scope.info.StartDate),
finishDate = asDate($scope.info.FinishDate);
if (id === $routeParams.id && startDate === $routeParams.StartDate && finishDate === $routeParams.FinishDate) {
Reconcile.get({id: id, StartDate: startDate, FinishDate: finishDate}, function (data) {
- $scope.doFilter.cache = {};
$scope.info = data;
});
} else {
@@ -49,7 +47,7 @@ var ReconcileCtrl = ['$scope', '$routeParams', '$location', 'asDateFilter', 'rec
};
$scope.shortcuts = {
- 'up': function () {
+ 'up': function (e) {
if ($scope.selected > 0) {
$scope.$apply(function () {
$scope.selected = $scope.selected -= 1;
@@ -58,7 +56,7 @@ var ReconcileCtrl = ['$scope', '$routeParams', '$location', 'asDateFilter', 'rec
e.preventDefault();
}
},
- 'down': function () {
+ 'down': function (e) {
if ($scope.selected < $scope.info.Body.length - 1) {
$scope.$apply(function () {
$scope.selected = $scope.selected += 1;
@@ -67,7 +65,7 @@ var ReconcileCtrl = ['$scope', '$routeParams', '$location', 'asDateFilter', 'rec
e.preventDefault();
}
},
- 'enter': function () {
+ 'enter': function (e) {
var path = $scope.info.Body[$scope.selected].Url.replace(/^(?:\/\/|[^\/]+)*/, "");
$scope.$apply(function () {
$location.path(path).search('StartDate', null).search('FinishDate', null);