From d9874e5cd310d2139744ad2385e2e14d0bd7d211 Mon Sep 17 00:00:00 2001 From: Thomas Wilburn Date: Thu, 22 Aug 2013 18:27:16 -0700 Subject: [PATCH] Added ability for presets in menus (currently just used for dividers) --- config/menus.json | 13 ++++++++++++- css/editor.less | 6 ++++++ js/menus.js | 11 ++++++++++- main.html | 9 --------- 4 files changed, 28 insertions(+), 11 deletions(-) diff --git a/config/menus.json b/config/menus.json index 68f888f..efbad1e 100644 --- a/config/menus.json +++ b/config/menus.json @@ -8,6 +8,17 @@ { "label": "Save As", "command": "session:save-file-as" }, { "label": "Exit", "command": "app:exit" } ] - } + }/*, + { + "label": "Edit", + "sub": [ + { "label": "Cut", "command": "editor:cut" }, + { "label": "Copy", "command": "editor:copy" }, + { "label": "Paste", "command": "editor:paste" }, + { "label": "Paste and Indent", "command": "editor:paste-indented" }, + "divider", + { "label": "To Upper Case", "command": "editor:upper-case" } + ] + }*/ ] \ No newline at end of file diff --git a/css/editor.less b/css/editor.less index 56432a0..3a43bc7 100644 --- a/css/editor.less +++ b/css/editor.less @@ -17,9 +17,15 @@ body { list-style-type: none; z-index: 99; + hr { + border: 1px solid rgba(0, 0, 0, .2); + margin: 4px 8px; + } + & > li { display: inline-block; padding: 0 8px; + line-height: initial; &:hover { background: #EEE; diff --git a/js/menus.js b/js/menus.js index 8c9d769..567f19a 100644 --- a/js/menus.js +++ b/js/menus.js @@ -6,7 +6,16 @@ define(["json!config/menus.json","dom2"], function(cfg) { var fragment = document.createDocumentFragment(); for (var i = 0; i < list.length; i++) { var entry = list[i]; - console.log(entry); + if (typeof entry == "string") { + var preset; + switch (entry) { + case "divider": + preset = document.createElement("hr"); + break; + } + fragment.appendChild(preset); + continue; + } var li = document.createElement("li"); li.innerHTML = entry.label; if (entry.command) li.setAttribute("command", entry.command); diff --git a/main.html b/main.html index 9f525d1..bd2cdd6 100644 --- a/main.html +++ b/main.html @@ -7,15 +7,6 @@