增加全局网址一键到达
This commit is contained in:
parent
f854cabf74
commit
89a6585164
|
|
@ -1,4 +1,4 @@
|
|||
app.controller('menuCtr', ['$scope', '$stateParams', '$state', '$window', '$timeout', 'pubSubService', 'bookmarkService', 'dataService', function($scope, $stateParams, $state, $window, $timeout, pubSubService, bookmarkService, dataService) {
|
||||
app.controller('menuCtr', ['$scope', '$stateParams', '$state', '$window', '$timeout', '$document', 'pubSubService', 'bookmarkService', 'dataService', function($scope, $stateParams, $state, $window, $timeout, $document, pubSubService, bookmarkService, dataService) {
|
||||
console.log("Hello menuCtr")
|
||||
$scope.login = false; /**< 是否登陆 */
|
||||
$scope.selectLoginIndex = 0; /**< 默认登陆之后的选择的菜单索引,下表从 0 开始 */
|
||||
|
|
@ -7,7 +7,6 @@ app.controller('menuCtr', ['$scope', '$stateParams', '$state', '$window', '$time
|
|||
$scope.showStyle = null;
|
||||
$scope.searchHistory = [];
|
||||
$scope.historyTypes = dataService.historyTypes;
|
||||
$scope.blur = false;
|
||||
|
||||
// 防止在登陆的情况下,在浏览器里面直接输入url,这时候要更新菜单选项
|
||||
pubSubService.subscribe('Common.menuActive', $scope, function(event, params) {
|
||||
|
|
@ -20,10 +19,6 @@ app.controller('menuCtr', ['$scope', '$stateParams', '$state', '$window', '$time
|
|||
$scope.loginMenus = dataService.loginMenus; // 登陆之后显示的菜单数据。uiSerf:内部跳转链接。
|
||||
$scope.notLoginMenus = dataService.notLoginMenus; // 未登陆显示的菜单数据
|
||||
|
||||
$scope.inputBlur = function(blur) {
|
||||
$scope.blur = blur;
|
||||
}
|
||||
|
||||
/**
|
||||
* @func
|
||||
* @desc 点击搜索按钮搜索书签
|
||||
|
|
@ -187,4 +182,28 @@ app.controller('menuCtr', ['$scope', '$stateParams', '$state', '$window', '$time
|
|||
console.log(err);
|
||||
// toastr.error('获取信息失败。错误信息:' + JSON.stringify(err), "错误");
|
||||
});
|
||||
|
||||
// 在输入文字的时候也会触发,所以不要用Ctrl,Shift之类的按键
|
||||
$document.bind("keydown", function(event) {
|
||||
$scope.$apply(function() {
|
||||
if (dataService.keyShortcuts()) {
|
||||
var key = event.key.toUpperCase();
|
||||
var urls = {
|
||||
'B':'https://www.baidu.com/',
|
||||
'G':'https://www.google.com.hk/',
|
||||
'L':'http://luchenqun.com/',
|
||||
'H':'https://github.com/',
|
||||
'S':'https://stackoverflow.com/',
|
||||
'V':'https://www.v2ex.com/',
|
||||
'Q':'http://www.iqiyi.com/',
|
||||
};
|
||||
|
||||
var url = urls[key];
|
||||
if (url) {
|
||||
$window.open(url, '_blank');
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
}]);
|
||||
|
|
|
|||
|
|
@ -47,16 +47,8 @@ app.controller('noteCtr', ['$scope', '$state', '$stateParams', '$filter', '$wind
|
|||
// 快捷键a增加书签
|
||||
$document.bind("keydown", function(event) {
|
||||
$scope.$apply(function() {
|
||||
var menusScope = $('div[ng-controller="menuCtr"]').scope();
|
||||
var login = (menusScope && menusScope.login) || false;
|
||||
var blur = (menusScope && menusScope.blur) || false;
|
||||
// a按键,显示
|
||||
if (event.keyCode == 65 && login && (!blur) && (!$scope.add)) {
|
||||
$scope.showAddNote();
|
||||
}
|
||||
|
||||
// Esc按键,退出
|
||||
if (event.keyCode == 27 && login && (!blur) && ($scope.add)) {
|
||||
if (event.keyCode == 65 && dataService.keyShortcuts() && (!$scope.add)) {
|
||||
$scope.showAddNote();
|
||||
}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -62,6 +62,36 @@ app.factory('dataService', [function() {
|
|||
},
|
||||
historyTypes: ['书签', '谷歌', 'Github', '栈溢出', '百度', '备忘录'],
|
||||
showStyles: ['navigate', 'costomTag', 'card', 'table'],
|
||||
keyShortcuts: function() { // 判断快捷方式是否生效
|
||||
var ret = true;
|
||||
var menusScope = $('div[ng-controller="menuCtr"]').scope();
|
||||
var login = (menusScope && menusScope.login) || false;
|
||||
|
||||
if (login) {
|
||||
do {
|
||||
// 如果有对话框(删除,备忘录详情等)
|
||||
ret = $(".ngdialog").length == 0;
|
||||
if (!ret) break;
|
||||
|
||||
// 如果有对话框(新增书签,更新书签,书签详情)
|
||||
ret = $(".ui.modals.visible").length == 0;
|
||||
if (!ret) break;
|
||||
|
||||
// 输入框是否聚焦
|
||||
ret = !($('input').is(':focus'));
|
||||
if (!ret) break;
|
||||
|
||||
// textarea 是否聚焦
|
||||
ret = !($('textarea').is(':focus'));
|
||||
if (!ret) break;
|
||||
|
||||
} while (false);
|
||||
} else {
|
||||
ret = false;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
return service;
|
||||
|
|
|
|||
|
|
@ -54,9 +54,7 @@
|
|||
ng-keypress="($event.which === 13)?search(searchWord):0"
|
||||
data-position="bottom left"
|
||||
data-variation="large"
|
||||
id="lcq"
|
||||
ng-focus="inputBlur(true)"
|
||||
ng-blur="inputBlur(false)">
|
||||
id="lcq">
|
||||
<div class="ui fluid popup top left transition hidden" style="padding-left: 0px; padding-right: 0px;">
|
||||
<div class="ui selection list">
|
||||
<div class="item" ng-repeat="item in searchHistory" ng-click="searchByHistory(item.t, item.d)" style="height:30px;">
|
||||
|
|
|
|||
Loading…
Reference in New Issue