From 3cc78f06799b0c91957767e8d9255e67b30edd96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Mon, 24 Oct 2016 11:20:11 +0200 Subject: Added shortcuts --- app/Resources/static/themes/_global/js/tools.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'app/Resources') diff --git a/app/Resources/static/themes/_global/js/tools.js b/app/Resources/static/themes/_global/js/tools.js index 55de090c..9a98f0a6 100644 --- a/app/Resources/static/themes/_global/js/tools.js +++ b/app/Resources/static/themes/_global/js/tools.js @@ -1,4 +1,5 @@ const $ = require('jquery'); +require('mousetrap'); /* Allows inline call qr-code call */ import jrQrcode from 'jr-qrcode'; // eslint-disable-line @@ -51,3 +52,14 @@ function initExport() { } export { savePercent, retrievePercent, initFilters, initExport }; + +/** Shortcuts **/ + +/* Go to */ +Mousetrap.bind('g u', function() { window.location.href = Routing.generate('homepage') }); +Mousetrap.bind('g s', function() { window.location.href = Routing.generate('starred') }); + +/* Actions */ +Mousetrap.bind('g a', function() { + $("#nav-btn-add").trigger("click"); +}); -- cgit v1.2.3 From f9cded7dd2acab3af8ff8481941e0c199daf8270 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Mon, 24 Oct 2016 20:37:49 +0200 Subject: Added new shortcuts --- app/Resources/static/themes/_global/js/tools.js | 37 ++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) (limited to 'app/Resources') diff --git a/app/Resources/static/themes/_global/js/tools.js b/app/Resources/static/themes/_global/js/tools.js index 9a98f0a6..d6a2d803 100644 --- a/app/Resources/static/themes/_global/js/tools.js +++ b/app/Resources/static/themes/_global/js/tools.js @@ -58,8 +58,43 @@ export { savePercent, retrievePercent, initFilters, initExport }; /* Go to */ Mousetrap.bind('g u', function() { window.location.href = Routing.generate('homepage') }); Mousetrap.bind('g s', function() { window.location.href = Routing.generate('starred') }); +Mousetrap.bind('g r', function() { window.location.href = Routing.generate('archive') }); +Mousetrap.bind('g a', function() { window.location.href = Routing.generate('all') }); +Mousetrap.bind('g t', function() { window.location.href = Routing.generate('tag') }); +Mousetrap.bind('g c', function() { window.location.href = Routing.generate('config') }); +Mousetrap.bind('g i', function() { window.location.href = Routing.generate('import') }); +Mousetrap.bind('g d', function() { window.location.href = Routing.generate('developer') }); +Mousetrap.bind('g h', function() { window.location.href = Routing.generate('howto') }); +Mousetrap.bind('g l', function() { window.location.href = Routing.generate('logout') }); + /* Actions */ -Mousetrap.bind('g a', function() { +Mousetrap.bind('g n', function() { $("#nav-btn-add").trigger("click"); }); + +Mousetrap.bind('esc', function() { + $(".close").trigger("click"); +}); + +// Display the first element of the current view +Mousetrap.bind('right', function() { + $("ul.data li:first-child span.dot-ellipsis a")[0].click(); +}); + +/* Article view */ +Mousetrap.bind('o', function() { + $("ul.side-nav li:nth-child(2) a i")[0].click(); +}); + +Mousetrap.bind('s', function() { + $("ul.side-nav li:nth-child(5) a i")[0].click(); +}); + +Mousetrap.bind('a', function() { + $("ul.side-nav li:nth-child(4) a i")[0].click(); +}); + +Mousetrap.bind('del', function() { + $("ul.side-nav li:nth-child(6) a i")[0].click(); +}); -- cgit v1.2.3 From af61cb80eb600618df95a01a15a08e87fc878c2a Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Thu, 27 Oct 2016 01:57:27 +0200 Subject: es6 imports Signed-off-by: Thomas Citharel --- .../static/themes/_global/js/bookmarklet.js | 1 - app/Resources/static/themes/_global/js/tools.js | 52 +++++++++++----------- .../static/themes/baggy/js/autoCompleteTags.js | 2 +- app/Resources/static/themes/baggy/js/init.js | 18 +++++--- app/Resources/static/themes/baggy/js/uiTools.js | 4 +- app/Resources/static/themes/material/js/init.js | 6 +-- 6 files changed, 44 insertions(+), 39 deletions(-) (limited to 'app/Resources') diff --git a/app/Resources/static/themes/_global/js/bookmarklet.js b/app/Resources/static/themes/_global/js/bookmarklet.js index 5174ff47..a497628b 100644 --- a/app/Resources/static/themes/_global/js/bookmarklet.js +++ b/app/Resources/static/themes/_global/js/bookmarklet.js @@ -1,4 +1,3 @@ - top['bookmarklet-url@wallabag.org'] = 'bag it!' + '' + diff --git a/app/Resources/static/themes/_global/js/tools.js b/app/Resources/static/themes/_global/js/tools.js index d6a2d803..96d9fcf6 100644 --- a/app/Resources/static/themes/_global/js/tools.js +++ b/app/Resources/static/themes/_global/js/tools.js @@ -1,5 +1,5 @@ -const $ = require('jquery'); -require('mousetrap'); +import $ from 'jquery'; +import Mousetrap from 'mousetrap'; /* Allows inline call qr-code call */ import jrQrcode from 'jr-qrcode'; // eslint-disable-line @@ -56,45 +56,45 @@ export { savePercent, retrievePercent, initFilters, initExport }; /** Shortcuts **/ /* Go to */ -Mousetrap.bind('g u', function() { window.location.href = Routing.generate('homepage') }); -Mousetrap.bind('g s', function() { window.location.href = Routing.generate('starred') }); -Mousetrap.bind('g r', function() { window.location.href = Routing.generate('archive') }); -Mousetrap.bind('g a', function() { window.location.href = Routing.generate('all') }); -Mousetrap.bind('g t', function() { window.location.href = Routing.generate('tag') }); -Mousetrap.bind('g c', function() { window.location.href = Routing.generate('config') }); -Mousetrap.bind('g i', function() { window.location.href = Routing.generate('import') }); -Mousetrap.bind('g d', function() { window.location.href = Routing.generate('developer') }); -Mousetrap.bind('g h', function() { window.location.href = Routing.generate('howto') }); -Mousetrap.bind('g l', function() { window.location.href = Routing.generate('logout') }); +Mousetrap.bind('g u', () => { window.location.href = Routing.generate('homepage'); }); +Mousetrap.bind('g s', () => { window.location.href = Routing.generate('starred'); }); +Mousetrap.bind('g r', () => { window.location.href = Routing.generate('archive'); }); +Mousetrap.bind('g a', () => { window.location.href = Routing.generate('all'); }); +Mousetrap.bind('g t', () => { window.location.href = Routing.generate('tag'); }); +Mousetrap.bind('g c', () => { window.location.href = Routing.generate('config'); }); +Mousetrap.bind('g i', () => { window.location.href = Routing.generate('import'); }); +Mousetrap.bind('g d', () => { window.location.href = Routing.generate('developer'); }); +Mousetrap.bind('g h', () => { window.location.href = Routing.generate('howto'); }); +Mousetrap.bind('g l', () => { window.location.href = Routing.generate('logout'); }); /* Actions */ -Mousetrap.bind('g n', function() { - $("#nav-btn-add").trigger("click"); +Mousetrap.bind('g n', () => { + $('#nav-btn-add').trigger('click'); }); -Mousetrap.bind('esc', function() { - $(".close").trigger("click"); +Mousetrap.bind('esc', () => { + $('.close').trigger('click'); }); // Display the first element of the current view -Mousetrap.bind('right', function() { - $("ul.data li:first-child span.dot-ellipsis a")[0].click(); +Mousetrap.bind('right', () => { + $('ul.data li:first-child span.dot-ellipsis a')[0].click(); }); /* Article view */ -Mousetrap.bind('o', function() { - $("ul.side-nav li:nth-child(2) a i")[0].click(); +Mousetrap.bind('o', () => { + $('ul.side-nav li:nth-child(2) a i')[0].click(); }); -Mousetrap.bind('s', function() { - $("ul.side-nav li:nth-child(5) a i")[0].click(); +Mousetrap.bind('s', () => { + $('ul.side-nav li:nth-child(5) a i')[0].click(); }); -Mousetrap.bind('a', function() { - $("ul.side-nav li:nth-child(4) a i")[0].click(); +Mousetrap.bind('a', () => { + $('ul.side-nav li:nth-child(4) a i')[0].click(); }); -Mousetrap.bind('del', function() { - $("ul.side-nav li:nth-child(6) a i")[0].click(); +Mousetrap.bind('del', () => { + $('ul.side-nav li:nth-child(6) a i')[0].click(); }); diff --git a/app/Resources/static/themes/baggy/js/autoCompleteTags.js b/app/Resources/static/themes/baggy/js/autoCompleteTags.js index f287ebfa..64fdaa92 100755 --- a/app/Resources/static/themes/baggy/js/autoCompleteTags.js +++ b/app/Resources/static/themes/baggy/js/autoCompleteTags.js @@ -5,4 +5,4 @@ function extractLast(term) { return split(term).pop(); } -export { split, extractLast }; +export default { split, extractLast }; diff --git a/app/Resources/static/themes/baggy/js/init.js b/app/Resources/static/themes/baggy/js/init.js index dc11043a..b7347f7c 100755 --- a/app/Resources/static/themes/baggy/js/init.js +++ b/app/Resources/static/themes/baggy/js/init.js @@ -1,11 +1,17 @@ -import { savePercent, retrievePercent } from '../../_global/js/tools'; -import { toggleSaveLinkForm } from './uiTools'; +import $ from 'jquery'; + +/* eslint-disable no-unused-vars */ +/* jquery has default scope */ +import cookie from 'jquery.cookie'; +import ui from 'jquery-ui-browserify'; +/* eslint-enable no-unused-vars */ -const $ = global.jquery = require('jquery'); -require('jquery.cookie'); -require('jquery-ui-browserify'); -const annotator = require('annotator'); +import annotator from 'annotator'; + +import { savePercent, retrievePercent } from '../../_global/js/tools'; +import toggleSaveLinkForm from './uiTools'; +global.jquery = $; $.fn.ready(() => { const $listmode = $('#listmode'); diff --git a/app/Resources/static/themes/baggy/js/uiTools.js b/app/Resources/static/themes/baggy/js/uiTools.js index 900b2707..713c53f7 100644 --- a/app/Resources/static/themes/baggy/js/uiTools.js +++ b/app/Resources/static/themes/baggy/js/uiTools.js @@ -1,4 +1,4 @@ -const $ = require('jquery'); +import $ from 'jquery'; function toggleSaveLinkForm(url, event) { $('#add-link-result').empty(); @@ -32,4 +32,4 @@ function toggleSaveLinkForm(url, event) { plainUrl.focus(); } -export { toggleSaveLinkForm }; +export default toggleSaveLinkForm; diff --git a/app/Resources/static/themes/material/js/init.js b/app/Resources/static/themes/material/js/init.js index a68269e0..d8edeed1 100755 --- a/app/Resources/static/themes/material/js/init.js +++ b/app/Resources/static/themes/material/js/init.js @@ -1,10 +1,10 @@ +import $ from 'jquery'; +import annotator from 'annotator'; import { savePercent, retrievePercent, initFilters, initExport } from '../../_global/js/tools'; -const $ = require('jquery'); +require('materialize'); // eslint-disable-line global.jQuery = $; -require('materialize'); // eslint-disable-line -const annotator = require('annotator'); $(document).ready(() => { // sideNav -- cgit v1.2.3 From 16ef7607f43ebc3e0134360b7657af191e14fe12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Wed, 2 Nov 2016 16:44:20 +0100 Subject: Reorganized JS folders for shortcuts --- .../static/themes/_global/js/shortcuts/entry.js | 0 .../static/themes/_global/js/shortcuts/main.js | 13 ++++++ app/Resources/static/themes/_global/js/tools.js | 48 +--------------------- app/Resources/static/themes/baggy/js/init.js | 3 ++ .../static/themes/baggy/js/shortcuts/entry.js | 19 +++++++++ .../static/themes/baggy/js/shortcuts/main.js | 0 app/Resources/static/themes/material/js/init.js | 2 + .../static/themes/material/js/shortcuts/entry.js | 19 +++++++++ .../static/themes/material/js/shortcuts/main.js | 13 ++++++ 9 files changed, 71 insertions(+), 46 deletions(-) create mode 100644 app/Resources/static/themes/_global/js/shortcuts/entry.js create mode 100644 app/Resources/static/themes/_global/js/shortcuts/main.js create mode 100644 app/Resources/static/themes/baggy/js/shortcuts/entry.js create mode 100644 app/Resources/static/themes/baggy/js/shortcuts/main.js create mode 100644 app/Resources/static/themes/material/js/shortcuts/entry.js create mode 100644 app/Resources/static/themes/material/js/shortcuts/main.js (limited to 'app/Resources') diff --git a/app/Resources/static/themes/_global/js/shortcuts/entry.js b/app/Resources/static/themes/_global/js/shortcuts/entry.js new file mode 100644 index 00000000..e69de29b diff --git a/app/Resources/static/themes/_global/js/shortcuts/main.js b/app/Resources/static/themes/_global/js/shortcuts/main.js new file mode 100644 index 00000000..0bb962d0 --- /dev/null +++ b/app/Resources/static/themes/_global/js/shortcuts/main.js @@ -0,0 +1,13 @@ +/** Shortcuts **/ + +/* Go to */ +Mousetrap.bind('g u', () => { window.location.href = Routing.generate('homepage'); }); +Mousetrap.bind('g s', () => { window.location.href = Routing.generate('starred'); }); +Mousetrap.bind('g r', () => { window.location.href = Routing.generate('archive'); }); +Mousetrap.bind('g a', () => { window.location.href = Routing.generate('all'); }); +Mousetrap.bind('g t', () => { window.location.href = Routing.generate('tag'); }); +Mousetrap.bind('g c', () => { window.location.href = Routing.generate('config'); }); +Mousetrap.bind('g i', () => { window.location.href = Routing.generate('import'); }); +Mousetrap.bind('g d', () => { window.location.href = Routing.generate('developer'); }); +Mousetrap.bind('?', () => { window.location.href = Routing.generate('howto'); }); +Mousetrap.bind('g l', () => { window.location.href = Routing.generate('logout'); }); diff --git a/app/Resources/static/themes/_global/js/tools.js b/app/Resources/static/themes/_global/js/tools.js index 96d9fcf6..77879dcd 100644 --- a/app/Resources/static/themes/_global/js/tools.js +++ b/app/Resources/static/themes/_global/js/tools.js @@ -1,5 +1,7 @@ import $ from 'jquery'; import Mousetrap from 'mousetrap'; +import './shortcuts/main.js'; +import './shortcuts/entry.js'; /* Allows inline call qr-code call */ import jrQrcode from 'jr-qrcode'; // eslint-disable-line @@ -52,49 +54,3 @@ function initExport() { } export { savePercent, retrievePercent, initFilters, initExport }; - -/** Shortcuts **/ - -/* Go to */ -Mousetrap.bind('g u', () => { window.location.href = Routing.generate('homepage'); }); -Mousetrap.bind('g s', () => { window.location.href = Routing.generate('starred'); }); -Mousetrap.bind('g r', () => { window.location.href = Routing.generate('archive'); }); -Mousetrap.bind('g a', () => { window.location.href = Routing.generate('all'); }); -Mousetrap.bind('g t', () => { window.location.href = Routing.generate('tag'); }); -Mousetrap.bind('g c', () => { window.location.href = Routing.generate('config'); }); -Mousetrap.bind('g i', () => { window.location.href = Routing.generate('import'); }); -Mousetrap.bind('g d', () => { window.location.href = Routing.generate('developer'); }); -Mousetrap.bind('g h', () => { window.location.href = Routing.generate('howto'); }); -Mousetrap.bind('g l', () => { window.location.href = Routing.generate('logout'); }); - - -/* Actions */ -Mousetrap.bind('g n', () => { - $('#nav-btn-add').trigger('click'); -}); - -Mousetrap.bind('esc', () => { - $('.close').trigger('click'); -}); - -// Display the first element of the current view -Mousetrap.bind('right', () => { - $('ul.data li:first-child span.dot-ellipsis a')[0].click(); -}); - -/* Article view */ -Mousetrap.bind('o', () => { - $('ul.side-nav li:nth-child(2) a i')[0].click(); -}); - -Mousetrap.bind('s', () => { - $('ul.side-nav li:nth-child(5) a i')[0].click(); -}); - -Mousetrap.bind('a', () => { - $('ul.side-nav li:nth-child(4) a i')[0].click(); -}); - -Mousetrap.bind('del', () => { - $('ul.side-nav li:nth-child(6) a i')[0].click(); -}); diff --git a/app/Resources/static/themes/baggy/js/init.js b/app/Resources/static/themes/baggy/js/init.js index b7347f7c..5a8911ad 100755 --- a/app/Resources/static/themes/baggy/js/init.js +++ b/app/Resources/static/themes/baggy/js/init.js @@ -1,4 +1,7 @@ import $ from 'jquery'; +import { initFilters, initExport } from '../../_global/js/tools'; +import './shortcuts/main.js'; +import './shortcuts/entry.js'; /* eslint-disable no-unused-vars */ /* jquery has default scope */ diff --git a/app/Resources/static/themes/baggy/js/shortcuts/entry.js b/app/Resources/static/themes/baggy/js/shortcuts/entry.js new file mode 100644 index 00000000..d618f28e --- /dev/null +++ b/app/Resources/static/themes/baggy/js/shortcuts/entry.js @@ -0,0 +1,19 @@ +/* Article view */ +Mousetrap.bind('o', () => { + $('div#article_toolbar ul.links li:nth-child(2) a')[0].click(); +}); + +/* mark as favorite */ +Mousetrap.bind('s', () => { + $('div#article_toolbar ul.links li:nth-child(5) a')[0].click(); +}); + +/* mark as read */ +Mousetrap.bind('a', () => { + $('div#article_toolbar ul.links li:nth-child(4) a')[0].click(); +}); + +/* delete */ +Mousetrap.bind('del', () => { + $('div#article_toolbar ul.links li:nth-child(7) a')[0].click(); +}); diff --git a/app/Resources/static/themes/baggy/js/shortcuts/main.js b/app/Resources/static/themes/baggy/js/shortcuts/main.js new file mode 100644 index 00000000..e69de29b diff --git a/app/Resources/static/themes/material/js/init.js b/app/Resources/static/themes/material/js/init.js index d8edeed1..3ff8de0a 100755 --- a/app/Resources/static/themes/material/js/init.js +++ b/app/Resources/static/themes/material/js/init.js @@ -1,6 +1,8 @@ import $ from 'jquery'; import annotator from 'annotator'; import { savePercent, retrievePercent, initFilters, initExport } from '../../_global/js/tools'; +import './shortcuts/main.js'; +import './shortcuts/entry.js'; require('materialize'); // eslint-disable-line diff --git a/app/Resources/static/themes/material/js/shortcuts/entry.js b/app/Resources/static/themes/material/js/shortcuts/entry.js new file mode 100644 index 00000000..900a8214 --- /dev/null +++ b/app/Resources/static/themes/material/js/shortcuts/entry.js @@ -0,0 +1,19 @@ +/* open original article */ +Mousetrap.bind('o', () => { + $('ul.side-nav li:nth-child(2) a i')[0].click(); +}); + +/* mark as favorite */ +Mousetrap.bind('s', () => { + $('ul.side-nav li:nth-child(5) a i')[0].click(); +}); + +/* mark as read */ +Mousetrap.bind('a', () => { + $('ul.side-nav li:nth-child(4) a i')[0].click(); +}); + +/* delete */ +Mousetrap.bind('del', () => { + $('ul.side-nav li:nth-child(6) a i')[0].click(); +}); diff --git a/app/Resources/static/themes/material/js/shortcuts/main.js b/app/Resources/static/themes/material/js/shortcuts/main.js new file mode 100644 index 00000000..ccd3c92d --- /dev/null +++ b/app/Resources/static/themes/material/js/shortcuts/main.js @@ -0,0 +1,13 @@ +/* Actions */ +Mousetrap.bind('g n', () => { + $('#nav-btn-add').trigger('click'); +}); + +Mousetrap.bind('esc', () => { + $('.close').trigger('click'); +}); + +// Display the first element of the current view +Mousetrap.bind('right', () => { + $('ul.data li:first-child span.dot-ellipsis a')[0].click(); +}); -- cgit v1.2.3 From 5637a26e9af98a05c76823c85611315cd1a986e0 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Thu, 3 Nov 2016 10:02:16 +0100 Subject: Bring navigation (with right, left and enter) on material entries page. Supports going to next and previous page ! Also better indentation for js files (changed editorconfig for them). Signed-off-by: Thomas Citharel --- .../static/themes/_global/js/shortcuts/main.js | 3 + app/Resources/static/themes/_global/js/tools.js | 5 +- app/Resources/static/themes/baggy/js/init.js | 12 +++- .../static/themes/baggy/js/shortcuts/entry.js | 11 ++-- app/Resources/static/themes/material/js/init.js | 13 +++- .../static/themes/material/js/shortcuts/entry.js | 11 ++-- .../static/themes/material/js/shortcuts/main.js | 74 +++++++++++++++++++--- 7 files changed, 105 insertions(+), 24 deletions(-) (limited to 'app/Resources') diff --git a/app/Resources/static/themes/_global/js/shortcuts/main.js b/app/Resources/static/themes/_global/js/shortcuts/main.js index 0bb962d0..1f2c1c52 100644 --- a/app/Resources/static/themes/_global/js/shortcuts/main.js +++ b/app/Resources/static/themes/_global/js/shortcuts/main.js @@ -1,3 +1,6 @@ +import Mousetrap from 'mousetrap'; + + /** Shortcuts **/ /* Go to */ diff --git a/app/Resources/static/themes/_global/js/tools.js b/app/Resources/static/themes/_global/js/tools.js index 77879dcd..568b2dce 100644 --- a/app/Resources/static/themes/_global/js/tools.js +++ b/app/Resources/static/themes/_global/js/tools.js @@ -1,7 +1,6 @@ import $ from 'jquery'; -import Mousetrap from 'mousetrap'; -import './shortcuts/main.js'; -import './shortcuts/entry.js'; +import './shortcuts/main'; +import './shortcuts/entry'; /* Allows inline call qr-code call */ import jrQrcode from 'jr-qrcode'; // eslint-disable-line diff --git a/app/Resources/static/themes/baggy/js/init.js b/app/Resources/static/themes/baggy/js/init.js index 5a8911ad..05360a28 100755 --- a/app/Resources/static/themes/baggy/js/init.js +++ b/app/Resources/static/themes/baggy/js/init.js @@ -1,7 +1,5 @@ +/* jQuery */ import $ from 'jquery'; -import { initFilters, initExport } from '../../_global/js/tools'; -import './shortcuts/main.js'; -import './shortcuts/entry.js'; /* eslint-disable no-unused-vars */ /* jquery has default scope */ @@ -9,8 +7,16 @@ import cookie from 'jquery.cookie'; import ui from 'jquery-ui-browserify'; /* eslint-enable no-unused-vars */ +/* Annotations */ import annotator from 'annotator'; +/* Shortcuts */ +import './shortcuts/main'; +import './shortcuts/entry'; +import '../../_global/js/shortcuts/main'; +import '../../_global/js/shortcuts/entry'; + +/* Tools */ import { savePercent, retrievePercent } from '../../_global/js/tools'; import toggleSaveLinkForm from './uiTools'; diff --git a/app/Resources/static/themes/baggy/js/shortcuts/entry.js b/app/Resources/static/themes/baggy/js/shortcuts/entry.js index d618f28e..77d267a3 100644 --- a/app/Resources/static/themes/baggy/js/shortcuts/entry.js +++ b/app/Resources/static/themes/baggy/js/shortcuts/entry.js @@ -1,19 +1,22 @@ +import Mousetrap from 'mousetrap'; +import $ from 'jquery'; + /* Article view */ Mousetrap.bind('o', () => { - $('div#article_toolbar ul.links li:nth-child(2) a')[0].click(); + $('div#article_toolbar ul.links li:nth-child(2) a')[0].click(); }); /* mark as favorite */ Mousetrap.bind('s', () => { - $('div#article_toolbar ul.links li:nth-child(5) a')[0].click(); + $('div#article_toolbar ul.links li:nth-child(5) a')[0].click(); }); /* mark as read */ Mousetrap.bind('a', () => { - $('div#article_toolbar ul.links li:nth-child(4) a')[0].click(); + $('div#article_toolbar ul.links li:nth-child(4) a')[0].click(); }); /* delete */ Mousetrap.bind('del', () => { - $('div#article_toolbar ul.links li:nth-child(7) a')[0].click(); + $('div#article_toolbar ul.links li:nth-child(7) a')[0].click(); }); diff --git a/app/Resources/static/themes/material/js/init.js b/app/Resources/static/themes/material/js/init.js index 3ff8de0a..9746224b 100755 --- a/app/Resources/static/themes/material/js/init.js +++ b/app/Resources/static/themes/material/js/init.js @@ -1,8 +1,17 @@ +/* jQuery */ import $ from 'jquery'; + +/* Annotations */ import annotator from 'annotator'; + +/* Tools */ import { savePercent, retrievePercent, initFilters, initExport } from '../../_global/js/tools'; -import './shortcuts/main.js'; -import './shortcuts/entry.js'; + +/* Import shortcuts */ +import './shortcuts/main'; +import './shortcuts/entry'; +import '../../_global/js/shortcuts/main'; +import '../../_global/js/shortcuts/entry'; require('materialize'); // eslint-disable-line diff --git a/app/Resources/static/themes/material/js/shortcuts/entry.js b/app/Resources/static/themes/material/js/shortcuts/entry.js index 900a8214..674253b5 100644 --- a/app/Resources/static/themes/material/js/shortcuts/entry.js +++ b/app/Resources/static/themes/material/js/shortcuts/entry.js @@ -1,19 +1,22 @@ +import Mousetrap from 'mousetrap'; +import $ from 'jquery'; + /* open original article */ Mousetrap.bind('o', () => { - $('ul.side-nav li:nth-child(2) a i')[0].click(); + $('ul.side-nav li:nth-child(2) a i')[0].click(); }); /* mark as favorite */ Mousetrap.bind('s', () => { - $('ul.side-nav li:nth-child(5) a i')[0].click(); + $('ul.side-nav li:nth-child(5) a i')[0].click(); }); /* mark as read */ Mousetrap.bind('a', () => { - $('ul.side-nav li:nth-child(4) a i')[0].click(); + $('ul.side-nav li:nth-child(4) a i')[0].click(); }); /* delete */ Mousetrap.bind('del', () => { - $('ul.side-nav li:nth-child(6) a i')[0].click(); + $('ul.side-nav li:nth-child(6) a i')[0].click(); }); diff --git a/app/Resources/static/themes/material/js/shortcuts/main.js b/app/Resources/static/themes/material/js/shortcuts/main.js index ccd3c92d..62b7ec64 100644 --- a/app/Resources/static/themes/material/js/shortcuts/main.js +++ b/app/Resources/static/themes/material/js/shortcuts/main.js @@ -1,13 +1,71 @@ -/* Actions */ -Mousetrap.bind('g n', () => { +import Mousetrap from 'mousetrap'; +import $ from 'jquery'; + +function toggleFocus(cardToToogleFocus) { + if (cardToToogleFocus) { + $(cardToToogleFocus).toggleClass('z-depth-4'); + } +} +let card; +let cardIndex; +let cardNumber; +let pagination; + +$(document).ready(() => { + cardIndex = 0; + cardNumber = $('#content ul.data > li').length; + card = $('#content ul.data > li')[cardIndex]; + pagination = $('.pagination'); + + /* If we come from next page */ + if (window.location.hash === '#prev') { + cardIndex = cardNumber - 1; + card = $('ul.data > li')[cardIndex]; + } + + /* Focus current card */ + toggleFocus(card); + + /* Actions */ + Mousetrap.bind('g n', () => { $('#nav-btn-add').trigger('click'); -}); + }); -Mousetrap.bind('esc', () => { + Mousetrap.bind('esc', () => { $('.close').trigger('click'); -}); + }); + + /* Select right card. If there's a next page, go to next page */ + Mousetrap.bind('right', () => { + if (cardIndex >= 0 && cardIndex < cardNumber - 1) { + toggleFocus(card); + cardIndex += 1; + card = $('ul.data > li')[cardIndex]; + toggleFocus(card); + return; + } + if (pagination != null && pagination.find('li.next') && cardIndex === cardNumber - 1) { + window.location.href = window.location.origin + $(pagination).find('li.next a').attr('href'); + return; + } + }); + + /* Select previous card. If there's a previous page, go to next page */ + Mousetrap.bind('left', () => { + if (cardIndex > 0 && cardIndex < cardNumber) { + toggleFocus(card); + cardIndex -= 1; + card = $('ul.data > li')[cardIndex]; + toggleFocus(card); + return; + } + if (pagination !== null && $(pagination).find('li.prev') && cardIndex === 0) { + window.location.href = `${window.location.origin + $(pagination).find('li.prev a').attr('href')}#prev`; + return; + } + }); -// Display the first element of the current view -Mousetrap.bind('right', () => { - $('ul.data li:first-child span.dot-ellipsis a')[0].click(); + Mousetrap.bind('enter', () => { + window.location.href = window.location.origin + $(card).find('span.card-title a').attr('href'); + }); }); -- cgit v1.2.3 From c930992348d81c70884791ee3edbec4a3cc1d128 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Sat, 5 Nov 2016 16:06:13 +0100 Subject: fix next/prev page --- .../static/themes/_global/js/shortcuts/main.js | 1 - .../static/themes/material/js/shortcuts/main.js | 18 ++++++------------ 2 files changed, 6 insertions(+), 13 deletions(-) (limited to 'app/Resources') diff --git a/app/Resources/static/themes/_global/js/shortcuts/main.js b/app/Resources/static/themes/_global/js/shortcuts/main.js index 1f2c1c52..ef6a1b84 100644 --- a/app/Resources/static/themes/_global/js/shortcuts/main.js +++ b/app/Resources/static/themes/_global/js/shortcuts/main.js @@ -1,6 +1,5 @@ import Mousetrap from 'mousetrap'; - /** Shortcuts **/ /* Go to */ diff --git a/app/Resources/static/themes/material/js/shortcuts/main.js b/app/Resources/static/themes/material/js/shortcuts/main.js index 62b7ec64..ba396841 100644 --- a/app/Resources/static/themes/material/js/shortcuts/main.js +++ b/app/Resources/static/themes/material/js/shortcuts/main.js @@ -6,16 +6,12 @@ function toggleFocus(cardToToogleFocus) { $(cardToToogleFocus).toggleClass('z-depth-4'); } } -let card; -let cardIndex; -let cardNumber; -let pagination; $(document).ready(() => { - cardIndex = 0; - cardNumber = $('#content ul.data > li').length; - card = $('#content ul.data > li')[cardIndex]; - pagination = $('.pagination'); + let cardIndex = 0; + const cardNumber = $('#content ul.data > li').length; + let card = $('#content ul.data > li')[cardIndex]; + const pagination = $('.pagination'); /* If we come from next page */ if (window.location.hash === '#prev') { @@ -44,9 +40,8 @@ $(document).ready(() => { toggleFocus(card); return; } - if (pagination != null && pagination.find('li.next') && cardIndex === cardNumber - 1) { + if (pagination.length > 0 && pagination.find('li.next:not(.disabled)').length > 0 && cardIndex === cardNumber - 1) { window.location.href = window.location.origin + $(pagination).find('li.next a').attr('href'); - return; } }); @@ -59,9 +54,8 @@ $(document).ready(() => { toggleFocus(card); return; } - if (pagination !== null && $(pagination).find('li.prev') && cardIndex === 0) { + if (pagination.length > 0 && $(pagination).find('li.prev:not(.disabled)').length > 0 && cardIndex === 0) { window.location.href = `${window.location.origin + $(pagination).find('li.prev a').attr('href')}#prev`; - return; } }); -- cgit v1.2.3 From 10a1ffae5313b0f77287b92aca93bb0066d3b1e3 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Tue, 15 Nov 2016 22:23:50 +0100 Subject: Fix keyboard navigation on quickstart view Signed-off-by: Thomas Citharel --- app/Resources/static/themes/material/js/shortcuts/main.js | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'app/Resources') diff --git a/app/Resources/static/themes/material/js/shortcuts/main.js b/app/Resources/static/themes/material/js/shortcuts/main.js index ba396841..8514f71e 100644 --- a/app/Resources/static/themes/material/js/shortcuts/main.js +++ b/app/Resources/static/themes/material/js/shortcuts/main.js @@ -13,6 +13,11 @@ $(document).ready(() => { let card = $('#content ul.data > li')[cardIndex]; const pagination = $('.pagination'); + /* Show nothing on quickstart */ + if ($('#content > div.quickstart').length > 0) { + return; + } + /* If we come from next page */ if (window.location.hash === '#prev') { cardIndex = cardNumber - 1; -- cgit v1.2.3 From 94f2057ffefdb164ae388a6971b4ed052082a434 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Wed, 16 Nov 2016 09:17:12 +0100 Subject: Added CSS class on links --- app/Resources/static/themes/baggy/js/shortcuts/entry.js | 8 ++++---- app/Resources/static/themes/material/js/shortcuts/entry.js | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'app/Resources') diff --git a/app/Resources/static/themes/baggy/js/shortcuts/entry.js b/app/Resources/static/themes/baggy/js/shortcuts/entry.js index 77d267a3..728df8bd 100644 --- a/app/Resources/static/themes/baggy/js/shortcuts/entry.js +++ b/app/Resources/static/themes/baggy/js/shortcuts/entry.js @@ -3,20 +3,20 @@ import $ from 'jquery'; /* Article view */ Mousetrap.bind('o', () => { - $('div#article_toolbar ul.links li:nth-child(2) a')[0].click(); + $('div#article_toolbar ul.links a.original')[0].click(); }); /* mark as favorite */ Mousetrap.bind('s', () => { - $('div#article_toolbar ul.links li:nth-child(5) a')[0].click(); + $('div#article_toolbar ul.links a.favorite')[0].click(); }); /* mark as read */ Mousetrap.bind('a', () => { - $('div#article_toolbar ul.links li:nth-child(4) a')[0].click(); + $('div#article_toolbar ul.links a.markasread')[0].click(); }); /* delete */ Mousetrap.bind('del', () => { - $('div#article_toolbar ul.links li:nth-child(7) a')[0].click(); + $('div#article_toolbar ul.links a.delete')[0].click(); }); diff --git a/app/Resources/static/themes/material/js/shortcuts/entry.js b/app/Resources/static/themes/material/js/shortcuts/entry.js index 674253b5..357c22fe 100644 --- a/app/Resources/static/themes/material/js/shortcuts/entry.js +++ b/app/Resources/static/themes/material/js/shortcuts/entry.js @@ -3,20 +3,20 @@ import $ from 'jquery'; /* open original article */ Mousetrap.bind('o', () => { - $('ul.side-nav li:nth-child(2) a i')[0].click(); + $('ul.side-nav a.original i')[0].click(); }); /* mark as favorite */ Mousetrap.bind('s', () => { - $('ul.side-nav li:nth-child(5) a i')[0].click(); + $('ul.side-nav a.favorite i')[0].click(); }); /* mark as read */ Mousetrap.bind('a', () => { - $('ul.side-nav li:nth-child(4) a i')[0].click(); + $('ul.side-nav a.markasread i')[0].click(); }); /* delete */ Mousetrap.bind('del', () => { - $('ul.side-nav li:nth-child(6) a i')[0].click(); + $('ul.side-nav a.delete i')[0].click(); }); -- cgit v1.2.3