-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.html
More file actions
305 lines (294 loc) · 14.1 KB
/
example.html
File metadata and controls
305 lines (294 loc) · 14.1 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
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="author" content="Giulio Auriemma" />
<meta name="description" content="How to use SushiMenuJs.'">
<meta HTTP-EQUIV="keywords" content="HTMLMenu Menu WebMenu">
<meta charset="utf-8" />
<title>SushiMenuJs</title>
<!-- Jquery -->
<link href="https://code.jquery.com/ui/1.10.4/themes/ui-lightness/jquery-ui.css" rel="stylesheet">
<script src="https://code.jquery.com/jquery-3.3.1.min.js"
integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
<!-- Cloudfire -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.6/umd/popper.min.js" integrity="sha384-wHAiFfRlMFy6i5SRaxvfOCifBUQy1xHdJ/yoi7FRNXMRBu5WHdZYu1hA6ZOblgut"
crossorigin="anonymous"></script>
<!-- Bootstrap -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS"
crossorigin="anonymous">
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js" integrity="sha384-B0UglyR+jN6CkvvICOB2joaf5I4l3gm9GU6Hc1og6Ls7i6U/mkkaduKaBhlAXv9k"
crossorigin="anonymous"></script>
<!-- SushiMenu -->
<script src="scr/sushiMenu.js"></script>
<script src="scr/sushiMenuInput.js"></script>
<link rel="stylesheet" href="styles/index.min.css">
<script>
let menuGraph;
let isNopeChoice;
let bugsNum = 0;
function buildMenu() {
// Build the menu.
menuGraph = new SM.Graph({ shouldSave: true, logError: true, layoutMap: myLayoutMap, playFirstAnimation: false});
menuGraph.addDataCallback(detectNope, true);
menuGraph.addDataCallback(countBugs, false);
// Bind input
SM.input.bindInput(menuGraph, {
back: [], // No keyboard back
select: [13], // Enter
down: [83, 40], // S, DownArrow
left: [65, 37], // A, LeftArrow
up: [87, 38], // W, UpArrow
right: [68, 39], // D, RightArrow
});
// Custom events
Array.from(document.getElementsByClassName('sm-item')).forEach( i => {
// Called on activation.
i.addEventListener('sm-activate', () => {
if (i.parentElement.classList.contains('sm-item-container'))
i.parentElement.style.backgroundColor = 'grey';
});
// Called on deactivation.
i.addEventListener('sm-deactivate', () => {
if (i.parentElement.classList.contains('sm-item-container'))
i.parentElement.style.backgroundColor = '';
});
});
}
/**
* The function used to choose the correct menu.
*
* @param {string} menu The current menu id.
*/
function myLayoutMap(menu) {
if (menu == 'bug-menu' && bugsNum >= 6)
return 'right';
return isNopeChoice ? 'nope' : 'main';
}
/**
* The functions called to configure data before the menu has changed (and the animations have been played).
*
* @param {HTMLElement} old The old menu.
* @param {HTMLElement} new The new menu.
* @returns {Boolean} False to prevent the menu changing to happen.
*/
function detectNope(from, to) {
const activeElement = from.querySelector('.sm-active');
isNopeChoice = activeElement && activeElement.classList.contains('nope-item');
return true;
}
/**
* The functions called to configure data before the menu has changed (and the animations have been played).
*
* @param {HTMLElement} old The old menu.
* @param {HTMLElement} new The new menu.
* @returns {Boolean} False to prevent the menu changing to happen.
*/
function countBugs(from, to) {
if (from.id == 'bug-menu')
++bugsNum;
else if (from.id == 'sub-menu' && bugsNum >= 10)
bugsNum = 3;
}
/**
* Animate the entering menu.
*
* @param {HTMLElement} from The exiting menu.
* @param {HTMLElement} to The entering menu.
* @param {Boolean} isBack true if is a back animation.
*/
function standardInAnimation(from, to, isBack) {
// Enter the new menu.
$(to)
.css('left', isBack ? '-100%' : '100%')
.show()
.animate({left: '0'}, { duration: 1000 });
}
/**
* Animate the exiting menu.
*
* @param {HTMLElement} from The exiting menu.
* @param {HTMLElement} to The entering menu.
* @param {Boolean} isBack true if is a back animation.
*/
function standardOutAnimation(from, to, isBack) {
// Exit the current menu.
$(from)
.animate({left: isBack ? '100%' : '-100%'}, { duration: 1000 }, () => $(from).hide());
}
</script>
</head>
<body onload="buildMenu()">
<div id="sm-viewport" class="h-100 w-100">
<!-- START -->
<div id="sm-main-menu" class="sm-menu container-fluid h-100" data-sm-out="standardOutAnimation" data-sm-in="standardInAnimation">
<header>
Software's lifecycle
</header>
<div class="sm-layout sm-main-layout">
<div class="row d-flex justify-content-center w-100">
<div class="sm-item-container">
<div class="sm-item" data-goto="development-menu">
<h1>Start Developing</h1>
</div>
</div>
</div>
</div>
</div>
<!-- DEVELOPMENT -->
<div id="development-menu" class="sm-menu container-fluid h-100" data-sm-out="standardOutAnimation" data-sm-in="standardInAnimation">
<header>
Development
</header>
<div class="sm-layout sm-main-layout">
<div class="row d-flex justify-content-center w-100">
<div class="sm-item-container">
<div class="sm-item" data-goto="design-menu">
<h1>Design a feature</h1>
</div>
</div>
</div>
<div class="row d-flex justify-content-center w-100">
<div class="sm-item-container">
<div class="sm-item nope-item" data-goto="feature-menu">
<h1>Develop a feature</h1>
</div>
</div>
</div>
<div class="row d-flex justify-content-center w-100">
<div class="sm-item-container">
<div class="sm-item sm-redirect-blank-item" data-goto="https://media2.giphy.com/media/wmgsmee4a4vx6/giphy.gif?cid=3640f6095c97ae92544d305141562b47">
<h1>Give Up</h1>
</div>
</div>
</div>
</div>
<footer>
<button type="button" class="btn btn-secondary sm-item sm-back-item back-button">Back</button>
</footer>
</div>
<!-- DESIGN -->
<div id="design-menu" class="sm-menu container-fluid h-100" data-sm-out="standardOutAnimation" data-sm-in="standardInAnimation">
<header>
Design
</header>
<div class="sm-layout sm-main-layout">
<div class="row d-flex justify-content-center w-100">
<div class="sm-item-container">
<div class="sm-item" data-goto="feature-menu">
<h1>Develop feature</h1>
</div>
</div>
</div>
</div>
<footer>
<button type="button" class="btn btn-secondary back-button sm-item sm-back-item">Back</button>
</footer>
</div>
<!-- FEATURE -->
<div id="feature-menu" class="sm-menu container-fluid h-100" data-sm-out="standardOutAnimation" data-sm-in="standardInAnimation">
<header>
Feature's development
</header>
<div class="sm-layout sm-main-layout">
<div class="row d-flex justify-content-center w-100">
<div class="sm-item-container">
<div class="sm-item design-item" data-goto="design-menu">
<h1>Think again about design</h1>
</div>
</div>
</div>
<div class="row d-flex justify-content-center w-100">
<div class="sm-item-container">
<div class="sm-item" data-goto="test-menu">
<h1>Test feature</h1>
</div>
</div>
</div>
<div class="row d-flex justify-content-center w-100">
<div class="sm-item-container">
<div class="sm-item" data-goto="sub-menu">
<h1>Go to submission</h1>
</div>
</div>
</div>
</div>
<div class="sm-layout sm-nope-layout">
<div class="row d-flex justify-content-center w-100">
<div class="sm-item-container" data-item="design-item">
</div>
</div>
</div>
<footer>
<button type="button" class="btn btn-secondary back-button sm-item sm-back-item">Back</button>
</footer>
</div>
<!-- TESTING -->
<div id="test-menu" class="sm-menu container-fluid h-100" data-sm-out="standardOutAnimation" data-sm-in="standardInAnimation">
<header>
Testing phase
</header>
<div class="sm-layout sm-main-layout">
<div class="row d-flex justify-content-center w-100">
<div class="sm-item-container">
<div class="sm-item" data-goto="bug-menu">
<h1>It compiles, now run it!</h1>
</div>
</div>
</div>
</div>
<footer>
<button type="button" class="btn btn-secondary back-button sm-item sm-back-item">Back</button>
</footer>
</div>
<!-- BUG -->
<div id="bug-menu" class="sm-menu container-fluid h-100" data-sm-out="standardOutAnimation" data-sm-in="standardInAnimation">
<header>
BUG
</header>
<div class="sm-layout sm-main-layout">
<div class="row d-flex justify-content-center w-100">
<div class="sm-item-container">
<div class="sm-item" data-goto="feature-menu">
<h1>NOPE! Try again!</h1>
</div>
</div>
</div>
</div>
<div class="sm-layout sm-right-layout">
<div class="row d-flex justify-content-center w-100">
<div class="sm-item-container">
<div class="sm-item" data-goto="sub-menu">
<h1>Ok, seems good. Let's go for sub!</h1>
</div>
</div>
</div>
</div>
</div>
<!-- SUBMISSION -->
<div id="sub-menu" class="sm-menu container-fluid h-100" data-sm-out="standardOutAnimation" data-sm-in="standardInAnimation">
<header>
Submission
</header>
<div class="sm-layout sm-main-layout">
<div class="row d-flex justify-content-center w-100">
<div class="sm-item-container">
<div class="sm-item sm-back-item" data-goto="feature-menu">
<h1>BUGS! BUGS EVERYWHERE!</h1>
</div>
</div>
</div>
</div>
<div class="sm-layout sm-nope-layout">
<div class="row d-flex justify-content-center w-100">
<div class="sm-item-container">
<div class="sm-item sm-back-item" data-goto="sm-main-menu">
<h1>Are you serious? Do you aspect even a candy for it?</h1>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>