summaryrefslogtreecommitdiff
path: root/searx/static/themes/simple/js/searx_src/searx_keyboard.js
diff options
context:
space:
mode:
authorAlex <alex@al-f.net>2018-08-09 16:13:50 +0200
committerAlexandre Flament <alex@al-f.net>2018-08-14 17:21:30 +0200
commit3ba0d0516e5cabce8ebcc9a27c0fe069fa23f52c (patch)
treedffd7311f1bf9bba9386101c67f5e03c30a53116 /searx/static/themes/simple/js/searx_src/searx_keyboard.js
parent845ba79e7532dedad2bb96e5d68504b6729bee14 (diff)
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
Diffstat (limited to 'searx/static/themes/simple/js/searx_src/searx_keyboard.js')
-rw-r--r--searx/static/themes/simple/js/searx_src/searx_keyboard.js62
1 files changed, 34 insertions, 28 deletions
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 = '<div id="vim-hotkeys-help" class="well vim-hotkeys-help">';
- html += '<div class="container-fluid">';
-
- html += '<div class="row">';
- html += '<div class="col-sm-12">';
- html += '<h3>How to navigate searx with Vim-like hotkeys</h3>';
- html += '</div>'; // col-sm-12
- html += '</div>'; // row
+ var html = '<a href="#" class="close" aria-label="close" title="close">×</a>';
+ html += '<h3>How to navigate searx with Vim-like hotkeys</h3>';
+ html += '<table>';
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 += '<div class="row dflex">';
+ html += '<tr>';
}
- html += '<div class="col-sm-' + (first && lastCategory ? 12 : 6) + ' dflex">';
+ html += '<td>';
- html += '<div class="panel panel-default iflex">';
- html += '<div class="panel-heading">' + cat[0].cat + '</div>';
- html += '<div class="panel-body">';
+ html += '<h4>' + cat[0].cat + '</h4>';
html += '<ul class="list-unstyled">';
for (var cj in cat) {
@@ -343,18 +331,36 @@ searx.ready(function() {
}
html += '</ul>';
- html += '</div>'; // panel-body
- html += '</div>'; // panel
- html += '</div>'; // col-sm-*
+ html += '</td>'; // col-sm-*
if (!first || lastCategory) {
- html += '</div>'; // row
+ html += '</tr>'; // row
}
}
- html += '</div>'; // container-fluid
- html += '</div>'; // vim-hotkeys-help
+ html += '</table>';
+
+ 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);
}
+
});