1
0
mirror of https://github.com/moparisthebest/mail synced 2024-12-23 15:58:49 -05:00

add keyboard shortcuts

This commit is contained in:
Tankred Hase 2013-10-13 12:46:24 +02:00
parent d8176062f5
commit 62ce7bea60
4 changed files with 27 additions and 4 deletions

View File

@ -16,7 +16,7 @@
<script src="require-config.js"></script>
<script src="js/app.js"></script>
</head>
<body>
<body key-shortcuts>
<div ng-view class="main-app-view"></div>

View File

@ -13,7 +13,7 @@ require([
], function(angular, LoginCtrl, MailListCtrl, ReadCtrl, WriteCtrl, NavigationCtrl) {
'use strict';
var app = angular.module('mail', ['ngRoute', 'ngTouch', 'write', 'read']);
var app = angular.module('mail', ['ngRoute', 'ngTouch', 'navigation', 'write', 'read']);
// set router paths
app.config(function($routeProvider) {

View File

@ -73,7 +73,6 @@ define(function(require) {
//
function initList() {
firstSelect = true;
updateStatus('Read cache ...');
// list messaged from local db
@ -116,6 +115,7 @@ define(function(require) {
}
function listLocalMessages(options, callback) {
firstSelect = true;
emailDao.listMessages(options, function(err, emails) {
if (err) {
console.log(err);

View File

@ -1,7 +1,8 @@
define(function(require) {
'use strict';
var appController = require('js/app-controller'),
var angular = require('angular'),
appController = require('js/app-controller'),
emailDao;
var NavigationCtrl = function($scope) {
@ -86,5 +87,27 @@ define(function(require) {
}
};
//
// Directives
//
var ngModule = angular.module('navigation', []);
ngModule.directive('keyShortcuts', function() {
return function(scope, elm) {
elm.bind('keydown', function(e) {
if (e.keyCode === 78 && scope.$$childTail && scope.$$childTail.write) {
// n
e.preventDefault();
return scope.$$childTail.write();
} else if (e.keyCode === 82 && scope.$$childTail && scope.$$childTail.write && scope.$$childTail.selected) {
// r
e.preventDefault();
return scope.$$childTail.write(scope.$$childTail.selected);
}
});
};
});
return NavigationCtrl;
});