增加数字键切换菜单

This commit is contained in:
luchenqun 2017-06-09 21:12:49 +08:00
parent 31b9d41126
commit a930cb11b1
5 changed files with 58 additions and 52 deletions

View File

@ -31,6 +31,7 @@
- [x] 在热门标签里面有在网上找的热门书签。可以转存收藏到自己书签里面快捷键R随机查看热门书签。 - [x] 在热门标签里面有在网上找的热门书签。可以转存收藏到自己书签里面快捷键R随机查看热门书签。
- [x] 新增备忘录功能有时候随手要做点纪录就方便了。任意界面按快捷键A增加备忘录。双击备忘录可查看详情 - [x] 新增备忘录功能有时候随手要做点纪录就方便了。任意界面按快捷键A增加备忘录。双击备忘录可查看详情
- [x] 在设置的全局链接,可设置快捷键,用来在任何页面,快速打开设置的链接。 - [x] 在设置的全局链接,可设置快捷键,用来在任何页面,快速打开设置的链接。
- [ ] 适配手机平板。
4 主要用到的模块说明 4 主要用到的模块说明
------------------ ------------------

View File

@ -7,7 +7,7 @@ app.controller('menuCtr', ['$scope', '$stateParams', '$state', '$window', '$time
$scope.showStyle = null; $scope.showStyle = null;
$scope.searchHistory = []; $scope.searchHistory = [];
$scope.historyTypes = dataService.historyTypes; $scope.historyTypes = dataService.historyTypes;
$scope.quickUrl = { }; $scope.quickUrl = {};
$scope.longPress = false; $scope.longPress = false;
// 防止在登陆的情况下在浏览器里面直接输入url这时候要更新菜单选项 // 防止在登陆的情况下在浏览器里面直接输入url这时候要更新菜单选项
@ -213,11 +213,23 @@ app.controller('menuCtr', ['$scope', '$stateParams', '$state', '$window', '$time
} }
} }
// 数字键用来切换菜单
if (!isNaN(key)) {
var num = parseInt(key);
pubSubService.publish('Common.menuActive', {
login: $scope.login,
index: num - 1
});
$state.go(dataService.loginMenus[num - 1].uiSref, {}, {
reload: true,
})
} else {
var url = $scope.quickUrl[key]; var url = $scope.quickUrl[key];
if (url) { if (url) {
$window.open(url, '_blank'); $window.open(url, '_blank');
} }
} }
}
}) })
}); });

View File

@ -116,16 +116,16 @@ app.controller('settingsCtr', ['$scope', '$stateParams', '$filter', '$state', '$
$scope.quickKey = function(key) { $scope.quickKey = function(key) {
key = key.toUpperCase(); key = key.toUpperCase();
console.log('key = ', key); console.log('key = ', key);
if (!((key >= 'A' && key <= 'Z') || (key >= '1' && key <= '9'))) { if (!(key >= 'A' && key <= 'Z')) {
key = ''; key = '';
toastr.warning('快捷键只能是数字1 ~ 9或者字母a ~ z字母不区分大小写。', "警告"); toastr.warning('快捷键只能是字母a ~ z字母不区分大小写。', "警告");
} }
$timeout(function() { $timeout(function() {
$scope.key = key; $scope.key = key;
}); });
} }
$scope.addQuickUrl = function(){ $scope.addQuickUrl = function() {
if ($scope.url == '' || $scope.key == '') { if ($scope.url == '' || $scope.key == '') {
toastr.warning('快捷键或者网站地址为空!', "警告"); toastr.warning('快捷键或者网站地址为空!', "警告");
} }
@ -136,7 +136,7 @@ app.controller('settingsCtr', ['$scope', '$stateParams', '$filter', '$state', '$
return; return;
} }
if (!(($scope.key >= 'A' && $scope.key <= 'Z') || ($scope.key >= 'a' && $scope.key <= 'z') || ($scope.key >= '1' && $scope.key <= '9'))) { if (!(($scope.key >= 'A' && $scope.key <= 'Z') || ($scope.key >= 'a' && $scope.key <= 'z') || ($scope.key >= '1' && $scope.key <= '9'))) {
toastr.warning('快捷键只能是数字1 ~ 9或者字母a ~ z字母不区分大小写。', "警告"); toastr.warning('快捷键只能是字母a ~ z字母不区分大小写。', "警告");
$scope.key = ''; $scope.key = '';
return; return;
} }
@ -227,6 +227,7 @@ app.controller('settingsCtr', ['$scope', '$stateParams', '$filter', '$state', '$
} }
transition(); transition();
function transition() { function transition() {
var className = 'js-segment-settings'; var className = 'js-segment-settings';
$('.' + className).transition('hide'); $('.' + className).transition('hide');

View File

@ -46,15 +46,7 @@
</div> </div>
</div> </div>
</label> </label>
<input <input class="prompt search-item" type="text" ng-model="searchWord" placeholder="" ng-keypress="($event.which === 13)?search(searchWord):0" data-position="bottom left" data-variation="large" id="lcq">
class="prompt search-item"
type="text"
ng-model="searchWord"
placeholder=""
ng-keypress="($event.which === 13)?search(searchWord):0"
data-position="bottom left"
data-variation="large"
id="lcq">
<div class="ui fluid popup top left transition hidden" style="padding-left: 0px; padding-right: 0px;"> <div class="ui fluid popup top left transition hidden" style="padding-left: 0px; padding-right: 0px;">
<div class="ui selection list"> <div class="ui selection list">
<div class="item" ng-repeat="item in searchHistory" ng-click="searchByHistory(item.t, item.d)" style="height:30px;"> <div class="item" ng-repeat="item in searchHistory" ng-click="searchByHistory(item.t, item.d)" style="height:30px;">
@ -81,7 +73,7 @@
</span> </span>
</div> </div>
<div class="item" style="padding:0 8px 0 13px;"> <div class="item" style="padding:0 8px 0 13px;">
<span data-tooltip="1、在备忘录页面按A键添加备忘录。2、在热门收藏页面按R键随机查看热门收藏。"> <span data-tooltip="1、在任意页面按A键添加备忘录。2、在热门收藏页面按R键随机查看热门收藏。3、在任意页面按数字键切换菜单栏。">
<i class="info circle icon"></i> <i class="info circle icon"></i>
</span> </span>
</div> </div>

View File

@ -158,7 +158,7 @@
<p>1、该代码我托管在Github上<a href="https://github.com/luchenqun/my-bookmark" target="_blank">my-bookmark</a>。该地址有文件夹详细说明以及部署步骤。git地址git@github.com:luchenqun/my-bookmark.git。如果你需要源码你尽可随意使用此项目无需通知我。</p> <p>1、该代码我托管在Github上<a href="https://github.com/luchenqun/my-bookmark" target="_blank">my-bookmark</a>。该地址有文件夹详细说明以及部署步骤。git地址git@github.com:luchenqun/my-bookmark.git。如果你需要源码你尽可随意使用此项目无需通知我。</p>
</div> </div>
<div class="ui container js-p-info" ng-show="form[4]"> <div class="ui container js-p-info" ng-show="form[4]">
<p>功能说明:可在该页面,设置全局快速打开的链接。快捷键只能是数字1 ~ 9或者字母a ~ z字母不区分大小写。</p> <p>功能说明可在该页面设置全局快速打开的链接。快捷键只能是字母a ~ z字母不区分大小写。</p>
<div class="ui divider"></div> <div class="ui divider"></div>
<table class="ui selectable sortable celled table js-quick-url-table"> <table class="ui selectable sortable celled table js-quick-url-table">
<thead> <thead>
@ -196,5 +196,5 @@
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>