@tomasvn/glightbox 0.0.0-stage → 3.3.4
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/.editorconfig +16 -0
- package/.eslintignore +3 -0
- package/.eslintrc.json +94 -0
- package/.github/FUNDING.yml +3 -0
- package/.github/ISSUE_TEMPLATE/bug_report.md +41 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +23 -0
- package/.github/stale.yml +21 -0
- package/.github/workflows/greetings.yml +13 -0
- package/.husky/pre-commit +3 -0
- package/.lando.yml +10 -0
- package/.prettierignore +3 -0
- package/.prettierrc.json +30 -0
- package/CHANGELOG.md +259 -0
- package/CONTRIBUTING.md +29 -0
- package/LICENSE.md +21 -0
- package/README.md +714 -2
- package/bower.json +29 -0
- package/development/build.js +44 -0
- package/development/jscompiler.js +90 -0
- package/development/notifications.js +15 -0
- package/development/package.js +116 -0
- package/development/postcss.js +63 -0
- package/development/watcher.js +105 -0
- package/dist/css/glightbox.css +939 -0
- package/dist/css/glightbox.min.css +1 -0
- package/dist/js/glightbox.js +3109 -0
- package/dist/js/glightbox.min.js +1 -0
- package/index.d.ts +586 -0
- package/package.json +60 -4
- package/src/js/.jshintrc +6 -0
- package/src/js/core/drag.js +203 -0
- package/src/js/core/keyboard-navigation.js +101 -0
- package/src/js/core/slide-parser.js +236 -0
- package/src/js/core/slide.js +251 -0
- package/src/js/core/touch-events.js +378 -0
- package/src/js/core/touch-navigation.js +291 -0
- package/src/js/core/zoom.js +156 -0
- package/src/js/glightbox.js +1351 -0
- package/src/js/slides/iframe.js +24 -0
- package/src/js/slides/image.js +56 -0
- package/src/js/slides/inline.js +71 -0
- package/src/js/slides/video.js +108 -0
- package/src/js/utils/helpers.js +541 -0
- package/src/postcss/glightbox.css +725 -0
- package/tests/slide.test.mjs +130 -0
- package/tests/touch-navigation.test.mjs +13 -0
|
@@ -0,0 +1,3109 @@
|
|
|
1
|
+
(function (global, factory) {
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(factory) :
|
|
4
|
+
(global = global || self, global.GLightbox = factory());
|
|
5
|
+
}(this, (function () { 'use strict';
|
|
6
|
+
|
|
7
|
+
function _classCallCheck(a, n) {
|
|
8
|
+
if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
|
|
9
|
+
}
|
|
10
|
+
function _defineProperties(e, r) {
|
|
11
|
+
for (var t = 0; t < r.length; t++) {
|
|
12
|
+
var o = r[t];
|
|
13
|
+
o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function _createClass(e, r, t) {
|
|
17
|
+
return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
|
|
18
|
+
writable: !1
|
|
19
|
+
}), e;
|
|
20
|
+
}
|
|
21
|
+
function _toPrimitive(t, e) {
|
|
22
|
+
if ("object" != typeof t || !t) return t;
|
|
23
|
+
var r;
|
|
24
|
+
if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) {
|
|
25
|
+
var i = r.call(t, e || "default");
|
|
26
|
+
if ("object" != typeof i) return i;
|
|
27
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
28
|
+
}
|
|
29
|
+
return ("string" === e ? String : Number)(t);
|
|
30
|
+
}
|
|
31
|
+
function _toPropertyKey(t) {
|
|
32
|
+
var i = _toPrimitive(t, "string");
|
|
33
|
+
return "symbol" == typeof i ? i : i + "";
|
|
34
|
+
}
|
|
35
|
+
function _typeof(o) {
|
|
36
|
+
"@babel/helpers - typeof";
|
|
37
|
+
|
|
38
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
39
|
+
return typeof o;
|
|
40
|
+
} : function (o) {
|
|
41
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
42
|
+
}, _typeof(o);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
var uid = Date.now();
|
|
46
|
+
function extend() {
|
|
47
|
+
var extended = {};
|
|
48
|
+
var deep = true;
|
|
49
|
+
var i = 0;
|
|
50
|
+
var length = arguments.length;
|
|
51
|
+
if (Object.prototype.toString.call(arguments[0]) === '[object Boolean]') {
|
|
52
|
+
deep = arguments[0];
|
|
53
|
+
i++;
|
|
54
|
+
}
|
|
55
|
+
var merge = function merge(obj) {
|
|
56
|
+
for (var prop in obj) {
|
|
57
|
+
if (Object.prototype.hasOwnProperty.call(obj, prop)) {
|
|
58
|
+
if (deep && Object.prototype.toString.call(obj[prop]) === '[object Object]') {
|
|
59
|
+
extended[prop] = extend(true, extended[prop], obj[prop]);
|
|
60
|
+
} else {
|
|
61
|
+
extended[prop] = obj[prop];
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
for (; i < length; i++) {
|
|
67
|
+
var obj = arguments[i];
|
|
68
|
+
merge(obj);
|
|
69
|
+
}
|
|
70
|
+
return extended;
|
|
71
|
+
}
|
|
72
|
+
function each(collection, callback) {
|
|
73
|
+
if (isNode(collection) || collection === window || collection === document) {
|
|
74
|
+
collection = [collection];
|
|
75
|
+
}
|
|
76
|
+
if (!isArrayLike(collection) && !isObject(collection)) {
|
|
77
|
+
collection = [collection];
|
|
78
|
+
}
|
|
79
|
+
if (size(collection) == 0) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
if (isArrayLike(collection) && !isObject(collection)) {
|
|
83
|
+
var l = collection.length,
|
|
84
|
+
i = 0;
|
|
85
|
+
for (; i < l; i++) {
|
|
86
|
+
if (callback.call(collection[i], collection[i], i, collection) === false) {
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
} else if (isObject(collection)) {
|
|
91
|
+
for (var key in collection) {
|
|
92
|
+
if (has(collection, key)) {
|
|
93
|
+
if (callback.call(collection[key], collection[key], key, collection) === false) {
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
function getNodeEvents(node) {
|
|
101
|
+
var name = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
102
|
+
var fn = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
103
|
+
var cache = node[uid] = node[uid] || [];
|
|
104
|
+
var data = {
|
|
105
|
+
all: cache,
|
|
106
|
+
evt: null,
|
|
107
|
+
found: null
|
|
108
|
+
};
|
|
109
|
+
if (name && fn && size(cache) > 0) {
|
|
110
|
+
each(cache, function (cl, i) {
|
|
111
|
+
if (cl.eventName == name && cl.fn.toString() == fn.toString()) {
|
|
112
|
+
data.found = true;
|
|
113
|
+
data.evt = i;
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
return data;
|
|
119
|
+
}
|
|
120
|
+
function addEvent(eventName) {
|
|
121
|
+
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
122
|
+
onElement = _ref.onElement,
|
|
123
|
+
withCallback = _ref.withCallback,
|
|
124
|
+
_ref$avoidDuplicate = _ref.avoidDuplicate,
|
|
125
|
+
avoidDuplicate = _ref$avoidDuplicate === void 0 ? true : _ref$avoidDuplicate,
|
|
126
|
+
_ref$once = _ref.once,
|
|
127
|
+
once = _ref$once === void 0 ? false : _ref$once,
|
|
128
|
+
_ref$useCapture = _ref.useCapture,
|
|
129
|
+
useCapture = _ref$useCapture === void 0 ? false : _ref$useCapture;
|
|
130
|
+
var thisArg = arguments.length > 2 ? arguments[2] : undefined;
|
|
131
|
+
var element = onElement || [];
|
|
132
|
+
if (isString(element)) {
|
|
133
|
+
element = document.querySelectorAll(element);
|
|
134
|
+
}
|
|
135
|
+
function handler(event) {
|
|
136
|
+
if (isFunction(withCallback)) {
|
|
137
|
+
withCallback.call(thisArg, event, this);
|
|
138
|
+
}
|
|
139
|
+
if (once) {
|
|
140
|
+
handler.destroy();
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
handler.destroy = function () {
|
|
144
|
+
each(element, function (el) {
|
|
145
|
+
var events = getNodeEvents(el, eventName, handler);
|
|
146
|
+
if (events.found) {
|
|
147
|
+
events.all.splice(events.evt, 1);
|
|
148
|
+
}
|
|
149
|
+
if (el.removeEventListener) {
|
|
150
|
+
el.removeEventListener(eventName, handler, useCapture);
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
};
|
|
154
|
+
each(element, function (el) {
|
|
155
|
+
var events = getNodeEvents(el, eventName, handler);
|
|
156
|
+
if (el.addEventListener && avoidDuplicate && !events.found || !avoidDuplicate) {
|
|
157
|
+
el.addEventListener(eventName, handler, useCapture);
|
|
158
|
+
events.all.push({
|
|
159
|
+
eventName: eventName,
|
|
160
|
+
fn: handler
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
return handler;
|
|
165
|
+
}
|
|
166
|
+
function addClass(node, name) {
|
|
167
|
+
each(name.split(' '), function (cl) {
|
|
168
|
+
return node.classList.add(cl);
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
function removeClass(node, name) {
|
|
172
|
+
each(name.split(' '), function (cl) {
|
|
173
|
+
return node.classList.remove(cl);
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
function hasClass(node, name) {
|
|
177
|
+
return node.classList.contains(name);
|
|
178
|
+
}
|
|
179
|
+
function closest(elem, selector) {
|
|
180
|
+
while (elem !== document.body) {
|
|
181
|
+
elem = elem.parentElement;
|
|
182
|
+
if (!elem) {
|
|
183
|
+
return false;
|
|
184
|
+
}
|
|
185
|
+
var matches = typeof elem.matches == 'function' ? elem.matches(selector) : elem.msMatchesSelector(selector);
|
|
186
|
+
if (matches) {
|
|
187
|
+
return elem;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
function animateElement(element) {
|
|
192
|
+
var animation = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
193
|
+
var callback = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
194
|
+
if (!element || animation === '') {
|
|
195
|
+
return false;
|
|
196
|
+
}
|
|
197
|
+
if (animation === 'none') {
|
|
198
|
+
if (isFunction(callback)) {
|
|
199
|
+
callback();
|
|
200
|
+
}
|
|
201
|
+
return false;
|
|
202
|
+
}
|
|
203
|
+
var animationEnd = whichAnimationEvent();
|
|
204
|
+
var animationNames = animation.split(' ');
|
|
205
|
+
each(animationNames, function (name) {
|
|
206
|
+
addClass(element, 'g' + name);
|
|
207
|
+
});
|
|
208
|
+
addEvent(animationEnd, {
|
|
209
|
+
onElement: element,
|
|
210
|
+
avoidDuplicate: false,
|
|
211
|
+
once: true,
|
|
212
|
+
withCallback: function withCallback(event, target) {
|
|
213
|
+
each(animationNames, function (name) {
|
|
214
|
+
removeClass(target, 'g' + name);
|
|
215
|
+
});
|
|
216
|
+
if (isFunction(callback)) {
|
|
217
|
+
callback();
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
function cssTransform(node) {
|
|
223
|
+
var translate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
224
|
+
if (translate === '') {
|
|
225
|
+
node.style.webkitTransform = '';
|
|
226
|
+
node.style.MozTransform = '';
|
|
227
|
+
node.style.msTransform = '';
|
|
228
|
+
node.style.OTransform = '';
|
|
229
|
+
node.style.transform = '';
|
|
230
|
+
return false;
|
|
231
|
+
}
|
|
232
|
+
node.style.webkitTransform = translate;
|
|
233
|
+
node.style.MozTransform = translate;
|
|
234
|
+
node.style.msTransform = translate;
|
|
235
|
+
node.style.OTransform = translate;
|
|
236
|
+
node.style.transform = translate;
|
|
237
|
+
}
|
|
238
|
+
function show(element) {
|
|
239
|
+
element.style.display = 'block';
|
|
240
|
+
}
|
|
241
|
+
function hide(element) {
|
|
242
|
+
element.style.display = 'none';
|
|
243
|
+
}
|
|
244
|
+
function createHTML(htmlStr) {
|
|
245
|
+
var frag = document.createDocumentFragment(),
|
|
246
|
+
temp = document.createElement('div');
|
|
247
|
+
temp.innerHTML = htmlStr;
|
|
248
|
+
while (temp.firstChild) {
|
|
249
|
+
frag.appendChild(temp.firstChild);
|
|
250
|
+
}
|
|
251
|
+
return frag;
|
|
252
|
+
}
|
|
253
|
+
function windowSize() {
|
|
254
|
+
return {
|
|
255
|
+
width: window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth,
|
|
256
|
+
height: window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
function whichAnimationEvent() {
|
|
260
|
+
var t,
|
|
261
|
+
el = document.createElement('fakeelement');
|
|
262
|
+
var animations = {
|
|
263
|
+
animation: 'animationend',
|
|
264
|
+
OAnimation: 'oAnimationEnd',
|
|
265
|
+
MozAnimation: 'animationend',
|
|
266
|
+
WebkitAnimation: 'webkitAnimationEnd'
|
|
267
|
+
};
|
|
268
|
+
for (t in animations) {
|
|
269
|
+
if (el.style[t] !== undefined) {
|
|
270
|
+
return animations[t];
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
function whichTransitionEvent() {
|
|
275
|
+
var t,
|
|
276
|
+
el = document.createElement('fakeelement');
|
|
277
|
+
var transitions = {
|
|
278
|
+
transition: 'transitionend',
|
|
279
|
+
OTransition: 'oTransitionEnd',
|
|
280
|
+
MozTransition: 'transitionend',
|
|
281
|
+
WebkitTransition: 'webkitTransitionEnd'
|
|
282
|
+
};
|
|
283
|
+
for (t in transitions) {
|
|
284
|
+
if (el.style[t] !== undefined) {
|
|
285
|
+
return transitions[t];
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
function createIframe(config) {
|
|
290
|
+
var url = config.url,
|
|
291
|
+
allow = config.allow,
|
|
292
|
+
callback = config.callback,
|
|
293
|
+
appendTo = config.appendTo;
|
|
294
|
+
var iframe = document.createElement('iframe');
|
|
295
|
+
iframe.className = 'vimeo-video gvideo';
|
|
296
|
+
iframe.src = url;
|
|
297
|
+
iframe.style.width = '100%';
|
|
298
|
+
iframe.style.height = '100%';
|
|
299
|
+
if (allow) {
|
|
300
|
+
iframe.setAttribute('allow', allow);
|
|
301
|
+
}
|
|
302
|
+
iframe.onload = function () {
|
|
303
|
+
iframe.onload = null;
|
|
304
|
+
addClass(iframe, 'node-ready');
|
|
305
|
+
if (isFunction(callback)) {
|
|
306
|
+
callback();
|
|
307
|
+
}
|
|
308
|
+
};
|
|
309
|
+
if (appendTo) {
|
|
310
|
+
appendTo.appendChild(iframe);
|
|
311
|
+
}
|
|
312
|
+
return iframe;
|
|
313
|
+
}
|
|
314
|
+
function waitUntil(check, onComplete, delay, timeout) {
|
|
315
|
+
if (check()) {
|
|
316
|
+
onComplete();
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
if (!delay) {
|
|
320
|
+
delay = 100;
|
|
321
|
+
}
|
|
322
|
+
var timeoutPointer;
|
|
323
|
+
var intervalPointer = setInterval(function () {
|
|
324
|
+
if (!check()) {
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
clearInterval(intervalPointer);
|
|
328
|
+
if (timeoutPointer) {
|
|
329
|
+
clearTimeout(timeoutPointer);
|
|
330
|
+
}
|
|
331
|
+
onComplete();
|
|
332
|
+
}, delay);
|
|
333
|
+
if (timeout) {
|
|
334
|
+
timeoutPointer = setTimeout(function () {
|
|
335
|
+
clearInterval(intervalPointer);
|
|
336
|
+
}, timeout);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
function injectAssets(url, waitFor, callback) {
|
|
340
|
+
if (isNil(url)) {
|
|
341
|
+
console.error('Inject assets error');
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
if (isFunction(waitFor)) {
|
|
345
|
+
callback = waitFor;
|
|
346
|
+
waitFor = false;
|
|
347
|
+
}
|
|
348
|
+
if (isString(waitFor) && waitFor in window) {
|
|
349
|
+
if (isFunction(callback)) {
|
|
350
|
+
callback();
|
|
351
|
+
}
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
var found;
|
|
355
|
+
if (url.indexOf('.css') !== -1) {
|
|
356
|
+
found = document.querySelectorAll('link[href="' + url + '"]');
|
|
357
|
+
if (found && found.length > 0) {
|
|
358
|
+
if (isFunction(callback)) {
|
|
359
|
+
callback();
|
|
360
|
+
}
|
|
361
|
+
return;
|
|
362
|
+
}
|
|
363
|
+
var head = document.getElementsByTagName('head')[0];
|
|
364
|
+
var headStyles = head.querySelectorAll('link[rel="stylesheet"]');
|
|
365
|
+
var link = document.createElement('link');
|
|
366
|
+
link.rel = 'stylesheet';
|
|
367
|
+
link.type = 'text/css';
|
|
368
|
+
link.href = url;
|
|
369
|
+
link.media = 'all';
|
|
370
|
+
if (headStyles) {
|
|
371
|
+
head.insertBefore(link, headStyles[0]);
|
|
372
|
+
} else {
|
|
373
|
+
head.appendChild(link);
|
|
374
|
+
}
|
|
375
|
+
if (isFunction(callback)) {
|
|
376
|
+
callback();
|
|
377
|
+
}
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
found = document.querySelectorAll('script[src="' + url + '"]');
|
|
381
|
+
if (found && found.length > 0) {
|
|
382
|
+
if (isFunction(callback)) {
|
|
383
|
+
if (isString(waitFor)) {
|
|
384
|
+
waitUntil(function () {
|
|
385
|
+
return typeof window[waitFor] !== 'undefined';
|
|
386
|
+
}, function () {
|
|
387
|
+
callback();
|
|
388
|
+
});
|
|
389
|
+
return false;
|
|
390
|
+
}
|
|
391
|
+
callback();
|
|
392
|
+
}
|
|
393
|
+
return;
|
|
394
|
+
}
|
|
395
|
+
var script = document.createElement('script');
|
|
396
|
+
script.type = 'text/javascript';
|
|
397
|
+
script.src = url;
|
|
398
|
+
script.onload = function () {
|
|
399
|
+
if (isFunction(callback)) {
|
|
400
|
+
if (isString(waitFor)) {
|
|
401
|
+
waitUntil(function () {
|
|
402
|
+
return typeof window[waitFor] !== 'undefined';
|
|
403
|
+
}, function () {
|
|
404
|
+
callback();
|
|
405
|
+
});
|
|
406
|
+
return false;
|
|
407
|
+
}
|
|
408
|
+
callback();
|
|
409
|
+
}
|
|
410
|
+
};
|
|
411
|
+
document.body.appendChild(script);
|
|
412
|
+
}
|
|
413
|
+
function isMobile() {
|
|
414
|
+
return 'navigator' in window && window.navigator.userAgent.match(/(iPad)|(iPhone)|(iPod)|(Android)|(PlayBook)|(BB10)|(BlackBerry)|(Opera Mini)|(IEMobile)|(webOS)|(MeeGo)/i);
|
|
415
|
+
}
|
|
416
|
+
function isTouch() {
|
|
417
|
+
return isMobile() !== null || document.createTouch !== undefined || 'ontouchstart' in window || 'onmsgesturechange' in window || navigator.msMaxTouchPoints;
|
|
418
|
+
}
|
|
419
|
+
function isFunction(f) {
|
|
420
|
+
return typeof f === 'function';
|
|
421
|
+
}
|
|
422
|
+
function isString(s) {
|
|
423
|
+
return typeof s === 'string';
|
|
424
|
+
}
|
|
425
|
+
function isNode(el) {
|
|
426
|
+
return !!(el && el.nodeType && el.nodeType == 1);
|
|
427
|
+
}
|
|
428
|
+
function isArray(ar) {
|
|
429
|
+
return Array.isArray(ar);
|
|
430
|
+
}
|
|
431
|
+
function isArrayLike(ar) {
|
|
432
|
+
return ar && ar.length && isFinite(ar.length);
|
|
433
|
+
}
|
|
434
|
+
function isObject(o) {
|
|
435
|
+
var type = _typeof(o);
|
|
436
|
+
return type === 'object' && o != null && !isFunction(o) && !isArray(o);
|
|
437
|
+
}
|
|
438
|
+
function isNil(o) {
|
|
439
|
+
return o == null;
|
|
440
|
+
}
|
|
441
|
+
function has(obj, key) {
|
|
442
|
+
return obj !== null && hasOwnProperty.call(obj, key);
|
|
443
|
+
}
|
|
444
|
+
function size(o) {
|
|
445
|
+
if (isObject(o)) {
|
|
446
|
+
if (o.keys) {
|
|
447
|
+
return o.keys().length;
|
|
448
|
+
}
|
|
449
|
+
var l = 0;
|
|
450
|
+
for (var k in o) {
|
|
451
|
+
if (has(o, k)) {
|
|
452
|
+
l++;
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
return l;
|
|
456
|
+
} else {
|
|
457
|
+
return o.length;
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
function isNumber(n) {
|
|
461
|
+
return !isNaN(parseFloat(n)) && isFinite(n);
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
function getNextFocusElement() {
|
|
465
|
+
var current = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : -1;
|
|
466
|
+
var btns = document.querySelectorAll('.gbtn[data-taborder]:not(.disabled)');
|
|
467
|
+
if (!btns.length) {
|
|
468
|
+
return false;
|
|
469
|
+
}
|
|
470
|
+
if (btns.length == 1) {
|
|
471
|
+
return btns[0];
|
|
472
|
+
}
|
|
473
|
+
if (typeof current == 'string') {
|
|
474
|
+
current = parseInt(current);
|
|
475
|
+
}
|
|
476
|
+
var orders = [];
|
|
477
|
+
each(btns, function (btn) {
|
|
478
|
+
orders.push(btn.getAttribute('data-taborder'));
|
|
479
|
+
});
|
|
480
|
+
var highestOrder = Math.max.apply(Math, orders.map(function (order) {
|
|
481
|
+
return parseInt(order);
|
|
482
|
+
}));
|
|
483
|
+
var newIndex = current < 0 ? 1 : current + 1;
|
|
484
|
+
if (newIndex > highestOrder) {
|
|
485
|
+
newIndex = '1';
|
|
486
|
+
}
|
|
487
|
+
var nextOrders = orders.filter(function (el) {
|
|
488
|
+
return el >= parseInt(newIndex);
|
|
489
|
+
});
|
|
490
|
+
var nextFocus = nextOrders.sort()[0];
|
|
491
|
+
return document.querySelector(".gbtn[data-taborder=\"".concat(nextFocus, "\"]"));
|
|
492
|
+
}
|
|
493
|
+
function keyboardNavigation(instance) {
|
|
494
|
+
if (instance.events.hasOwnProperty('keyboard')) {
|
|
495
|
+
return false;
|
|
496
|
+
}
|
|
497
|
+
instance.events['keyboard'] = addEvent('keydown', {
|
|
498
|
+
onElement: window,
|
|
499
|
+
withCallback: function withCallback(event, target) {
|
|
500
|
+
event = event || window.event;
|
|
501
|
+
var key = event.keyCode;
|
|
502
|
+
if (key == 9) {
|
|
503
|
+
var focusedButton = document.querySelector('.gbtn.focused');
|
|
504
|
+
if (!focusedButton) {
|
|
505
|
+
var activeElement = document.activeElement && document.activeElement.nodeName ? document.activeElement.nodeName.toLocaleLowerCase() : false;
|
|
506
|
+
if (activeElement == 'input' || activeElement == 'textarea' || activeElement == 'button') {
|
|
507
|
+
return;
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
event.preventDefault();
|
|
511
|
+
var btns = document.querySelectorAll('.gbtn[data-taborder]');
|
|
512
|
+
if (!btns || btns.length <= 0) {
|
|
513
|
+
return;
|
|
514
|
+
}
|
|
515
|
+
if (!focusedButton) {
|
|
516
|
+
var first = getNextFocusElement();
|
|
517
|
+
if (first) {
|
|
518
|
+
first.focus();
|
|
519
|
+
addClass(first, 'focused');
|
|
520
|
+
}
|
|
521
|
+
return;
|
|
522
|
+
}
|
|
523
|
+
var currentFocusOrder = focusedButton.getAttribute('data-taborder');
|
|
524
|
+
var nextFocus = getNextFocusElement(currentFocusOrder);
|
|
525
|
+
removeClass(focusedButton, 'focused');
|
|
526
|
+
if (nextFocus) {
|
|
527
|
+
nextFocus.focus();
|
|
528
|
+
addClass(nextFocus, 'focused');
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
if (key == 39) {
|
|
532
|
+
instance.nextSlide();
|
|
533
|
+
}
|
|
534
|
+
if (key == 37) {
|
|
535
|
+
instance.prevSlide();
|
|
536
|
+
}
|
|
537
|
+
if (key == 27) {
|
|
538
|
+
instance.close();
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
});
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
var ZoomImages = function () {
|
|
545
|
+
function ZoomImages(el, slide) {
|
|
546
|
+
var _this = this;
|
|
547
|
+
var onclose = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
548
|
+
_classCallCheck(this, ZoomImages);
|
|
549
|
+
this.img = el;
|
|
550
|
+
this.slide = slide;
|
|
551
|
+
this.onclose = onclose;
|
|
552
|
+
if (this.img.setZoomEvents) {
|
|
553
|
+
return false;
|
|
554
|
+
}
|
|
555
|
+
this.active = false;
|
|
556
|
+
this.zoomedIn = false;
|
|
557
|
+
this.dragging = false;
|
|
558
|
+
this.currentX = null;
|
|
559
|
+
this.currentY = null;
|
|
560
|
+
this.initialX = null;
|
|
561
|
+
this.initialY = null;
|
|
562
|
+
this.xOffset = 0;
|
|
563
|
+
this.yOffset = 0;
|
|
564
|
+
this.img.addEventListener('mousedown', function (e) {
|
|
565
|
+
return _this.dragStart(e);
|
|
566
|
+
}, false);
|
|
567
|
+
this.img.addEventListener('mouseup', function (e) {
|
|
568
|
+
return _this.dragEnd(e);
|
|
569
|
+
}, false);
|
|
570
|
+
this.img.addEventListener('mousemove', function (e) {
|
|
571
|
+
return _this.drag(e);
|
|
572
|
+
}, false);
|
|
573
|
+
this.img.addEventListener('click', function (e) {
|
|
574
|
+
if (_this.slide.classList.contains('dragging-nav')) {
|
|
575
|
+
_this.zoomOut();
|
|
576
|
+
return false;
|
|
577
|
+
}
|
|
578
|
+
if (!_this.zoomedIn) {
|
|
579
|
+
return _this.zoomIn();
|
|
580
|
+
}
|
|
581
|
+
if (_this.zoomedIn && !_this.dragging) {
|
|
582
|
+
_this.zoomOut();
|
|
583
|
+
}
|
|
584
|
+
}, false);
|
|
585
|
+
this.img.setZoomEvents = true;
|
|
586
|
+
}
|
|
587
|
+
return _createClass(ZoomImages, [{
|
|
588
|
+
key: "zoomIn",
|
|
589
|
+
value: function zoomIn() {
|
|
590
|
+
var winWidth = this.widowWidth();
|
|
591
|
+
if (this.zoomedIn || winWidth <= 768) {
|
|
592
|
+
return;
|
|
593
|
+
}
|
|
594
|
+
var img = this.img;
|
|
595
|
+
img.setAttribute('data-style', img.getAttribute('style'));
|
|
596
|
+
img.style.maxWidth = img.naturalWidth + 'px';
|
|
597
|
+
img.style.maxHeight = img.naturalHeight + 'px';
|
|
598
|
+
if (img.naturalWidth > winWidth) {
|
|
599
|
+
var centerX = winWidth / 2 - img.naturalWidth / 2;
|
|
600
|
+
this.setTranslate(this.img.parentNode, centerX, 0);
|
|
601
|
+
}
|
|
602
|
+
this.slide.classList.add('zoomed');
|
|
603
|
+
this.zoomedIn = true;
|
|
604
|
+
}
|
|
605
|
+
}, {
|
|
606
|
+
key: "zoomOut",
|
|
607
|
+
value: function zoomOut() {
|
|
608
|
+
this.img.parentNode.setAttribute('style', '');
|
|
609
|
+
this.img.setAttribute('style', this.img.getAttribute('data-style'));
|
|
610
|
+
this.slide.classList.remove('zoomed');
|
|
611
|
+
this.zoomedIn = false;
|
|
612
|
+
this.currentX = null;
|
|
613
|
+
this.currentY = null;
|
|
614
|
+
this.initialX = null;
|
|
615
|
+
this.initialY = null;
|
|
616
|
+
this.xOffset = 0;
|
|
617
|
+
this.yOffset = 0;
|
|
618
|
+
if (this.onclose && typeof this.onclose == 'function') {
|
|
619
|
+
this.onclose();
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
}, {
|
|
623
|
+
key: "dragStart",
|
|
624
|
+
value: function dragStart(e) {
|
|
625
|
+
e.preventDefault();
|
|
626
|
+
if (!this.zoomedIn) {
|
|
627
|
+
this.active = false;
|
|
628
|
+
return;
|
|
629
|
+
}
|
|
630
|
+
if (e.type === 'touchstart') {
|
|
631
|
+
this.initialX = e.touches[0].clientX - this.xOffset;
|
|
632
|
+
this.initialY = e.touches[0].clientY - this.yOffset;
|
|
633
|
+
} else {
|
|
634
|
+
this.initialX = e.clientX - this.xOffset;
|
|
635
|
+
this.initialY = e.clientY - this.yOffset;
|
|
636
|
+
}
|
|
637
|
+
if (e.target === this.img) {
|
|
638
|
+
this.active = true;
|
|
639
|
+
this.img.classList.add('dragging');
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
}, {
|
|
643
|
+
key: "dragEnd",
|
|
644
|
+
value: function dragEnd(e) {
|
|
645
|
+
var _this2 = this;
|
|
646
|
+
e.preventDefault();
|
|
647
|
+
this.initialX = this.currentX;
|
|
648
|
+
this.initialY = this.currentY;
|
|
649
|
+
this.active = false;
|
|
650
|
+
setTimeout(function () {
|
|
651
|
+
_this2.dragging = false;
|
|
652
|
+
_this2.img.isDragging = false;
|
|
653
|
+
_this2.img.classList.remove('dragging');
|
|
654
|
+
}, 100);
|
|
655
|
+
}
|
|
656
|
+
}, {
|
|
657
|
+
key: "drag",
|
|
658
|
+
value: function drag(e) {
|
|
659
|
+
if (this.active) {
|
|
660
|
+
e.preventDefault();
|
|
661
|
+
if (e.type === 'touchmove') {
|
|
662
|
+
this.currentX = e.touches[0].clientX - this.initialX;
|
|
663
|
+
this.currentY = e.touches[0].clientY - this.initialY;
|
|
664
|
+
} else {
|
|
665
|
+
this.currentX = e.clientX - this.initialX;
|
|
666
|
+
this.currentY = e.clientY - this.initialY;
|
|
667
|
+
}
|
|
668
|
+
this.xOffset = this.currentX;
|
|
669
|
+
this.yOffset = this.currentY;
|
|
670
|
+
this.img.isDragging = true;
|
|
671
|
+
this.dragging = true;
|
|
672
|
+
this.setTranslate(this.img, this.currentX, this.currentY);
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
}, {
|
|
676
|
+
key: "onMove",
|
|
677
|
+
value: function onMove(e) {
|
|
678
|
+
if (!this.zoomedIn) {
|
|
679
|
+
return;
|
|
680
|
+
}
|
|
681
|
+
var xOffset = e.clientX - this.img.naturalWidth / 2;
|
|
682
|
+
var yOffset = e.clientY - this.img.naturalHeight / 2;
|
|
683
|
+
this.setTranslate(this.img, xOffset, yOffset);
|
|
684
|
+
}
|
|
685
|
+
}, {
|
|
686
|
+
key: "setTranslate",
|
|
687
|
+
value: function setTranslate(node, xPos, yPos) {
|
|
688
|
+
node.style.transform = 'translate3d(' + xPos + 'px, ' + yPos + 'px, 0)';
|
|
689
|
+
}
|
|
690
|
+
}, {
|
|
691
|
+
key: "widowWidth",
|
|
692
|
+
value: function widowWidth() {
|
|
693
|
+
return window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
|
|
694
|
+
}
|
|
695
|
+
}]);
|
|
696
|
+
}();
|
|
697
|
+
|
|
698
|
+
var DragSlides = function () {
|
|
699
|
+
function DragSlides() {
|
|
700
|
+
var _this = this;
|
|
701
|
+
var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
702
|
+
_classCallCheck(this, DragSlides);
|
|
703
|
+
var dragEl = config.dragEl,
|
|
704
|
+
_config$toleranceX = config.toleranceX,
|
|
705
|
+
toleranceX = _config$toleranceX === void 0 ? 40 : _config$toleranceX,
|
|
706
|
+
_config$toleranceY = config.toleranceY,
|
|
707
|
+
toleranceY = _config$toleranceY === void 0 ? 65 : _config$toleranceY,
|
|
708
|
+
_config$slide = config.slide,
|
|
709
|
+
slide = _config$slide === void 0 ? null : _config$slide,
|
|
710
|
+
_config$instance = config.instance,
|
|
711
|
+
instance = _config$instance === void 0 ? null : _config$instance;
|
|
712
|
+
this.el = dragEl;
|
|
713
|
+
this.active = false;
|
|
714
|
+
this.dragging = false;
|
|
715
|
+
this.currentX = null;
|
|
716
|
+
this.currentY = null;
|
|
717
|
+
this.initialX = null;
|
|
718
|
+
this.initialY = null;
|
|
719
|
+
this.xOffset = 0;
|
|
720
|
+
this.yOffset = 0;
|
|
721
|
+
this.direction = null;
|
|
722
|
+
this.lastDirection = null;
|
|
723
|
+
this.toleranceX = toleranceX;
|
|
724
|
+
this.toleranceY = toleranceY;
|
|
725
|
+
this.toleranceReached = false;
|
|
726
|
+
this.dragContainer = this.el;
|
|
727
|
+
this.slide = slide;
|
|
728
|
+
this.instance = instance;
|
|
729
|
+
this.el.addEventListener('mousedown', function (e) {
|
|
730
|
+
return _this.dragStart(e);
|
|
731
|
+
}, false);
|
|
732
|
+
this.el.addEventListener('mouseup', function (e) {
|
|
733
|
+
return _this.dragEnd(e);
|
|
734
|
+
}, false);
|
|
735
|
+
this.el.addEventListener('mousemove', function (e) {
|
|
736
|
+
return _this.drag(e);
|
|
737
|
+
}, false);
|
|
738
|
+
}
|
|
739
|
+
return _createClass(DragSlides, [{
|
|
740
|
+
key: "dragStart",
|
|
741
|
+
value: function dragStart(e) {
|
|
742
|
+
if (this.slide.classList.contains('zoomed')) {
|
|
743
|
+
this.active = false;
|
|
744
|
+
return;
|
|
745
|
+
}
|
|
746
|
+
if (e.type === 'touchstart') {
|
|
747
|
+
this.initialX = e.touches[0].clientX - this.xOffset;
|
|
748
|
+
this.initialY = e.touches[0].clientY - this.yOffset;
|
|
749
|
+
} else {
|
|
750
|
+
this.initialX = e.clientX - this.xOffset;
|
|
751
|
+
this.initialY = e.clientY - this.yOffset;
|
|
752
|
+
}
|
|
753
|
+
var clicked = e.target.nodeName.toLowerCase();
|
|
754
|
+
var exludeClicks = ['input', 'select', 'textarea', 'button', 'a'];
|
|
755
|
+
if (e.target.classList.contains('nodrag') || closest(e.target, '.nodrag') || exludeClicks.indexOf(clicked) !== -1) {
|
|
756
|
+
this.active = false;
|
|
757
|
+
return;
|
|
758
|
+
}
|
|
759
|
+
e.preventDefault();
|
|
760
|
+
if (e.target === this.el || clicked !== 'img' && closest(e.target, '.gslide-inline')) {
|
|
761
|
+
this.active = true;
|
|
762
|
+
this.el.classList.add('dragging');
|
|
763
|
+
this.dragContainer = closest(e.target, '.ginner-container');
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
}, {
|
|
767
|
+
key: "dragEnd",
|
|
768
|
+
value: function dragEnd(e) {
|
|
769
|
+
var _this2 = this;
|
|
770
|
+
e && e.preventDefault();
|
|
771
|
+
this.initialX = 0;
|
|
772
|
+
this.initialY = 0;
|
|
773
|
+
this.currentX = null;
|
|
774
|
+
this.currentY = null;
|
|
775
|
+
this.initialX = null;
|
|
776
|
+
this.initialY = null;
|
|
777
|
+
this.xOffset = 0;
|
|
778
|
+
this.yOffset = 0;
|
|
779
|
+
this.active = false;
|
|
780
|
+
if (this.doSlideChange) {
|
|
781
|
+
this.instance.preventOutsideClick = true;
|
|
782
|
+
this.doSlideChange == 'right' && this.instance.prevSlide();
|
|
783
|
+
this.doSlideChange == 'left' && this.instance.nextSlide();
|
|
784
|
+
}
|
|
785
|
+
if (this.doSlideClose) {
|
|
786
|
+
this.instance.close();
|
|
787
|
+
}
|
|
788
|
+
if (!this.toleranceReached) {
|
|
789
|
+
this.setTranslate(this.dragContainer, 0, 0, true);
|
|
790
|
+
}
|
|
791
|
+
setTimeout(function () {
|
|
792
|
+
_this2.instance.preventOutsideClick = false;
|
|
793
|
+
_this2.toleranceReached = false;
|
|
794
|
+
_this2.lastDirection = null;
|
|
795
|
+
_this2.dragging = false;
|
|
796
|
+
_this2.el.isDragging = false;
|
|
797
|
+
_this2.el.classList.remove('dragging');
|
|
798
|
+
_this2.slide.classList.remove('dragging-nav');
|
|
799
|
+
_this2.dragContainer.style.transform = '';
|
|
800
|
+
_this2.dragContainer.style.transition = '';
|
|
801
|
+
}, 100);
|
|
802
|
+
}
|
|
803
|
+
}, {
|
|
804
|
+
key: "drag",
|
|
805
|
+
value: function drag(e) {
|
|
806
|
+
if (this.active) {
|
|
807
|
+
e.preventDefault();
|
|
808
|
+
this.slide.classList.add('dragging-nav');
|
|
809
|
+
if (e.type === 'touchmove') {
|
|
810
|
+
this.currentX = e.touches[0].clientX - this.initialX;
|
|
811
|
+
this.currentY = e.touches[0].clientY - this.initialY;
|
|
812
|
+
} else {
|
|
813
|
+
this.currentX = e.clientX - this.initialX;
|
|
814
|
+
this.currentY = e.clientY - this.initialY;
|
|
815
|
+
}
|
|
816
|
+
this.xOffset = this.currentX;
|
|
817
|
+
this.yOffset = this.currentY;
|
|
818
|
+
this.el.isDragging = true;
|
|
819
|
+
this.dragging = true;
|
|
820
|
+
this.doSlideChange = false;
|
|
821
|
+
this.doSlideClose = false;
|
|
822
|
+
var currentXInt = Math.abs(this.currentX);
|
|
823
|
+
var currentYInt = Math.abs(this.currentY);
|
|
824
|
+
if (currentXInt > 0 && currentXInt >= Math.abs(this.currentY) && (!this.lastDirection || this.lastDirection == 'x')) {
|
|
825
|
+
this.yOffset = 0;
|
|
826
|
+
this.lastDirection = 'x';
|
|
827
|
+
this.setTranslate(this.dragContainer, this.currentX, 0);
|
|
828
|
+
var doChange = this.shouldChange();
|
|
829
|
+
if (!this.instance.settings.dragAutoSnap && doChange) {
|
|
830
|
+
this.doSlideChange = doChange;
|
|
831
|
+
}
|
|
832
|
+
if (this.instance.settings.dragAutoSnap && doChange) {
|
|
833
|
+
this.instance.preventOutsideClick = true;
|
|
834
|
+
this.toleranceReached = true;
|
|
835
|
+
this.active = false;
|
|
836
|
+
this.instance.preventOutsideClick = true;
|
|
837
|
+
this.dragEnd(null);
|
|
838
|
+
doChange == 'right' && this.instance.prevSlide();
|
|
839
|
+
doChange == 'left' && this.instance.nextSlide();
|
|
840
|
+
return;
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
if (this.toleranceY > 0 && currentYInt > 0 && currentYInt >= currentXInt && (!this.lastDirection || this.lastDirection == 'y')) {
|
|
844
|
+
this.xOffset = 0;
|
|
845
|
+
this.lastDirection = 'y';
|
|
846
|
+
this.setTranslate(this.dragContainer, 0, this.currentY);
|
|
847
|
+
var doClose = this.shouldClose();
|
|
848
|
+
if (!this.instance.settings.dragAutoSnap && doClose) {
|
|
849
|
+
this.doSlideClose = true;
|
|
850
|
+
}
|
|
851
|
+
if (this.instance.settings.dragAutoSnap && doClose) {
|
|
852
|
+
this.instance.close();
|
|
853
|
+
}
|
|
854
|
+
return;
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
}, {
|
|
859
|
+
key: "shouldChange",
|
|
860
|
+
value: function shouldChange() {
|
|
861
|
+
var doChange = false;
|
|
862
|
+
var currentXInt = Math.abs(this.currentX);
|
|
863
|
+
if (currentXInt >= this.toleranceX) {
|
|
864
|
+
var dragDir = this.currentX > 0 ? 'right' : 'left';
|
|
865
|
+
if (dragDir == 'left' && this.slide !== this.slide.parentNode.lastChild || dragDir == 'right' && this.slide !== this.slide.parentNode.firstChild) {
|
|
866
|
+
doChange = dragDir;
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
return doChange;
|
|
870
|
+
}
|
|
871
|
+
}, {
|
|
872
|
+
key: "shouldClose",
|
|
873
|
+
value: function shouldClose() {
|
|
874
|
+
var doClose = false;
|
|
875
|
+
var currentYInt = Math.abs(this.currentY);
|
|
876
|
+
if (currentYInt >= this.toleranceY) {
|
|
877
|
+
doClose = true;
|
|
878
|
+
}
|
|
879
|
+
return doClose;
|
|
880
|
+
}
|
|
881
|
+
}, {
|
|
882
|
+
key: "setTranslate",
|
|
883
|
+
value: function setTranslate(node, xPos, yPos) {
|
|
884
|
+
var animated = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
885
|
+
if (animated) {
|
|
886
|
+
node.style.transition = 'all .2s ease';
|
|
887
|
+
} else {
|
|
888
|
+
node.style.transition = '';
|
|
889
|
+
}
|
|
890
|
+
node.style.transform = "translate3d(".concat(xPos, "px, ").concat(yPos, "px, 0)");
|
|
891
|
+
}
|
|
892
|
+
}]);
|
|
893
|
+
}();
|
|
894
|
+
|
|
895
|
+
function slideImage(slide, data, index, callback) {
|
|
896
|
+
var slideMedia = slide.querySelector('.gslide-media');
|
|
897
|
+
var img = new Image();
|
|
898
|
+
var titleID = 'gSlideTitle_' + index;
|
|
899
|
+
var textID = 'gSlideDesc_' + index;
|
|
900
|
+
img.addEventListener('load', function () {
|
|
901
|
+
if (isFunction(callback)) {
|
|
902
|
+
callback();
|
|
903
|
+
}
|
|
904
|
+
}, false);
|
|
905
|
+
img.src = data.href;
|
|
906
|
+
if (data.sizes != '' && data.srcset != '') {
|
|
907
|
+
img.sizes = data.sizes;
|
|
908
|
+
img.srcset = data.srcset;
|
|
909
|
+
}
|
|
910
|
+
img.alt = '';
|
|
911
|
+
if (!isNil(data.alt) && data.alt !== '') {
|
|
912
|
+
img.alt = data.alt;
|
|
913
|
+
}
|
|
914
|
+
if (data.title !== '') {
|
|
915
|
+
img.setAttribute('aria-labelledby', titleID);
|
|
916
|
+
}
|
|
917
|
+
if (data.description !== '') {
|
|
918
|
+
img.setAttribute('aria-describedby', textID);
|
|
919
|
+
}
|
|
920
|
+
if (data.hasOwnProperty('_hasCustomWidth') && data._hasCustomWidth) {
|
|
921
|
+
img.style.width = data.width;
|
|
922
|
+
}
|
|
923
|
+
if (data.hasOwnProperty('_hasCustomHeight') && data._hasCustomHeight) {
|
|
924
|
+
img.style.height = data.height;
|
|
925
|
+
}
|
|
926
|
+
slideMedia.insertBefore(img, slideMedia.firstChild);
|
|
927
|
+
return;
|
|
928
|
+
}
|
|
929
|
+
|
|
930
|
+
function slideVideo(slide, data, index, callback) {
|
|
931
|
+
var _this = this;
|
|
932
|
+
var slideContainer = slide.querySelector('.ginner-container');
|
|
933
|
+
var videoID = 'gvideo' + index;
|
|
934
|
+
var slideMedia = slide.querySelector('.gslide-media');
|
|
935
|
+
var videoPlayers = this.getAllPlayers();
|
|
936
|
+
addClass(slideContainer, 'gvideo-container');
|
|
937
|
+
slideMedia.insertBefore(createHTML('<div class="gvideo-wrapper"></div>'), slideMedia.firstChild);
|
|
938
|
+
var videoWrapper = slide.querySelector('.gvideo-wrapper');
|
|
939
|
+
injectAssets(this.settings.plyr.css, 'Plyr');
|
|
940
|
+
var url = data.href;
|
|
941
|
+
var provider = data === null || data === void 0 ? void 0 : data.videoProvider;
|
|
942
|
+
var customPlaceholder = false;
|
|
943
|
+
slideMedia.style.maxWidth = data.width;
|
|
944
|
+
injectAssets(this.settings.plyr.js, 'Plyr', function () {
|
|
945
|
+
if (!provider && url.match(/vimeo\.com\/([0-9]*)/)) {
|
|
946
|
+
provider = 'vimeo';
|
|
947
|
+
}
|
|
948
|
+
if (!provider && (url.match(/(youtube\.com|youtube-nocookie\.com)\/watch\?v=([a-zA-Z0-9\-_]+)/) || url.match(/youtu\.be\/([a-zA-Z0-9\-_]+)/) || url.match(/(youtube\.com|youtube-nocookie\.com)\/embed\/([a-zA-Z0-9\-_]+)/) || url.match(/(youtube\.com|youtube-nocookie\.com)\/shorts\/([a-zA-Z0-9\-_]+)/))) {
|
|
949
|
+
provider = 'youtube';
|
|
950
|
+
}
|
|
951
|
+
if (provider === 'local' || !provider) {
|
|
952
|
+
provider = 'local';
|
|
953
|
+
var html = '<video id="' + videoID + '" ';
|
|
954
|
+
html += "style=\"background:#000; max-width: ".concat(data.width, ";\" ");
|
|
955
|
+
html += 'preload="metadata" ';
|
|
956
|
+
html += 'x-webkit-airplay="allow" ';
|
|
957
|
+
html += 'playsinline ';
|
|
958
|
+
html += 'controls ';
|
|
959
|
+
html += 'class="gvideo-local">';
|
|
960
|
+
html += "<source src=\"".concat(url, "\">");
|
|
961
|
+
html += '</video>';
|
|
962
|
+
customPlaceholder = createHTML(html);
|
|
963
|
+
}
|
|
964
|
+
var placeholder = customPlaceholder ? customPlaceholder : createHTML("<div id=\"".concat(videoID, "\" data-plyr-provider=\"").concat(provider, "\" data-plyr-embed-id=\"").concat(url, "\"></div>"));
|
|
965
|
+
addClass(videoWrapper, "".concat(provider, "-video gvideo"));
|
|
966
|
+
videoWrapper.appendChild(placeholder);
|
|
967
|
+
videoWrapper.setAttribute('data-id', videoID);
|
|
968
|
+
videoWrapper.setAttribute('data-index', index);
|
|
969
|
+
var playerConfig = has(_this.settings.plyr, 'config') ? _this.settings.plyr.config : {};
|
|
970
|
+
var player = new Plyr('#' + videoID, playerConfig);
|
|
971
|
+
player.on('ready', function (event) {
|
|
972
|
+
videoPlayers[videoID] = event.detail.plyr;
|
|
973
|
+
if (isFunction(callback)) {
|
|
974
|
+
callback();
|
|
975
|
+
}
|
|
976
|
+
});
|
|
977
|
+
waitUntil(function () {
|
|
978
|
+
return slide.querySelector('iframe') && slide.querySelector('iframe').dataset.ready == 'true';
|
|
979
|
+
}, function () {
|
|
980
|
+
_this.resize(slide);
|
|
981
|
+
});
|
|
982
|
+
player.on('enterfullscreen', handleMediaFullScreen);
|
|
983
|
+
player.on('exitfullscreen', handleMediaFullScreen);
|
|
984
|
+
});
|
|
985
|
+
}
|
|
986
|
+
function handleMediaFullScreen(event) {
|
|
987
|
+
var media = closest(event.target, '.gslide-media');
|
|
988
|
+
if (event.type === 'enterfullscreen') {
|
|
989
|
+
addClass(media, 'fullscreen');
|
|
990
|
+
}
|
|
991
|
+
if (event.type === 'exitfullscreen') {
|
|
992
|
+
removeClass(media, 'fullscreen');
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
function slideInline(slide, data, index, callback) {
|
|
997
|
+
var _this = this;
|
|
998
|
+
var slideMedia = slide.querySelector('.gslide-media');
|
|
999
|
+
var hash = has(data, 'href') && data.href ? data.href.split('#').pop().trim() : false;
|
|
1000
|
+
var content = has(data, 'content') && data.content ? data.content : false;
|
|
1001
|
+
var innerContent;
|
|
1002
|
+
if (content) {
|
|
1003
|
+
if (isString(content)) {
|
|
1004
|
+
innerContent = createHTML("<div class=\"ginlined-content\">".concat(content, "</div>"));
|
|
1005
|
+
}
|
|
1006
|
+
if (isNode(content)) {
|
|
1007
|
+
if (content.style.display == 'none') {
|
|
1008
|
+
content.style.display = 'block';
|
|
1009
|
+
}
|
|
1010
|
+
var container = document.createElement('div');
|
|
1011
|
+
container.className = 'ginlined-content';
|
|
1012
|
+
container.appendChild(content);
|
|
1013
|
+
innerContent = container;
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
if (hash) {
|
|
1017
|
+
var div = document.getElementById(hash);
|
|
1018
|
+
if (!div) {
|
|
1019
|
+
return false;
|
|
1020
|
+
}
|
|
1021
|
+
var cloned = div.cloneNode(true);
|
|
1022
|
+
cloned.style.height = data.height;
|
|
1023
|
+
cloned.style.maxWidth = data.width;
|
|
1024
|
+
addClass(cloned, 'ginlined-content');
|
|
1025
|
+
innerContent = cloned;
|
|
1026
|
+
}
|
|
1027
|
+
if (!innerContent) {
|
|
1028
|
+
console.error('Unable to append inline slide content', data);
|
|
1029
|
+
return false;
|
|
1030
|
+
}
|
|
1031
|
+
slideMedia.style.height = data.height;
|
|
1032
|
+
slideMedia.style.width = data.width;
|
|
1033
|
+
slideMedia.appendChild(innerContent);
|
|
1034
|
+
this.events['inlineclose' + hash] = addEvent('click', {
|
|
1035
|
+
onElement: slideMedia.querySelectorAll('.gtrigger-close'),
|
|
1036
|
+
withCallback: function withCallback(e) {
|
|
1037
|
+
e.preventDefault();
|
|
1038
|
+
_this.close();
|
|
1039
|
+
}
|
|
1040
|
+
});
|
|
1041
|
+
if (isFunction(callback)) {
|
|
1042
|
+
callback();
|
|
1043
|
+
}
|
|
1044
|
+
return;
|
|
1045
|
+
}
|
|
1046
|
+
|
|
1047
|
+
function slideIframe(slide, data, index, callback) {
|
|
1048
|
+
var slideMedia = slide.querySelector('.gslide-media');
|
|
1049
|
+
var iframe = createIframe({
|
|
1050
|
+
url: data.href,
|
|
1051
|
+
callback: callback
|
|
1052
|
+
});
|
|
1053
|
+
slideMedia.parentNode.style.maxWidth = data.width;
|
|
1054
|
+
slideMedia.parentNode.style.height = data.height;
|
|
1055
|
+
slideMedia.appendChild(iframe);
|
|
1056
|
+
return;
|
|
1057
|
+
}
|
|
1058
|
+
|
|
1059
|
+
var SlideConfigParser = function () {
|
|
1060
|
+
function SlideConfigParser() {
|
|
1061
|
+
var slideParamas = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1062
|
+
_classCallCheck(this, SlideConfigParser);
|
|
1063
|
+
this.defaults = {
|
|
1064
|
+
href: '',
|
|
1065
|
+
sizes: '',
|
|
1066
|
+
srcset: '',
|
|
1067
|
+
title: '',
|
|
1068
|
+
type: '',
|
|
1069
|
+
videoProvider: '',
|
|
1070
|
+
description: '',
|
|
1071
|
+
alt: '',
|
|
1072
|
+
descPosition: 'bottom',
|
|
1073
|
+
effect: '',
|
|
1074
|
+
width: '',
|
|
1075
|
+
height: '',
|
|
1076
|
+
content: false,
|
|
1077
|
+
zoomable: true,
|
|
1078
|
+
draggable: true
|
|
1079
|
+
};
|
|
1080
|
+
if (isObject(slideParamas)) {
|
|
1081
|
+
this.defaults = extend(this.defaults, slideParamas);
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
return _createClass(SlideConfigParser, [{
|
|
1085
|
+
key: "sourceType",
|
|
1086
|
+
value: function sourceType(url) {
|
|
1087
|
+
var origin = url;
|
|
1088
|
+
url = url.toLowerCase();
|
|
1089
|
+
if (url.match(/\.(jpeg|jpg|jpe|gif|png|apn|webp|avif|svg)/) !== null) {
|
|
1090
|
+
return 'image';
|
|
1091
|
+
}
|
|
1092
|
+
if (url.match(/(youtube\.com|youtube-nocookie\.com)\/watch\?v=([a-zA-Z0-9\-_]+)/) || url.match(/youtu\.be\/([a-zA-Z0-9\-_]+)/) || url.match(/(youtube\.com|youtube-nocookie\.com)\/embed\/([a-zA-Z0-9\-_]+)/) || url.match(/(youtube\.com|youtube-nocookie\.com)\/shorts\/([a-zA-Z0-9\-_]+)/)) {
|
|
1093
|
+
return 'video';
|
|
1094
|
+
}
|
|
1095
|
+
if (url.match(/vimeo\.com\/([0-9]*)/)) {
|
|
1096
|
+
return 'video';
|
|
1097
|
+
}
|
|
1098
|
+
if (url.match(/\.(mp4|ogg|webm|mov)/) !== null) {
|
|
1099
|
+
return 'video';
|
|
1100
|
+
}
|
|
1101
|
+
if (url.match(/\.(mp3|wav|wma|aac|ogg)/) !== null) {
|
|
1102
|
+
return 'audio';
|
|
1103
|
+
}
|
|
1104
|
+
if (url.indexOf('#') > -1) {
|
|
1105
|
+
var hash = origin.split('#').pop();
|
|
1106
|
+
if (hash.trim() !== '') {
|
|
1107
|
+
return 'inline';
|
|
1108
|
+
}
|
|
1109
|
+
}
|
|
1110
|
+
if (url.indexOf('goajax=true') > -1) {
|
|
1111
|
+
return 'ajax';
|
|
1112
|
+
}
|
|
1113
|
+
return 'external';
|
|
1114
|
+
}
|
|
1115
|
+
}, {
|
|
1116
|
+
key: "parseConfig",
|
|
1117
|
+
value: function parseConfig(element, settings) {
|
|
1118
|
+
var _this = this;
|
|
1119
|
+
var data = extend({
|
|
1120
|
+
descPosition: settings.descPosition
|
|
1121
|
+
}, this.defaults);
|
|
1122
|
+
if (isObject(element) && !isNode(element)) {
|
|
1123
|
+
if (!has(element, 'type')) {
|
|
1124
|
+
if (has(element, 'content') && element.content) {
|
|
1125
|
+
element.type = 'inline';
|
|
1126
|
+
} else if (has(element, 'href')) {
|
|
1127
|
+
element.type = this.sourceType(element.href);
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1130
|
+
var objectData = extend(data, element);
|
|
1131
|
+
this.setSize(objectData, settings);
|
|
1132
|
+
return objectData;
|
|
1133
|
+
}
|
|
1134
|
+
var url = '';
|
|
1135
|
+
var config = element.getAttribute('data-glightbox');
|
|
1136
|
+
var nodeType = element.nodeName.toLowerCase();
|
|
1137
|
+
if (nodeType === 'a') {
|
|
1138
|
+
url = element.href;
|
|
1139
|
+
}
|
|
1140
|
+
if (nodeType === 'img') {
|
|
1141
|
+
url = element.src;
|
|
1142
|
+
data.alt = element.alt;
|
|
1143
|
+
}
|
|
1144
|
+
data.href = url;
|
|
1145
|
+
each(data, function (val, key) {
|
|
1146
|
+
if (has(settings, key) && key !== 'width') {
|
|
1147
|
+
data[key] = settings[key];
|
|
1148
|
+
}
|
|
1149
|
+
var nodeData = element.dataset[key];
|
|
1150
|
+
if (!isNil(nodeData)) {
|
|
1151
|
+
data[key] = _this.sanitizeValue(nodeData);
|
|
1152
|
+
}
|
|
1153
|
+
});
|
|
1154
|
+
if (data.content) {
|
|
1155
|
+
data.type = 'inline';
|
|
1156
|
+
}
|
|
1157
|
+
if (!data.type && url) {
|
|
1158
|
+
data.type = this.sourceType(url);
|
|
1159
|
+
}
|
|
1160
|
+
if (!isNil(config)) {
|
|
1161
|
+
var cleanKeys = [];
|
|
1162
|
+
each(data, function (v, k) {
|
|
1163
|
+
cleanKeys.push(';\\s?' + k);
|
|
1164
|
+
});
|
|
1165
|
+
cleanKeys = cleanKeys.join('\\s?:|');
|
|
1166
|
+
if (config.trim() !== '') {
|
|
1167
|
+
each(data, function (val, key) {
|
|
1168
|
+
var str = config;
|
|
1169
|
+
var match = 's?' + key + 's?:s?(.*?)(' + cleanKeys + 's?:|$)';
|
|
1170
|
+
var regex = new RegExp(match);
|
|
1171
|
+
var matches = str.match(regex);
|
|
1172
|
+
if (matches && matches.length && matches[1]) {
|
|
1173
|
+
var value = matches[1].trim().replace(/;\s*$/, '');
|
|
1174
|
+
data[key] = _this.sanitizeValue(value);
|
|
1175
|
+
}
|
|
1176
|
+
});
|
|
1177
|
+
}
|
|
1178
|
+
} else {
|
|
1179
|
+
if (!data.title && nodeType == 'a') {
|
|
1180
|
+
var title = element.title;
|
|
1181
|
+
if (!isNil(title) && title !== '') {
|
|
1182
|
+
data.title = title;
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
if (!data.title && nodeType == 'img') {
|
|
1186
|
+
var alt = element.alt;
|
|
1187
|
+
if (!isNil(alt) && alt !== '') {
|
|
1188
|
+
data.title = alt;
|
|
1189
|
+
}
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1192
|
+
if (data.description && data.description.substring(0, 1) === '.') {
|
|
1193
|
+
var description;
|
|
1194
|
+
try {
|
|
1195
|
+
description = document.querySelector(data.description).innerHTML;
|
|
1196
|
+
} catch (error) {
|
|
1197
|
+
if (!(error instanceof DOMException)) {
|
|
1198
|
+
throw error;
|
|
1199
|
+
}
|
|
1200
|
+
}
|
|
1201
|
+
if (description) {
|
|
1202
|
+
data.description = description;
|
|
1203
|
+
}
|
|
1204
|
+
}
|
|
1205
|
+
if (!data.description) {
|
|
1206
|
+
var nodeDesc = element.querySelector('.glightbox-desc');
|
|
1207
|
+
if (nodeDesc) {
|
|
1208
|
+
data.description = nodeDesc.innerHTML;
|
|
1209
|
+
}
|
|
1210
|
+
}
|
|
1211
|
+
this.setSize(data, settings, element);
|
|
1212
|
+
this.slideConfig = data;
|
|
1213
|
+
return data;
|
|
1214
|
+
}
|
|
1215
|
+
}, {
|
|
1216
|
+
key: "setSize",
|
|
1217
|
+
value: function setSize(data, settings) {
|
|
1218
|
+
var element = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
1219
|
+
var defaultWith = data.type == 'video' ? this.checkSize(settings.videosWidth) : this.checkSize(settings.width);
|
|
1220
|
+
var defaultHeight = this.checkSize(settings.height);
|
|
1221
|
+
data.width = has(data, 'width') && data.width !== '' ? this.checkSize(data.width) : defaultWith;
|
|
1222
|
+
data.height = has(data, 'height') && data.height !== '' ? this.checkSize(data.height) : defaultHeight;
|
|
1223
|
+
if (element && data.type == 'image') {
|
|
1224
|
+
data._hasCustomWidth = element.dataset.width ? true : false;
|
|
1225
|
+
data._hasCustomHeight = element.dataset.height ? true : false;
|
|
1226
|
+
}
|
|
1227
|
+
return data;
|
|
1228
|
+
}
|
|
1229
|
+
}, {
|
|
1230
|
+
key: "checkSize",
|
|
1231
|
+
value: function checkSize(size) {
|
|
1232
|
+
return isNumber(size) ? "".concat(size, "px") : size;
|
|
1233
|
+
}
|
|
1234
|
+
}, {
|
|
1235
|
+
key: "sanitizeValue",
|
|
1236
|
+
value: function sanitizeValue(val) {
|
|
1237
|
+
if (val !== 'true' && val !== 'false') {
|
|
1238
|
+
return val;
|
|
1239
|
+
}
|
|
1240
|
+
return val === 'true';
|
|
1241
|
+
}
|
|
1242
|
+
}]);
|
|
1243
|
+
}();
|
|
1244
|
+
|
|
1245
|
+
var Slide = function () {
|
|
1246
|
+
function Slide(el, instance, index) {
|
|
1247
|
+
_classCallCheck(this, Slide);
|
|
1248
|
+
this.element = el;
|
|
1249
|
+
this.instance = instance;
|
|
1250
|
+
this.index = index;
|
|
1251
|
+
}
|
|
1252
|
+
return _createClass(Slide, [{
|
|
1253
|
+
key: "setContent",
|
|
1254
|
+
value: function setContent() {
|
|
1255
|
+
var _this = this;
|
|
1256
|
+
var slide = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
1257
|
+
var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
1258
|
+
if (hasClass(slide, 'loaded')) {
|
|
1259
|
+
return false;
|
|
1260
|
+
}
|
|
1261
|
+
var settings = this.instance.settings;
|
|
1262
|
+
var slideConfig = this.slideConfig;
|
|
1263
|
+
var isMobileDevice = isMobile();
|
|
1264
|
+
if (isFunction(settings.beforeSlideLoad)) {
|
|
1265
|
+
settings.beforeSlideLoad({
|
|
1266
|
+
index: this.index,
|
|
1267
|
+
slide: slide,
|
|
1268
|
+
player: false
|
|
1269
|
+
});
|
|
1270
|
+
}
|
|
1271
|
+
var type = slideConfig.type;
|
|
1272
|
+
var position = slideConfig.descPosition;
|
|
1273
|
+
var slideMedia = slide.querySelector('.gslide-media');
|
|
1274
|
+
var slideTitle = slide.querySelector('.gslide-title');
|
|
1275
|
+
var slideText = slide.querySelector('.gslide-desc');
|
|
1276
|
+
var slideDesc = slide.querySelector('.gdesc-inner');
|
|
1277
|
+
var finalCallback = callback;
|
|
1278
|
+
var titleID = 'gSlideTitle_' + this.index;
|
|
1279
|
+
var textID = 'gSlideDesc_' + this.index;
|
|
1280
|
+
if (isFunction(settings.afterSlideLoad)) {
|
|
1281
|
+
finalCallback = function finalCallback() {
|
|
1282
|
+
if (isFunction(callback)) {
|
|
1283
|
+
callback();
|
|
1284
|
+
}
|
|
1285
|
+
settings.afterSlideLoad({
|
|
1286
|
+
index: _this.index,
|
|
1287
|
+
slide: slide,
|
|
1288
|
+
player: _this.instance.getSlidePlayerInstance(_this.index)
|
|
1289
|
+
});
|
|
1290
|
+
};
|
|
1291
|
+
}
|
|
1292
|
+
if (slideConfig.title == '' && slideConfig.description == '') {
|
|
1293
|
+
if (slideDesc) {
|
|
1294
|
+
slideDesc.parentNode.parentNode.removeChild(slideDesc.parentNode);
|
|
1295
|
+
}
|
|
1296
|
+
} else {
|
|
1297
|
+
if (slideTitle && slideConfig.title !== '') {
|
|
1298
|
+
slideTitle.id = titleID;
|
|
1299
|
+
slideTitle.innerHTML = slideConfig.title;
|
|
1300
|
+
} else {
|
|
1301
|
+
slideTitle.parentNode.removeChild(slideTitle);
|
|
1302
|
+
}
|
|
1303
|
+
if (slideText && slideConfig.description !== '') {
|
|
1304
|
+
slideText.id = textID;
|
|
1305
|
+
if (isMobileDevice && settings.moreLength > 0) {
|
|
1306
|
+
slideConfig.smallDescription = this.slideShortDesc(slideConfig.description, settings.moreLength, settings.moreText);
|
|
1307
|
+
slideText.innerHTML = slideConfig.smallDescription;
|
|
1308
|
+
this.descriptionEvents(slideText, slideConfig);
|
|
1309
|
+
} else {
|
|
1310
|
+
slideText.innerHTML = slideConfig.description;
|
|
1311
|
+
}
|
|
1312
|
+
} else {
|
|
1313
|
+
slideText.parentNode.removeChild(slideText);
|
|
1314
|
+
}
|
|
1315
|
+
addClass(slideMedia.parentNode, "desc-".concat(position));
|
|
1316
|
+
addClass(slideDesc.parentNode, "description-".concat(position));
|
|
1317
|
+
}
|
|
1318
|
+
addClass(slideMedia, "gslide-".concat(type));
|
|
1319
|
+
addClass(slide, 'loaded');
|
|
1320
|
+
if (type === 'video') {
|
|
1321
|
+
slideVideo.apply(this.instance, [slide, slideConfig, this.index, finalCallback]);
|
|
1322
|
+
return;
|
|
1323
|
+
}
|
|
1324
|
+
if (type === 'external') {
|
|
1325
|
+
slideIframe.apply(this, [slide, slideConfig, this.index, finalCallback]);
|
|
1326
|
+
return;
|
|
1327
|
+
}
|
|
1328
|
+
if (type === 'inline') {
|
|
1329
|
+
slideInline.apply(this.instance, [slide, slideConfig, this.index, finalCallback]);
|
|
1330
|
+
if (slideConfig.draggable) {
|
|
1331
|
+
new DragSlides({
|
|
1332
|
+
dragEl: slide.querySelector('.gslide-inline'),
|
|
1333
|
+
toleranceX: settings.dragToleranceX,
|
|
1334
|
+
toleranceY: settings.dragToleranceY,
|
|
1335
|
+
slide: slide,
|
|
1336
|
+
instance: this.instance
|
|
1337
|
+
});
|
|
1338
|
+
}
|
|
1339
|
+
return;
|
|
1340
|
+
}
|
|
1341
|
+
if (type === 'image') {
|
|
1342
|
+
slideImage(slide, slideConfig, this.index, function () {
|
|
1343
|
+
var img = slide.querySelector('img');
|
|
1344
|
+
if (slideConfig.draggable) {
|
|
1345
|
+
new DragSlides({
|
|
1346
|
+
dragEl: img,
|
|
1347
|
+
toleranceX: settings.dragToleranceX,
|
|
1348
|
+
toleranceY: settings.dragToleranceY,
|
|
1349
|
+
slide: slide,
|
|
1350
|
+
instance: _this.instance
|
|
1351
|
+
});
|
|
1352
|
+
}
|
|
1353
|
+
if (slideConfig.zoomable && img.naturalWidth > img.offsetWidth) {
|
|
1354
|
+
addClass(img, 'zoomable');
|
|
1355
|
+
new ZoomImages(img, slide, function () {
|
|
1356
|
+
_this.instance.resize();
|
|
1357
|
+
});
|
|
1358
|
+
}
|
|
1359
|
+
if (isFunction(finalCallback)) {
|
|
1360
|
+
finalCallback();
|
|
1361
|
+
}
|
|
1362
|
+
});
|
|
1363
|
+
return;
|
|
1364
|
+
}
|
|
1365
|
+
if (isFunction(finalCallback)) {
|
|
1366
|
+
finalCallback();
|
|
1367
|
+
}
|
|
1368
|
+
}
|
|
1369
|
+
}, {
|
|
1370
|
+
key: "slideShortDesc",
|
|
1371
|
+
value: function slideShortDesc(string) {
|
|
1372
|
+
var n = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 50;
|
|
1373
|
+
var wordBoundary = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
1374
|
+
var div = document.createElement('div');
|
|
1375
|
+
div.innerHTML = string;
|
|
1376
|
+
var cleanedString = div.innerText;
|
|
1377
|
+
var useWordBoundary = wordBoundary;
|
|
1378
|
+
string = cleanedString.trim();
|
|
1379
|
+
if (string.length <= n) {
|
|
1380
|
+
return string;
|
|
1381
|
+
}
|
|
1382
|
+
var subString = string.substr(0, n - 1);
|
|
1383
|
+
if (!useWordBoundary) {
|
|
1384
|
+
return subString;
|
|
1385
|
+
}
|
|
1386
|
+
div = null;
|
|
1387
|
+
return subString + '... <a href="#" class="desc-more">' + wordBoundary + '</a>';
|
|
1388
|
+
}
|
|
1389
|
+
}, {
|
|
1390
|
+
key: "descriptionEvents",
|
|
1391
|
+
value: function descriptionEvents(desc, data) {
|
|
1392
|
+
var _this2 = this;
|
|
1393
|
+
var moreLink = desc.querySelector('.desc-more');
|
|
1394
|
+
if (!moreLink) {
|
|
1395
|
+
return false;
|
|
1396
|
+
}
|
|
1397
|
+
addEvent('click', {
|
|
1398
|
+
onElement: moreLink,
|
|
1399
|
+
withCallback: function withCallback(event, target) {
|
|
1400
|
+
event.preventDefault();
|
|
1401
|
+
event.stopPropagation();
|
|
1402
|
+
var body = document.body;
|
|
1403
|
+
var desc = closest(target, '.gslide-desc');
|
|
1404
|
+
if (!desc) {
|
|
1405
|
+
return false;
|
|
1406
|
+
}
|
|
1407
|
+
desc.innerHTML = "".concat(data.description, " <a href=\"#\" class=\"desc-less\">").concat(_this2.instance.settings.lessText, "</a>");
|
|
1408
|
+
addClass(body, 'gdesc-open');
|
|
1409
|
+
var shortEvent = addEvent('click', {
|
|
1410
|
+
onElement: [body, closest(desc, '.gslide-description')],
|
|
1411
|
+
withCallback: function withCallback(event, target) {
|
|
1412
|
+
var isLessLink = hasClass(event.target, 'desc-less');
|
|
1413
|
+
if (event.target.nodeName.toLowerCase() !== 'a' || isLessLink) {
|
|
1414
|
+
event.stopPropagation();
|
|
1415
|
+
if (isLessLink) {
|
|
1416
|
+
event.preventDefault();
|
|
1417
|
+
}
|
|
1418
|
+
removeClass(body, 'gdesc-open');
|
|
1419
|
+
addClass(body, 'gdesc-closed');
|
|
1420
|
+
desc.innerHTML = data.smallDescription;
|
|
1421
|
+
_this2.descriptionEvents(desc, data);
|
|
1422
|
+
setTimeout(function () {
|
|
1423
|
+
removeClass(body, 'gdesc-closed');
|
|
1424
|
+
}, 400);
|
|
1425
|
+
shortEvent.destroy();
|
|
1426
|
+
}
|
|
1427
|
+
}
|
|
1428
|
+
});
|
|
1429
|
+
}
|
|
1430
|
+
});
|
|
1431
|
+
}
|
|
1432
|
+
}, {
|
|
1433
|
+
key: "create",
|
|
1434
|
+
value: function create() {
|
|
1435
|
+
return createHTML(this.instance.settings.slideHTML);
|
|
1436
|
+
}
|
|
1437
|
+
}, {
|
|
1438
|
+
key: "getConfig",
|
|
1439
|
+
value: function getConfig() {
|
|
1440
|
+
if (!isNode(this.element) && !this.element.hasOwnProperty('draggable')) {
|
|
1441
|
+
this.element.draggable = this.instance.settings.draggable;
|
|
1442
|
+
}
|
|
1443
|
+
var parser = new SlideConfigParser(this.instance.settings.slideExtraAttributes);
|
|
1444
|
+
this.slideConfig = parser.parseConfig(this.element, this.instance.settings);
|
|
1445
|
+
return this.slideConfig;
|
|
1446
|
+
}
|
|
1447
|
+
}]);
|
|
1448
|
+
}();
|
|
1449
|
+
|
|
1450
|
+
function getLen(v) {
|
|
1451
|
+
return Math.sqrt(v.x * v.x + v.y * v.y);
|
|
1452
|
+
}
|
|
1453
|
+
function dot(v1, v2) {
|
|
1454
|
+
return v1.x * v2.x + v1.y * v2.y;
|
|
1455
|
+
}
|
|
1456
|
+
function getAngle(v1, v2) {
|
|
1457
|
+
var mr = getLen(v1) * getLen(v2);
|
|
1458
|
+
if (mr === 0) {
|
|
1459
|
+
return 0;
|
|
1460
|
+
}
|
|
1461
|
+
var r = dot(v1, v2) / mr;
|
|
1462
|
+
if (r > 1) {
|
|
1463
|
+
r = 1;
|
|
1464
|
+
}
|
|
1465
|
+
return Math.acos(r);
|
|
1466
|
+
}
|
|
1467
|
+
function cross(v1, v2) {
|
|
1468
|
+
return v1.x * v2.y - v2.x * v1.y;
|
|
1469
|
+
}
|
|
1470
|
+
function getRotateAngle(v1, v2) {
|
|
1471
|
+
var angle = getAngle(v1, v2);
|
|
1472
|
+
if (cross(v1, v2) > 0) {
|
|
1473
|
+
angle *= -1;
|
|
1474
|
+
}
|
|
1475
|
+
return angle * 180 / Math.PI;
|
|
1476
|
+
}
|
|
1477
|
+
var EventsHandlerAdmin = function () {
|
|
1478
|
+
function EventsHandlerAdmin(el) {
|
|
1479
|
+
_classCallCheck(this, EventsHandlerAdmin);
|
|
1480
|
+
this.handlers = [];
|
|
1481
|
+
this.el = el;
|
|
1482
|
+
}
|
|
1483
|
+
return _createClass(EventsHandlerAdmin, [{
|
|
1484
|
+
key: "add",
|
|
1485
|
+
value: function add(handler) {
|
|
1486
|
+
this.handlers.push(handler);
|
|
1487
|
+
}
|
|
1488
|
+
}, {
|
|
1489
|
+
key: "del",
|
|
1490
|
+
value: function del(handler) {
|
|
1491
|
+
if (!handler) {
|
|
1492
|
+
this.handlers = [];
|
|
1493
|
+
}
|
|
1494
|
+
for (var i = this.handlers.length; i >= 0; i--) {
|
|
1495
|
+
if (this.handlers[i] === handler) {
|
|
1496
|
+
this.handlers.splice(i, 1);
|
|
1497
|
+
}
|
|
1498
|
+
}
|
|
1499
|
+
}
|
|
1500
|
+
}, {
|
|
1501
|
+
key: "dispatch",
|
|
1502
|
+
value: function dispatch() {
|
|
1503
|
+
for (var i = 0, len = this.handlers.length; i < len; i++) {
|
|
1504
|
+
var handler = this.handlers[i];
|
|
1505
|
+
if (typeof handler === 'function') {
|
|
1506
|
+
handler.apply(this.el, arguments);
|
|
1507
|
+
}
|
|
1508
|
+
}
|
|
1509
|
+
}
|
|
1510
|
+
}]);
|
|
1511
|
+
}();
|
|
1512
|
+
function wrapFunc(el, handler) {
|
|
1513
|
+
var EventshandlerAdmin = new EventsHandlerAdmin(el);
|
|
1514
|
+
EventshandlerAdmin.add(handler);
|
|
1515
|
+
return EventshandlerAdmin;
|
|
1516
|
+
}
|
|
1517
|
+
var TouchEvents = function () {
|
|
1518
|
+
function TouchEvents(el, option) {
|
|
1519
|
+
_classCallCheck(this, TouchEvents);
|
|
1520
|
+
this.element = typeof el == 'string' ? document.querySelector(el) : el;
|
|
1521
|
+
this.start = this.start.bind(this);
|
|
1522
|
+
this.move = this.move.bind(this);
|
|
1523
|
+
this.end = this.end.bind(this);
|
|
1524
|
+
this.cancel = this.cancel.bind(this);
|
|
1525
|
+
this.element.addEventListener('touchstart', this.start, false);
|
|
1526
|
+
this.element.addEventListener('touchmove', this.move, false);
|
|
1527
|
+
this.element.addEventListener('touchend', this.end, false);
|
|
1528
|
+
this.element.addEventListener('touchcancel', this.cancel, false);
|
|
1529
|
+
this.preV = {
|
|
1530
|
+
x: null,
|
|
1531
|
+
y: null
|
|
1532
|
+
};
|
|
1533
|
+
this.pinchStartLen = null;
|
|
1534
|
+
this.zoom = 1;
|
|
1535
|
+
this.isDoubleTap = false;
|
|
1536
|
+
var noop = function noop() {};
|
|
1537
|
+
this.rotate = wrapFunc(this.element, option.rotate || noop);
|
|
1538
|
+
this.touchStart = wrapFunc(this.element, option.touchStart || noop);
|
|
1539
|
+
this.multipointStart = wrapFunc(this.element, option.multipointStart || noop);
|
|
1540
|
+
this.multipointEnd = wrapFunc(this.element, option.multipointEnd || noop);
|
|
1541
|
+
this.pinch = wrapFunc(this.element, option.pinch || noop);
|
|
1542
|
+
this.swipe = wrapFunc(this.element, option.swipe || noop);
|
|
1543
|
+
this.tap = wrapFunc(this.element, option.tap || noop);
|
|
1544
|
+
this.doubleTap = wrapFunc(this.element, option.doubleTap || noop);
|
|
1545
|
+
this.longTap = wrapFunc(this.element, option.longTap || noop);
|
|
1546
|
+
this.singleTap = wrapFunc(this.element, option.singleTap || noop);
|
|
1547
|
+
this.pressMove = wrapFunc(this.element, option.pressMove || noop);
|
|
1548
|
+
this.twoFingerPressMove = wrapFunc(this.element, option.twoFingerPressMove || noop);
|
|
1549
|
+
this.touchMove = wrapFunc(this.element, option.touchMove || noop);
|
|
1550
|
+
this.touchEnd = wrapFunc(this.element, option.touchEnd || noop);
|
|
1551
|
+
this.touchCancel = wrapFunc(this.element, option.touchCancel || noop);
|
|
1552
|
+
this.translateContainer = this.element;
|
|
1553
|
+
this._cancelAllHandler = this.cancelAll.bind(this);
|
|
1554
|
+
window.addEventListener('scroll', this._cancelAllHandler);
|
|
1555
|
+
this.delta = null;
|
|
1556
|
+
this.last = null;
|
|
1557
|
+
this.now = null;
|
|
1558
|
+
this.tapTimeout = null;
|
|
1559
|
+
this.singleTapTimeout = null;
|
|
1560
|
+
this.longTapTimeout = null;
|
|
1561
|
+
this.swipeTimeout = null;
|
|
1562
|
+
this.x1 = this.x2 = this.y1 = this.y2 = null;
|
|
1563
|
+
this.preTapPosition = {
|
|
1564
|
+
x: null,
|
|
1565
|
+
y: null
|
|
1566
|
+
};
|
|
1567
|
+
}
|
|
1568
|
+
return _createClass(TouchEvents, [{
|
|
1569
|
+
key: "start",
|
|
1570
|
+
value: function start(evt) {
|
|
1571
|
+
if (!evt.touches) {
|
|
1572
|
+
return;
|
|
1573
|
+
}
|
|
1574
|
+
var ignoreDragFor = ['a', 'button', 'input'];
|
|
1575
|
+
if (evt.target && evt.target.nodeName && ignoreDragFor.indexOf(evt.target.nodeName.toLowerCase()) >= 0) {
|
|
1576
|
+
console.log('ignore drag for this touched element', evt.target.nodeName.toLowerCase());
|
|
1577
|
+
return;
|
|
1578
|
+
}
|
|
1579
|
+
this.now = Date.now();
|
|
1580
|
+
this.x1 = evt.touches[0].pageX;
|
|
1581
|
+
this.y1 = evt.touches[0].pageY;
|
|
1582
|
+
this.delta = this.now - (this.last || this.now);
|
|
1583
|
+
this.touchStart.dispatch(evt, this.element);
|
|
1584
|
+
if (this.preTapPosition.x !== null) {
|
|
1585
|
+
this.isDoubleTap = this.delta > 0 && this.delta <= 250 && Math.abs(this.preTapPosition.x - this.x1) < 30 && Math.abs(this.preTapPosition.y - this.y1) < 30;
|
|
1586
|
+
if (this.isDoubleTap) {
|
|
1587
|
+
clearTimeout(this.singleTapTimeout);
|
|
1588
|
+
}
|
|
1589
|
+
}
|
|
1590
|
+
this.preTapPosition.x = this.x1;
|
|
1591
|
+
this.preTapPosition.y = this.y1;
|
|
1592
|
+
this.last = this.now;
|
|
1593
|
+
var preV = this.preV,
|
|
1594
|
+
len = evt.touches.length;
|
|
1595
|
+
if (len > 1) {
|
|
1596
|
+
this._cancelLongTap();
|
|
1597
|
+
this._cancelSingleTap();
|
|
1598
|
+
var v = {
|
|
1599
|
+
x: evt.touches[1].pageX - this.x1,
|
|
1600
|
+
y: evt.touches[1].pageY - this.y1
|
|
1601
|
+
};
|
|
1602
|
+
preV.x = v.x;
|
|
1603
|
+
preV.y = v.y;
|
|
1604
|
+
this.pinchStartLen = getLen(preV);
|
|
1605
|
+
this.multipointStart.dispatch(evt, this.element);
|
|
1606
|
+
}
|
|
1607
|
+
this._preventTap = false;
|
|
1608
|
+
this.longTapTimeout = setTimeout(function () {
|
|
1609
|
+
this.longTap.dispatch(evt, this.element);
|
|
1610
|
+
this._preventTap = true;
|
|
1611
|
+
}.bind(this), 750);
|
|
1612
|
+
}
|
|
1613
|
+
}, {
|
|
1614
|
+
key: "move",
|
|
1615
|
+
value: function move(evt) {
|
|
1616
|
+
if (!evt.touches) {
|
|
1617
|
+
return;
|
|
1618
|
+
}
|
|
1619
|
+
var preV = this.preV,
|
|
1620
|
+
len = evt.touches.length,
|
|
1621
|
+
currentX = evt.touches[0].pageX,
|
|
1622
|
+
currentY = evt.touches[0].pageY;
|
|
1623
|
+
this.isDoubleTap = false;
|
|
1624
|
+
if (len > 1) {
|
|
1625
|
+
var sCurrentX = evt.touches[1].pageX,
|
|
1626
|
+
sCurrentY = evt.touches[1].pageY;
|
|
1627
|
+
var v = {
|
|
1628
|
+
x: evt.touches[1].pageX - currentX,
|
|
1629
|
+
y: evt.touches[1].pageY - currentY
|
|
1630
|
+
};
|
|
1631
|
+
if (preV.x !== null) {
|
|
1632
|
+
if (this.pinchStartLen > 0) {
|
|
1633
|
+
evt.zoom = getLen(v) / this.pinchStartLen;
|
|
1634
|
+
this.pinch.dispatch(evt, this.element);
|
|
1635
|
+
}
|
|
1636
|
+
evt.angle = getRotateAngle(v, preV);
|
|
1637
|
+
this.rotate.dispatch(evt, this.element);
|
|
1638
|
+
}
|
|
1639
|
+
preV.x = v.x;
|
|
1640
|
+
preV.y = v.y;
|
|
1641
|
+
if (this.x2 !== null && this.sx2 !== null) {
|
|
1642
|
+
evt.deltaX = (currentX - this.x2 + sCurrentX - this.sx2) / 2;
|
|
1643
|
+
evt.deltaY = (currentY - this.y2 + sCurrentY - this.sy2) / 2;
|
|
1644
|
+
} else {
|
|
1645
|
+
evt.deltaX = 0;
|
|
1646
|
+
evt.deltaY = 0;
|
|
1647
|
+
}
|
|
1648
|
+
this.twoFingerPressMove.dispatch(evt, this.element);
|
|
1649
|
+
this.sx2 = sCurrentX;
|
|
1650
|
+
this.sy2 = sCurrentY;
|
|
1651
|
+
} else {
|
|
1652
|
+
if (this.x2 !== null) {
|
|
1653
|
+
evt.deltaX = currentX - this.x2;
|
|
1654
|
+
evt.deltaY = currentY - this.y2;
|
|
1655
|
+
var movedX = Math.abs(this.x1 - this.x2),
|
|
1656
|
+
movedY = Math.abs(this.y1 - this.y2);
|
|
1657
|
+
if (movedX > 10 || movedY > 10) {
|
|
1658
|
+
this._preventTap = true;
|
|
1659
|
+
}
|
|
1660
|
+
} else {
|
|
1661
|
+
evt.deltaX = 0;
|
|
1662
|
+
evt.deltaY = 0;
|
|
1663
|
+
}
|
|
1664
|
+
this.pressMove.dispatch(evt, this.element);
|
|
1665
|
+
}
|
|
1666
|
+
this.touchMove.dispatch(evt, this.element);
|
|
1667
|
+
this._cancelLongTap();
|
|
1668
|
+
this.x2 = currentX;
|
|
1669
|
+
this.y2 = currentY;
|
|
1670
|
+
if (len > 1) {
|
|
1671
|
+
evt.preventDefault();
|
|
1672
|
+
}
|
|
1673
|
+
}
|
|
1674
|
+
}, {
|
|
1675
|
+
key: "end",
|
|
1676
|
+
value: function end(evt) {
|
|
1677
|
+
if (!evt.changedTouches) {
|
|
1678
|
+
return;
|
|
1679
|
+
}
|
|
1680
|
+
this._cancelLongTap();
|
|
1681
|
+
var self = this;
|
|
1682
|
+
if (evt.touches.length < 2) {
|
|
1683
|
+
this.multipointEnd.dispatch(evt, this.element);
|
|
1684
|
+
this.sx2 = this.sy2 = null;
|
|
1685
|
+
}
|
|
1686
|
+
if (this.x2 && Math.abs(this.x1 - this.x2) > 30 || this.y2 && Math.abs(this.y1 - this.y2) > 30) {
|
|
1687
|
+
evt.direction = this._swipeDirection(this.x1, this.x2, this.y1, this.y2);
|
|
1688
|
+
this.swipeTimeout = setTimeout(function () {
|
|
1689
|
+
self.swipe.dispatch(evt, self.element);
|
|
1690
|
+
}, 0);
|
|
1691
|
+
} else {
|
|
1692
|
+
this.tapTimeout = setTimeout(function () {
|
|
1693
|
+
if (!self._preventTap) {
|
|
1694
|
+
self.tap.dispatch(evt, self.element);
|
|
1695
|
+
}
|
|
1696
|
+
if (self.isDoubleTap) {
|
|
1697
|
+
self.doubleTap.dispatch(evt, self.element);
|
|
1698
|
+
self.isDoubleTap = false;
|
|
1699
|
+
}
|
|
1700
|
+
}, 0);
|
|
1701
|
+
if (!self.isDoubleTap) {
|
|
1702
|
+
self.singleTapTimeout = setTimeout(function () {
|
|
1703
|
+
self.singleTap.dispatch(evt, self.element);
|
|
1704
|
+
}, 250);
|
|
1705
|
+
}
|
|
1706
|
+
}
|
|
1707
|
+
this.touchEnd.dispatch(evt, this.element);
|
|
1708
|
+
this.preV.x = 0;
|
|
1709
|
+
this.preV.y = 0;
|
|
1710
|
+
this.zoom = 1;
|
|
1711
|
+
this.pinchStartLen = null;
|
|
1712
|
+
this.x1 = this.x2 = this.y1 = this.y2 = null;
|
|
1713
|
+
}
|
|
1714
|
+
}, {
|
|
1715
|
+
key: "cancelAll",
|
|
1716
|
+
value: function cancelAll() {
|
|
1717
|
+
this._preventTap = true;
|
|
1718
|
+
clearTimeout(this.singleTapTimeout);
|
|
1719
|
+
clearTimeout(this.tapTimeout);
|
|
1720
|
+
clearTimeout(this.longTapTimeout);
|
|
1721
|
+
clearTimeout(this.swipeTimeout);
|
|
1722
|
+
}
|
|
1723
|
+
}, {
|
|
1724
|
+
key: "cancel",
|
|
1725
|
+
value: function cancel(evt) {
|
|
1726
|
+
this.cancelAll();
|
|
1727
|
+
this.touchCancel.dispatch(evt, this.element);
|
|
1728
|
+
}
|
|
1729
|
+
}, {
|
|
1730
|
+
key: "_cancelLongTap",
|
|
1731
|
+
value: function _cancelLongTap() {
|
|
1732
|
+
clearTimeout(this.longTapTimeout);
|
|
1733
|
+
}
|
|
1734
|
+
}, {
|
|
1735
|
+
key: "_cancelSingleTap",
|
|
1736
|
+
value: function _cancelSingleTap() {
|
|
1737
|
+
clearTimeout(this.singleTapTimeout);
|
|
1738
|
+
}
|
|
1739
|
+
}, {
|
|
1740
|
+
key: "_swipeDirection",
|
|
1741
|
+
value: function _swipeDirection(x1, x2, y1, y2) {
|
|
1742
|
+
return Math.abs(x1 - x2) >= Math.abs(y1 - y2) ? x1 - x2 > 0 ? 'Left' : 'Right' : y1 - y2 > 0 ? 'Up' : 'Down';
|
|
1743
|
+
}
|
|
1744
|
+
}, {
|
|
1745
|
+
key: "on",
|
|
1746
|
+
value: function on(evt, handler) {
|
|
1747
|
+
if (this[evt]) {
|
|
1748
|
+
this[evt].add(handler);
|
|
1749
|
+
}
|
|
1750
|
+
}
|
|
1751
|
+
}, {
|
|
1752
|
+
key: "off",
|
|
1753
|
+
value: function off(evt, handler) {
|
|
1754
|
+
if (this[evt]) {
|
|
1755
|
+
this[evt].del(handler);
|
|
1756
|
+
}
|
|
1757
|
+
}
|
|
1758
|
+
}, {
|
|
1759
|
+
key: "destroy",
|
|
1760
|
+
value: function destroy() {
|
|
1761
|
+
if (this.singleTapTimeout) {
|
|
1762
|
+
clearTimeout(this.singleTapTimeout);
|
|
1763
|
+
}
|
|
1764
|
+
if (this.tapTimeout) {
|
|
1765
|
+
clearTimeout(this.tapTimeout);
|
|
1766
|
+
}
|
|
1767
|
+
if (this.longTapTimeout) {
|
|
1768
|
+
clearTimeout(this.longTapTimeout);
|
|
1769
|
+
}
|
|
1770
|
+
if (this.swipeTimeout) {
|
|
1771
|
+
clearTimeout(this.swipeTimeout);
|
|
1772
|
+
}
|
|
1773
|
+
this.element.removeEventListener('touchstart', this.start);
|
|
1774
|
+
this.element.removeEventListener('touchmove', this.move);
|
|
1775
|
+
this.element.removeEventListener('touchend', this.end);
|
|
1776
|
+
this.element.removeEventListener('touchcancel', this.cancel);
|
|
1777
|
+
this.rotate.del();
|
|
1778
|
+
this.touchStart.del();
|
|
1779
|
+
this.multipointStart.del();
|
|
1780
|
+
this.multipointEnd.del();
|
|
1781
|
+
this.pinch.del();
|
|
1782
|
+
this.swipe.del();
|
|
1783
|
+
this.tap.del();
|
|
1784
|
+
this.doubleTap.del();
|
|
1785
|
+
this.longTap.del();
|
|
1786
|
+
this.singleTap.del();
|
|
1787
|
+
this.pressMove.del();
|
|
1788
|
+
this.twoFingerPressMove.del();
|
|
1789
|
+
this.touchMove.del();
|
|
1790
|
+
this.touchEnd.del();
|
|
1791
|
+
this.touchCancel.del();
|
|
1792
|
+
this.preV = this.pinchStartLen = this.zoom = this.isDoubleTap = this.delta = this.last = this.now = this.tapTimeout = this.singleTapTimeout = this.longTapTimeout = this.swipeTimeout = this.x1 = this.x2 = this.y1 = this.y2 = this.preTapPosition = this.rotate = this.touchStart = this.multipointStart = this.multipointEnd = this.pinch = this.swipe = this.tap = this.doubleTap = this.longTap = this.singleTap = this.pressMove = this.touchMove = this.touchEnd = this.touchCancel = this.twoFingerPressMove = null;
|
|
1793
|
+
window.removeEventListener('scroll', this._cancelAllHandler);
|
|
1794
|
+
return null;
|
|
1795
|
+
}
|
|
1796
|
+
}]);
|
|
1797
|
+
}();
|
|
1798
|
+
|
|
1799
|
+
function resetSlideMove(slide) {
|
|
1800
|
+
if (!slide) {
|
|
1801
|
+
return;
|
|
1802
|
+
}
|
|
1803
|
+
var transitionEnd = whichTransitionEvent();
|
|
1804
|
+
var windowWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
|
|
1805
|
+
var media = hasClass(slide, 'gslide-media') ? slide : slide.querySelector('.gslide-media');
|
|
1806
|
+
var container = closest(media, '.ginner-container');
|
|
1807
|
+
var desc = slide.querySelector('.gslide-description');
|
|
1808
|
+
if (windowWidth > 769) {
|
|
1809
|
+
media = container;
|
|
1810
|
+
}
|
|
1811
|
+
addClass(media, 'greset');
|
|
1812
|
+
cssTransform(media, 'translate3d(0, 0, 0)');
|
|
1813
|
+
addEvent(transitionEnd, {
|
|
1814
|
+
onElement: media,
|
|
1815
|
+
once: true,
|
|
1816
|
+
withCallback: function withCallback(event, target) {
|
|
1817
|
+
removeClass(media, 'greset');
|
|
1818
|
+
}
|
|
1819
|
+
});
|
|
1820
|
+
media.style.opacity = '';
|
|
1821
|
+
if (desc) {
|
|
1822
|
+
desc.style.opacity = '';
|
|
1823
|
+
}
|
|
1824
|
+
}
|
|
1825
|
+
function touchNavigation(instance) {
|
|
1826
|
+
if (instance.events.hasOwnProperty('touch')) {
|
|
1827
|
+
return false;
|
|
1828
|
+
}
|
|
1829
|
+
var winSize = windowSize();
|
|
1830
|
+
var winWidth = winSize.width;
|
|
1831
|
+
var winHeight = winSize.height;
|
|
1832
|
+
var process = false;
|
|
1833
|
+
var currentSlide = null;
|
|
1834
|
+
var media = null;
|
|
1835
|
+
var mediaImage = null;
|
|
1836
|
+
var doingMove = false;
|
|
1837
|
+
var initScale = 1;
|
|
1838
|
+
var maxScale = 4.5;
|
|
1839
|
+
var currentScale = 1;
|
|
1840
|
+
var doingZoom = false;
|
|
1841
|
+
var imageZoomed = false;
|
|
1842
|
+
var zoomedPosX = null;
|
|
1843
|
+
var zoomedPosY = null;
|
|
1844
|
+
var lastZoomedPosX = null;
|
|
1845
|
+
var lastZoomedPosY = null;
|
|
1846
|
+
var hDistance;
|
|
1847
|
+
var vDistance;
|
|
1848
|
+
var hDistancePercent = 0;
|
|
1849
|
+
var vDistancePercent = 0;
|
|
1850
|
+
var vSwipe = false;
|
|
1851
|
+
var hSwipe = false;
|
|
1852
|
+
var startCoords = {};
|
|
1853
|
+
var endCoords = {};
|
|
1854
|
+
var xDown = 0;
|
|
1855
|
+
var yDown = 0;
|
|
1856
|
+
var isInlined;
|
|
1857
|
+
var sliderWrapper = document.getElementById('glightbox-slider');
|
|
1858
|
+
var overlay = document.querySelector('.goverlay');
|
|
1859
|
+
var touchInstance = new TouchEvents(sliderWrapper, {
|
|
1860
|
+
touchStart: function touchStart(e) {
|
|
1861
|
+
process = true;
|
|
1862
|
+
if (hasClass(e.targetTouches[0].target, 'ginner-container') || closest(e.targetTouches[0].target, '.gslide-desc') || e.targetTouches[0].target.nodeName.toLowerCase() == 'a') {
|
|
1863
|
+
process = false;
|
|
1864
|
+
}
|
|
1865
|
+
if (closest(e.targetTouches[0].target, '.gslide-inline') && !hasClass(e.targetTouches[0].target.parentNode, 'gslide-inline')) {
|
|
1866
|
+
process = false;
|
|
1867
|
+
}
|
|
1868
|
+
if (process) {
|
|
1869
|
+
endCoords = e.targetTouches[0];
|
|
1870
|
+
startCoords.pageX = e.targetTouches[0].pageX;
|
|
1871
|
+
startCoords.pageY = e.targetTouches[0].pageY;
|
|
1872
|
+
xDown = e.targetTouches[0].clientX;
|
|
1873
|
+
yDown = e.targetTouches[0].clientY;
|
|
1874
|
+
currentSlide = instance.activeSlide;
|
|
1875
|
+
media = currentSlide.querySelector('.gslide-media');
|
|
1876
|
+
isInlined = currentSlide.querySelector('.gslide-inline');
|
|
1877
|
+
mediaImage = null;
|
|
1878
|
+
if (hasClass(media, 'gslide-image')) {
|
|
1879
|
+
mediaImage = media.querySelector('img');
|
|
1880
|
+
}
|
|
1881
|
+
var windowWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
|
|
1882
|
+
if (windowWidth > 769) {
|
|
1883
|
+
media = currentSlide.querySelector('.ginner-container');
|
|
1884
|
+
}
|
|
1885
|
+
removeClass(overlay, 'greset');
|
|
1886
|
+
if (e.pageX > 20 && e.pageX < window.innerWidth - 20) {
|
|
1887
|
+
return;
|
|
1888
|
+
}
|
|
1889
|
+
e.preventDefault();
|
|
1890
|
+
}
|
|
1891
|
+
},
|
|
1892
|
+
touchMove: function touchMove(e) {
|
|
1893
|
+
if (!process) {
|
|
1894
|
+
return;
|
|
1895
|
+
}
|
|
1896
|
+
endCoords = e.targetTouches[0];
|
|
1897
|
+
if (doingZoom || imageZoomed) {
|
|
1898
|
+
return;
|
|
1899
|
+
}
|
|
1900
|
+
if (isInlined && isInlined.offsetHeight > winHeight) {
|
|
1901
|
+
var moved = startCoords.pageX - endCoords.pageX;
|
|
1902
|
+
if (Math.abs(moved) <= 13) {
|
|
1903
|
+
return false;
|
|
1904
|
+
}
|
|
1905
|
+
}
|
|
1906
|
+
doingMove = true;
|
|
1907
|
+
var xUp = e.targetTouches[0].clientX;
|
|
1908
|
+
var yUp = e.targetTouches[0].clientY;
|
|
1909
|
+
var xDiff = xDown - xUp;
|
|
1910
|
+
var yDiff = yDown - yUp;
|
|
1911
|
+
if (Math.abs(xDiff) > Math.abs(yDiff)) {
|
|
1912
|
+
vSwipe = false;
|
|
1913
|
+
hSwipe = true;
|
|
1914
|
+
} else {
|
|
1915
|
+
hSwipe = false;
|
|
1916
|
+
vSwipe = true;
|
|
1917
|
+
}
|
|
1918
|
+
hDistance = endCoords.pageX - startCoords.pageX;
|
|
1919
|
+
hDistancePercent = hDistance * 100 / winWidth;
|
|
1920
|
+
vDistance = endCoords.pageY - startCoords.pageY;
|
|
1921
|
+
vDistancePercent = vDistance * 100 / winHeight;
|
|
1922
|
+
var opacity;
|
|
1923
|
+
if (vSwipe && mediaImage) {
|
|
1924
|
+
opacity = 1 - Math.abs(vDistance) / winHeight;
|
|
1925
|
+
overlay.style.opacity = opacity;
|
|
1926
|
+
if (instance.settings.touchFollowAxis) {
|
|
1927
|
+
hDistancePercent = 0;
|
|
1928
|
+
}
|
|
1929
|
+
}
|
|
1930
|
+
if (hSwipe) {
|
|
1931
|
+
opacity = 1 - Math.abs(hDistance) / winWidth;
|
|
1932
|
+
media.style.opacity = opacity;
|
|
1933
|
+
if (instance.settings.touchFollowAxis) {
|
|
1934
|
+
vDistancePercent = 0;
|
|
1935
|
+
}
|
|
1936
|
+
}
|
|
1937
|
+
if (!mediaImage) {
|
|
1938
|
+
return cssTransform(media, "translate3d(".concat(hDistancePercent, "%, 0, 0)"));
|
|
1939
|
+
}
|
|
1940
|
+
cssTransform(media, "translate3d(".concat(hDistancePercent, "%, ").concat(vDistancePercent, "%, 0)"));
|
|
1941
|
+
},
|
|
1942
|
+
touchEnd: function touchEnd() {
|
|
1943
|
+
if (!process) {
|
|
1944
|
+
return;
|
|
1945
|
+
}
|
|
1946
|
+
doingMove = false;
|
|
1947
|
+
if (imageZoomed || doingZoom) {
|
|
1948
|
+
lastZoomedPosX = zoomedPosX;
|
|
1949
|
+
lastZoomedPosY = zoomedPosY;
|
|
1950
|
+
return;
|
|
1951
|
+
}
|
|
1952
|
+
var v = Math.abs(parseInt(vDistancePercent));
|
|
1953
|
+
var h = Math.abs(parseInt(hDistancePercent));
|
|
1954
|
+
if (v > 29 && mediaImage) {
|
|
1955
|
+
instance.close();
|
|
1956
|
+
return;
|
|
1957
|
+
}
|
|
1958
|
+
if (v < 29 && h < 25) {
|
|
1959
|
+
addClass(overlay, 'greset');
|
|
1960
|
+
overlay.style.opacity = 1;
|
|
1961
|
+
return resetSlideMove(media);
|
|
1962
|
+
}
|
|
1963
|
+
},
|
|
1964
|
+
multipointEnd: function multipointEnd() {
|
|
1965
|
+
setTimeout(function () {
|
|
1966
|
+
doingZoom = false;
|
|
1967
|
+
}, 50);
|
|
1968
|
+
},
|
|
1969
|
+
multipointStart: function multipointStart() {
|
|
1970
|
+
doingZoom = true;
|
|
1971
|
+
initScale = currentScale ? currentScale : 1;
|
|
1972
|
+
},
|
|
1973
|
+
pinch: function pinch(evt) {
|
|
1974
|
+
if (!mediaImage || doingMove) {
|
|
1975
|
+
return false;
|
|
1976
|
+
}
|
|
1977
|
+
doingZoom = true;
|
|
1978
|
+
mediaImage.scaleX = mediaImage.scaleY = initScale * evt.zoom;
|
|
1979
|
+
var scale = initScale * evt.zoom;
|
|
1980
|
+
imageZoomed = true;
|
|
1981
|
+
if (scale <= 1) {
|
|
1982
|
+
imageZoomed = false;
|
|
1983
|
+
scale = 1;
|
|
1984
|
+
lastZoomedPosY = null;
|
|
1985
|
+
lastZoomedPosX = null;
|
|
1986
|
+
zoomedPosX = null;
|
|
1987
|
+
zoomedPosY = null;
|
|
1988
|
+
mediaImage.setAttribute('style', '');
|
|
1989
|
+
return;
|
|
1990
|
+
}
|
|
1991
|
+
if (scale > maxScale) {
|
|
1992
|
+
scale = maxScale;
|
|
1993
|
+
}
|
|
1994
|
+
mediaImage.style.transform = "scale3d(".concat(scale, ", ").concat(scale, ", 1)");
|
|
1995
|
+
currentScale = scale;
|
|
1996
|
+
},
|
|
1997
|
+
pressMove: function pressMove(e) {
|
|
1998
|
+
if (imageZoomed && !doingZoom) {
|
|
1999
|
+
var mhDistance = endCoords.pageX - startCoords.pageX;
|
|
2000
|
+
var mvDistance = endCoords.pageY - startCoords.pageY;
|
|
2001
|
+
if (lastZoomedPosX) {
|
|
2002
|
+
mhDistance = mhDistance + lastZoomedPosX;
|
|
2003
|
+
}
|
|
2004
|
+
if (lastZoomedPosY) {
|
|
2005
|
+
mvDistance = mvDistance + lastZoomedPosY;
|
|
2006
|
+
}
|
|
2007
|
+
zoomedPosX = mhDistance;
|
|
2008
|
+
zoomedPosY = mvDistance;
|
|
2009
|
+
var style = "translate3d(".concat(mhDistance, "px, ").concat(mvDistance, "px, 0)");
|
|
2010
|
+
if (currentScale) {
|
|
2011
|
+
style += " scale3d(".concat(currentScale, ", ").concat(currentScale, ", 1)");
|
|
2012
|
+
}
|
|
2013
|
+
cssTransform(mediaImage, style);
|
|
2014
|
+
}
|
|
2015
|
+
},
|
|
2016
|
+
swipe: function swipe(evt) {
|
|
2017
|
+
if (imageZoomed) {
|
|
2018
|
+
return;
|
|
2019
|
+
}
|
|
2020
|
+
if (doingZoom) {
|
|
2021
|
+
doingZoom = false;
|
|
2022
|
+
return;
|
|
2023
|
+
}
|
|
2024
|
+
if (evt.direction == 'Left') {
|
|
2025
|
+
if (instance.index == instance.elements.length - 1) {
|
|
2026
|
+
return resetSlideMove(media);
|
|
2027
|
+
}
|
|
2028
|
+
instance.nextSlide();
|
|
2029
|
+
}
|
|
2030
|
+
if (evt.direction == 'Right') {
|
|
2031
|
+
if (instance.index == 0) {
|
|
2032
|
+
return resetSlideMove(media);
|
|
2033
|
+
}
|
|
2034
|
+
instance.prevSlide();
|
|
2035
|
+
}
|
|
2036
|
+
}
|
|
2037
|
+
});
|
|
2038
|
+
instance.events['touch'] = touchInstance;
|
|
2039
|
+
}
|
|
2040
|
+
|
|
2041
|
+
var _version = '3.3.4';
|
|
2042
|
+
var isMobile$1 = isMobile();
|
|
2043
|
+
var isTouch$1 = isTouch();
|
|
2044
|
+
var html = document.getElementsByTagName('html')[0];
|
|
2045
|
+
var defaults = {
|
|
2046
|
+
selector: '.glightbox',
|
|
2047
|
+
elements: null,
|
|
2048
|
+
skin: 'clean',
|
|
2049
|
+
theme: 'clean',
|
|
2050
|
+
closeButton: true,
|
|
2051
|
+
closeButtonText: 'Close',
|
|
2052
|
+
prevButtonText: 'Previous',
|
|
2053
|
+
nextButtonText: 'Next',
|
|
2054
|
+
startAt: null,
|
|
2055
|
+
autoplayVideos: true,
|
|
2056
|
+
autofocusVideos: true,
|
|
2057
|
+
descPosition: 'bottom',
|
|
2058
|
+
width: '900px',
|
|
2059
|
+
height: '506px',
|
|
2060
|
+
videosWidth: '960px',
|
|
2061
|
+
beforeSlideChange: null,
|
|
2062
|
+
afterSlideChange: null,
|
|
2063
|
+
beforeSlideLoad: null,
|
|
2064
|
+
afterSlideLoad: null,
|
|
2065
|
+
slideInserted: null,
|
|
2066
|
+
slideRemoved: null,
|
|
2067
|
+
slideExtraAttributes: null,
|
|
2068
|
+
onOpen: null,
|
|
2069
|
+
onClose: null,
|
|
2070
|
+
loop: false,
|
|
2071
|
+
zoomable: true,
|
|
2072
|
+
draggable: true,
|
|
2073
|
+
dragAutoSnap: false,
|
|
2074
|
+
dragToleranceX: 40,
|
|
2075
|
+
dragToleranceY: 65,
|
|
2076
|
+
preload: true,
|
|
2077
|
+
oneSlidePerOpen: false,
|
|
2078
|
+
touchNavigation: true,
|
|
2079
|
+
touchFollowAxis: true,
|
|
2080
|
+
keyboardNavigation: true,
|
|
2081
|
+
closeOnOutsideClick: true,
|
|
2082
|
+
plugins: false,
|
|
2083
|
+
plyr: {
|
|
2084
|
+
css: 'https://cdn.plyr.io/3.6.12/plyr.css',
|
|
2085
|
+
js: 'https://cdn.plyr.io/3.6.12/plyr.js',
|
|
2086
|
+
config: {
|
|
2087
|
+
ratio: '16:9',
|
|
2088
|
+
fullscreen: {
|
|
2089
|
+
enabled: true,
|
|
2090
|
+
iosNative: true
|
|
2091
|
+
},
|
|
2092
|
+
youtube: {
|
|
2093
|
+
noCookie: true,
|
|
2094
|
+
rel: 0,
|
|
2095
|
+
showinfo: 0,
|
|
2096
|
+
iv_load_policy: 3
|
|
2097
|
+
},
|
|
2098
|
+
vimeo: {
|
|
2099
|
+
byline: false,
|
|
2100
|
+
portrait: false,
|
|
2101
|
+
title: false,
|
|
2102
|
+
transparent: false
|
|
2103
|
+
}
|
|
2104
|
+
}
|
|
2105
|
+
},
|
|
2106
|
+
openEffect: 'zoom',
|
|
2107
|
+
closeEffect: 'zoom',
|
|
2108
|
+
slideEffect: 'slide',
|
|
2109
|
+
moreText: 'See more',
|
|
2110
|
+
lessText: 'See less',
|
|
2111
|
+
moreLength: 60,
|
|
2112
|
+
cssEfects: {
|
|
2113
|
+
fade: {
|
|
2114
|
+
"in": 'fadeIn',
|
|
2115
|
+
out: 'fadeOut'
|
|
2116
|
+
},
|
|
2117
|
+
zoom: {
|
|
2118
|
+
"in": 'zoomIn',
|
|
2119
|
+
out: 'zoomOut'
|
|
2120
|
+
},
|
|
2121
|
+
slide: {
|
|
2122
|
+
"in": 'slideInRight',
|
|
2123
|
+
out: 'slideOutLeft'
|
|
2124
|
+
},
|
|
2125
|
+
slideBack: {
|
|
2126
|
+
"in": 'slideInLeft',
|
|
2127
|
+
out: 'slideOutRight'
|
|
2128
|
+
},
|
|
2129
|
+
none: {
|
|
2130
|
+
"in": 'none',
|
|
2131
|
+
out: 'none'
|
|
2132
|
+
}
|
|
2133
|
+
},
|
|
2134
|
+
svg: {
|
|
2135
|
+
close: '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 512 512" xml:space="preserve"><g><g><path d="M505.943,6.058c-8.077-8.077-21.172-8.077-29.249,0L6.058,476.693c-8.077,8.077-8.077,21.172,0,29.249C10.096,509.982,15.39,512,20.683,512c5.293,0,10.586-2.019,14.625-6.059L505.943,35.306C514.019,27.23,514.019,14.135,505.943,6.058z"/></g></g><g><g><path d="M505.942,476.694L35.306,6.059c-8.076-8.077-21.172-8.077-29.248,0c-8.077,8.076-8.077,21.171,0,29.248l470.636,470.636c4.038,4.039,9.332,6.058,14.625,6.058c5.293,0,10.587-2.019,14.624-6.057C514.018,497.866,514.018,484.771,505.942,476.694z"/></g></g></svg>',
|
|
2136
|
+
next: '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 477.175 477.175" xml:space="preserve"> <g><path d="M360.731,229.075l-225.1-225.1c-5.3-5.3-13.8-5.3-19.1,0s-5.3,13.8,0,19.1l215.5,215.5l-215.5,215.5c-5.3,5.3-5.3,13.8,0,19.1c2.6,2.6,6.1,4,9.5,4c3.4,0,6.9-1.3,9.5-4l225.1-225.1C365.931,242.875,365.931,234.275,360.731,229.075z"/></g></svg>',
|
|
2137
|
+
prev: '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 477.175 477.175" xml:space="preserve"><g><path d="M145.188,238.575l215.5-215.5c5.3-5.3,5.3-13.8,0-19.1s-13.8-5.3-19.1,0l-225.1,225.1c-5.3,5.3-5.3,13.8,0,19.1l225.1,225c2.6,2.6,6.1,4,9.5,4s6.9-1.3,9.5-4c5.3-5.3,5.3-13.8,0-19.1L145.188,238.575z"/></g></svg>'
|
|
2138
|
+
}
|
|
2139
|
+
};
|
|
2140
|
+
defaults.slideHTML = "<div class=\"gslide\">\n <div class=\"gslide-inner-content\">\n <div class=\"ginner-container\">\n <div class=\"gslide-media\">\n </div>\n <div class=\"gslide-description\">\n <div class=\"gdesc-inner\">\n <h4 class=\"gslide-title\"></h4>\n <div class=\"gslide-desc\"></div>\n </div>\n </div>\n </div>\n </div>\n</div>";
|
|
2141
|
+
defaults.lightboxHTML = "<div id=\"glightbox-body\" class=\"glightbox-container\" tabindex=\"-1\" role=\"dialog\" aria-hidden=\"false\">\n <div class=\"gloader visible\"></div>\n <div class=\"goverlay\"></div>\n <div class=\"gcontainer\">\n <div id=\"glightbox-slider\" class=\"gslider\"></div>\n <button class=\"gclose gbtn\" aria-label=\"{closeButtonText}\" data-taborder=\"3\">{closeSVG}</button>\n <button class=\"gprev gbtn\" aria-label=\"{prevButtonText}\" data-taborder=\"2\">{prevSVG}</button>\n <button class=\"gnext gbtn\" aria-label=\"{nextButtonText}\" data-taborder=\"1\">{nextSVG}</button>\n</div>\n</div>";
|
|
2142
|
+
var GlightboxInit = function () {
|
|
2143
|
+
function GlightboxInit() {
|
|
2144
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2145
|
+
_classCallCheck(this, GlightboxInit);
|
|
2146
|
+
this.customOptions = options;
|
|
2147
|
+
this.settings = extend(defaults, options);
|
|
2148
|
+
this.effectsClasses = this.getAnimationClasses();
|
|
2149
|
+
this.videoPlayers = {};
|
|
2150
|
+
this.apiEvents = [];
|
|
2151
|
+
this.fullElementsList = false;
|
|
2152
|
+
}
|
|
2153
|
+
return _createClass(GlightboxInit, [{
|
|
2154
|
+
key: "init",
|
|
2155
|
+
value: function init() {
|
|
2156
|
+
var _this = this;
|
|
2157
|
+
var selector = this.getSelector();
|
|
2158
|
+
if (selector) {
|
|
2159
|
+
this.baseEvents = addEvent('click', {
|
|
2160
|
+
onElement: selector,
|
|
2161
|
+
withCallback: function withCallback(e, target) {
|
|
2162
|
+
e.preventDefault();
|
|
2163
|
+
_this.open(target);
|
|
2164
|
+
}
|
|
2165
|
+
});
|
|
2166
|
+
}
|
|
2167
|
+
this.elements = this.getElements();
|
|
2168
|
+
}
|
|
2169
|
+
}, {
|
|
2170
|
+
key: "open",
|
|
2171
|
+
value: function open() {
|
|
2172
|
+
var element = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
2173
|
+
var startAt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
2174
|
+
if (this.elements.length === 0) {
|
|
2175
|
+
return false;
|
|
2176
|
+
}
|
|
2177
|
+
this.activeSlide = null;
|
|
2178
|
+
this.prevActiveSlideIndex = null;
|
|
2179
|
+
this.prevActiveSlide = null;
|
|
2180
|
+
var index = isNumber(startAt) ? startAt : this.settings.startAt;
|
|
2181
|
+
if (isNode(element)) {
|
|
2182
|
+
var gallery = element.getAttribute('data-gallery');
|
|
2183
|
+
if (gallery) {
|
|
2184
|
+
this.fullElementsList = this.elements;
|
|
2185
|
+
this.elements = this.getGalleryElements(this.elements, gallery);
|
|
2186
|
+
}
|
|
2187
|
+
if (isNil(index)) {
|
|
2188
|
+
index = this.getElementIndex(element);
|
|
2189
|
+
if (index < 0) {
|
|
2190
|
+
index = 0;
|
|
2191
|
+
}
|
|
2192
|
+
}
|
|
2193
|
+
}
|
|
2194
|
+
if (!isNumber(index)) {
|
|
2195
|
+
index = 0;
|
|
2196
|
+
}
|
|
2197
|
+
this.build();
|
|
2198
|
+
animateElement(this.overlay, this.settings.openEffect === 'none' ? 'none' : this.settings.cssEfects.fade["in"]);
|
|
2199
|
+
var body = document.body;
|
|
2200
|
+
var scrollBar = window.innerWidth - document.documentElement.clientWidth;
|
|
2201
|
+
if (scrollBar > 0) {
|
|
2202
|
+
var styleSheet = document.createElement('style');
|
|
2203
|
+
styleSheet.type = 'text/css';
|
|
2204
|
+
styleSheet.className = 'gcss-styles';
|
|
2205
|
+
styleSheet.innerText = ".gscrollbar-fixer {margin-right: ".concat(scrollBar, "px}");
|
|
2206
|
+
document.head.appendChild(styleSheet);
|
|
2207
|
+
addClass(body, 'gscrollbar-fixer');
|
|
2208
|
+
}
|
|
2209
|
+
addClass(body, 'glightbox-open');
|
|
2210
|
+
addClass(html, 'glightbox-open');
|
|
2211
|
+
if (isMobile$1) {
|
|
2212
|
+
addClass(document.body, 'glightbox-mobile');
|
|
2213
|
+
this.settings.slideEffect = 'slide';
|
|
2214
|
+
}
|
|
2215
|
+
this.showSlide(index, true);
|
|
2216
|
+
if (this.elements.length === 1) {
|
|
2217
|
+
addClass(this.prevButton, 'glightbox-button-hidden');
|
|
2218
|
+
addClass(this.nextButton, 'glightbox-button-hidden');
|
|
2219
|
+
} else {
|
|
2220
|
+
removeClass(this.prevButton, 'glightbox-button-hidden');
|
|
2221
|
+
removeClass(this.nextButton, 'glightbox-button-hidden');
|
|
2222
|
+
}
|
|
2223
|
+
this.lightboxOpen = true;
|
|
2224
|
+
this.trigger('open');
|
|
2225
|
+
if (isFunction(this.settings.onOpen)) {
|
|
2226
|
+
this.settings.onOpen();
|
|
2227
|
+
}
|
|
2228
|
+
if (isTouch$1 && this.settings.touchNavigation) {
|
|
2229
|
+
touchNavigation(this);
|
|
2230
|
+
}
|
|
2231
|
+
if (this.settings.keyboardNavigation) {
|
|
2232
|
+
keyboardNavigation(this);
|
|
2233
|
+
}
|
|
2234
|
+
}
|
|
2235
|
+
}, {
|
|
2236
|
+
key: "openAt",
|
|
2237
|
+
value: function openAt() {
|
|
2238
|
+
var index = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
2239
|
+
this.open(null, index);
|
|
2240
|
+
}
|
|
2241
|
+
}, {
|
|
2242
|
+
key: "showSlide",
|
|
2243
|
+
value: function showSlide() {
|
|
2244
|
+
var _this2 = this;
|
|
2245
|
+
var index = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
2246
|
+
var first = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
2247
|
+
show(this.loader);
|
|
2248
|
+
this.index = parseInt(index);
|
|
2249
|
+
var current = this.slidesContainer.querySelector('.current');
|
|
2250
|
+
if (current) {
|
|
2251
|
+
removeClass(current, 'current');
|
|
2252
|
+
}
|
|
2253
|
+
this.slideAnimateOut();
|
|
2254
|
+
var slideNode = this.slidesContainer.querySelectorAll('.gslide')[index];
|
|
2255
|
+
if (hasClass(slideNode, 'loaded')) {
|
|
2256
|
+
this.slideAnimateIn(slideNode, first);
|
|
2257
|
+
hide(this.loader);
|
|
2258
|
+
} else {
|
|
2259
|
+
show(this.loader);
|
|
2260
|
+
var slide = this.elements[index];
|
|
2261
|
+
var slideData = {
|
|
2262
|
+
index: this.index,
|
|
2263
|
+
slide: slideNode,
|
|
2264
|
+
slideNode: slideNode,
|
|
2265
|
+
slideConfig: slide.slideConfig,
|
|
2266
|
+
slideIndex: this.index,
|
|
2267
|
+
trigger: slide.node,
|
|
2268
|
+
player: null
|
|
2269
|
+
};
|
|
2270
|
+
this.trigger('slide_before_load', slideData);
|
|
2271
|
+
slide.instance.setContent(slideNode, function () {
|
|
2272
|
+
hide(_this2.loader);
|
|
2273
|
+
_this2.resize();
|
|
2274
|
+
_this2.slideAnimateIn(slideNode, first);
|
|
2275
|
+
_this2.trigger('slide_after_load', slideData);
|
|
2276
|
+
});
|
|
2277
|
+
}
|
|
2278
|
+
this.slideDescription = slideNode.querySelector('.gslide-description');
|
|
2279
|
+
this.slideDescriptionContained = this.slideDescription && hasClass(this.slideDescription.parentNode, 'gslide-media');
|
|
2280
|
+
if (this.settings.preload) {
|
|
2281
|
+
this.preloadSlide(index + 1);
|
|
2282
|
+
this.preloadSlide(index - 1);
|
|
2283
|
+
}
|
|
2284
|
+
this.updateNavigationClasses();
|
|
2285
|
+
this.activeSlide = slideNode;
|
|
2286
|
+
}
|
|
2287
|
+
}, {
|
|
2288
|
+
key: "preloadSlide",
|
|
2289
|
+
value: function preloadSlide(index) {
|
|
2290
|
+
var _this3 = this;
|
|
2291
|
+
if (index < 0 || index > this.elements.length - 1) {
|
|
2292
|
+
return false;
|
|
2293
|
+
}
|
|
2294
|
+
if (isNil(this.elements[index])) {
|
|
2295
|
+
return false;
|
|
2296
|
+
}
|
|
2297
|
+
var slideNode = this.slidesContainer.querySelectorAll('.gslide')[index];
|
|
2298
|
+
if (hasClass(slideNode, 'loaded')) {
|
|
2299
|
+
return false;
|
|
2300
|
+
}
|
|
2301
|
+
var slide = this.elements[index];
|
|
2302
|
+
var type = slide.type;
|
|
2303
|
+
var slideData = {
|
|
2304
|
+
index: index,
|
|
2305
|
+
slide: slideNode,
|
|
2306
|
+
slideNode: slideNode,
|
|
2307
|
+
slideConfig: slide.slideConfig,
|
|
2308
|
+
slideIndex: index,
|
|
2309
|
+
trigger: slide.node,
|
|
2310
|
+
player: null
|
|
2311
|
+
};
|
|
2312
|
+
this.trigger('slide_before_load', slideData);
|
|
2313
|
+
if (type === 'video' || type === 'external') {
|
|
2314
|
+
setTimeout(function () {
|
|
2315
|
+
slide.instance.setContent(slideNode, function () {
|
|
2316
|
+
_this3.trigger('slide_after_load', slideData);
|
|
2317
|
+
});
|
|
2318
|
+
}, 200);
|
|
2319
|
+
} else {
|
|
2320
|
+
slide.instance.setContent(slideNode, function () {
|
|
2321
|
+
_this3.trigger('slide_after_load', slideData);
|
|
2322
|
+
});
|
|
2323
|
+
}
|
|
2324
|
+
}
|
|
2325
|
+
}, {
|
|
2326
|
+
key: "prevSlide",
|
|
2327
|
+
value: function prevSlide() {
|
|
2328
|
+
this.goToSlide(this.index - 1);
|
|
2329
|
+
}
|
|
2330
|
+
}, {
|
|
2331
|
+
key: "nextSlide",
|
|
2332
|
+
value: function nextSlide() {
|
|
2333
|
+
this.goToSlide(this.index + 1);
|
|
2334
|
+
}
|
|
2335
|
+
}, {
|
|
2336
|
+
key: "goToSlide",
|
|
2337
|
+
value: function goToSlide() {
|
|
2338
|
+
var index = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
2339
|
+
this.prevActiveSlide = this.activeSlide;
|
|
2340
|
+
this.prevActiveSlideIndex = this.index;
|
|
2341
|
+
if (!this.loop() && (index < 0 || index > this.elements.length - 1)) {
|
|
2342
|
+
return false;
|
|
2343
|
+
}
|
|
2344
|
+
if (index < 0) {
|
|
2345
|
+
index = this.elements.length - 1;
|
|
2346
|
+
} else if (index >= this.elements.length) {
|
|
2347
|
+
index = 0;
|
|
2348
|
+
}
|
|
2349
|
+
this.showSlide(index);
|
|
2350
|
+
}
|
|
2351
|
+
}, {
|
|
2352
|
+
key: "insertSlide",
|
|
2353
|
+
value: function insertSlide() {
|
|
2354
|
+
var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2355
|
+
var index = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : -1;
|
|
2356
|
+
if (index < 0) {
|
|
2357
|
+
index = this.elements.length;
|
|
2358
|
+
}
|
|
2359
|
+
var slide = new Slide(config, this, index);
|
|
2360
|
+
var data = slide.getConfig();
|
|
2361
|
+
var slideInfo = extend({}, data);
|
|
2362
|
+
var newSlide = slide.create();
|
|
2363
|
+
var totalSlides = this.elements.length - 1;
|
|
2364
|
+
slideInfo.index = index;
|
|
2365
|
+
slideInfo.node = false;
|
|
2366
|
+
slideInfo.instance = slide;
|
|
2367
|
+
slideInfo.slideConfig = data;
|
|
2368
|
+
this.elements.splice(index, 0, slideInfo);
|
|
2369
|
+
var addedSlideNode = null;
|
|
2370
|
+
var addedSlidePlayer = null;
|
|
2371
|
+
if (this.slidesContainer) {
|
|
2372
|
+
if (index > totalSlides) {
|
|
2373
|
+
this.slidesContainer.appendChild(newSlide);
|
|
2374
|
+
} else {
|
|
2375
|
+
var existingSlide = this.slidesContainer.querySelectorAll('.gslide')[index];
|
|
2376
|
+
this.slidesContainer.insertBefore(newSlide, existingSlide);
|
|
2377
|
+
}
|
|
2378
|
+
if (this.settings.preload && this.index == 0 && index == 0 || this.index - 1 == index || this.index + 1 == index) {
|
|
2379
|
+
this.preloadSlide(index);
|
|
2380
|
+
}
|
|
2381
|
+
if (this.index === 0 && index === 0) {
|
|
2382
|
+
this.index = 1;
|
|
2383
|
+
}
|
|
2384
|
+
this.updateNavigationClasses();
|
|
2385
|
+
addedSlideNode = this.slidesContainer.querySelectorAll('.gslide')[index];
|
|
2386
|
+
addedSlidePlayer = this.getSlidePlayerInstance(index);
|
|
2387
|
+
slideInfo.slideNode = addedSlideNode;
|
|
2388
|
+
}
|
|
2389
|
+
this.trigger('slide_inserted', {
|
|
2390
|
+
index: index,
|
|
2391
|
+
slide: addedSlideNode,
|
|
2392
|
+
slideNode: addedSlideNode,
|
|
2393
|
+
slideConfig: data,
|
|
2394
|
+
slideIndex: index,
|
|
2395
|
+
trigger: null,
|
|
2396
|
+
player: addedSlidePlayer
|
|
2397
|
+
});
|
|
2398
|
+
if (isFunction(this.settings.slideInserted)) {
|
|
2399
|
+
this.settings.slideInserted({
|
|
2400
|
+
index: index,
|
|
2401
|
+
slide: addedSlideNode,
|
|
2402
|
+
player: addedSlidePlayer
|
|
2403
|
+
});
|
|
2404
|
+
}
|
|
2405
|
+
}
|
|
2406
|
+
}, {
|
|
2407
|
+
key: "removeSlide",
|
|
2408
|
+
value: function removeSlide() {
|
|
2409
|
+
var index = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : -1;
|
|
2410
|
+
if (index < 0 || index > this.elements.length - 1) {
|
|
2411
|
+
return false;
|
|
2412
|
+
}
|
|
2413
|
+
var slide = this.slidesContainer && this.slidesContainer.querySelectorAll('.gslide')[index];
|
|
2414
|
+
if (slide) {
|
|
2415
|
+
if (this.getActiveSlideIndex() == index) {
|
|
2416
|
+
if (index == this.elements.length - 1) {
|
|
2417
|
+
this.prevSlide();
|
|
2418
|
+
} else {
|
|
2419
|
+
this.nextSlide();
|
|
2420
|
+
}
|
|
2421
|
+
}
|
|
2422
|
+
slide.parentNode.removeChild(slide);
|
|
2423
|
+
}
|
|
2424
|
+
this.elements.splice(index, 1);
|
|
2425
|
+
this.trigger('slide_removed', index);
|
|
2426
|
+
if (isFunction(this.settings.slideRemoved)) {
|
|
2427
|
+
this.settings.slideRemoved(index);
|
|
2428
|
+
}
|
|
2429
|
+
}
|
|
2430
|
+
}, {
|
|
2431
|
+
key: "slideAnimateIn",
|
|
2432
|
+
value: function slideAnimateIn(slide, first) {
|
|
2433
|
+
var _this4 = this;
|
|
2434
|
+
var slideMedia = slide.querySelector('.gslide-media');
|
|
2435
|
+
var slideDesc = slide.querySelector('.gslide-description');
|
|
2436
|
+
var prevData = {
|
|
2437
|
+
index: this.prevActiveSlideIndex,
|
|
2438
|
+
slide: this.prevActiveSlide,
|
|
2439
|
+
slideNode: this.prevActiveSlide,
|
|
2440
|
+
slideIndex: this.prevActiveSlide,
|
|
2441
|
+
slideConfig: isNil(this.prevActiveSlideIndex) ? null : this.elements[this.prevActiveSlideIndex].slideConfig,
|
|
2442
|
+
trigger: isNil(this.prevActiveSlideIndex) ? null : this.elements[this.prevActiveSlideIndex].node,
|
|
2443
|
+
player: this.getSlidePlayerInstance(this.prevActiveSlideIndex)
|
|
2444
|
+
};
|
|
2445
|
+
var nextData = {
|
|
2446
|
+
index: this.index,
|
|
2447
|
+
slide: this.activeSlide,
|
|
2448
|
+
slideNode: this.activeSlide,
|
|
2449
|
+
slideConfig: this.elements[this.index].slideConfig,
|
|
2450
|
+
slideIndex: this.index,
|
|
2451
|
+
trigger: this.elements[this.index].node,
|
|
2452
|
+
player: this.getSlidePlayerInstance(this.index)
|
|
2453
|
+
};
|
|
2454
|
+
if (slideMedia.offsetWidth > 0 && slideDesc) {
|
|
2455
|
+
hide(slideDesc);
|
|
2456
|
+
slideDesc.style.display = '';
|
|
2457
|
+
}
|
|
2458
|
+
removeClass(slide, this.effectsClasses);
|
|
2459
|
+
if (first) {
|
|
2460
|
+
animateElement(slide, this.settings.cssEfects[this.settings.openEffect]["in"], function () {
|
|
2461
|
+
if (_this4.settings.autoplayVideos) {
|
|
2462
|
+
_this4.slidePlayerPlay(slide);
|
|
2463
|
+
}
|
|
2464
|
+
_this4.trigger('slide_changed', {
|
|
2465
|
+
prev: prevData,
|
|
2466
|
+
current: nextData
|
|
2467
|
+
});
|
|
2468
|
+
if (isFunction(_this4.settings.afterSlideChange)) {
|
|
2469
|
+
_this4.settings.afterSlideChange.apply(_this4, [prevData, nextData]);
|
|
2470
|
+
}
|
|
2471
|
+
});
|
|
2472
|
+
} else {
|
|
2473
|
+
var effectName = this.settings.slideEffect;
|
|
2474
|
+
var animIn = effectName !== 'none' ? this.settings.cssEfects[effectName]["in"] : effectName;
|
|
2475
|
+
if (this.prevActiveSlideIndex > this.index) {
|
|
2476
|
+
if (this.settings.slideEffect == 'slide') {
|
|
2477
|
+
animIn = this.settings.cssEfects.slideBack["in"];
|
|
2478
|
+
}
|
|
2479
|
+
}
|
|
2480
|
+
animateElement(slide, animIn, function () {
|
|
2481
|
+
if (_this4.settings.autoplayVideos) {
|
|
2482
|
+
_this4.slidePlayerPlay(slide);
|
|
2483
|
+
}
|
|
2484
|
+
_this4.trigger('slide_changed', {
|
|
2485
|
+
prev: prevData,
|
|
2486
|
+
current: nextData
|
|
2487
|
+
});
|
|
2488
|
+
if (isFunction(_this4.settings.afterSlideChange)) {
|
|
2489
|
+
_this4.settings.afterSlideChange.apply(_this4, [prevData, nextData]);
|
|
2490
|
+
}
|
|
2491
|
+
});
|
|
2492
|
+
}
|
|
2493
|
+
setTimeout(function () {
|
|
2494
|
+
_this4.resize(slide);
|
|
2495
|
+
}, 100);
|
|
2496
|
+
addClass(slide, 'current');
|
|
2497
|
+
}
|
|
2498
|
+
}, {
|
|
2499
|
+
key: "slideAnimateOut",
|
|
2500
|
+
value: function slideAnimateOut() {
|
|
2501
|
+
if (!this.prevActiveSlide) {
|
|
2502
|
+
return false;
|
|
2503
|
+
}
|
|
2504
|
+
var prevSlide = this.prevActiveSlide;
|
|
2505
|
+
removeClass(prevSlide, this.effectsClasses);
|
|
2506
|
+
addClass(prevSlide, 'prev');
|
|
2507
|
+
var animation = this.settings.slideEffect;
|
|
2508
|
+
var animOut = animation !== 'none' ? this.settings.cssEfects[animation].out : animation;
|
|
2509
|
+
this.slidePlayerPause(prevSlide);
|
|
2510
|
+
this.trigger('slide_before_change', {
|
|
2511
|
+
prev: {
|
|
2512
|
+
index: this.prevActiveSlideIndex,
|
|
2513
|
+
slide: this.prevActiveSlide,
|
|
2514
|
+
slideNode: this.prevActiveSlide,
|
|
2515
|
+
slideIndex: this.prevActiveSlideIndex,
|
|
2516
|
+
slideConfig: isNil(this.prevActiveSlideIndex) ? null : this.elements[this.prevActiveSlideIndex].slideConfig,
|
|
2517
|
+
trigger: isNil(this.prevActiveSlideIndex) ? null : this.elements[this.prevActiveSlideIndex].node,
|
|
2518
|
+
player: this.getSlidePlayerInstance(this.prevActiveSlideIndex)
|
|
2519
|
+
},
|
|
2520
|
+
current: {
|
|
2521
|
+
index: this.index,
|
|
2522
|
+
slide: this.activeSlide,
|
|
2523
|
+
slideNode: this.activeSlide,
|
|
2524
|
+
slideIndex: this.index,
|
|
2525
|
+
slideConfig: this.elements[this.index].slideConfig,
|
|
2526
|
+
trigger: this.elements[this.index].node,
|
|
2527
|
+
player: this.getSlidePlayerInstance(this.index)
|
|
2528
|
+
}
|
|
2529
|
+
});
|
|
2530
|
+
if (isFunction(this.settings.beforeSlideChange)) {
|
|
2531
|
+
this.settings.beforeSlideChange.apply(this, [{
|
|
2532
|
+
index: this.prevActiveSlideIndex,
|
|
2533
|
+
slide: this.prevActiveSlide,
|
|
2534
|
+
player: this.getSlidePlayerInstance(this.prevActiveSlideIndex)
|
|
2535
|
+
}, {
|
|
2536
|
+
index: this.index,
|
|
2537
|
+
slide: this.activeSlide,
|
|
2538
|
+
player: this.getSlidePlayerInstance(this.index)
|
|
2539
|
+
}]);
|
|
2540
|
+
}
|
|
2541
|
+
if (this.prevActiveSlideIndex > this.index && this.settings.slideEffect == 'slide') {
|
|
2542
|
+
animOut = this.settings.cssEfects.slideBack.out;
|
|
2543
|
+
}
|
|
2544
|
+
animateElement(prevSlide, animOut, function () {
|
|
2545
|
+
var container = prevSlide.querySelector('.ginner-container');
|
|
2546
|
+
var media = prevSlide.querySelector('.gslide-media');
|
|
2547
|
+
var desc = prevSlide.querySelector('.gslide-description');
|
|
2548
|
+
container.style.transform = '';
|
|
2549
|
+
media.style.transform = '';
|
|
2550
|
+
removeClass(media, 'greset');
|
|
2551
|
+
media.style.opacity = '';
|
|
2552
|
+
if (desc) {
|
|
2553
|
+
desc.style.opacity = '';
|
|
2554
|
+
}
|
|
2555
|
+
removeClass(prevSlide, 'prev');
|
|
2556
|
+
});
|
|
2557
|
+
}
|
|
2558
|
+
}, {
|
|
2559
|
+
key: "getAllPlayers",
|
|
2560
|
+
value: function getAllPlayers() {
|
|
2561
|
+
return this.videoPlayers;
|
|
2562
|
+
}
|
|
2563
|
+
}, {
|
|
2564
|
+
key: "getSlidePlayerInstance",
|
|
2565
|
+
value: function getSlidePlayerInstance(index) {
|
|
2566
|
+
var id = 'gvideo' + index;
|
|
2567
|
+
var videoPlayers = this.getAllPlayers();
|
|
2568
|
+
if (has(videoPlayers, id) && videoPlayers[id]) {
|
|
2569
|
+
return videoPlayers[id];
|
|
2570
|
+
}
|
|
2571
|
+
return false;
|
|
2572
|
+
}
|
|
2573
|
+
}, {
|
|
2574
|
+
key: "stopSlideVideo",
|
|
2575
|
+
value: function stopSlideVideo(slide) {
|
|
2576
|
+
if (isNode(slide)) {
|
|
2577
|
+
var node = slide.querySelector('.gvideo-wrapper');
|
|
2578
|
+
if (node) {
|
|
2579
|
+
slide = node.getAttribute('data-index');
|
|
2580
|
+
}
|
|
2581
|
+
}
|
|
2582
|
+
console.log('stopSlideVideo is deprecated, use slidePlayerPause');
|
|
2583
|
+
var player = this.getSlidePlayerInstance(slide);
|
|
2584
|
+
if (player && player.playing) {
|
|
2585
|
+
player.pause();
|
|
2586
|
+
}
|
|
2587
|
+
}
|
|
2588
|
+
}, {
|
|
2589
|
+
key: "slidePlayerPause",
|
|
2590
|
+
value: function slidePlayerPause(slide) {
|
|
2591
|
+
if (isNode(slide)) {
|
|
2592
|
+
var node = slide.querySelector('.gvideo-wrapper');
|
|
2593
|
+
if (node) {
|
|
2594
|
+
slide = node.getAttribute('data-index');
|
|
2595
|
+
}
|
|
2596
|
+
}
|
|
2597
|
+
var player = this.getSlidePlayerInstance(slide);
|
|
2598
|
+
if (player && player.playing) {
|
|
2599
|
+
player.pause();
|
|
2600
|
+
}
|
|
2601
|
+
}
|
|
2602
|
+
}, {
|
|
2603
|
+
key: "playSlideVideo",
|
|
2604
|
+
value: function playSlideVideo(slide) {
|
|
2605
|
+
if (isNode(slide)) {
|
|
2606
|
+
var node = slide.querySelector('.gvideo-wrapper');
|
|
2607
|
+
if (node) {
|
|
2608
|
+
slide = node.getAttribute('data-index');
|
|
2609
|
+
}
|
|
2610
|
+
}
|
|
2611
|
+
console.log('playSlideVideo is deprecated, use slidePlayerPlay');
|
|
2612
|
+
var player = this.getSlidePlayerInstance(slide);
|
|
2613
|
+
if (player && !player.playing) {
|
|
2614
|
+
player.play();
|
|
2615
|
+
}
|
|
2616
|
+
}
|
|
2617
|
+
}, {
|
|
2618
|
+
key: "slidePlayerPlay",
|
|
2619
|
+
value: function slidePlayerPlay(slide) {
|
|
2620
|
+
var _this$settings$plyr$c;
|
|
2621
|
+
if (isMobile$1 && !((_this$settings$plyr$c = this.settings.plyr.config) !== null && _this$settings$plyr$c !== void 0 && _this$settings$plyr$c.muted)) {
|
|
2622
|
+
return;
|
|
2623
|
+
}
|
|
2624
|
+
if (isNode(slide)) {
|
|
2625
|
+
var node = slide.querySelector('.gvideo-wrapper');
|
|
2626
|
+
if (node) {
|
|
2627
|
+
slide = node.getAttribute('data-index');
|
|
2628
|
+
}
|
|
2629
|
+
}
|
|
2630
|
+
var player = this.getSlidePlayerInstance(slide);
|
|
2631
|
+
if (player && !player.playing) {
|
|
2632
|
+
player.play();
|
|
2633
|
+
if (this.settings.autofocusVideos) {
|
|
2634
|
+
player.elements.container.focus();
|
|
2635
|
+
}
|
|
2636
|
+
}
|
|
2637
|
+
}
|
|
2638
|
+
}, {
|
|
2639
|
+
key: "setElements",
|
|
2640
|
+
value: function setElements(elements) {
|
|
2641
|
+
var _this5 = this;
|
|
2642
|
+
this.settings.elements = false;
|
|
2643
|
+
var newElements = [];
|
|
2644
|
+
if (elements && elements.length) {
|
|
2645
|
+
each(elements, function (el, i) {
|
|
2646
|
+
var slide = new Slide(el, _this5, i);
|
|
2647
|
+
var data = slide.getConfig();
|
|
2648
|
+
var slideInfo = extend({}, data);
|
|
2649
|
+
slideInfo.slideConfig = data;
|
|
2650
|
+
slideInfo.instance = slide;
|
|
2651
|
+
slideInfo.index = i;
|
|
2652
|
+
newElements.push(slideInfo);
|
|
2653
|
+
});
|
|
2654
|
+
}
|
|
2655
|
+
this.elements = newElements;
|
|
2656
|
+
if (this.lightboxOpen) {
|
|
2657
|
+
this.slidesContainer.innerHTML = '';
|
|
2658
|
+
if (this.elements.length) {
|
|
2659
|
+
each(this.elements, function () {
|
|
2660
|
+
var slide = createHTML(_this5.settings.slideHTML);
|
|
2661
|
+
_this5.slidesContainer.appendChild(slide);
|
|
2662
|
+
});
|
|
2663
|
+
this.showSlide(0, true);
|
|
2664
|
+
}
|
|
2665
|
+
}
|
|
2666
|
+
}
|
|
2667
|
+
}, {
|
|
2668
|
+
key: "getElementIndex",
|
|
2669
|
+
value: function getElementIndex(node) {
|
|
2670
|
+
var index = false;
|
|
2671
|
+
each(this.elements, function (el, i) {
|
|
2672
|
+
if (has(el, 'node') && el.node == node) {
|
|
2673
|
+
index = i;
|
|
2674
|
+
return true;
|
|
2675
|
+
}
|
|
2676
|
+
});
|
|
2677
|
+
return index;
|
|
2678
|
+
}
|
|
2679
|
+
}, {
|
|
2680
|
+
key: "getElements",
|
|
2681
|
+
value: function getElements() {
|
|
2682
|
+
var _this6 = this;
|
|
2683
|
+
var list = [];
|
|
2684
|
+
this.elements = this.elements ? this.elements : [];
|
|
2685
|
+
if (!isNil(this.settings.elements) && isArray(this.settings.elements) && this.settings.elements.length) {
|
|
2686
|
+
each(this.settings.elements, function (el, i) {
|
|
2687
|
+
var slide = new Slide(el, _this6, i);
|
|
2688
|
+
var elData = slide.getConfig();
|
|
2689
|
+
var slideInfo = extend({}, elData);
|
|
2690
|
+
slideInfo.node = false;
|
|
2691
|
+
slideInfo.index = i;
|
|
2692
|
+
slideInfo.instance = slide;
|
|
2693
|
+
slideInfo.slideConfig = elData;
|
|
2694
|
+
list.push(slideInfo);
|
|
2695
|
+
});
|
|
2696
|
+
}
|
|
2697
|
+
var nodes = false;
|
|
2698
|
+
var selector = this.getSelector();
|
|
2699
|
+
if (selector) {
|
|
2700
|
+
nodes = document.querySelectorAll(this.getSelector());
|
|
2701
|
+
}
|
|
2702
|
+
if (!nodes) {
|
|
2703
|
+
return list;
|
|
2704
|
+
}
|
|
2705
|
+
each(nodes, function (el, i) {
|
|
2706
|
+
var slide = new Slide(el, _this6, i);
|
|
2707
|
+
var elData = slide.getConfig();
|
|
2708
|
+
var slideInfo = extend({}, elData);
|
|
2709
|
+
slideInfo.node = el;
|
|
2710
|
+
slideInfo.index = i;
|
|
2711
|
+
slideInfo.instance = slide;
|
|
2712
|
+
slideInfo.slideConfig = elData;
|
|
2713
|
+
slideInfo.gallery = el.getAttribute('data-gallery');
|
|
2714
|
+
list.push(slideInfo);
|
|
2715
|
+
});
|
|
2716
|
+
return list;
|
|
2717
|
+
}
|
|
2718
|
+
}, {
|
|
2719
|
+
key: "getGalleryElements",
|
|
2720
|
+
value: function getGalleryElements(list, gallery) {
|
|
2721
|
+
return list.filter(function (el) {
|
|
2722
|
+
return el.gallery == gallery;
|
|
2723
|
+
});
|
|
2724
|
+
}
|
|
2725
|
+
}, {
|
|
2726
|
+
key: "getSelector",
|
|
2727
|
+
value: function getSelector() {
|
|
2728
|
+
if (this.settings.elements) {
|
|
2729
|
+
return false;
|
|
2730
|
+
}
|
|
2731
|
+
if (this.settings.selector && this.settings.selector.substring(0, 5) == 'data-') {
|
|
2732
|
+
return "*[".concat(this.settings.selector, "]");
|
|
2733
|
+
}
|
|
2734
|
+
return this.settings.selector;
|
|
2735
|
+
}
|
|
2736
|
+
}, {
|
|
2737
|
+
key: "getActiveSlide",
|
|
2738
|
+
value: function getActiveSlide() {
|
|
2739
|
+
return this.slidesContainer.querySelectorAll('.gslide')[this.index];
|
|
2740
|
+
}
|
|
2741
|
+
}, {
|
|
2742
|
+
key: "getActiveSlideIndex",
|
|
2743
|
+
value: function getActiveSlideIndex() {
|
|
2744
|
+
return this.index;
|
|
2745
|
+
}
|
|
2746
|
+
}, {
|
|
2747
|
+
key: "getAnimationClasses",
|
|
2748
|
+
value: function getAnimationClasses() {
|
|
2749
|
+
var effects = [];
|
|
2750
|
+
for (var key in this.settings.cssEfects) {
|
|
2751
|
+
if (this.settings.cssEfects.hasOwnProperty(key)) {
|
|
2752
|
+
var effect = this.settings.cssEfects[key];
|
|
2753
|
+
effects.push("g".concat(effect["in"]));
|
|
2754
|
+
effects.push("g".concat(effect.out));
|
|
2755
|
+
}
|
|
2756
|
+
}
|
|
2757
|
+
return effects.join(' ');
|
|
2758
|
+
}
|
|
2759
|
+
}, {
|
|
2760
|
+
key: "build",
|
|
2761
|
+
value: function build() {
|
|
2762
|
+
var _this$settings$closeB,
|
|
2763
|
+
_this$settings$prevBu,
|
|
2764
|
+
_this$settings$nextBu,
|
|
2765
|
+
_this7 = this;
|
|
2766
|
+
if (this.built) {
|
|
2767
|
+
return false;
|
|
2768
|
+
}
|
|
2769
|
+
var children = document.body.childNodes;
|
|
2770
|
+
var bodyChildElms = [];
|
|
2771
|
+
each(children, function (el) {
|
|
2772
|
+
if (el.parentNode == document.body && el.nodeName.charAt(0) !== '#' && el.hasAttribute && !el.hasAttribute('aria-hidden')) {
|
|
2773
|
+
bodyChildElms.push(el);
|
|
2774
|
+
el.setAttribute('aria-hidden', 'true');
|
|
2775
|
+
}
|
|
2776
|
+
});
|
|
2777
|
+
var nextSVG = has(this.settings.svg, 'next') ? this.settings.svg.next : '';
|
|
2778
|
+
var prevSVG = has(this.settings.svg, 'prev') ? this.settings.svg.prev : '';
|
|
2779
|
+
var closeSVG = has(this.settings.svg, 'close') ? this.settings.svg.close : '';
|
|
2780
|
+
var closeButtonText = (_this$settings$closeB = this.settings.closeButtonText) !== null && _this$settings$closeB !== void 0 ? _this$settings$closeB : 'Close';
|
|
2781
|
+
var prevButtonText = (_this$settings$prevBu = this.settings.prevButtonText) !== null && _this$settings$prevBu !== void 0 ? _this$settings$prevBu : 'Previous';
|
|
2782
|
+
var nextButtonText = (_this$settings$nextBu = this.settings.nextButtonText) !== null && _this$settings$nextBu !== void 0 ? _this$settings$nextBu : 'Next';
|
|
2783
|
+
var lightboxHTML = this.settings.lightboxHTML;
|
|
2784
|
+
lightboxHTML = lightboxHTML.replace(/{nextSVG}/g, nextSVG);
|
|
2785
|
+
lightboxHTML = lightboxHTML.replace(/{prevSVG}/g, prevSVG);
|
|
2786
|
+
lightboxHTML = lightboxHTML.replace(/{closeSVG}/g, closeSVG);
|
|
2787
|
+
lightboxHTML = lightboxHTML.replace(/{closeButtonText}/g, closeButtonText);
|
|
2788
|
+
lightboxHTML = lightboxHTML.replace(/{prevButtonText}/g, prevButtonText);
|
|
2789
|
+
lightboxHTML = lightboxHTML.replace(/{nextButtonText}/g, nextButtonText);
|
|
2790
|
+
lightboxHTML = createHTML(lightboxHTML);
|
|
2791
|
+
document.body.appendChild(lightboxHTML);
|
|
2792
|
+
var modal = document.getElementById('glightbox-body');
|
|
2793
|
+
this.modal = modal;
|
|
2794
|
+
var closeButton = modal.querySelector('.gclose');
|
|
2795
|
+
this.prevButton = modal.querySelector('.gprev');
|
|
2796
|
+
this.nextButton = modal.querySelector('.gnext');
|
|
2797
|
+
this.overlay = modal.querySelector('.goverlay');
|
|
2798
|
+
this.loader = modal.querySelector('.gloader');
|
|
2799
|
+
this.slidesContainer = document.getElementById('glightbox-slider');
|
|
2800
|
+
this.bodyHiddenChildElms = bodyChildElms;
|
|
2801
|
+
this.events = {};
|
|
2802
|
+
addClass(this.modal, 'glightbox-' + this.settings.skin);
|
|
2803
|
+
if (this.settings.closeButton && closeButton) {
|
|
2804
|
+
this.events['close'] = addEvent('click', {
|
|
2805
|
+
onElement: closeButton,
|
|
2806
|
+
withCallback: function withCallback(e, target) {
|
|
2807
|
+
e.preventDefault();
|
|
2808
|
+
_this7.close();
|
|
2809
|
+
}
|
|
2810
|
+
});
|
|
2811
|
+
}
|
|
2812
|
+
if (closeButton && !this.settings.closeButton) {
|
|
2813
|
+
closeButton.parentNode.removeChild(closeButton);
|
|
2814
|
+
}
|
|
2815
|
+
if (this.nextButton) {
|
|
2816
|
+
this.events['next'] = addEvent('click', {
|
|
2817
|
+
onElement: this.nextButton,
|
|
2818
|
+
withCallback: function withCallback(e, target) {
|
|
2819
|
+
e.preventDefault();
|
|
2820
|
+
_this7.nextSlide();
|
|
2821
|
+
}
|
|
2822
|
+
});
|
|
2823
|
+
}
|
|
2824
|
+
if (this.prevButton) {
|
|
2825
|
+
this.events['prev'] = addEvent('click', {
|
|
2826
|
+
onElement: this.prevButton,
|
|
2827
|
+
withCallback: function withCallback(e, target) {
|
|
2828
|
+
e.preventDefault();
|
|
2829
|
+
_this7.prevSlide();
|
|
2830
|
+
}
|
|
2831
|
+
});
|
|
2832
|
+
}
|
|
2833
|
+
if (this.settings.closeOnOutsideClick) {
|
|
2834
|
+
this.events['outClose'] = addEvent('click', {
|
|
2835
|
+
onElement: modal,
|
|
2836
|
+
withCallback: function withCallback(e, target) {
|
|
2837
|
+
if (!_this7.preventOutsideClick && !hasClass(document.body, 'glightbox-mobile') && !closest(e.target, '.ginner-container')) {
|
|
2838
|
+
if (!closest(e.target, '.gbtn') && !hasClass(e.target, 'gnext') && !hasClass(e.target, 'gprev')) {
|
|
2839
|
+
_this7.close();
|
|
2840
|
+
}
|
|
2841
|
+
}
|
|
2842
|
+
}
|
|
2843
|
+
});
|
|
2844
|
+
}
|
|
2845
|
+
each(this.elements, function (slide, i) {
|
|
2846
|
+
_this7.slidesContainer.appendChild(slide.instance.create());
|
|
2847
|
+
slide.slideNode = _this7.slidesContainer.querySelectorAll('.gslide')[i];
|
|
2848
|
+
});
|
|
2849
|
+
if (isTouch$1) {
|
|
2850
|
+
addClass(document.body, 'glightbox-touch');
|
|
2851
|
+
}
|
|
2852
|
+
this.events['resize'] = addEvent('resize', {
|
|
2853
|
+
onElement: window,
|
|
2854
|
+
withCallback: function withCallback() {
|
|
2855
|
+
_this7.resize();
|
|
2856
|
+
}
|
|
2857
|
+
});
|
|
2858
|
+
this.built = true;
|
|
2859
|
+
}
|
|
2860
|
+
}, {
|
|
2861
|
+
key: "resize",
|
|
2862
|
+
value: function resize() {
|
|
2863
|
+
var slide = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
2864
|
+
slide = !slide ? this.activeSlide : slide;
|
|
2865
|
+
if (!slide || hasClass(slide, 'zoomed')) {
|
|
2866
|
+
return;
|
|
2867
|
+
}
|
|
2868
|
+
var winSize = windowSize();
|
|
2869
|
+
var video = slide.querySelector('.gvideo-wrapper');
|
|
2870
|
+
var image = slide.querySelector('.gslide-image');
|
|
2871
|
+
var description = this.slideDescription;
|
|
2872
|
+
var winWidth = winSize.width;
|
|
2873
|
+
var winHeight = winSize.height;
|
|
2874
|
+
if (winWidth <= 768) {
|
|
2875
|
+
addClass(document.body, 'glightbox-mobile');
|
|
2876
|
+
} else {
|
|
2877
|
+
removeClass(document.body, 'glightbox-mobile');
|
|
2878
|
+
}
|
|
2879
|
+
if (!video && !image) {
|
|
2880
|
+
return;
|
|
2881
|
+
}
|
|
2882
|
+
var descriptionResize = false;
|
|
2883
|
+
if (description && (hasClass(description, 'description-bottom') || hasClass(description, 'description-top')) && !hasClass(description, 'gabsolute')) {
|
|
2884
|
+
descriptionResize = true;
|
|
2885
|
+
}
|
|
2886
|
+
if (image) {
|
|
2887
|
+
if (winWidth <= 768) {
|
|
2888
|
+
var imgNode = image.querySelector('img');
|
|
2889
|
+
} else if (descriptionResize) {
|
|
2890
|
+
var _this$elements$this$i;
|
|
2891
|
+
var descHeight = description.offsetHeight;
|
|
2892
|
+
var _imgNode = image.querySelector('img');
|
|
2893
|
+
var slideTriggerNode = (_this$elements$this$i = this.elements[this.index]) === null || _this$elements$this$i === void 0 ? void 0 : _this$elements$this$i.node;
|
|
2894
|
+
var maxHeightValue = '100vh';
|
|
2895
|
+
if (slideTriggerNode) {
|
|
2896
|
+
var _slideTriggerNode$get;
|
|
2897
|
+
maxHeightValue = (_slideTriggerNode$get = slideTriggerNode.getAttribute('data-height')) !== null && _slideTriggerNode$get !== void 0 ? _slideTriggerNode$get : maxHeightValue;
|
|
2898
|
+
}
|
|
2899
|
+
_imgNode.setAttribute('style', "max-height: calc(".concat(maxHeightValue, " - ").concat(descHeight, "px)"));
|
|
2900
|
+
description.setAttribute('style', "max-width: ".concat(_imgNode.offsetWidth, "px;"));
|
|
2901
|
+
}
|
|
2902
|
+
}
|
|
2903
|
+
if (video) {
|
|
2904
|
+
var ratio = has(this.settings.plyr.config, 'ratio') ? this.settings.plyr.config.ratio : '';
|
|
2905
|
+
if (!ratio) {
|
|
2906
|
+
var containerWidth = video.clientWidth;
|
|
2907
|
+
var containerHeight = video.clientHeight;
|
|
2908
|
+
var divisor = containerWidth / containerHeight;
|
|
2909
|
+
ratio = "".concat(containerWidth / divisor, ":").concat(containerHeight / divisor);
|
|
2910
|
+
}
|
|
2911
|
+
var videoRatio = ratio.split(':');
|
|
2912
|
+
var videoWidth = this.settings.videosWidth;
|
|
2913
|
+
var maxWidth = this.settings.videosWidth;
|
|
2914
|
+
if (isNumber(videoWidth) || videoWidth.indexOf('px') !== -1) {
|
|
2915
|
+
maxWidth = parseInt(videoWidth);
|
|
2916
|
+
} else {
|
|
2917
|
+
if (videoWidth.indexOf('vw') !== -1) {
|
|
2918
|
+
maxWidth = winWidth * parseInt(videoWidth) / 100;
|
|
2919
|
+
} else if (videoWidth.indexOf('vh') !== -1) {
|
|
2920
|
+
maxWidth = winHeight * parseInt(videoWidth) / 100;
|
|
2921
|
+
} else if (videoWidth.indexOf('%') !== -1) {
|
|
2922
|
+
maxWidth = winWidth * parseInt(videoWidth) / 100;
|
|
2923
|
+
} else {
|
|
2924
|
+
maxWidth = parseInt(video.clientWidth);
|
|
2925
|
+
}
|
|
2926
|
+
}
|
|
2927
|
+
var maxHeight = maxWidth / (parseInt(videoRatio[0]) / parseInt(videoRatio[1]));
|
|
2928
|
+
maxHeight = Math.floor(maxHeight);
|
|
2929
|
+
if (descriptionResize) {
|
|
2930
|
+
winHeight = winHeight - description.offsetHeight;
|
|
2931
|
+
}
|
|
2932
|
+
if (maxWidth > winWidth || maxHeight > winHeight || winHeight < maxHeight && winWidth > maxWidth) {
|
|
2933
|
+
var vwidth = video.offsetWidth;
|
|
2934
|
+
var vheight = video.offsetHeight;
|
|
2935
|
+
var _ratio = winHeight / vheight;
|
|
2936
|
+
var vsize = {
|
|
2937
|
+
width: vwidth * _ratio,
|
|
2938
|
+
height: vheight * _ratio
|
|
2939
|
+
};
|
|
2940
|
+
video.parentNode.setAttribute('style', "max-width: ".concat(vsize.width, "px"));
|
|
2941
|
+
if (descriptionResize) {
|
|
2942
|
+
description.setAttribute('style', "max-width: ".concat(vsize.width, "px;"));
|
|
2943
|
+
}
|
|
2944
|
+
} else {
|
|
2945
|
+
video.parentNode.style.maxWidth = "".concat(videoWidth);
|
|
2946
|
+
if (descriptionResize) {
|
|
2947
|
+
description.setAttribute('style', "max-width: ".concat(videoWidth, ";"));
|
|
2948
|
+
}
|
|
2949
|
+
}
|
|
2950
|
+
}
|
|
2951
|
+
}
|
|
2952
|
+
}, {
|
|
2953
|
+
key: "reload",
|
|
2954
|
+
value: function reload() {
|
|
2955
|
+
this.init();
|
|
2956
|
+
}
|
|
2957
|
+
}, {
|
|
2958
|
+
key: "updateNavigationClasses",
|
|
2959
|
+
value: function updateNavigationClasses() {
|
|
2960
|
+
var loop = this.loop();
|
|
2961
|
+
removeClass(this.nextButton, 'disabled');
|
|
2962
|
+
removeClass(this.prevButton, 'disabled');
|
|
2963
|
+
if (this.index == 0 && this.elements.length - 1 == 0) {
|
|
2964
|
+
addClass(this.prevButton, 'disabled');
|
|
2965
|
+
addClass(this.nextButton, 'disabled');
|
|
2966
|
+
} else if (this.index === 0 && !loop) {
|
|
2967
|
+
addClass(this.prevButton, 'disabled');
|
|
2968
|
+
} else if (this.index === this.elements.length - 1 && !loop) {
|
|
2969
|
+
addClass(this.nextButton, 'disabled');
|
|
2970
|
+
}
|
|
2971
|
+
}
|
|
2972
|
+
}, {
|
|
2973
|
+
key: "loop",
|
|
2974
|
+
value: function loop() {
|
|
2975
|
+
var loop = has(this.settings, 'loopAtEnd') ? this.settings.loopAtEnd : null;
|
|
2976
|
+
loop = has(this.settings, 'loop') ? this.settings.loop : loop;
|
|
2977
|
+
return loop;
|
|
2978
|
+
}
|
|
2979
|
+
}, {
|
|
2980
|
+
key: "close",
|
|
2981
|
+
value: function close() {
|
|
2982
|
+
var _this8 = this;
|
|
2983
|
+
if (!this.lightboxOpen) {
|
|
2984
|
+
if (this.events) {
|
|
2985
|
+
for (var key in this.events) {
|
|
2986
|
+
if (this.events.hasOwnProperty(key)) {
|
|
2987
|
+
this.events[key].destroy();
|
|
2988
|
+
}
|
|
2989
|
+
}
|
|
2990
|
+
this.events = null;
|
|
2991
|
+
}
|
|
2992
|
+
return false;
|
|
2993
|
+
}
|
|
2994
|
+
if (this.closing) {
|
|
2995
|
+
return false;
|
|
2996
|
+
}
|
|
2997
|
+
this.closing = true;
|
|
2998
|
+
this.slidePlayerPause(this.activeSlide);
|
|
2999
|
+
if (this.fullElementsList) {
|
|
3000
|
+
this.elements = this.fullElementsList;
|
|
3001
|
+
}
|
|
3002
|
+
if (this.bodyHiddenChildElms.length) {
|
|
3003
|
+
each(this.bodyHiddenChildElms, function (el) {
|
|
3004
|
+
el.removeAttribute('aria-hidden');
|
|
3005
|
+
});
|
|
3006
|
+
}
|
|
3007
|
+
addClass(this.modal, 'glightbox-closing');
|
|
3008
|
+
animateElement(this.overlay, this.settings.openEffect == 'none' ? 'none' : this.settings.cssEfects.fade.out);
|
|
3009
|
+
animateElement(this.activeSlide, this.settings.cssEfects[this.settings.closeEffect].out, function () {
|
|
3010
|
+
_this8.activeSlide = null;
|
|
3011
|
+
_this8.prevActiveSlideIndex = null;
|
|
3012
|
+
_this8.prevActiveSlide = null;
|
|
3013
|
+
_this8.built = false;
|
|
3014
|
+
if (_this8.events) {
|
|
3015
|
+
for (var _key in _this8.events) {
|
|
3016
|
+
if (_this8.events.hasOwnProperty(_key)) {
|
|
3017
|
+
_this8.events[_key].destroy();
|
|
3018
|
+
}
|
|
3019
|
+
}
|
|
3020
|
+
_this8.events = null;
|
|
3021
|
+
}
|
|
3022
|
+
var body = document.body;
|
|
3023
|
+
removeClass(html, 'glightbox-open');
|
|
3024
|
+
removeClass(body, 'glightbox-open touching gdesc-open glightbox-touch glightbox-mobile gscrollbar-fixer');
|
|
3025
|
+
_this8.modal.parentNode.removeChild(_this8.modal);
|
|
3026
|
+
_this8.trigger('close');
|
|
3027
|
+
if (isFunction(_this8.settings.onClose)) {
|
|
3028
|
+
_this8.settings.onClose();
|
|
3029
|
+
}
|
|
3030
|
+
var styles = document.querySelector('.gcss-styles');
|
|
3031
|
+
if (styles) {
|
|
3032
|
+
styles.parentNode.removeChild(styles);
|
|
3033
|
+
}
|
|
3034
|
+
_this8.lightboxOpen = false;
|
|
3035
|
+
_this8.closing = null;
|
|
3036
|
+
});
|
|
3037
|
+
}
|
|
3038
|
+
}, {
|
|
3039
|
+
key: "destroy",
|
|
3040
|
+
value: function destroy() {
|
|
3041
|
+
this.close();
|
|
3042
|
+
this.clearAllEvents();
|
|
3043
|
+
if (this.baseEvents) {
|
|
3044
|
+
this.baseEvents.destroy();
|
|
3045
|
+
}
|
|
3046
|
+
}
|
|
3047
|
+
}, {
|
|
3048
|
+
key: "on",
|
|
3049
|
+
value: function on(evt, callback) {
|
|
3050
|
+
var once = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
3051
|
+
if (!evt || !isFunction(callback)) {
|
|
3052
|
+
throw new TypeError('Event name and callback must be defined');
|
|
3053
|
+
}
|
|
3054
|
+
this.apiEvents.push({
|
|
3055
|
+
evt: evt,
|
|
3056
|
+
once: once,
|
|
3057
|
+
callback: callback
|
|
3058
|
+
});
|
|
3059
|
+
}
|
|
3060
|
+
}, {
|
|
3061
|
+
key: "once",
|
|
3062
|
+
value: function once(evt, callback) {
|
|
3063
|
+
this.on(evt, callback, true);
|
|
3064
|
+
}
|
|
3065
|
+
}, {
|
|
3066
|
+
key: "trigger",
|
|
3067
|
+
value: function trigger(eventName) {
|
|
3068
|
+
var _this9 = this;
|
|
3069
|
+
var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
3070
|
+
var onceTriggered = [];
|
|
3071
|
+
each(this.apiEvents, function (event, i) {
|
|
3072
|
+
var evt = event.evt,
|
|
3073
|
+
once = event.once,
|
|
3074
|
+
callback = event.callback;
|
|
3075
|
+
if (evt == eventName) {
|
|
3076
|
+
callback(data);
|
|
3077
|
+
if (once) {
|
|
3078
|
+
onceTriggered.push(i);
|
|
3079
|
+
}
|
|
3080
|
+
}
|
|
3081
|
+
});
|
|
3082
|
+
if (onceTriggered.length) {
|
|
3083
|
+
each(onceTriggered, function (i) {
|
|
3084
|
+
return _this9.apiEvents.splice(i, 1);
|
|
3085
|
+
});
|
|
3086
|
+
}
|
|
3087
|
+
}
|
|
3088
|
+
}, {
|
|
3089
|
+
key: "clearAllEvents",
|
|
3090
|
+
value: function clearAllEvents() {
|
|
3091
|
+
this.apiEvents.splice(0, this.apiEvents.length);
|
|
3092
|
+
}
|
|
3093
|
+
}, {
|
|
3094
|
+
key: "version",
|
|
3095
|
+
value: function version() {
|
|
3096
|
+
return _version;
|
|
3097
|
+
}
|
|
3098
|
+
}]);
|
|
3099
|
+
}();
|
|
3100
|
+
function glightbox () {
|
|
3101
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
3102
|
+
var instance = new GlightboxInit(options);
|
|
3103
|
+
instance.init();
|
|
3104
|
+
return instance;
|
|
3105
|
+
}
|
|
3106
|
+
|
|
3107
|
+
return glightbox;
|
|
3108
|
+
|
|
3109
|
+
})));
|