在任何页面,按A键触发添加添加备忘录
This commit is contained in:
parent
d41fa8d2fe
commit
fb9bd39f95
|
|
@ -29,6 +29,7 @@ app.config(function($stateProvider, $urlRouterProvider, $httpProvider) {
|
|||
templateUrl: '/views/note.html',
|
||||
params: {
|
||||
searchWord: null,
|
||||
key:null,
|
||||
},
|
||||
controller: 'noteCtr'
|
||||
})
|
||||
|
|
|
|||
|
|
@ -209,10 +209,10 @@ app.controller('editCtr', ['$scope', '$state', '$timeout', '$document', 'bookmar
|
|||
// 在输入文字的时候也会触发,所以不要用Ctrl,Shift之类的按键
|
||||
$document.bind("keydown", function(event) {
|
||||
$scope.$apply(function() {
|
||||
// console.log(event.keyCode);
|
||||
var menusScope = $('div[ng-controller="menuCtr"]').scope();
|
||||
// Insert按键,显示
|
||||
if (event.keyCode == 45 && menusScope.login) {
|
||||
var key = event.key.toUpperCase();
|
||||
// console.log(key);
|
||||
if (key == 'INSERT' && menusScope.login) {
|
||||
if ($('.ui.modal.js-add-bookmark').modal('is active')) {
|
||||
$scope.ok();
|
||||
} else {
|
||||
|
|
@ -228,7 +228,7 @@ app.controller('editCtr', ['$scope', '$state', '$timeout', '$document', 'bookmar
|
|||
}
|
||||
|
||||
// Esc按键,退出
|
||||
if (event.keyCode == 27 && menusScope.login) {
|
||||
if (key == 'ESCAPE' && menusScope.login) {
|
||||
$scope.cancel();
|
||||
}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -195,6 +195,18 @@ app.controller('menuCtr', ['$scope', '$stateParams', '$state', '$window', '$time
|
|||
$scope.$apply(function() {
|
||||
if (dataService.keyShortcuts()) {
|
||||
var key = event.key.toUpperCase();
|
||||
// 全局处理添加备忘录
|
||||
if (key == 'A') {
|
||||
if ($scope.selectLoginIndex !== dataService.LoginIndexNote) {
|
||||
updateMenuActive($scope.selectLoginIndex = dataService.LoginIndexNote);
|
||||
$state.go('note', {
|
||||
key: key,
|
||||
}, {
|
||||
reload: true,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
var url = $scope.quickUrl[key];
|
||||
if (url) {
|
||||
$window.open(url, '_blank');
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ app.controller('noteCtr', ['$scope', '$state', '$stateParams', '$filter', '$wind
|
|||
$scope.currentPage = 1;
|
||||
$scope.inputPage = '';
|
||||
$scope.searchWord = $stateParams.searchWord
|
||||
$scope.key = $stateParams.key
|
||||
$scope.totalItems = 0;
|
||||
|
||||
var timeagoInstance = timeago();
|
||||
|
|
@ -48,7 +49,8 @@ app.controller('noteCtr', ['$scope', '$state', '$stateParams', '$filter', '$wind
|
|||
$document.bind("keydown", function(event) {
|
||||
$scope.$apply(function() {
|
||||
// a按键,显示
|
||||
if (event.keyCode == 65 && dataService.keyShortcuts() && (!$scope.add)) {
|
||||
var key = event.key.toUpperCase();
|
||||
if (key == 'A' && dataService.keyShortcuts() && (!$scope.add)) {
|
||||
$scope.showAddNote();
|
||||
}
|
||||
})
|
||||
|
|
@ -215,6 +217,11 @@ app.controller('noteCtr', ['$scope', '$state', '$stateParams', '$filter', '$wind
|
|||
$timeout(function() {
|
||||
timeagoInstance.cancel();
|
||||
timeagoInstance.render(document.querySelectorAll('.need_to_be_rendered'), 'zh_CN');
|
||||
// 如果需要增加书签
|
||||
if ($scope.key == 'A') {
|
||||
$scope.key = null;
|
||||
$scope.showAddNote();
|
||||
}
|
||||
}, 100)
|
||||
$scope.loadBusy = false;
|
||||
transition();
|
||||
|
|
|
|||
Loading…
Reference in New Issue