增加快捷操作复制链接,编辑书签,删除书签等操作

This commit is contained in:
luchenqun 2017-06-11 16:28:54 +08:00
parent 6b5f10b1c4
commit 7cae54117a
14 changed files with 141 additions and 47 deletions

View File

@ -1,12 +1,12 @@
app.controller('bookmarksCtr', ['$scope', '$state', '$stateParams', '$filter', '$window', '$timeout', 'ngDialog', 'bookmarkService', 'pubSubService', 'dataService', function($scope, $state, $stateParams, $filter, $window, $timeout, ngDialog, bookmarkService, pubSubService, dataService) {
app.controller('bookmarksCtr', ['$scope', '$state', '$stateParams', '$filter', '$window', '$timeout', '$document', 'ngDialog', 'bookmarkService', 'pubSubService', 'dataService', function($scope, $state, $stateParams, $filter, $window, $timeout, $document, ngDialog, bookmarkService, pubSubService, dataService) {
console.log("Hello bookmarksCtr...", $stateParams);
$scope.bookmarks = []; // 书签数据
$scope.showSearch = false; // 搜索对话框
$scope.bookmarkNormalHover = false;
$scope.bookmarkEditHover = false;
$scope.hoverBookmark = null;
var menusScope = $('div[ng-controller="menuCtr"]').scope();
$scope.showStyle = ($stateParams && $stateParams.showStyle) || (menusScope && menusScope.showStyle); // 显示风格'navigate', 'costomTag', 'card', 'table'
$scope.edit = false;
const perPageItems = 20;
var dialog = null;
$scope.totalPages = 0;
@ -48,33 +48,28 @@ app.controller('bookmarksCtr', ['$scope', '$state', '$stateParams', '$filter', '
}
$scope.jumpToUrl = function(url, id) {
if (!$scope.edit) {
$window.open(url, '_blank');
bookmarkService.clickBookmark({
id: id
});
$window.open(url, '_blank');
bookmarkService.clickBookmark({
id: id
});
if ($scope.showStyle != 'navigate') {
var bookmarks = $scope.showStyle == 'table' ? $scope.bookmarkData.bookmarks : $scope.bookmarkData;
bookmarks.forEach(function(bookmark) {
if (bookmark.id == id) {
bookmark.click_count += 1;
bookmark.last_click = $filter("date")(new Date(), "yyyy-MM-dd HH:mm:ss");
}
})
} else {
if ($scope.showStyle != 'navigate') {
var bookmarks = $scope.showStyle == 'table' ? $scope.bookmarkData.bookmarks : $scope.bookmarkData;
bookmarks.forEach(function(bookmark) {
if (bookmark.id == id) {
bookmark.click_count += 1;
bookmark.last_click = $filter("date")(new Date(), "yyyy-MM-dd HH:mm:ss");
}
})
} else {
}
$timeout(function() {
timeagoInstance.cancel();
timeagoInstance.render(document.querySelectorAll('.need_to_be_rendered'), 'zh_CN');
}, 100)
}
$timeout(function() {
timeagoInstance.cancel();
timeagoInstance.render(document.querySelectorAll('.need_to_be_rendered'), 'zh_CN');
}, 100)
}
$scope.toggleMode = function() {
$scope.edit = !$scope.edit
};
$scope.delBookmark = function(bookmark) {
console.log('delBookmark..........')
@ -256,6 +251,29 @@ app.controller('bookmarksCtr', ['$scope', '$state', '$stateParams', '$filter', '
}
});
$scope.setHoverBookmark = function(bookmark) {
$scope.hoverBookmark = bookmark;
}
// 在输入文字的时候也会触发所以不要用Ctrl,Shift之类的按键
$document.bind("keydown", function(event) {
$scope.$apply(function() {
var key = event.key.toUpperCase();
console.log(key);
if ($scope.hoverBookmark && dataService.keyShortcuts()) {
if (key == 'E') {
$scope.editBookmark($scope.hoverBookmark.id)
} else if (key == 'I') {
$scope.detailBookmark($scope.hoverBookmark)
} else if (key == 'D') {
$scope.delBookmark($scope.hoverBookmark)
} else if (key == 'C') {
$scope.copy($scope.hoverBookmark.url)
}
}
})
});
function getBookmarks() {
var params = {}
params.showStyle = $scope.showStyle

View File

@ -1,5 +1,7 @@
app.controller('hotCtr', ['$scope', '$state', '$stateParams', '$filter', '$window', '$timeout', '$document', 'ngDialog', 'bookmarkService', 'pubSubService', 'dataService', function($scope, $state, $stateParams, $filter, $window, $timeout, $document, ngDialog, bookmarkService, pubSubService, dataService) {
console.log("Hello hotCtr...");
$scope.hoverBookmark = null;
$scope.bookmarks = []; // 书签数据
$scope.bookmarkNormalHover = false;
$scope.bookmarkEditHover = false;
@ -140,6 +142,24 @@ app.controller('hotCtr', ['$scope', '$state', '$stateParams', '$filter', '$windo
}
}
$scope.setHoverBookmark = function(bookmark) {
$scope.hoverBookmark = bookmark;
}
// 在输入文字的时候也会触发所以不要用Ctrl,Shift之类的按键
$document.bind("keydown", function(event) {
$scope.$apply(function() {
var key = event.key.toUpperCase();
if ($scope.hoverBookmark && dataService.keyShortcuts()) {
if (key == 'I') {
$scope.detailBookmark($scope.hoverBookmark)
} else if (key == 'C') {
$scope.copy($scope.hoverBookmark.url)
}
}
})
});
function getHotBookmarks() {
getHotBookmarksbyAPI(); // 先实时获取,实时获取失败再从缓存中获取

View File

@ -191,6 +191,16 @@ app.controller('menuCtr', ['$scope', '$stateParams', '$state', '$window', '$time
// toastr.error('获取信息失败。错误信息:' + JSON.stringify(err), "错误");
});
$timeout(function() {
$('.suggest')
.popup({
title: '操作提示',
position: 'bottom center',
variation: "very wide",
html: '<span>1、在任意页面按A键添加备忘录。<br/>2、在热门收藏页面按R键随机查看热门收藏。<br/>3、在任意页面按数字键切换菜单栏。<br/>4、在书签页面鼠标放在书签上按C复制书签链接<br/>5、在书签页面鼠标放在书签上按E编辑书签<br/>6、在书签页面鼠标放在书签上按D删除书签<br/>7、在书签页面鼠标放在书签上按I查看书签详情<br/>8、在任意页面按INSERT做添加书签<br/>9、在任意页面按ESC退出弹窗<br/></span>'
});
}, 1000)
// 在输入文字的时候也会触发所以不要用Ctrl,Shift之类的按键
$document.bind("keydown", function(event) {
$scope.$apply(function() {

View File

@ -3,6 +3,7 @@ app.controller('noteCtr', ['$scope', '$state', '$stateParams', '$filter', '$wind
const perPageItems = 35;
var dialog = null;
$scope.hoverNote = null;
$scope.loadBusy = false;
$scope.add = false;
$scope.edit = false;
@ -214,6 +215,28 @@ app.controller('noteCtr', ['$scope', '$state', '$stateParams', '$filter', '$wind
});
}
$scope.setHoverNote = function(note) {
$scope.hoverNote = note;
}
// 在输入文字的时候也会触发所以不要用Ctrl,Shift之类的按键
$document.bind("keydown", function(event) {
$scope.$apply(function() {
var key = event.key.toUpperCase();
if ($scope.hoverNote && dataService.keyShortcuts()) {
if (key == 'E') {
$scope.editNote($scope.hoverNote.id, $scope.hoverNote.content)
} else if (key == 'I') {
$scope.detailNote($scope.hoverNote.content)
} else if (key == 'D') {
$scope.delNote($scope.hoverNote.id, $scope.hoverNote.content)
} else if (key == 'C') {
$scope.copy($scope.hoverNote.content)
}
}
})
});
function getNotes() {
$scope.loadBusy = true;
var params = {

View File

@ -1,7 +1,8 @@
app.controller('searchCtr', ['$scope', '$state', '$stateParams', '$filter', '$window', '$timeout', 'ngDialog', 'bookmarkService', 'pubSubService', 'dataService', function($scope, $state, $stateParams, $filter, $window, $timeout, ngDialog, bookmarkService, pubSubService, dataService) {
app.controller('searchCtr', ['$scope', '$state', '$stateParams', '$filter', '$window', '$timeout', '$document', 'ngDialog', 'bookmarkService', 'pubSubService', 'dataService', function($scope, $state, $stateParams, $filter, $window, $timeout, $document, ngDialog, bookmarkService, pubSubService, dataService) {
console.log("Hello searchCtr...", $stateParams);
const perPageItems = 20;
var dialog = null;
$scope.hoverBookmark = null;
$scope.searchBookmarks = []; // 书签数据
$scope.showSearch = false; //
$scope.showTags = false; //
@ -220,6 +221,29 @@ app.controller('searchCtr', ['$scope', '$state', '$stateParams', '$filter', '$wi
$('.ui.dropdown.js-search-tags .text').text(text);
}
$scope.setHoverBookmark = function(bookmark) {
$scope.hoverBookmark = bookmark;
}
// 在输入文字的时候也会触发所以不要用Ctrl,Shift之类的按键
$document.bind("keydown", function(event) {
$scope.$apply(function() {
var key = event.key.toUpperCase();
console.log($scope.hoverBookmark);
if ($scope.hoverBookmark && dataService.keyShortcuts()) {
if (key == 'E' && $scope.hoverBookmark.own) {
$scope.editBookmark($scope.hoverBookmark.id)
} else if (key == 'I') {
$scope.detailBookmark($scope.hoverBookmark)
} else if (key == 'D' && $scope.hoverBookmark.own) {
$scope.delBookmark($scope.hoverBookmark)
} else if (key == 'C') {
$scope.copy($scope.hoverBookmark.url)
}
}
})
});
pubSubService.subscribe('EditCtr.inserBookmarsSuccess', $scope, function(event, data) {
console.log('subscribe EditCtr.inserBookmarsSuccess', JSON.stringify(data));
$scope.searchBookmarks.forEach((bookmark) => {

View File

@ -1,5 +1,7 @@
app.controller('settingsCtr', ['$scope', '$stateParams', '$filter', '$state', '$window', '$timeout', 'bookmarkService', 'pubSubService', 'dataService', function($scope, $stateParams, $filter, $state, $window, $timeout, bookmarkService, pubSubService, dataService) {
console.log('Hello settingsCtr......', $stateParams);
$scope.forbidQuickKey = dataService.forbidQuickKey
$scope.form = [false, false, false, false];
$scope.passwordOrgin = "";
$scope.passwordNew1 = "";

View File

@ -6,7 +6,7 @@ app.controller('tagsCtr', ['$scope', '$filter', '$window', '$stateParams', '$tim
var dialog = null;
$scope.hoverBookmark = null;
$scope.order = [false, false, false];
$scope.order[($stateParams && $stateParams.orderIndex) || 1] = true;
$scope.order[($stateParams && $stateParams.orderIndex) || 0] = true;
$scope.loadBookmarks = false;
$scope.loadTags = false;
$scope.tags = []; // 书签数据

View File

@ -58,6 +58,10 @@ app.factory('dataService', [function() {
showStyles: ['navigate', 'costomTag', 'card', 'table'],
forbidQuickKey: {
'A': '在任意界面,已用做新增备忘录',
'C': '在有关书签页面,用作复制书签链接',
'E': '在有关书签页面,用作编辑书签',
'D': '在有关书签页面,用作删除书签',
'I': '在有关书签页面,用作查看书签详情',
'R': '在热门收藏界面,已用作随机查看热门收藏',
'INSERT': '全局页面,已用做添加书签',
'ESC': '全局页面,已用做退出弹窗',

View File

@ -22,26 +22,22 @@
<div
class="four wide column js-navigate-bookmark"
ng-class="{bookmarkNormalHover:bookmarkNormalHover, bookmarkEditHover:bookmarkEditHover, bookmark:(!bookmarkNormalHover && !bookmarkEditHover)}"
ng-mouseover="edit ? (bookmarkEditHover=true) : (bookmarkNormalHover=true)"
ng-mouseleave="edit ? (bookmarkEditHover=false) : (bookmarkNormalHover=false)"
ng-mouseover="bookmarkNormalHover=true; setHoverBookmark(bookmark)"
ng-mouseleave="bookmarkNormalHover=false; setHoverBookmark(null)"
ng-repeat="bookmark in tag.bookmarks"
ng-click="jumpToUrl(bookmark.url, bookmark.id)"
title="{{ bookmark.title }}"
id="{{bookmark.id}}">
<img class="ui ui middle aligned tiny image bookmarkOperaterHover" style="width:16px;height:16px" ng-src="./images/{{ bookmarkEditHover ? 'delete-hover' : 'delete'}}.png" ng-if="edit" ng-click="delBookmark(bookmark)">
<img class="ui ui middle aligned tiny image bookmarkOperaterHover" style="width:16px;height:16px;float:right;" ng-src="./images/{{ bookmarkEditHover ? 'edit-bookmark-hover' : 'edit-bookmark'}}.png" ng-if="edit" ng-click="editBookmark(bookmark.id)">
<img
class="ui ui middle aligned tiny image bookmarkInfo"
ng-src="http://g.soz.im/{{bookmark.url}}/cdn.ico"
style="width:16px;height:16px;"
ng-click="detailBookmark(bookmark);$event.stopPropagation()"
ng-if="!edit"
favicon-err="./images/favicon/{{bookmark.id}}.ico">
<span>{{ bookmark.title}}</span>
</div>
</div>
</div>
<div ng-if="tagIndex === 0" style="width:22px;height:22px;" class="js-bookmark-edit" ng-click="toggleMode()" data-tooltip="{{edit ? '退出编辑模式' : '点击进入编辑模式'}}"><img class="ui ui middle aligned tiny image" ng-src="./images/{{ edit ? 'back' : 'edit'}}.png"></div>
</div>
</div>
<div class="ui divider"></div>
@ -62,8 +58,8 @@
<div
class="column js-costomTag-item"
ng-class="{bookmarkNormalHover:bookmarkNormalHover, bookmark:(!bookmarkNormalHover)}"
ng-mouseover="bookmarkNormalHover=true"
ng-mouseleave="bookmarkNormalHover=false"
ng-mouseover="bookmarkNormalHover=true; setHoverBookmark(bookmark)"
ng-mouseleave="bookmarkNormalHover=false; setHoverBookmark(null)"
ng-repeat="bookmark in bookmarks"
ng-click="jumpToUrl(bookmark.url, bookmark.id)"
title="{{ bookmark.title }}"
@ -91,7 +87,7 @@
</tr>
</thead>
<tbody>
<tr ng-repeat="bookmark in bookmarks" id="{{ bookmark.id }}">
<tr ng-repeat="bookmark in bookmarks" id="{{ bookmark.id }}" ng-mouseover="setHoverBookmark(bookmark)" ng-mouseleave="setHoverBookmark(null)">
<td>
<img class="ui ui middle aligned tiny image" ng-src="http://g.soz.im/{{bookmark.url}}/cdn.ico" style="width:16px;height:16px;cursor:pointer;" ng-click="jumpToUrl(bookmark.url, bookmark.id)" favicon-err="./images/favicon/{{bookmark.id}}.ico">
<span ng-click="jumpToUrl(bookmark.url, bookmark.id)" title="{{bookmark.title}}" style="cursor:pointer;">
@ -130,7 +126,7 @@
</table>
<div class="ui segment js-segment-card" ng-if="showStyle === 'card'" ng-show="!loadBusy || currentPage>1">
<div class="ui five stackable cards" infinite-scroll='loadCardData()' infinite-scroll-immediate-check="false">
<div class="card" ng-repeat="bookmark in bookmarks" id="{{bookmark.id}}">
<div class="card" ng-repeat="bookmark in bookmarks" id="{{bookmark.id}}" ng-mouseover="setHoverBookmark(bookmark)" ng-mouseleave="setHoverBookmark(null)">
<div class="content" ng-click="jumpToUrl(bookmark.url, bookmark.id)" style="max-height:70px;cursor:pointer">
<div class="description bookmarkTitle">
{{bookmark.title}}

View File

@ -1,7 +1,7 @@
<!-- 高度至少要设置1000元素少时才能触发滚动条事件 -->
<div class="ui segment js-hot-card" style="min-height:1000px;" ng-show="!loadBusy || (!random && curDay<0)">
<div class="ui five stackable cards" infinite-scroll='loadHotBookmarks()' infinite-scroll-immediate-check="false">
<div class="card" ng-repeat="bookmark in bookmarks">
<div class="ui five stackable cards" infinite-scroll='loadHotBookmarks()' infinite-scroll-immediate-check="false">
<div class="card" ng-repeat="bookmark in bookmarks" ng-mouseover="setHoverBookmark(bookmark)" ng-mouseleave="setHoverBookmark(null)">
<div class="content" style="max-height:70px;cursor:pointer" ng-click="jumpToUrl(bookmark.url)">
<div class="description bookmarkTitle" title="{{bookmark.title}}">
{{bookmark.title}}

View File

@ -73,7 +73,7 @@
</span>
</div>
<div class="item" style="padding:0 8px 0 13px;">
<span data-tooltip="1、在任意页面按A键添加备忘录。2、在热门收藏页面按R键随机查看热门收藏。3、在任意页面按数字键切换菜单栏。">
<span class="suggest">
<i class="info circle icon"></i>
</span>
</div>

View File

@ -25,7 +25,7 @@
</div>
<div class="ui divider" ng-show="add"></div>
<div class="ui five stackable cards">
<div class="card" ng-repeat="note in notes" id="{{note.id}}">
<div class="card" ng-repeat="note in notes" id="{{note.id}}" ng-mouseover="setHoverNote(note)" ng-mouseleave="setHoverNote(null)">
<div class="content" style="height:200px;margin-bottom:8px;" ng-dblclick="detailNote(note.content)">
<div class="description" style="word-break:break-all;max-width:175px;height:184px;line-height:21px; word-wrap:break-word;text-overflow:ellipsis;overflow:hidden;">
<pre class="note-content" style="margin-top:0px;">{{ note.content }}</pre>

View File

@ -131,7 +131,7 @@
</tr>
</thead>
<tbody>
<tr ng-repeat="bookmark in searchBookmarks" id="{{ bookmark.id }}">
<tr ng-repeat="bookmark in searchBookmarks" id="{{ bookmark.id }}" ng-mouseover="setHoverBookmark(bookmark)" ng-mouseleave="setHoverBookmark(null)">
<td>
<img
class="ui ui middle aligned mini image"

View File

@ -159,11 +159,8 @@
</div>
<div class="ui container js-p-info" ng-show="form[4]">
<p>功能说明可在该页面设置全局快速打开的链接。快捷键只能是字母a ~ z字母不区分大小写。</p>
<p>以下几个系统默认使用的按键无法使用:
<br/>
A: 在任意界面,已用做新增备忘录。
<br/>
R: 在热门收藏界面,已用作随机查看热门收藏。
<p>以下几个系统默认使用的按键无法使用:<br/>
<span ng-repeat="(key, value) in forbidQuickKey">{{key}}{{value}}<br/></span>
</p>
<div class="ui divider"></div>
<table class="ui selectable sortable celled table js-quick-url-table">