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