diff --git a/src/css/cheatsheet.css b/src/css/cheatsheet.css index 121e14c1..dc90fa93 100644 --- a/src/css/cheatsheet.css +++ b/src/css/cheatsheet.css @@ -23,25 +23,7 @@ opacity: 1; } -#cheatsheet-wrapper { - position: absolute; - z-index: 10000; - - top: 50px; - right: 50px; - bottom: 50px; - left: 50px; - - box-sizing: border-box; - -moz-box-sizing : border-box; - - color: white; -} - .cheatsheet-container { - width: 100%; - height: 100%; - box-sizing: border-box; -moz-box-sizing : border-box; diff --git a/src/css/dialogs.css b/src/css/dialogs.css index 5994f949..7dd6c06c 100644 --- a/src/css/dialogs.css +++ b/src/css/dialogs.css @@ -70,6 +70,14 @@ position : relative; } +.dialog-content { + position: absolute; + top: 45px; + bottom: 0; + width: 100%; + box-sizing: border-box; +} + .dialog-head { width: 100%; background: gold; @@ -77,6 +85,7 @@ padding: 10px; color: black; font-size: 1.8em; + height: 45px; box-sizing: border-box; -moz-box-sizing: border-box; } diff --git a/src/index.html b/src/index.html index 19deabcc..6a5befc7 100644 --- a/src/index.html +++ b/src/index.html @@ -90,13 +90,15 @@ + - + + diff --git a/src/js/app.js b/src/js/app.js index 8d9f4a60..bd43b32c 100644 --- a/src/js/app.js +++ b/src/js/app.js @@ -127,9 +127,6 @@ this.imageUploadService = new pskl.service.ImageUploadService(); this.imageUploadService.init(); - this.cheatsheetService = new pskl.service.keyboard.CheatsheetService(); - this.cheatsheetService.init(); - this.savedStatusService = new pskl.service.SavedStatusService(this.piskelController); this.savedStatusService.init(); diff --git a/src/js/controller/PalettesListController.js b/src/js/controller/PalettesListController.js index a4f57489..846e4004 100644 --- a/src/js/controller/PalettesListController.js +++ b/src/js/controller/PalettesListController.js @@ -152,7 +152,9 @@ }; ns.PalettesListController.prototype.onCreatePaletteClick_ = function (evt) { - $.publish(Events.DIALOG_DISPLAY, 'create-palette'); + $.publish(Events.DIALOG_DISPLAY, { + dialogId : 'create-palette' + }); }; ns.PalettesListController.prototype.onEditPaletteClick_ = function (evt) { diff --git a/src/js/controller/dialogs/CheatsheetController.js b/src/js/controller/dialogs/CheatsheetController.js new file mode 100644 index 00000000..886a82d0 --- /dev/null +++ b/src/js/controller/dialogs/CheatsheetController.js @@ -0,0 +1,93 @@ +(function () { + var ns = $.namespace('pskl.controller.dialogs'); + + ns.CheatsheetController = function () { + this.shortcuts = pskl.service.keyboard.Shortcuts; + }; + + pskl.utils.inherit(ns.CheatsheetController, ns.AbstractDialogController); + + ns.CheatsheetController.prototype.init = function () { + this.cheatsheetEl = document.getElementById('cheatsheetContainer'); + if (!this.cheatsheetEl) { + throw 'cheatsheetEl DOM element could not be retrieved'; + } + console.log('>>>>>> CheatsheetController INIT'); + this.initMarkup_(); + }; + + ns.CheatsheetController.prototype.initMarkup_ = function () { + this.initMarkupForTools_(); + this.initMarkupForMisc_(); + this.initMarkupForColors_(); + this.initMarkupForSelection_(); + }; + + ns.CheatsheetController.prototype.initMarkupForTools_ = function () { + var descriptors = this.createShortcutDescriptors_(this.shortcuts.TOOL, this.getToolShortcutClassname_); + this.initMarkupForDescriptors_(descriptors, '.cheatsheet-tool-shortcuts'); + }; + + ns.CheatsheetController.prototype.getToolShortcutClassname_ = function (shortcut) { + return 'tool-icon ' + shortcut.getId(); + }; + + ns.CheatsheetController.prototype.initMarkupForMisc_ = function () { + var descriptors = this.createShortcutDescriptors_(this.shortcuts.MISC); + this.initMarkupForDescriptors_(descriptors, '.cheatsheet-misc-shortcuts'); + }; + + ns.CheatsheetController.prototype.initMarkupForColors_ = function () { + var descriptors = this.createShortcutDescriptors_(this.shortcuts.COLOR); + this.initMarkupForDescriptors_(descriptors, '.cheatsheet-colors-shortcuts'); + }; + + ns.CheatsheetController.prototype.initMarkupForSelection_ = function () { + var descriptors = this.createShortcutDescriptors_(this.shortcuts.SELECTION); + this.initMarkupForDescriptors_(descriptors, '.cheatsheet-selection-shortcuts'); + }; + + ns.CheatsheetController.prototype.createShortcutDescriptors_ = function (shortcutMap, classnameProvider) { + return Object.keys(shortcutMap).map(function (shortcutKey) { + var shortcut = shortcutMap[shortcutKey]; + var classname = typeof classnameProvider == 'function' ? classnameProvider(shortcut) : ''; + return this.toDescriptor_(shortcut.getKey(), shortcut.getDescription(), classname); + }.bind(this)); + }; + + ns.CheatsheetController.prototype.toDescriptor_ = function (key, description, icon) { + if (pskl.utils.UserAgent.isMac) { + key = key.replace('ctrl', 'cmd'); + } + key = key.replace('up', '↑'); + key = key.replace('down', '↓'); + key = key.replace(/>/g, '>'); + key = key.replace(//g, '>'); - key = key.replace(/X -