增加数字键切换菜单

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] 新增备忘录功能有时候随手要做点纪录就方便了。任意界面按快捷键A增加备忘录。双击备忘录可查看详情
- [x] 在设置的全局链接,可设置快捷键,用来在任何页面,快速打开设置的链接。
- [ ] 适配手机平板。
4 主要用到的模块说明
------------------

View File

@ -7,7 +7,7 @@ app.controller('menuCtr', ['$scope', '$stateParams', '$state', '$window', '$time
$scope.showStyle = null;
$scope.searchHistory = [];
$scope.historyTypes = dataService.historyTypes;
$scope.quickUrl = { };
$scope.quickUrl = {};
$scope.longPress = false;
// 防止在登陆的情况下在浏览器里面直接输入url这时候要更新菜单选项
@ -213,9 +213,21 @@ app.controller('menuCtr', ['$scope', '$stateParams', '$state', '$window', '$time
}
}
var url = $scope.quickUrl[key];
if (url) {
$window.open(url, '_blank');
// 数字键用来切换菜单
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];
if (url) {
$window.open(url, '_blank');
}
}
}
})

View File

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

View File

@ -46,15 +46,7 @@
</div>
</div>
</label>
<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">
<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">
<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;">
@ -81,7 +73,7 @@
</span>
</div>
<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>
</span>
</div>

View File

@ -158,43 +158,43 @@
<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 class="ui container js-p-info" ng-show="form[4]">
<p>功能说明可在该页面设置全局快速打开的链接。快捷键只能是数字1 ~ 9或者字母a ~ z字母不区分大小写。</p>
<div class="ui divider"></div>
<table class="ui selectable sortable celled table js-quick-url-table">
<thead>
<tr>
<th style="width:80px;">快捷键</th>
<th>网站地址</th>
<th style="width:45px;">操作</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="(key, value) in quickUrl">
<td>{{key}}</td>
<td>{{value}}</td>
<td>
<img class="ui mini spaced image" style="width:16px;height:16px;margin:0 1px" ng-src="./images/delete.png" ng-click="delUrl(key)" title="删除书签">
</td>
</tr>
</tbody>
</table>
<div class="ui divider"></div>
<div class="ui form">
<div class="inline fields">
<div class="five wide field">
<label style="min-width:55px;">快捷键:</label>
<input type="text" placeholder="请按相应的快捷键" ng-model="key" ng-keypress="quickKey($event.key)">
</div>
<div class="nine wide field">
<label style="min-width:66px;">网站地址:</label>
<input type="text" placeholder="请输入你需要快捷打开的网站地址" ng-model="url">
</div>
<div class="two wide field">
<div class="ui green button" ng-click="addQuickUrl()">确定</div>
<p>功能说明可在该页面设置全局快速打开的链接。快捷键只能是字母a ~ z字母不区分大小写。</p>
<div class="ui divider"></div>
<table class="ui selectable sortable celled table js-quick-url-table">
<thead>
<tr>
<th style="width:80px;">快捷键</th>
<th>网站地址</th>
<th style="width:45px;">操作</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="(key, value) in quickUrl">
<td>{{key}}</td>
<td>{{value}}</td>
<td>
<img class="ui mini spaced image" style="width:16px;height:16px;margin:0 1px" ng-src="./images/delete.png" ng-click="delUrl(key)" title="删除书签">
</td>
</tr>
</tbody>
</table>
<div class="ui divider"></div>
<div class="ui form">
<div class="inline fields">
<div class="five wide field">
<label style="min-width:55px;">快捷键:</label>
<input type="text" placeholder="请按相应的快捷键" ng-model="key" ng-keypress="quickKey($event.key)">
</div>
<div class="nine wide field">
<label style="min-width:66px;">网站地址:</label>
<input type="text" placeholder="请输入你需要快捷打开的网站地址" ng-model="url">
</div>
<div class="two wide field">
<div class="ui green button" ng-click="addQuickUrl()">确定</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>