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 --- app/Resources/static/themes/material/js/shortcuts/main.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 app/Resources/static/themes/material/js/shortcuts/main.js (limited to 'app/Resources/static/themes/material/js/shortcuts/main.js') 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/material/js/shortcuts/main.js | 74 +++++++++++++++++++--- 1 file changed, 66 insertions(+), 8 deletions(-) (limited to 'app/Resources/static/themes/material/js/shortcuts/main.js') 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/material/js/shortcuts/main.js | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'app/Resources/static/themes/material/js/shortcuts/main.js') 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/static/themes/material/js/shortcuts/main.js') 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