From 3ba0d0516e5cabce8ebcc9a27c0fe069fa23f52c Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 9 Aug 2018 16:13:50 +0200 Subject: simple theme update - npm package update - apply #1226 - implement vim help dialog - display cookies and search URL with preferences - allow to enable / disable Open Access DOI rewrite - add a clear text button on the left of the search button - implement #1011 : the HTML title page is not set when using POST - remove searx/static/themes/simple/img/loader.gif - use full width when only there are only images as result --- .../themes/simple/js/searx_src/searx_keyboard.js | 62 ++++++++++++---------- 1 file changed, 34 insertions(+), 28 deletions(-) (limited to 'searx/static/themes/simple/js/searx_src/searx_keyboard.js') diff --git a/searx/static/themes/simple/js/searx_src/searx_keyboard.js b/searx/static/themes/simple/js/searx_src/searx_keyboard.js index 6365b5243..657d9ec93 100644 --- a/searx/static/themes/simple/js/searx_src/searx_keyboard.js +++ b/searx/static/themes/simple/js/searx_src/searx_keyboard.js @@ -116,7 +116,7 @@ searx.ready(function() { } }; - searx.on(document, "keyup", function(e) { + searx.on(document, "keydown", function(e) { // check for modifiers so we don't break browser's hotkeys if (vimKeys.hasOwnProperty(e.keyCode) && !e.ctrlKey && !e.altKey && !e.shiftKey && !e.metaKey) { var tagName = e.target.tagName.toLowerCase(); @@ -126,6 +126,7 @@ searx.ready(function() { } } else { if (e.target === document.body || tagName === 'a' || tagName === 'button') { + e.preventDefault(); vimKeys[e.keyCode].fun(); } } @@ -290,13 +291,7 @@ searx.ready(function() { }; } - function toggleHelp() { - var helpPanel = document.querySelector('#vim-hotkeys-help'); - if (helpPanel.length) { - helpPanel.classList.toggle('hidden'); - return; - } - + function initHelpContent(divElement) { var categories = {}; for (var k in vimKeys) { @@ -313,14 +308,9 @@ searx.ready(function() { return; } - var html = '
'; - html += '
'; - - html += '
'; - html += '
'; - html += '

How to navigate searx with Vim-like hotkeys

'; - html += '
'; // col-sm-12 - html += '
'; // row + var html = '×'; + html += '

How to navigate searx with Vim-like hotkeys

'; + html += ''; for (var i = 0; i < sorted.length; i++) { var cat = categories[sorted[i]]; @@ -329,13 +319,11 @@ searx.ready(function() { var first = i % 2 === 0; if (first) { - html += '
'; + html += '
'; } - html += '
'; + html += '
'; // col-sm-* if (!first || lastCategory) { - html += ''; // row + html += ''; // row } } - html += ''; // container-fluid - html += ''; // vim-hotkeys-help + html += '
'; - html += '
'; - html += '
' + cat[0].cat + '
'; - html += '
'; + html += '

' + cat[0].cat + '

'; html += '
    '; for (var cj in cat) { @@ -343,18 +331,36 @@ searx.ready(function() { } html += '
'; - html += '
'; // panel-body - html += '
'; // panel - html += ''; // col-sm-* + html += '
'; + + divElement.innerHTML = html; + } + + function toggleHelp() { + var helpPanel = document.querySelector('#vim-hotkeys-help'); + console.log(helpPanel); + if (helpPanel === undefined || helpPanel === null) { + // first call + helpPanel = document.createElement('div'); + helpPanel.id = 'vim-hotkeys-help'; + helpPanel.className='dialog-modal'; + helpPanel.style='width: 40%'; + initHelpContent(helpPanel); + var body = document.getElementsByTagName('body')[0]; + body.appendChild(helpPanel); + } else { + // togggle hidden + helpPanel.classList.toggle('invisible'); + return; + } - $('body').append(html); } + }); -- cgit v1.2.3