-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmoqups-full-preview.user.js
98 lines (83 loc) · 2.13 KB
/
moqups-full-preview.user.js
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
// ==UserScript==
// @name Moqups Full Preview
// @namespace dkdscripts
// @version 1.2.0
// @description Press Ctrl+F11 (or Shift+Alt+F) to hide all menus and go FULL PREVIEW
// @author dkd
// @downloadURL https://github.com/mold/userscripts/raw/master/moqups-full-preview.user.js
// @match https://app.moqups.com/*
// @require https://code.jquery.com/jquery-3.3.1.min.js
// @grant none
// ==/UserScript==
(function() {
var barsHidden = false;
var mainStage, stageWrapper;
var transitionDuration = 100;
var debounce = false;
function getElements() {
mainStage = $("#main-stage");
mainStage.origCSS = {
left: mainStage.css("left"),
right: mainStage.css("right"),
top: mainStage.css("top"),
bottom: mainStage.css("bottom"),
"z-index": mainStage.css("z-index"),
};
stageWrapper = $("#stage-wrapper");
stageWrapper.origCSS = {
top: stageWrapper.css("top"),
"z-index": stageWrapper.css("z-index"),
};
}
function toggleFullscreen(full) {
if (debounce) {
return;
}
if (undefined === full) {
full = !barsHidden;
}
if (full) {
getElements();
mainStage.css({
left: "0",
right: 0,
"z-index": "1000",
top: 0,
bottom: 0,
transition: transitionDuration + "ms all",
});
stageWrapper.css({
"z-index": "1000",
transition: transitionDuration + "ms all",
top: 0,
});
$(":focus").blur();
} else {
mainStage.css(mainStage.origCSS);
stageWrapper.css(stageWrapper.origCSS);
}
barsHidden = !barsHidden;
debounce = true;
window.setTimeout(function() {
debounce = false;
}, transitionDuration);
}
window.addEventListener("keydown", function(evt) {
// Ctrl+F11 or Alt+Shift+F
if ((evt.keyCode === 122 && evt.ctrlKey) ||
(evt.keyCode === 70 && evt.altKey && evt.shiftKey)) {
evt.preventDefault();
toggleFullscreen();
}
// Ctrl+F
else if (evt.keyCode === 70 && evt.ctrlKey) {
toggleFullscreen(false);
}
});
window.addEventListener("mousedown", function(evt) {
if(evt.button === 2){
// right click opens context menu
toggleFullscreen(false);
}
});
})();