Added ability for presets in menus (currently just used for dividers)
This commit is contained in:
parent
19c417d8d1
commit
d9874e5cd3
4 changed files with 28 additions and 11 deletions
|
@ -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" }
|
||||
]
|
||||
}*/
|
||||
|
||||
]
|
|
@ -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;
|
||||
|
|
11
js/menus.js
11
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);
|
||||
|
|
|
@ -7,15 +7,6 @@
|
|||
<body>
|
||||
|
||||
<ul class="toolbar">
|
||||
<li>File
|
||||
<ul class="menu">
|
||||
<li command="session:new-file">New</li>
|
||||
<li command="session:open-file">Open</li>
|
||||
<li command="session:save-file">Save</li>
|
||||
<li command="session:save-file-as">Save As</li>
|
||||
<li command="app:exit">Exit</li>
|
||||
</ul>
|
||||
</li>
|
||||
<!--<li>Edit
|
||||
<ul class="menu">
|
||||
<li command="editor:cut">Cut</li>
|
||||
|
|
Loading…
Reference in a new issue