vgapp 0.0.6 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app/modules/base-module.js +1 -1
- package/app/modules/module-fn.js +3 -2
- package/app/modules/vgformsender/js/vgformsender.js +99 -26
- package/app/modules/vgnav/js/vgnav.js +3 -2
- package/app/modules/vgrollup/js/vgrollup.js +91 -0
- package/app/modules/vgrollup/scss/_variables.scss +8 -0
- package/app/modules/vgrollup/scss/vgrollup.scss +49 -0
- package/app/modules/vgsidebar/js/!oldjs.txt +143 -0
- package/app/modules/vgsidebar/js/vgsidebar.js +1 -1
- package/app/utils/js/functions.js +5 -0
- package/build/vgapp.css +8 -4555
- package/build/vgapp.css.map +1 -1
- package/build/vgapp.js +2 -3242
- package/build/vgapp.js.map +1 -1
- package/index.js +5 -1
- package/package.json +1 -1
package/app/modules/module-fn.js
CHANGED
|
@@ -83,14 +83,15 @@ const Ajax = {
|
|
|
83
83
|
}
|
|
84
84
|
let x = Ajax.x();
|
|
85
85
|
x.open(method, url, async);
|
|
86
|
+
x.setRequestHeader("X-Requested-With", "XMLHttpRequest");
|
|
86
87
|
x.onreadystatechange = function () {
|
|
87
88
|
if (x.readyState === 4) {
|
|
88
89
|
switch (x.status) {
|
|
89
90
|
case 200:
|
|
90
|
-
callback('success', x.responseText)
|
|
91
|
+
callback('success', {text: x.statusText, response: x.responseText, code: x.status})
|
|
91
92
|
break;
|
|
92
93
|
default:
|
|
93
|
-
callback('error', x.statusText)
|
|
94
|
+
callback('error', {text: x.statusText, response: x.responseText, code: x.status})
|
|
94
95
|
break;
|
|
95
96
|
}
|
|
96
97
|
}
|
|
@@ -2,7 +2,7 @@ import BaseModule from "../../base-module";
|
|
|
2
2
|
import {Manipulator} from "../../../utils/js/dom/manipulator";
|
|
3
3
|
import EventHandler from "../../../utils/js/dom/event";
|
|
4
4
|
import VGModal from "../../vgmodal/js/vgmodal";
|
|
5
|
-
import {makeRandomString, mergeDeepObject, normalizeData} from "../../../utils/js/functions";
|
|
5
|
+
import {isObject, makeRandomString, mergeDeepObject, normalizeData} from "../../../utils/js/functions";
|
|
6
6
|
import Selectors from "../../../utils/js/dom/selectors";
|
|
7
7
|
import VGCollapse from "../../vgcollapse/js/vgcollapse";
|
|
8
8
|
import {getSVG} from "../../module-fn";
|
|
@@ -13,11 +13,6 @@ import {getSVG} from "../../module-fn";
|
|
|
13
13
|
const NAME = 'form-sender';
|
|
14
14
|
const NAME_KEY = 'vg.fs';
|
|
15
15
|
|
|
16
|
-
/**
|
|
17
|
-
* Constants Classes
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
|
|
21
16
|
/**
|
|
22
17
|
* Constants Events
|
|
23
18
|
*/
|
|
@@ -89,7 +84,7 @@ class VGFormSender extends BaseModule {
|
|
|
89
84
|
|
|
90
85
|
_this._alertBefore();
|
|
91
86
|
|
|
92
|
-
_this._params.ajax.
|
|
87
|
+
_this._params.ajax.data = data;
|
|
93
88
|
|
|
94
89
|
_this._route(function (status, data) {
|
|
95
90
|
_this._element.classList.remove('was-validated');
|
|
@@ -212,9 +207,27 @@ class VGFormSender extends BaseModule {
|
|
|
212
207
|
alert(data, status) {
|
|
213
208
|
const _this = this;
|
|
214
209
|
|
|
215
|
-
if (
|
|
216
|
-
if ('
|
|
217
|
-
|
|
210
|
+
if (isObject(data)) {
|
|
211
|
+
if (('code' in data) && data.code && data.code === 200) {
|
|
212
|
+
if ('response' in data && data.response) {
|
|
213
|
+
let response = normalizeData(data.response);
|
|
214
|
+
if (typeof response === 'string') {
|
|
215
|
+
if (response.indexOf("Parse error") !== -1 || response.indexOf("syntax error") !== -1) {
|
|
216
|
+
status = 'error';
|
|
217
|
+
data = {
|
|
218
|
+
response: {
|
|
219
|
+
title: 'Error',
|
|
220
|
+
message: 'Something went wrong, please repeat later'
|
|
221
|
+
},
|
|
222
|
+
text: 'Something went wrong, please repeat later'
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
} else {
|
|
226
|
+
if ('errors' in response && normalizeData(response.errors)) {
|
|
227
|
+
status = normalizeData(response.errors) ? 'error' : 'success';
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
218
231
|
}
|
|
219
232
|
}
|
|
220
233
|
|
|
@@ -288,21 +301,79 @@ class VGFormSender extends BaseModule {
|
|
|
288
301
|
setDataRelationStatus($element, status, data, type) {
|
|
289
302
|
let $alert = Selectors.find('.vg-alert-' + status, $element);
|
|
290
303
|
|
|
291
|
-
if (
|
|
292
|
-
if (
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
304
|
+
if (isObject(data)) {
|
|
305
|
+
if (status === 'error') {
|
|
306
|
+
if ('code' in data && data.code !== 200) {
|
|
307
|
+
if ('text' in data && !data.text) {
|
|
308
|
+
data.text = 'Something went wrong, please repeat later';
|
|
309
|
+
|
|
310
|
+
switch (data.code) {
|
|
311
|
+
case 400:
|
|
312
|
+
data.text = 'Bad Request'
|
|
313
|
+
break;
|
|
314
|
+
case 401:
|
|
315
|
+
data.text = 'Unauthorized'
|
|
316
|
+
break;
|
|
317
|
+
case 403:
|
|
318
|
+
data.text = 'Unauthorized'
|
|
319
|
+
break;
|
|
320
|
+
case 413:
|
|
321
|
+
data.text = 'Forbidden'
|
|
322
|
+
break;
|
|
323
|
+
case 404:
|
|
324
|
+
data.text = 'Not Found'
|
|
325
|
+
break;
|
|
326
|
+
case 422:
|
|
327
|
+
data.text = 'Unprocessable Entity'
|
|
328
|
+
break;
|
|
329
|
+
case 500:
|
|
330
|
+
data.text = 'Internal Server Error'
|
|
331
|
+
break;
|
|
332
|
+
case 504:
|
|
333
|
+
data.text = 'Gateway Timeout'
|
|
334
|
+
break;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
297
337
|
}
|
|
338
|
+
}
|
|
298
339
|
|
|
299
|
-
|
|
300
|
-
|
|
340
|
+
if ('response' in data) {
|
|
341
|
+
let response = normalizeData(data.response), title = '', txt = '', code = '';
|
|
342
|
+
if (typeof response !== 'string') {
|
|
343
|
+
if (!('view' in response)) {
|
|
344
|
+
if ('title' in response) title = response.title;
|
|
345
|
+
if (status === 'error' && data.code !== 200) {
|
|
346
|
+
code = ' ' + data.text + ' (' + data.code + ')';
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
txt += '<h4 class="vg-alert-content--title">' + title + code + '</h4>';
|
|
350
|
+
|
|
351
|
+
if ('message' in response) {
|
|
352
|
+
txt += '<div class="vg-alert-content--message">' + response.message + '</div>'
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
if ('errors' in response) {
|
|
356
|
+
let errors = normalizeData(response.errors) || null;
|
|
357
|
+
if (isObject(errors)) {
|
|
358
|
+
for (const error in errors) {
|
|
359
|
+
if (Array.isArray(errors[error])) {
|
|
360
|
+
errors[error].forEach(function (t) {
|
|
361
|
+
txt += '<div>'+ t +'</div>';
|
|
362
|
+
})
|
|
363
|
+
} else {
|
|
364
|
+
txt = '<div>'+ errors[error] +'</div>';
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
data = {
|
|
371
|
+
view: txt
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
} else {
|
|
375
|
+
data.view = response;
|
|
301
376
|
}
|
|
302
|
-
|
|
303
|
-
data = txt;
|
|
304
|
-
} else if ('view' in data && typeof data.view === "string") {
|
|
305
|
-
data = data.view;
|
|
306
377
|
}
|
|
307
378
|
}
|
|
308
379
|
|
|
@@ -324,13 +395,13 @@ class VGFormSender extends BaseModule {
|
|
|
324
395
|
|
|
325
396
|
let text = document.createElement('div');
|
|
326
397
|
text.classList.add('vg-alert-content--text');
|
|
327
|
-
text.innerHTML = data;
|
|
398
|
+
text.innerHTML = data.view;
|
|
328
399
|
|
|
329
400
|
content.append(text);
|
|
330
401
|
$alert.append(content);
|
|
331
402
|
} else {
|
|
332
403
|
let text = Selectors.find('.vg-alert-content--text', $alert);
|
|
333
|
-
text.innerHTML = data;
|
|
404
|
+
text.innerHTML = data.view;
|
|
334
405
|
}
|
|
335
406
|
|
|
336
407
|
return $alert;
|
|
@@ -389,9 +460,11 @@ EventHandler.on(document, EVENT_SUBMIT_DATA_API, function (event) {
|
|
|
389
460
|
event.preventDefault();
|
|
390
461
|
|
|
391
462
|
let data = new FormData(instance._element);
|
|
392
|
-
|
|
463
|
+
|
|
464
|
+
// TODO доделать
|
|
465
|
+
/*if (Array.isArray(instance._params.ajax.fields) && instance._params.ajax.fields.length) {
|
|
393
466
|
data = collectData(data, instance._params.ajax.fields);
|
|
394
|
-
}
|
|
467
|
+
}*/
|
|
395
468
|
|
|
396
469
|
return instance.request(data, event);
|
|
397
470
|
}
|
|
@@ -66,6 +66,7 @@ class VGNav extends BaseModule {
|
|
|
66
66
|
collapse: true,
|
|
67
67
|
toggle: '<span class="default"></span>',
|
|
68
68
|
hamburger: {
|
|
69
|
+
enable: true,
|
|
69
70
|
always: false,
|
|
70
71
|
title: '',
|
|
71
72
|
body: null
|
|
@@ -119,12 +120,12 @@ class VGNav extends BaseModule {
|
|
|
119
120
|
this._element.classList.add('vg-nav-' + params.placement);
|
|
120
121
|
|
|
121
122
|
// Если нужно оставить список меню или установить медиа точку
|
|
122
|
-
if (params.breakpoint
|
|
123
|
+
if (!params.breakpoint) {
|
|
123
124
|
params.expand = false;
|
|
124
125
|
}
|
|
125
126
|
|
|
126
127
|
if (!params.hamburger.always) {
|
|
127
|
-
if (params.breakpoint
|
|
128
|
+
if (!params.breakpoint || !params.expand) {
|
|
128
129
|
this._element.classList.add(params.classes.expand);
|
|
129
130
|
} else if (params.breakpoint !== false) {
|
|
130
131
|
this._element.classList.add('vg-nav-' + params.breakpoint);
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import BaseModule from "../../base-module";
|
|
2
|
+
import {execute, isDisabled, isVisible, mergeDeepObject, noop} from "../../../utils/js/functions";
|
|
3
|
+
import EventHandler from "../../../utils/js/dom/event";
|
|
4
|
+
import Selectors from "../../../utils/js/dom/selectors";
|
|
5
|
+
import {Manipulator} from "../../../utils/js/dom/manipulator";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Constants
|
|
9
|
+
*/
|
|
10
|
+
const NAME = 'rollup';
|
|
11
|
+
const NAME_KEY = 'vg.rollup';
|
|
12
|
+
const CLASS_NAME_SHOW = 'show';
|
|
13
|
+
const CLASS_NAME_HIDE = 'd-none';
|
|
14
|
+
const SELECTOR_DATA_TOGGLE= '[data-vg-toggle="rollup"]'
|
|
15
|
+
|
|
16
|
+
const EVENT_KEY_HIDE = `${NAME_KEY}.hide`;
|
|
17
|
+
const EVENT_KEY_HIDDEN = `${NAME_KEY}.hidden`;
|
|
18
|
+
const EVENT_KEY_SHOW = `${NAME_KEY}.show`;
|
|
19
|
+
const EVENT_KEY_SHOWN = `${NAME_KEY}.shown`;
|
|
20
|
+
|
|
21
|
+
const EVENT_KEY_CLICK_DATA_API = `click.${NAME_KEY}.data.api`;
|
|
22
|
+
|
|
23
|
+
class VGRollup extends BaseModule {
|
|
24
|
+
constructor(element, params = {}) {
|
|
25
|
+
super(element, params);
|
|
26
|
+
|
|
27
|
+
this._params = this._getParams(element, mergeDeepObject({
|
|
28
|
+
|
|
29
|
+
}, params));
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
static get NAME() {
|
|
35
|
+
return NAME;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
static get NAME_KEY() {
|
|
39
|
+
return NAME_KEY
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Инициализация
|
|
44
|
+
* @param element
|
|
45
|
+
* @param params
|
|
46
|
+
*/
|
|
47
|
+
static init(element, params = {}) {
|
|
48
|
+
const instance = VGRollup.getOrCreateInstance(element, params);
|
|
49
|
+
instance.build();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
build() {
|
|
53
|
+
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
toggle(relatedTarget) {
|
|
57
|
+
return !this._isShown() ? this.show(relatedTarget) : this.hide();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
show(relatedTarget) {
|
|
61
|
+
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
_isShown() {
|
|
65
|
+
return this._element.classList.contains(CLASS_NAME_SHOW);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Data API implementation
|
|
71
|
+
*/
|
|
72
|
+
EventHandler.on(document, EVENT_KEY_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) {
|
|
73
|
+
const target = Selectors.getElementFromSelector(this);
|
|
74
|
+
if (!target) return;
|
|
75
|
+
|
|
76
|
+
if (['A', 'AREA'].includes(this.tagName)) {
|
|
77
|
+
event.preventDefault()
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (isDisabled(this)) {
|
|
81
|
+
return
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
this.setAttribute('aria-expanded', true);
|
|
85
|
+
|
|
86
|
+
const data = VGRollup.getOrCreateInstance(target)
|
|
87
|
+
data.toggle(this);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
export default VGRollup;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*--------------------------------------------------------------------------
|
|
3
|
+
* Модуль: VGRollup
|
|
4
|
+
* Автор: Vegas DEV
|
|
5
|
+
* Лицензия: смотри LICENSE
|
|
6
|
+
*--------------------------------------------------------------------------
|
|
7
|
+
**/
|
|
8
|
+
|
|
9
|
+
@import "../../../utils/scss/functions";
|
|
10
|
+
@import "../../../utils/scss/mixin";
|
|
11
|
+
@import "../../../utils/scss/variables";
|
|
12
|
+
@import "variables";
|
|
13
|
+
|
|
14
|
+
.vg-rollup {
|
|
15
|
+
@include mix-vars('rollup', $rollup-map);
|
|
16
|
+
transform: var(--vg-rollup-transition);
|
|
17
|
+
|
|
18
|
+
&-button {
|
|
19
|
+
@include mix-vars('rollup-button', $rollup-button-map);
|
|
20
|
+
text-align: var(--vg-rollup-button-align);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
&-content {
|
|
24
|
+
&--hidden {
|
|
25
|
+
overflow: hidden;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
&--fade {
|
|
29
|
+
position: relative;
|
|
30
|
+
|
|
31
|
+
&:after {
|
|
32
|
+
content: '';
|
|
33
|
+
position: absolute;
|
|
34
|
+
left: 0;
|
|
35
|
+
bottom: 0;
|
|
36
|
+
width: 100%;
|
|
37
|
+
height: var(--vg-rollup-fade-height);
|
|
38
|
+
background: var(--vg-rollup-fade-background);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
&--ellipsis {
|
|
43
|
+
overflow: hidden;
|
|
44
|
+
text-overflow: ellipsis;
|
|
45
|
+
display: -webkit-box;
|
|
46
|
+
-webkit-box-orient: vertical;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
build(isFirstInit = true) {
|
|
2
|
+
let self_height = this._element.clientHeight,
|
|
3
|
+
set_height = parseInt(this._params.height) || (self_height / 2);
|
|
4
|
+
|
|
5
|
+
if (isFirstInit) this._element.classList.add('vg-rollup');
|
|
6
|
+
|
|
7
|
+
if (self_height > set_height && this._params.content === 'text') {
|
|
8
|
+
this._element.classList.add(this._params.classes.hidden);
|
|
9
|
+
this._element.style.height = set_height + "px";
|
|
10
|
+
|
|
11
|
+
this.ellipsis();
|
|
12
|
+
this.fade();
|
|
13
|
+
if (isFirstInit) this.button();
|
|
14
|
+
} else if (this._params.content === 'elements') {
|
|
15
|
+
let elementClass = this._params.elements,
|
|
16
|
+
items = this._element.querySelectorAll('.' + elementClass),
|
|
17
|
+
cnt = this._params.cnt,
|
|
18
|
+
i = 1;
|
|
19
|
+
|
|
20
|
+
this.total = items.length;
|
|
21
|
+
this.count = cnt;
|
|
22
|
+
|
|
23
|
+
for (const item of items) {
|
|
24
|
+
if (i > cnt) {
|
|
25
|
+
item.classList.add(CLASS_NAME_HIDE)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
i++;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (this._params.button === true) this._params.button = (i - 1) > cnt;
|
|
32
|
+
|
|
33
|
+
this.ellipsis();
|
|
34
|
+
this.fade();
|
|
35
|
+
if (isFirstInit) this.button();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (isFirstInit) {
|
|
39
|
+
this._button = document.querySelector('[data-vg-target="'+ this._element.id +'"]');
|
|
40
|
+
execute(this._params.callback.afterInit, [this]);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
ellipsis() {
|
|
45
|
+
if (this._params.ellipsis.line) {
|
|
46
|
+
this._element.classList.add(this._params.classes.ellipsis);
|
|
47
|
+
this._element.style.webkitLineClamp = this._params.ellipsis.line;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
fade() {
|
|
52
|
+
if (this._params.fade) {
|
|
53
|
+
if (this._element.classList.contains(this._params.classes.ellipsis)) {
|
|
54
|
+
this._element.classList.remove(this._params.classes.fade)
|
|
55
|
+
} else {
|
|
56
|
+
this._element.classList.add(this._params.classes.fade);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
button() {
|
|
62
|
+
if (this._params.button) {
|
|
63
|
+
let target = this._element.id,
|
|
64
|
+
button = document.querySelector('[data-vg-target="'+ target +'"]');
|
|
65
|
+
|
|
66
|
+
console.log(button)
|
|
67
|
+
|
|
68
|
+
if (!button) {
|
|
69
|
+
let textShowNum = '', btnTextShow = this._params.text.show;
|
|
70
|
+
|
|
71
|
+
if (this._params.number) {
|
|
72
|
+
let sum = (this.total) - (this.count);
|
|
73
|
+
|
|
74
|
+
if (sum > 0) {
|
|
75
|
+
textShowNum = this._params.text.more + sum;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
this._element.insertAdjacentHTML("afterend", '<div class="' + this._params.classes.button + '"><a href="#" aria-expanded="false" data-vg-target="#' + target + '" data-vg-toggle="rollup">' + btnTextShow + textShowNum + '</a></div>');
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
toggle(relatedTarget) {
|
|
85
|
+
return !this._isShown() ? this.show(relatedTarget) : this.hide();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
show(relatedTarget) {
|
|
89
|
+
if (isDisabled(this._element)) return;
|
|
90
|
+
|
|
91
|
+
const showEvent = EventHandler.trigger(this._element, EVENT_KEY_SHOW, { relatedTarget })
|
|
92
|
+
if (showEvent.defaultPrevented) return;
|
|
93
|
+
|
|
94
|
+
this._element.classList.add(CLASS_NAME_SHOW);
|
|
95
|
+
|
|
96
|
+
const completeCallBack = () => {
|
|
97
|
+
if (this._params.content === 'elements') {
|
|
98
|
+
[... Selectors.findAll('.' + this._params.elements, this._element)].forEach(el => {
|
|
99
|
+
if (el.classList.contains(CLASS_NAME_HIDE)) {
|
|
100
|
+
el.classList.remove(CLASS_NAME_HIDE)
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
} else {
|
|
104
|
+
this._element.style.height = this.self_height + "px";
|
|
105
|
+
this._element.classList.remove(this._params.classes.fade);
|
|
106
|
+
|
|
107
|
+
if (this._element.classList.contains(this._params.classes.ellipsis)) {
|
|
108
|
+
this._element.classList.remove(this._params.classes.ellipsis)
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
relatedTarget.innerHTML = this._params.text.hide;
|
|
113
|
+
|
|
114
|
+
EventHandler.trigger(this._element, EVENT_KEY_SHOWN, { relatedTarget });
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
this._button = relatedTarget;
|
|
118
|
+
execute(this._params.callback.show, [this]);
|
|
119
|
+
this._queueCallback(completeCallBack, this._element, true, 50)
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
hide() {
|
|
123
|
+
if (isDisabled(this._element)) return;
|
|
124
|
+
|
|
125
|
+
const hideEvent = EventHandler.trigger(this._element, EVENT_KEY_HIDE);
|
|
126
|
+
if (hideEvent.defaultPrevented) return;
|
|
127
|
+
|
|
128
|
+
this._element.setAttribute('aria-expanded', 'false');
|
|
129
|
+
|
|
130
|
+
this.build(false)
|
|
131
|
+
|
|
132
|
+
const completeCallback = () => {
|
|
133
|
+
this._element.classList.remove(CLASS_NAME_SHOW);
|
|
134
|
+
EventHandler.trigger(this._element, EVENT_KEY_HIDDEN)
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
execute(this._params.callback.hide, [this]);
|
|
138
|
+
this._queueCallback(completeCallback, this._element, true);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
_isShown() {
|
|
142
|
+
return this._element.classList.contains(CLASS_NAME_SHOW);
|
|
143
|
+
}
|
|
@@ -149,7 +149,7 @@ EventHandler.on(document, EVENT_KEY_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, functi
|
|
|
149
149
|
|
|
150
150
|
this.setAttribute('aria-expanded', true);
|
|
151
151
|
EventHandler.one(target, EVENT_KEY_HIDDEN, () => {
|
|
152
|
-
if (isVisible(this)) this.focus();
|
|
152
|
+
//if (isVisible(this)) this.focus();
|
|
153
153
|
this.setAttribute('aria-expanded', false);
|
|
154
154
|
})
|
|
155
155
|
|
|
@@ -51,6 +51,11 @@ const isDisabled = element => {
|
|
|
51
51
|
return element.hasAttribute('disabled') && element.getAttribute('disabled') !== 'false'
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
/**
|
|
55
|
+
* isVisible
|
|
56
|
+
* @param element
|
|
57
|
+
* @returns {boolean}
|
|
58
|
+
*/
|
|
54
59
|
function isVisible (element) {
|
|
55
60
|
if (!isElement(element) || element.getClientRects().length === 0) {
|
|
56
61
|
return false
|