From 54841a92de5f23508f4b684212a27583da94128a Mon Sep 17 00:00:00 2001 From: Athou Date: Fri, 17 May 2013 16:33:58 +0200 Subject: [PATCH] toolbar navigation icons --- src/main/resources/i18n/en.properties | 2 ++ src/main/webapp/js/controllers.js | 29 ++++++++++++++++++++++--- src/main/webapp/templates/_toolbar.html | 6 ++++- 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/src/main/resources/i18n/en.properties b/src/main/resources/i18n/en.properties index 4b24e32f..83bcc3ae 100644 --- a/src/main/resources/i18n/en.properties +++ b/src/main/resources/i18n/en.properties @@ -24,6 +24,8 @@ new_category.parent=Parent toolbar.unread=Unread toolbar.all=All +toolbar.previous_entry=Previous entry +toolbar.next_entry=Next entry toolbar.refresh=Refresh toolbar.sort_by_asc_desc=Sort by date asc/desc toolbar.mark_all_as_read=Mark all as read diff --git a/src/main/webapp/js/controllers.js b/src/main/webapp/js/controllers.js index 1ee6f6ce..0f37a67a 100644 --- a/src/main/webapp/js/controllers.js +++ b/src/main/webapp/js/controllers.js @@ -1,6 +1,12 @@ var module = angular.module('commafeed.controllers', []); module.run(['$rootScope', function($rootScope) { + $rootScope.$on('emitPreviousEntry', function(event, args) { + $rootScope.$broadcast('previousEntry', args); + }); + $rootScope.$on('emitNextEntry', function(event, args) { + $rootScope.$broadcast('nextEntry', args); + }); $rootScope.$on('emitMark', function(event, args) { // args.entry - the entry $rootScope.$broadcast('mark', args); @@ -381,6 +387,15 @@ function($scope, $http, $state, $stateParams, $route, $location, $scope.$emit('emitReload'); } }); + + $scope.previousEntry = function() { + $scope.$emit('emitPreviousEntry'); + }; + $scope.nextEntry = function() { + $scope.$emit('emitNextEntry'); + }; + + $scope.refresh = function() { if($stateParams._type == 'feed'){ FeedService.refresh({ @@ -580,7 +595,7 @@ function($scope, $stateParams, $http, $route, $window, EntryService, SettingsSer $scope.isOpen = SettingsService.settings.viewMode == 'expanded'; $scope.entryClicked = function(entry, event) { $scope.navigationMode = 'click'; - if (!event.ctrlKey && event.which != 2) { + if (!event || (!event.ctrlKey && event.which != 2)) { if ($scope.current != entry || SettingsService.settings.viewMode == 'expanded') { $scope.isOpen = true; } else { @@ -590,8 +605,10 @@ function($scope, $stateParams, $http, $route, $window, EntryService, SettingsSer $scope.mark(entry, true); } $scope.current = entry; - event.preventDefault(); - event.stopPropagation(); + if(event) { + event.preventDefault(); + event.stopPropagation(); + } } else { $scope.mark(entry, true); } @@ -731,6 +748,12 @@ function($scope, $stateParams, $http, $route, $window, EntryService, SettingsSer }); }); + $scope.$on('previousEntry', function(event, args) { + openPreviousEntry(); + }); + $scope.$on('nextEntry', function(event, args) { + openNextEntry(); + }); $scope.$on('markAll', function(event, args) { $scope.markAll(args.olderThan); }); diff --git a/src/main/webapp/templates/_toolbar.html b/src/main/webapp/templates/_toolbar.html index 2cc2dd22..2e587e1c 100644 --- a/src/main/webapp/templates/_toolbar.html +++ b/src/main/webapp/templates/_toolbar.html @@ -15,7 +15,11 @@ - +
+ + + +