-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWin31Layout.js
More file actions
62 lines (57 loc) · 1.25 KB
/
Copy pathWin31Layout.js
File metadata and controls
62 lines (57 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
var CHROME_BY_ID = {
close: "close",
scratchpad: "min",
fullscreen: "max",
"expand-left": "left",
"grow-right": "right",
"shrink-up": "top",
"grow-down": "bottom",
move: "move"
}
var MENU_ORDER = [
"float",
"pin",
"split",
"focus-left",
"focus-right",
"focus-up",
"focus-down",
"swap-left",
"swap-right",
"swap-up",
"swap-down"
]
function chromeSlot(id) {
return CHROME_BY_ID[String(id || "")] || ""
}
function menuIndex(id) {
var key = String(id || "")
var index = MENU_ORDER.indexOf(key)
return index === -1 ? MENU_ORDER.length : index
}
function classify(hints) {
var chrome = {}
var menu = []
var list = hints || []
for (var i = 0; i < list.length; i++) {
var hint = list[i]
if (!hint || !hint.id) continue
var slot = chromeSlot(hint.id)
if (slot) chrome[slot] = hint
else menu.push(hint)
}
menu.sort(function (a, b) {
var delta = menuIndex(a.id) - menuIndex(b.id)
if (delta !== 0) return delta
return String(a.id).localeCompare(String(b.id))
})
return { chrome: chrome, menu: menu }
}
if (typeof module !== "undefined" && module.exports) {
module.exports = {
CHROME_BY_ID: CHROME_BY_ID,
MENU_ORDER: MENU_ORDER,
chromeSlot: chromeSlot,
classify: classify
}
}