From 460688e2d5fef7c6f89e3a24318da76f1701bff6 Mon Sep 17 00:00:00 2001 From: jdescottes Date: Thu, 12 Nov 2015 22:47:51 +0100 Subject: [PATCH] Issue #287 : Move helptext to tooltip, change cheatsheet column layout --- src/css/dialogs-cheatsheet.css | 41 +++++++++++++++---- .../dialogs/CheatsheetController.js | 20 ++++++++- src/js/service/keyboard/KeycodeTranslator.js | 4 +- src/templates/dialogs/cheatsheet.html | 23 +++++++---- 4 files changed, 68 insertions(+), 20 deletions(-) diff --git a/src/css/dialogs-cheatsheet.css b/src/css/dialogs-cheatsheet.css index beb509c9..cd40f0df 100644 --- a/src/css/dialogs-cheatsheet.css +++ b/src/css/dialogs-cheatsheet.css @@ -26,8 +26,9 @@ .cheatsheet-container { box-sizing: border-box; + display: block; - bottom: 70px; + bottom: 46px; padding: 20px 3%; border-radius: 3px; background-color: rgba(0,0,0,0.9); @@ -44,16 +45,29 @@ } .cheatsheet-section { - display: inline-block; - vertical-align: top; - padding : 0 20px; box-sizing: border-box; + float: left; + + vertical-align: top; + padding : 0 20px 20px 20px; + min-width: 300px; } -@media (min-width: 1200px) { - .cheatsheet-section { +.cheatsheet-boxes { + display: flex; + flex-direction: row; + flex-wrap: wrap; + + float: left; +} + +@media (min-width: 1300px) { + .cheatsheet-container > div { width: 33%; } + .cheatsheet-boxes { + flex-direction: column; + } } .cheatsheet-shortcut { @@ -128,7 +142,7 @@ bottom : 0; left : 0; right : 0; - height : 70px; + height : 46px; padding : 10px; overflow: hidden; @@ -137,10 +151,19 @@ } .cheatsheet-helptext { - display: block; font-size: 14px; + height : 26px; + line-height : 26px; color: black; - padding-right: 150px; +} + +.cheatsheet-helptext-tooltip { + text-align: left; +} + +.cheatsheet-helptext-tooltip-item { + line-height: 0.9em; + margin: 10px 0; } .cheatsheet-button { diff --git a/src/js/controller/dialogs/CheatsheetController.js b/src/js/controller/dialogs/CheatsheetController.js index 379831c5..64ebb751 100644 --- a/src/js/controller/dialogs/CheatsheetController.js +++ b/src/js/controller/dialogs/CheatsheetController.js @@ -20,6 +20,7 @@ $.subscribe(Events.SHORTCUTS_CHANGED, this.onShortcutsChanged_.bind(this)); this.initMarkup_(); + document.querySelector('.cheatsheet-helptext').setAttribute('title', this.getHelptextTitle_()); }; ns.CheatsheetController.prototype.destroy = function () { @@ -29,7 +30,9 @@ }; ns.CheatsheetController.prototype.onRestoreDefaultsClick_ = function () { - pskl.service.keyboard.Shortcuts.restoreDefaultShortcuts(); + if (window.confirm('Replace all custom shortcuts by the default Piskel shortcuts ?')) { + pskl.service.keyboard.Shortcuts.restoreDefaultShortcuts(); + } }; ns.CheatsheetController.prototype.onShortcutsChanged_ = function () { @@ -152,4 +155,19 @@ key = key.replace(/([^ ])\+([^ ])/g, '$1 + $2'); return key; }; + + ns.CheatsheetController.prototype.getHelptextTitle_ = function () { + var helpItems = [ + 'Click on a shortcut to change the key.', + 'When the shortcut blinks, press the key on your keyboard to assign it.', + 'White shortcuts can not be edited.', + 'Click on \'Restore default shortcuts\' to erase all custom shortcuts.' + ]; + + var helptextTitle = helpItems.reduce(function (p, n) { + return p + '
' + n + '
'; + }, ''); + helptextTitle = '
' + helptextTitle + '
'; + return helptextTitle; + }; })(); diff --git a/src/js/service/keyboard/KeycodeTranslator.js b/src/js/service/keyboard/KeycodeTranslator.js index 0c46760b..0303ef9f 100644 --- a/src/js/service/keyboard/KeycodeTranslator.js +++ b/src/js/service/keyboard/KeycodeTranslator.js @@ -17,7 +17,9 @@ // 61 on Firefox for =/+ key 61 : '+', 188 : '<', - 190 : '>' + 190 : '>', + 219 : '[', + 221 : ']' }; var ns = $.namespace('pskl.service.keyboard'); diff --git a/src/templates/dialogs/cheatsheet.html b/src/templates/dialogs/cheatsheet.html index 718837db..2851f64b 100644 --- a/src/templates/dialogs/cheatsheet.html +++ b/src/templates/dialogs/cheatsheet.html @@ -12,18 +12,23 @@

Misc shortcuts

-
-

Selection shortcuts

- -

Color shortcuts

- -

Storage shortcuts

- +
+
+

Selection shortcuts

+
    +
    +
    +

    Color shortcuts

    +
      +
      +
      +

      Storage shortcuts

      +
        +
        - Change shortcuts : Click on a shortcut to remap its key. When the shortcut blinks, press the key on your keyboard to assign it. Conflicts will be highlighted in red. - White-colored shortcuts can not be edited. Click on 'Restore default shortcuts' to go back to the default Piskel shortcuts. + Customize shortcuts ?