-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmmenu.debugger.js
More file actions
417 lines (364 loc) · 12.8 KB
/
mmenu.debugger.js
File metadata and controls
417 lines (364 loc) · 12.8 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
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
/**
* Debugger for mmenu.js
* Include this file after including the mmenu.js plugin to debug your menu.
*/
(function() {
const _console = Mmenu.console ||
console || {
log: function() {},
warn: function() {},
error: function() {},
group: function() {},
groupEnd: function() {}
};
const warnings = [];
const deprecated = (depr, repl, vers) => {
var msg = 'Mmenu: ' + depr + ' is deprecated';
if (vers) {
msg += ' as of version ' + vers;
}
if (repl) {
msg += ', use ' + repl + ' instead';
}
msg += '.';
warnings.push(msg);
};
if (typeof Mmenu == 'undefined') {
_console.error(
'Global variable "Mmenu" (needed for the debugger) not found!'
);
return;
}
/** Log deprecated warnings. */
Mmenu.prototype._deprecatedWarnings = function() {
/**
* ----------------------------
* Version 8.4 > 8.5
* ----------------------------
*/
/* Add-ons */
// Navbars "next" content is removed.
if (this.opts.navbars) {
this.opts.navbars.forEach(navbar => {
if (navbar.content.includes('next')) {
deprecated(
'The "next" content for the "navbars" add-on',
null,
'8.5.0'
);
}
});
}
/* Extensions */
// Removed the tileview extension.
['tileview'].forEach(ext => {
Object.keys(this.opts.extensions).forEach(key => {
if (this.opts.extensions[key].includes(ext)) {
deprecated(
'The "' + ext + '" extension',
'custom CSS',
'8.5.0'
);
}
});
});
/**
* ----------------------------
* Version 8.3 > 8.4
* ----------------------------
*/
/* Config */
// Styling listitems with "spacer" is removed.
if (
this.conf.classNames.spacer ||
this.node.menu.querySelector('.Spacer')
) {
deprecated(
'Styling a listitem with "Spacer"',
'custom CSS',
'8.4.0'
);
}
/**
* ----------------------------
* Version 8.2 > 8.3
* ----------------------------
*/
/* OPTIONS */
// The navbar.title option can no longer be a function.
if (typeof this.opts.navbar.title == 'function') {
deprecated(
'A function for the "navbar.title" option',
'a custom JS loop',
'8.3.0'
);
// Prevent an error.
this.opts.navbar.title = Mmenu.options.navbar.title;
}
/* ADD-ONS */
// New Drag add-on with lesser options.
if (this.opts.drag) {
// Swiping to close panels no longer supported.
if (this.opts.drag.panels) {
deprecated(
'Swiping to close panels using the "drag" add-on',
null,
'8.3.0'
);
}
// "drag.menu" Suboptions now are the "drag" options.
if (this.opts.drag.menu) {
deprecated(
'The "drag.menu" options for the "drag" add-on',
'the "drag" option',
'8.3.0'
);
}
}
// The dividers.type option is removed.
if (this.opts.dividers) {
if (this.opts.dividers.type == 'light') {
deprecated(
'The "type" option for the "dividers" add-on',
'custom CSS',
'8.3.0'
);
}
}
/* EXTENSIONS */
// Removed panel-scoped extensions.
[
'mm-panel-border-none',
'mm-panel-border-full',
'mm-panel_listview-justify',
'mm-panel-slide-0',
'mm-panel-slide-100'
].forEach(ext => {
if (this.node.menu.querySelector(ext)) {
deprecated(
'Using the classname ' + ext + ' on a specific panel.',
'custom CSS',
'8.3.0'
);
}
});
// Removed (parts of) extensions.
[
'border-offset',
'fx-menu-fade',
'fx-menu-zoom',
'fx-panels-slide-up',
'fx-panels-slide-right',
'fx-panels-zoom',
'fx-listitems-drop',
'fx-listitems-fade',
'fx-listitems-slide'
].forEach(ext => {
Object.keys(this.opts.extensions).forEach(key => {
if (this.opts.extensions[key].includes(ext)) {
deprecated(
'The "' + ext + '" extension',
'custom CSS',
'8.3.0'
);
}
});
});
/**
* ----------------------------
* Version 8.1 > 8.2
* ----------------------------
*/
/* API */
// Deprecated API methods.
this.bind('initPanels:deprecated', method => {
deprecated('The "initPanels" API method', '"initPanel"', '8.2.0');
});
/**
* ----------------------------
* Version 8.0 > 8.1
* ----------------------------
*/
/* CONFIGURATION */
// conf.clone is moved to conf.offCanvas.clone.
if (typeof this.conf.clone != 'undefined') {
deprecated(
'The "clone" configuration option',
'"offCanvas.clone"',
'8.1.0'
);
// Try to fix it.
if (typeof this.conf.offCanvas.clone == 'undefined') {
this.conf.offCanvas.clone = this.conf.clone;
}
}
/**
* ----------------------------
* Version 7.3 > 8.0
* ----------------------------
*/
/* API */
// These methods no longer accept a jQuery object as an argument,
// they now only accept a HTMLElement.
[
'setPage',
'openPanel',
'closePanel',
'closeAllPanels',
'setSelected'
].forEach(method => {
this.bind(method + ':before', panel => {
if (
typeof panel != 'undefined' &&
typeof jQuery != 'undefined' &&
panel instanceof jQuery
) {
deprecated(
'Passing a jQuery object as an argument to the "' +
method +
'" API method',
'a HTMLElement',
'8.0.0'
);
}
});
});
// These methods no longer accept a jQuery object as an argument,
// they now only accept an array of HTMLElements.
['initPanels'].forEach(method => {
this.bind(method + ':before', panel => {
if (
typeof panel != 'undefined' &&
typeof jQuery != 'undefined' &&
panel instanceof jQuery
) {
deprecated(
'Passing a jQuery object as an argument to the "' +
method +
'" API method',
'a HTMLElement array',
'8.0.0'
);
}
});
});
/* OPTIONS */
// opts.navbars.navbar.height is removed in favor of specifying a different CSS variable (--mm-navbar-size ) for each navbar.
if (this.opts.navbars) {
this.opts.navbars.forEach(navbar => {
if (typeof navbar.height !== 'undefined') {
deprecated(
'The "height" option in the "navbars" options.',
'the CSS variable "--mm-navbar-size"',
'8.0.0'
);
}
});
}
// opts.dividers.fixed is removed, all dividers are now sticky by default.
if (this.opts.dividers) {
if (
typeof this.opts.dividers == 'object' &&
typeof this.opts.dividers.fixed !== 'undefined'
) {
deprecated(
'The "fixed" option in the "dividers" options.',
null,
'8.0.0'
);
}
}
// opts.iconbar.add is renamed to opts.iconbar.use.
if (this.opts.iconbar) {
if (
typeof this.opts.iconbar == 'object' &&
typeof this.opts.iconbar.add !== 'undefined'
) {
deprecated(
'The "add" option in the "iconbar" options.',
'"use"',
'8.0.0'
);
// Try to fix it.
this.opts.iconbar.use = this.opts.iconbar.add;
}
}
/* CONFIGURATION */
// conf.fixedElements.elemInsertMethod is changed to conf.fixedElements.fixed.insertMethod.
if (typeof this.conf.fixedElements.elemInsertMethod != 'undefined') {
deprecated(
'The "elemInsertMethod" option in the "fixedElements" configuration',
'"fixed.insertMethod"',
'8.0.0'
);
// Try to fix it.
if (
typeof this.conf.fixedElements.fixed.insertMethod == 'undefined'
) {
this.conf.fixedElements.fixed.insertMethod = this.conf.fixedElements.elemInsertMethod;
}
}
// conf.fixedElements.elemInsertSelector is changed to conf.fixedElements.fixed.insertSelector.
if (typeof this.conf.fixedElements.elemInsertMethod != 'undefined') {
deprecated(
'The "elemInsertSelector" option in the "fixedElements" configuration',
'"fixed.insertSelector"',
'8.0.0'
);
// Try to fix it.
if (
typeof this.conf.fixedElements.fixed.insertSelector ==
'undefined'
) {
this.conf.fixedElements.fixed.insertSelector = this.conf.fixedElements.elemInsertSelector;
}
}
/* WRAPPERS */
// Removed and renamed framework wrappers
if (this.opts.wrappers) {
this.opts.wrappers.forEach(wrapper => {
switch (wrapper) {
// Bootstrap 3 framework wrapper is removed
case 'bootstrap3':
deprecated('The "bootstrap3" wrapper', null, '8.0.0');
// Try to fix it.
let indexbs3 = this.opts.wrappers.indexOf(wrapper);
if (indexbs3 > -1) {
this.opts.wrappers.splice(indexbs3, 1);
}
break;
// Bootstrap 4 framework wrapper is renamed to "bootstrap"
case 'bootstrap4':
deprecated(
'The "bootstrap4" wrapper',
'"bootstrap"',
'8.0.0'
);
// Try to fix it.
this.opts.wrappers.push('bootstrap');
let indexbs4 = this.opts.wrappers.indexOf(wrapper);
if (indexbs4 > -1) {
this.opts.wrappers.splice(indexbs4, 1);
}
break;
// jQuery Mobile framework wrapper is removed
case 'jqueryMobile':
deprecated('The "jqueryMobile" wrapper', null, '8.0.0');
// Try to fix it.
let indexjqm = this.opts.wrappers.indexOf(wrapper);
if (indexjqm > -1) {
this.opts.wrappers.splice(indexjqm, 1);
}
break;
}
});
}
if (warnings.length) {
_console.group('Mmenu deprecated warnings.');
warnings.forEach(msg => {
_console.warn(msg);
});
_console.groupEnd();
}
};
})();