Added "P" hotkey to post list
This commit is contained in:
parent
e0bee3b78c
commit
57fb6da4b3
6 changed files with 42 additions and 26 deletions
1
TODO
1
TODO
|
@ -9,7 +9,6 @@ everything related to posts:
|
||||||
- fix thumbnails for files that are neither youtube or images
|
- fix thumbnails for files that are neither youtube or images
|
||||||
|
|
||||||
- post list
|
- post list
|
||||||
- add P hotkey to post list
|
|
||||||
- add style for hovered and focused element
|
- add style for hovered and focused element
|
||||||
- fav count
|
- fav count
|
||||||
- score
|
- score
|
||||||
|
|
|
@ -69,6 +69,7 @@
|
||||||
<script type="text/javascript" src="/js/Api.js"></script>
|
<script type="text/javascript" src="/js/Api.js"></script>
|
||||||
<script type="text/javascript" src="/js/Auth.js"></script>
|
<script type="text/javascript" src="/js/Auth.js"></script>
|
||||||
<script type="text/javascript" src="/js/Util.js"></script>
|
<script type="text/javascript" src="/js/Util.js"></script>
|
||||||
|
<script type="text/javascript" src="/js/Keyboard.js"></script>
|
||||||
<script type="text/javascript" src="/js/BrowsingSettings.js"></script>
|
<script type="text/javascript" src="/js/BrowsingSettings.js"></script>
|
||||||
<script type="text/javascript" src="/js/Controls/FileDropper.js"></script>
|
<script type="text/javascript" src="/js/Controls/FileDropper.js"></script>
|
||||||
<script type="text/javascript" src="/js/Controls/TagInput.js"></script>
|
<script type="text/javascript" src="/js/Controls/TagInput.js"></script>
|
||||||
|
|
27
public_html/js/Keyboard.js
Normal file
27
public_html/js/Keyboard.js
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
var App = App || {};
|
||||||
|
|
||||||
|
App.Keyboard = function(mousetrap) {
|
||||||
|
|
||||||
|
function keyup(key, callback) {
|
||||||
|
mousetrap.bind(key, simpleKeyPressed(callback), 'keyup');
|
||||||
|
}
|
||||||
|
|
||||||
|
function keydown(key, callback) {
|
||||||
|
mousetrap.bind(key, simpleKeyPressed(callback));
|
||||||
|
}
|
||||||
|
|
||||||
|
function simpleKeyPressed(callback) {
|
||||||
|
return function(e) {
|
||||||
|
if (!e.altKey && !e.ctrlKey) {
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
keydown: keydown,
|
||||||
|
keyup: keyup,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
App.DI.register('keyboard', ['mousetrap'], App.Keyboard);
|
|
@ -7,7 +7,7 @@ App.Presenters.PagedCollectionPresenter = function(
|
||||||
util,
|
util,
|
||||||
promise,
|
promise,
|
||||||
api,
|
api,
|
||||||
mousetrap,
|
keyboard,
|
||||||
router,
|
router,
|
||||||
presenterManager,
|
presenterManager,
|
||||||
browsingSettings) {
|
browsingSettings) {
|
||||||
|
@ -56,16 +56,8 @@ App.Presenters.PagedCollectionPresenter = function(
|
||||||
.fail(loaded);
|
.fail(loaded);
|
||||||
|
|
||||||
if (!endlessScroll) {
|
if (!endlessScroll) {
|
||||||
mousetrap.bind('a', function(e) {
|
keyboard.keydown('a', prevPage);
|
||||||
if (!e.altKey && !e.ctrlKey) {
|
keyboard.keydown('d', nextPage);
|
||||||
prevPage();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
mousetrap.bind('d', function(e) {
|
|
||||||
if (!e.altKey && !e.ctrlKey) {
|
|
||||||
nextPage();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -232,4 +224,4 @@ App.Presenters.PagedCollectionPresenter = function(
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
App.DI.register('pagedCollectionPresenter', ['_', 'jQuery', 'util', 'promise', 'api', 'mousetrap', 'router', 'presenterManager', 'browsingSettings'], App.Presenters.PagedCollectionPresenter);
|
App.DI.register('pagedCollectionPresenter', ['_', 'jQuery', 'util', 'promise', 'api', 'keyboard', 'router', 'presenterManager', 'browsingSettings'], App.Presenters.PagedCollectionPresenter);
|
||||||
|
|
|
@ -8,6 +8,7 @@ App.Presenters.PostListPresenter = function(
|
||||||
promise,
|
promise,
|
||||||
auth,
|
auth,
|
||||||
router,
|
router,
|
||||||
|
keyboard,
|
||||||
pagedCollectionPresenter,
|
pagedCollectionPresenter,
|
||||||
topNavigationPresenter,
|
topNavigationPresenter,
|
||||||
messagePresenter) {
|
messagePresenter) {
|
||||||
|
@ -57,6 +58,10 @@ App.Presenters.PostListPresenter = function(
|
||||||
|
|
||||||
function render() {
|
function render() {
|
||||||
$el.html(listTemplate());
|
$el.html(listTemplate());
|
||||||
|
|
||||||
|
keyboard.keyup('p', function() {
|
||||||
|
$el.find('.posts li a').eq(0).focus();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderPosts(posts, clear) {
|
function renderPosts(posts, clear) {
|
||||||
|
@ -84,4 +89,4 @@ App.Presenters.PostListPresenter = function(
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
App.DI.register('postListPresenter', ['_', 'jQuery', 'util', 'promise', 'auth', 'router', 'pagedCollectionPresenter', 'topNavigationPresenter', 'messagePresenter'], App.Presenters.PostListPresenter);
|
App.DI.register('postListPresenter', ['_', 'jQuery', 'util', 'promise', 'auth', 'router', 'keyboard', 'pagedCollectionPresenter', 'topNavigationPresenter', 'messagePresenter'], App.Presenters.PostListPresenter);
|
||||||
|
|
|
@ -4,7 +4,7 @@ App.Presenters = App.Presenters || {};
|
||||||
App.Presenters.PostUploadPresenter = function(
|
App.Presenters.PostUploadPresenter = function(
|
||||||
_,
|
_,
|
||||||
jQuery,
|
jQuery,
|
||||||
mousetrap,
|
keyboard,
|
||||||
promise,
|
promise,
|
||||||
util,
|
util,
|
||||||
auth,
|
auth,
|
||||||
|
@ -45,8 +45,8 @@ App.Presenters.PostUploadPresenter = function(
|
||||||
$el.find('.url-handler button').click(urlHandlerButtonClicked);
|
$el.find('.url-handler button').click(urlHandlerButtonClicked);
|
||||||
$el.find('thead th.checkbox').click(postTableSelectAllCheckboxClicked);
|
$el.find('thead th.checkbox').click(postTableSelectAllCheckboxClicked);
|
||||||
|
|
||||||
mousetrap.bind('a', simpleKeyPressed(selectPrevPostTableRow), 'keyup');
|
keyboard.keyup('a', selectPrevPostTableRow);
|
||||||
mousetrap.bind('d', simpleKeyPressed(selectNextPostTableRow), 'keyup');
|
keyboard.keyup('d', selectNextPostTableRow);
|
||||||
|
|
||||||
$el.find('.remove').click(removeButtonClicked);
|
$el.find('.remove').click(removeButtonClicked);
|
||||||
$el.find('.move-up').click(moveUpButtonClicked);
|
$el.find('.move-up').click(moveUpButtonClicked);
|
||||||
|
@ -54,14 +54,6 @@ App.Presenters.PostUploadPresenter = function(
|
||||||
$el.find('.submit').click(submitButtonClicked);
|
$el.find('.submit').click(submitButtonClicked);
|
||||||
}
|
}
|
||||||
|
|
||||||
function simpleKeyPressed(callback) {
|
|
||||||
return function(e) {
|
|
||||||
if (!e.altKey && !e.ctrlKey) {
|
|
||||||
callback();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function getDefaultPost() {
|
function getDefaultPost() {
|
||||||
return {
|
return {
|
||||||
safety: 'safe',
|
safety: 'safe',
|
||||||
|
@ -563,4 +555,4 @@ App.Presenters.PostUploadPresenter = function(
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
App.DI.register('postUploadPresenter', ['_', 'jQuery', 'mousetrap', 'promise', 'util', 'auth', 'api', 'router', 'topNavigationPresenter', 'messagePresenter'], App.Presenters.PostUploadPresenter);
|
App.DI.register('postUploadPresenter', ['_', 'jQuery', 'keyboard', 'promise', 'util', 'auth', 'api', 'router', 'topNavigationPresenter', 'messagePresenter'], App.Presenters.PostUploadPresenter);
|
||||||
|
|
Loading…
Reference in a new issue