From: Radek Czajka Date: Thu, 22 Apr 2021 10:27:41 +0000 (+0200) Subject: Add keyboard view. X-Git-Url: https://git.mdrn.pl/redakcja.git/commitdiff_plain/5860bfbc5f20cc7c29935cc95f1ad9cfcf8f698a?ds=inline Add keyboard view. --- diff --git a/src/redakcja/static/js/wiki/toolbar.js b/src/redakcja/static/js/wiki/toolbar.js index 9f4272ee..8e4c0f05 100644 --- a/src/redakcja/static/js/wiki/toolbar.js +++ b/src/redakcja/static/js/wiki/toolbar.js @@ -57,4 +57,9 @@ }; + + $("#keyboard-close").click(function() { + $(this).parent().toggle(); + }) + })(jQuery); diff --git a/src/toolbar/templates/toolbar/keyboard.html b/src/toolbar/templates/toolbar/keyboard.html new file mode 100644 index 00000000..3fd2748f --- /dev/null +++ b/src/toolbar/templates/toolbar/keyboard.html @@ -0,0 +1,88 @@ + + + +
+ {% for row in rows %} +
+ {% for key in row %} +
+ {% if key.upper %} + {{ key.upper.label|safe }} + {% endif %} + {% if key.lower %} + {{ key.lower.label|safe }} + {% endif %} + {{ key.symbol }} +
+ {% endfor %} +
+ {% endfor %} + + +
+ diff --git a/src/toolbar/templates/toolbar/toolbar.html b/src/toolbar/templates/toolbar/toolbar.html index e5fe1977..6c8beff6 100644 --- a/src/toolbar/templates/toolbar/toolbar.html +++ b/src/toolbar/templates/toolbar/toolbar.html @@ -19,3 +19,5 @@ + +{% keyboard toolbar_groups %} diff --git a/src/toolbar/templatetags/toolbar_tags.py b/src/toolbar/templatetags/toolbar_tags.py index 3fa5e1b0..6a2dddb5 100644 --- a/src/toolbar/templatetags/toolbar_tags.py +++ b/src/toolbar/templatetags/toolbar_tags.py @@ -15,3 +15,25 @@ def toolbar(): @register.inclusion_tag('toolbar/button.html') def toolbar_button(b): return {'button': b} + + +@register.inclusion_tag('toolbar/keyboard.html') +def keyboard(groups): + keys = {} + for g in groups: + for b in g.button_set.all(): + if b.accesskey: + keys[b.accesskey] = b + rows = [ + [ + { + 'symbol': symbol, + 'lower': keys.get(symbol.lower()), + 'upper': keys.get(symbol), + } + for symbol in row + ] + for row in ['QWERTYUIOP', 'ASDFGHJKL', 'ZXCVBNM'] + ] + + return {'rows': rows}