lightbox-bootstrap-rails 4.alpha5.0 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -4
- data/lib/lightbox/bootstrap/rails/version.rb +1 -1
- data/vendor/assets/javascripts/lightbox-bootstrap/ekko-lightbox.js +602 -398
- data/vendor/assets/javascripts/lightbox-bootstrap/ekko-lightbox.js.map +1 -0
- data/vendor/assets/javascripts/lightbox-bootstrap/ekko-lightbox.min.js +2 -7
- data/vendor/assets/javascripts/lightbox-bootstrap/ekko-lightbox.min.js.map +1 -0
- data/vendor/assets/stylesheets/lightbox-bootstrap/ekko-lightbox.css +2 -62
- data/vendor/assets/stylesheets/lightbox-bootstrap/ekko-lightbox.min.css +2 -6
- data/vendor/assets/stylesheets/lightbox-bootstrap/ekko-lightbox.min.css.map +1 -0
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b486085e5a08b5e755c05d4a1f2f80da6e8534b
|
4
|
+
data.tar.gz: 2ffcd305f0a8b36069fd00177aa86714f7b49247
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 45dca40428ef2458e609ce791010e2e39ca378faf452b40a4fad921885de5a10b23a6d07b64b05ed6c868bceed85b031573eec97b049ce4e2be077ddcb1bdf5a
|
7
|
+
data.tar.gz: 2f1597ca8cdb6f63a85e36f76c9a0d2f9afba2f80f6005f6b711640794dc0975b0f6f5878247501e71e413637f5e1721f27d7ea732b22684138b7d72babdef36
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
# Lightbox for Bootstrap
|
1
|
+
# Lightbox for Bootstrap 4
|
2
2
|
|
3
|
-
This gem was built for the use of 'Lightbox for Bootstrap
|
3
|
+
This gem was built for the use of 'Lightbox for Bootstrap 4' as Rails assets pipeline and you can look for the detailed documents at http://ashleydw.github.io/lightbox/
|
4
4
|
|
5
5
|
[![Gem Version](https://badge.fury.io/rb/lightbox-bootstrap-rails.svg)](http://badge.fury.io/rb/lightbox-bootstrap-rails)
|
6
6
|
|
@@ -9,7 +9,7 @@ This gem was built for the use of 'Lightbox for Bootstrap 3 and 4' as Rails asse
|
|
9
9
|
Add this line to your application's Gemfile:
|
10
10
|
|
11
11
|
```ruby
|
12
|
-
gem 'lightbox-bootstrap-rails'
|
12
|
+
gem 'lightbox-bootstrap-rails', '5.0.0'
|
13
13
|
```
|
14
14
|
|
15
15
|
And then execute:
|
@@ -70,7 +70,8 @@ Among the gem sources, a test application is provided and there you can find how
|
|
70
70
|
- v 3.3.0.0 : initially created.
|
71
71
|
- v 3.3.0.1 : deployed to Rubygems.org
|
72
72
|
- v 3.3.0.2 : modified @import stylesheet syntax
|
73
|
-
- v 3.3.0.3 : fixed typos in ekko-lightbox.min.js and ekko-lightbox.js
|
73
|
+
- v 3.3.0.3 : fixed typos in ekko-lightbox.min.js and ekko-lightbox.js ([lightbox v4.0.2](https://github.com/ashleydw/lightbox/tree/v4.0.2) for Boostrap 3).
|
74
|
+
- v 5.0.0.0 : updated with [lightbox v5.0.0](https://github.com/ashleydw/lightbox/tree/v5.0.0) for Boostrap 4.
|
74
75
|
|
75
76
|
## Contributing
|
76
77
|
|
@@ -1,398 +1,602 @@
|
|
1
|
-
|
2
|
-
Lightbox for Bootstrap
|
3
|
-
https://github.com/ashleydw/lightbox
|
4
|
-
|
5
|
-
License: https://github.com/ashleydw/lightbox/blob/master/LICENSE
|
6
|
-
*/
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
1
|
+
/*!
|
2
|
+
* Lightbox for Bootstrap by @ashleydw
|
3
|
+
* https://github.com/ashleydw/lightbox
|
4
|
+
*
|
5
|
+
* License: https://github.com/ashleydw/lightbox/blob/master/LICENSE
|
6
|
+
*/
|
7
|
+
+function ($) {
|
8
|
+
|
9
|
+
'use strict';
|
10
|
+
|
11
|
+
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
|
12
|
+
|
13
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
|
14
|
+
|
15
|
+
var Lightbox = (function ($) {
|
16
|
+
|
17
|
+
var NAME = 'ekkoLightbox';
|
18
|
+
var JQUERY_NO_CONFLICT = $.fn[NAME];
|
19
|
+
|
20
|
+
var Default = {
|
21
|
+
title: '',
|
22
|
+
footer: '',
|
23
|
+
showArrows: true, //display the left / right arrows or not
|
24
|
+
type: null, //force the lightbox into image / youtube mode. if null, or not image|youtube|vimeo; detect it
|
25
|
+
alwaysShowClose: false, //always show the close button, even if there is no title
|
26
|
+
loadingMessage: '<div class="ekko-lightbox-loader"><div><div></div><div></div></div></div>', // http://tobiasahlin.com/spinkit/
|
27
|
+
leftArrow: '<span>❮</span>',
|
28
|
+
rightArrow: '<span>❯</span>',
|
29
|
+
strings: {
|
30
|
+
close: 'Close',
|
31
|
+
fail: 'Failed to load image:',
|
32
|
+
type: 'Could not detect remote target type. Force the type using data-type'
|
33
|
+
},
|
34
|
+
doc: document, // if in an iframe can specify top.document
|
35
|
+
onShow: function onShow() {},
|
36
|
+
onShown: function onShown() {},
|
37
|
+
onHide: function onHide() {},
|
38
|
+
onHidden: function onHidden() {},
|
39
|
+
onNavigate: function onNavigate() {},
|
40
|
+
onContentLoaded: function onContentLoaded() {}
|
41
|
+
};
|
42
|
+
|
43
|
+
var Lightbox = (function () {
|
44
|
+
_createClass(Lightbox, null, [{
|
45
|
+
key: 'Default',
|
46
|
+
|
47
|
+
/**
|
48
|
+
|
49
|
+
Class properties:
|
50
|
+
|
51
|
+
_$element: null -> the <a> element currently being displayed
|
52
|
+
_$modal: The bootstrap modal generated
|
53
|
+
_$modalDialog: The .modal-dialog
|
54
|
+
_$modalContent: The .modal-content
|
55
|
+
_$modalBody: The .modal-body
|
56
|
+
_$modalHeader: The .modal-header
|
57
|
+
_$modalFooter: The .modal-footer
|
58
|
+
_$lightboxContainerOne: Container of the first lightbox element
|
59
|
+
_$lightboxContainerTwo: Container of the second lightbox element
|
60
|
+
_$lightboxBody: First element in the container
|
61
|
+
_$modalArrows: The overlayed arrows container
|
62
|
+
_$galleryItems: Other <a>'s available for this gallery
|
63
|
+
_galleryName: Name of the current data('gallery') showing
|
64
|
+
_galleryIndex: The current index of the _$galleryItems being shown
|
65
|
+
_config: {} the options for the modal
|
66
|
+
_modalId: unique id for the current lightbox
|
67
|
+
_padding / _border: CSS properties for the modal container; these are used to calculate the available space for the content
|
68
|
+
*/
|
69
|
+
|
70
|
+
get: function get() {
|
71
|
+
return Default;
|
72
|
+
}
|
73
|
+
}]);
|
74
|
+
|
75
|
+
function Lightbox($element, config) {
|
76
|
+
var _this = this;
|
77
|
+
|
78
|
+
_classCallCheck(this, Lightbox);
|
79
|
+
|
80
|
+
this._config = $.extend({}, Default, config);
|
81
|
+
this._$modalArrows = null;
|
82
|
+
this._galleryIndex = 0;
|
83
|
+
this._galleryName = null;
|
84
|
+
this._padding = null;
|
85
|
+
this._border = null;
|
86
|
+
this._titleIsShown = false;
|
87
|
+
this._footerIsShown = false;
|
88
|
+
this._wantedWidth = 0;
|
89
|
+
this._wantedHeight = 0;
|
90
|
+
this._modalId = 'ekkoLightbox-' + Math.floor(Math.random() * 1000 + 1);
|
91
|
+
this._$element = $element instanceof jQuery ? $element : $($element);
|
92
|
+
|
93
|
+
var header = '<div class="modal-header"' + (this._config.title || this._config.alwaysShowClose ? '' : ' style="display:none"') + '><button type="button" class="close" data-dismiss="modal" aria-label="' + this._config.strings.close + '"><span aria-hidden="true">×</span></button><h4 class="modal-title">' + (this._config.title || " ") + '</h4></div>';
|
94
|
+
var footer = '<div class="modal-footer"' + (this._config.footer ? '' : ' style="display:none"') + '>' + (this._config.footer || " ") + '</div>';
|
95
|
+
var body = '<div class="modal-body"><div class="ekko-lightbox-container"><div class="ekko-lightbox-item fade in"></div><div class="ekko-lightbox-item fade"></div></div></div>';
|
96
|
+
var dialog = '<div class="modal-dialog" role="document"><div class="modal-content">' + header + body + footer + '</div></div>';
|
97
|
+
$(this._config.doc.body).append('<div id="' + this._modalId + '" class="ekko-lightbox modal fade" tabindex="-1" tabindex="-1" role="dialog" aria-hidden="true">' + dialog + '</div>');
|
98
|
+
|
99
|
+
this._$modal = $('#' + this._modalId, this._config.doc);
|
100
|
+
this._$modalDialog = this._$modal.find('.modal-dialog').first();
|
101
|
+
this._$modalContent = this._$modal.find('.modal-content').first();
|
102
|
+
this._$modalBody = this._$modal.find('.modal-body').first();
|
103
|
+
this._$modalHeader = this._$modal.find('.modal-header').first();
|
104
|
+
this._$modalFooter = this._$modal.find('.modal-footer').first();
|
105
|
+
|
106
|
+
this._$lightboxContainer = this._$modalBody.find('.ekko-lightbox-container').first();
|
107
|
+
this._$lightboxBodyOne = this._$lightboxContainer.find('> div:first-child').first();
|
108
|
+
this._$lightboxBodyTwo = this._$lightboxContainer.find('> div:last-child').first();
|
109
|
+
|
110
|
+
this._border = this._calculateBorders();
|
111
|
+
this._padding = this._calculatePadding();
|
112
|
+
|
113
|
+
this._galleryName = this._$element.data('gallery');
|
114
|
+
if (this._galleryName) {
|
115
|
+
this._$galleryItems = $(document.body).find('*[data-gallery="' + this._galleryName + '"]');
|
116
|
+
this._galleryIndex = this._$galleryItems.index(this._$element);
|
117
|
+
$(document).on('keydown.ekkoLightbox', this._navigationalBinder.bind(this));
|
118
|
+
|
119
|
+
// add the directional arrows to the modal
|
120
|
+
if (this._config.showArrows && this._$galleryItems.length > 1) {
|
121
|
+
this._$lightboxContainer.append('<div class="ekko-lightbox-nav-overlay"><a href="#">' + this._config.leftArrow + '</a><a href="#">' + this._config.rightArrow + '</a></div>');
|
122
|
+
this._$modalArrows = this._$lightboxContainer.find('div.ekko-lightbox-nav-overlay').first();
|
123
|
+
this._$lightboxContainer.on('click', 'a:first-child', function (event) {
|
124
|
+
event.preventDefault();
|
125
|
+
return _this.navigateLeft();
|
126
|
+
});
|
127
|
+
this._$lightboxContainer.on('click', 'a:last-child', function (event) {
|
128
|
+
event.preventDefault();
|
129
|
+
return _this.navigateRight();
|
130
|
+
});
|
131
|
+
}
|
132
|
+
}
|
133
|
+
|
134
|
+
this._$modal.on('show.bs.modal', this._config.onShow.bind(this)).on('shown.bs.modal', function () {
|
135
|
+
_this._toggleLoading(true);
|
136
|
+
_this._handle();
|
137
|
+
return _this._config.onShown.call(_this);
|
138
|
+
}).on('hide.bs.modal', this._config.onHide.bind(this)).on('hidden.bs.modal', function () {
|
139
|
+
if (_this._galleryName) {
|
140
|
+
$(document).off('keydown.ekkoLightbox');
|
141
|
+
$(window).off('resize.ekkoLightbox');
|
142
|
+
}
|
143
|
+
_this._$modal.remove();
|
144
|
+
return _this._config.onHidden.call(_this);
|
145
|
+
}).modal(this._config);
|
146
|
+
|
147
|
+
$(window).on('resize.ekkoLightbox', function () {
|
148
|
+
_this._resize(_this._wantedWidth, _this._wantedHeight);
|
149
|
+
});
|
150
|
+
}
|
151
|
+
|
152
|
+
_createClass(Lightbox, [{
|
153
|
+
key: 'element',
|
154
|
+
value: function element() {
|
155
|
+
return this._$element;
|
156
|
+
}
|
157
|
+
}, {
|
158
|
+
key: 'modal',
|
159
|
+
value: function modal() {
|
160
|
+
return this._$modal;
|
161
|
+
}
|
162
|
+
}, {
|
163
|
+
key: 'navigateTo',
|
164
|
+
value: function navigateTo(index) {
|
165
|
+
|
166
|
+
if (index < 0 || index > this._$galleryItems.length - 1) return this;
|
167
|
+
|
168
|
+
this._galleryIndex = index;
|
169
|
+
|
170
|
+
this._$element = $(this._$galleryItems.get(this._galleryIndex));
|
171
|
+
this._handle();
|
172
|
+
}
|
173
|
+
}, {
|
174
|
+
key: 'navigateLeft',
|
175
|
+
value: function navigateLeft() {
|
176
|
+
|
177
|
+
if (this._$galleryItems.length === 1) return;
|
178
|
+
|
179
|
+
if (this._galleryIndex === 0) this._galleryIndex = this._$galleryItems.length - 1;else //circular
|
180
|
+
this._galleryIndex--;
|
181
|
+
|
182
|
+
this._config.onNavigate.call(this, 'left', this._galleryIndex);
|
183
|
+
return this.navigateTo(this._galleryIndex);
|
184
|
+
}
|
185
|
+
}, {
|
186
|
+
key: 'navigateRight',
|
187
|
+
value: function navigateRight() {
|
188
|
+
|
189
|
+
if (this._$galleryItems.length === 1) return;
|
190
|
+
|
191
|
+
if (this._galleryIndex === this._$galleryItems.length - 1) this._galleryIndex = 0;else //circular
|
192
|
+
this._galleryIndex++;
|
193
|
+
|
194
|
+
this._config.onNavigate.call(this, 'right', this._galleryIndex);
|
195
|
+
return this.navigateTo(this._galleryIndex);
|
196
|
+
}
|
197
|
+
}, {
|
198
|
+
key: 'close',
|
199
|
+
value: function close() {
|
200
|
+
return this._$modal.modal('hide');
|
201
|
+
}
|
202
|
+
|
203
|
+
// helper private methods
|
204
|
+
}, {
|
205
|
+
key: '_navigationalBinder',
|
206
|
+
value: function _navigationalBinder(event) {
|
207
|
+
event = event || window.event;
|
208
|
+
if (event.keyCode === 39) return this.navigateRight();
|
209
|
+
if (event.keyCode === 37) return this.navigateLeft();
|
210
|
+
}
|
211
|
+
|
212
|
+
// type detection private methods
|
213
|
+
}, {
|
214
|
+
key: '_detectRemoteType',
|
215
|
+
value: function _detectRemoteType(src, type) {
|
216
|
+
|
217
|
+
type = type || false;
|
218
|
+
|
219
|
+
if (!type && this._isImage(src)) type = 'image';
|
220
|
+
if (!type && this._getYoutubeId(src)) type = 'youtube';
|
221
|
+
if (!type && this._getVimeoId(src)) type = 'vimeo';
|
222
|
+
if (!type && this._getInstagramId(src)) type = 'instagram';
|
223
|
+
|
224
|
+
if (!type || ['image', 'youtube', 'vimeo', 'instagram', 'video', 'url'].indexOf(type) < 0) type = 'url';
|
225
|
+
|
226
|
+
return type;
|
227
|
+
}
|
228
|
+
}, {
|
229
|
+
key: '_isImage',
|
230
|
+
value: function _isImage(string) {
|
231
|
+
return string && string.match(/(^data:image\/.*,)|(\.(jp(e|g|eg)|gif|png|bmp|webp|svg)((\?|#).*)?$)/i);
|
232
|
+
}
|
233
|
+
}, {
|
234
|
+
key: '_containerToUse',
|
235
|
+
value: function _containerToUse() {
|
236
|
+
var _this2 = this;
|
237
|
+
|
238
|
+
// if currently showing an image, fade it out and remove
|
239
|
+
var $toUse = this._$lightboxBodyTwo;
|
240
|
+
var $current = this._$lightboxBodyOne;
|
241
|
+
|
242
|
+
if (this._$lightboxBodyTwo.hasClass('in')) {
|
243
|
+
$toUse = this._$lightboxBodyOne;
|
244
|
+
$current = this._$lightboxBodyTwo;
|
245
|
+
}
|
246
|
+
|
247
|
+
$current.removeClass('in');
|
248
|
+
setTimeout(function () {
|
249
|
+
if (!_this2._$lightboxBodyTwo.hasClass('in')) _this2._$lightboxBodyTwo.empty();
|
250
|
+
if (!_this2._$lightboxBodyOne.hasClass('in')) _this2._$lightboxBodyOne.empty();
|
251
|
+
}, 500);
|
252
|
+
|
253
|
+
$toUse.addClass('in');
|
254
|
+
return $toUse;
|
255
|
+
}
|
256
|
+
}, {
|
257
|
+
key: '_handle',
|
258
|
+
value: function _handle() {
|
259
|
+
|
260
|
+
var $toUse = this._containerToUse();
|
261
|
+
this._updateTitleAndFooter();
|
262
|
+
|
263
|
+
var currentRemote = this._$element.attr('data-remote') || this._$element.attr('href');
|
264
|
+
var currentType = this._detectRemoteType(currentRemote, this._$element.attr('data-type') || false);
|
265
|
+
|
266
|
+
if (['image', 'youtube', 'vimeo', 'instagram', 'video', 'url'].indexOf(currentType) < 0) return this._error(this._config.strings.type);
|
267
|
+
|
268
|
+
switch (currentType) {
|
269
|
+
case 'image':
|
270
|
+
this._preloadImage(currentRemote, $toUse);
|
271
|
+
this._preloadImageByIndex(this._galleryIndex, 3);
|
272
|
+
break;
|
273
|
+
case 'youtube':
|
274
|
+
this._showYoutubeVideo(currentRemote, $toUse);
|
275
|
+
break;
|
276
|
+
case 'vimeo':
|
277
|
+
this._showVimeoVideo(this._getVimeoId(currentRemote), $toUse);
|
278
|
+
break;
|
279
|
+
case 'instagram':
|
280
|
+
this._showInstagramVideo(this._getInstagramId(currentRemote), $toUse);
|
281
|
+
break;
|
282
|
+
case 'video':
|
283
|
+
this._showHtml5Video(currentRemote, $toUse);
|
284
|
+
break;
|
285
|
+
default:
|
286
|
+
// url
|
287
|
+
this._loadRemoteContent(currentRemote, $toUse);
|
288
|
+
break;
|
289
|
+
}
|
290
|
+
|
291
|
+
return this;
|
292
|
+
}
|
293
|
+
}, {
|
294
|
+
key: '_getYoutubeId',
|
295
|
+
value: function _getYoutubeId(string) {
|
296
|
+
if (!string) return false;
|
297
|
+
var matches = string.match(/^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/);
|
298
|
+
return matches && matches[2].length === 11 ? matches[2] : false;
|
299
|
+
}
|
300
|
+
}, {
|
301
|
+
key: '_getVimeoId',
|
302
|
+
value: function _getVimeoId(string) {
|
303
|
+
return string && string.indexOf('vimeo') > 0 ? string : false;
|
304
|
+
}
|
305
|
+
}, {
|
306
|
+
key: '_getInstagramId',
|
307
|
+
value: function _getInstagramId(string) {
|
308
|
+
return string && string.indexOf('instagram') > 0 ? string : false;
|
309
|
+
}
|
310
|
+
|
311
|
+
// layout private methods
|
312
|
+
}, {
|
313
|
+
key: '_toggleLoading',
|
314
|
+
value: function _toggleLoading(show) {
|
315
|
+
show = show || false;
|
316
|
+
if (show) {
|
317
|
+
this._$modalDialog.css('display', 'none');
|
318
|
+
this._$modal.removeClass('in');
|
319
|
+
$('.modal-backdrop').append(this._config.loadingMessage);
|
320
|
+
} else {
|
321
|
+
this._$modalDialog.css('display', 'block');
|
322
|
+
this._$modal.addClass('in');
|
323
|
+
$('.modal-backdrop').find('.ekko-lightbox-loader').remove();
|
324
|
+
}
|
325
|
+
return this;
|
326
|
+
}
|
327
|
+
}, {
|
328
|
+
key: '_calculateBorders',
|
329
|
+
value: function _calculateBorders() {
|
330
|
+
return {
|
331
|
+
top: this._totalCssByAttribute('border-top-width'),
|
332
|
+
right: this._totalCssByAttribute('border-right-width'),
|
333
|
+
bottom: this._totalCssByAttribute('border-bottom-width'),
|
334
|
+
left: this._totalCssByAttribute('border-left-width')
|
335
|
+
};
|
336
|
+
}
|
337
|
+
}, {
|
338
|
+
key: '_calculatePadding',
|
339
|
+
value: function _calculatePadding() {
|
340
|
+
return {
|
341
|
+
top: this._totalCssByAttribute('padding-top'),
|
342
|
+
right: this._totalCssByAttribute('padding-right'),
|
343
|
+
bottom: this._totalCssByAttribute('padding-bottom'),
|
344
|
+
left: this._totalCssByAttribute('padding-left')
|
345
|
+
};
|
346
|
+
}
|
347
|
+
}, {
|
348
|
+
key: '_totalCssByAttribute',
|
349
|
+
value: function _totalCssByAttribute(attribute) {
|
350
|
+
return parseInt(this._$modalDialog.css(attribute), 10) + parseInt(this._$modalContent.css(attribute), 10) + parseInt(this._$modalBody.css(attribute), 10);
|
351
|
+
}
|
352
|
+
}, {
|
353
|
+
key: '_updateTitleAndFooter',
|
354
|
+
value: function _updateTitleAndFooter() {
|
355
|
+
var title = this._$element.data('title') || "";
|
356
|
+
var caption = this._$element.data('footer') || "";
|
357
|
+
|
358
|
+
this._titleIsShown = false;
|
359
|
+
if (title || this._config.alwaysShowClose) {
|
360
|
+
this._titleIsShown = true;
|
361
|
+
this._$modalHeader.css('display', '').find('.modal-title').html(title || " ");
|
362
|
+
} else this._$modalHeader.css('display', 'none');
|
363
|
+
|
364
|
+
this._footerIsShown = false;
|
365
|
+
if (caption) {
|
366
|
+
this._footerIsShown = true;
|
367
|
+
this._$modalFooter.css('display', '').html(caption);
|
368
|
+
} else this._$modalFooter.css('display', 'none');
|
369
|
+
|
370
|
+
return this;
|
371
|
+
}
|
372
|
+
}, {
|
373
|
+
key: '_showYoutubeVideo',
|
374
|
+
value: function _showYoutubeVideo(remote, $containerForElement) {
|
375
|
+
var id = this._getYoutubeId(remote);
|
376
|
+
var query = remote.indexOf('&') > 0 ? remote.substr(remote.indexOf('&')) : '';
|
377
|
+
var width = this._$element.data('width') || 560;
|
378
|
+
var height = this._$element.data('height') || width / (560 / 315);
|
379
|
+
return this._showVideoIframe('//www.youtube.com/embed/' + id + '?badge=0&autoplay=1&html5=1' + query, width, height, $containerForElement);
|
380
|
+
}
|
381
|
+
}, {
|
382
|
+
key: '_showVimeoVideo',
|
383
|
+
value: function _showVimeoVideo(id, $containerForElement) {
|
384
|
+
var width = 500;
|
385
|
+
var height = this._$element.data('height') || width / (560 / 315);
|
386
|
+
return this._showVideoIframe(id + '?autoplay=1', width, height, $containerForElement);
|
387
|
+
}
|
388
|
+
}, {
|
389
|
+
key: '_showInstagramVideo',
|
390
|
+
value: function _showInstagramVideo(id, $containerForElement) {
|
391
|
+
// instagram load their content into iframe's so this can be put straight into the element
|
392
|
+
var width = this._$element.data('width') || 612;
|
393
|
+
var height = width + 80;
|
394
|
+
id = id.substr(-1) !== '/' ? id + '/' : id; // ensure id has trailing slash
|
395
|
+
$containerForElement.html('<iframe width="' + width + '" height="' + height + '" src="' + id + 'embed/" frameborder="0" allowfullscreen></iframe>');
|
396
|
+
this._resize(width, height);
|
397
|
+
this._config.onContentLoaded.call(this);
|
398
|
+
if (this._$modalArrows) //hide the arrows when showing video
|
399
|
+
this._$modalArrows.css('display', 'none');
|
400
|
+
this._toggleLoading(false);
|
401
|
+
return this;
|
402
|
+
}
|
403
|
+
}, {
|
404
|
+
key: '_showVideoIframe',
|
405
|
+
value: function _showVideoIframe(url, width, height, $containerForElement) {
|
406
|
+
// should be used for videos only. for remote content use loadRemoteContent (data-type=url)
|
407
|
+
height = height || width; // default to square
|
408
|
+
$containerForElement.html('<div class="embed-responsive embed-responsive-16by9"><iframe width="' + width + '" height="' + height + '" src="' + url + '" frameborder="0" allowfullscreen class="embed-responsive-item"></iframe></div>');
|
409
|
+
this._resize(width, height);
|
410
|
+
this._config.onContentLoaded.call(this);
|
411
|
+
if (this._$modalArrows) this._$modalArrows.css('display', 'none'); //hide the arrows when showing video
|
412
|
+
this._toggleLoading(false);
|
413
|
+
return this;
|
414
|
+
}
|
415
|
+
}, {
|
416
|
+
key: '_showHtml5Video',
|
417
|
+
value: function _showHtml5Video(url, $containerForElement) {
|
418
|
+
// should be used for videos only. for remote content use loadRemoteContent (data-type=url)
|
419
|
+
var width = this._$element.data('width') || 560;
|
420
|
+
var height = this._$element.data('height') || width / (560 / 315);
|
421
|
+
$containerForElement.html('<div class="embed-responsive embed-responsive-16by9"><video width="' + width + '" height="' + height + '" src="' + url + '" preload="auto" autoplay controls class="embed-responsive-item"></video></div>');
|
422
|
+
this._resize(width, height);
|
423
|
+
this._config.onContentLoaded.call(this);
|
424
|
+
if (this._$modalArrows) this._$modalArrows.css('display', 'none'); //hide the arrows when showing video
|
425
|
+
this._toggleLoading(false);
|
426
|
+
return this;
|
427
|
+
}
|
428
|
+
}, {
|
429
|
+
key: '_loadRemoteContent',
|
430
|
+
value: function _loadRemoteContent(url, $containerForElement) {
|
431
|
+
var _this3 = this;
|
432
|
+
|
433
|
+
var width = this._$element.data('width') || 560;
|
434
|
+
var height = this._$element.data('height') || 560;
|
435
|
+
|
436
|
+
var disableExternalCheck = this._$element.data('disableExternalCheck') || false;
|
437
|
+
this._toggleLoading(false);
|
438
|
+
|
439
|
+
// external urls are loading into an iframe
|
440
|
+
// local ajax can be loaded into the container itself
|
441
|
+
if (!disableExternalCheck && !this._isExternal(url)) {
|
442
|
+
$containerForElement.load(url, $.proxy(function () {
|
443
|
+
return _this3._$element.trigger('loaded.bs.modal');l;
|
444
|
+
}));
|
445
|
+
} else {
|
446
|
+
$containerForElement.html('<iframe src="' + url + '" frameborder="0" allowfullscreen></iframe>');
|
447
|
+
this._config.onContentLoaded.call(this);
|
448
|
+
}
|
449
|
+
|
450
|
+
if (this._$modalArrows) //hide the arrows when remote content
|
451
|
+
this._$modalArrows.css('display', 'none');
|
452
|
+
|
453
|
+
this._resize(width, height);
|
454
|
+
return this;
|
455
|
+
}
|
456
|
+
}, {
|
457
|
+
key: '_isExternal',
|
458
|
+
value: function _isExternal(url) {
|
459
|
+
var match = url.match(/^([^:\/?#]+:)?(?:\/\/([^\/?#]*))?([^?#]+)?(\?[^#]*)?(#.*)?/);
|
460
|
+
if (typeof match[1] === "string" && match[1].length > 0 && match[1].toLowerCase() !== location.protocol) return true;
|
461
|
+
|
462
|
+
if (typeof match[2] === "string" && match[2].length > 0 && match[2].replace(new RegExp(':(' + ({
|
463
|
+
"http:": 80,
|
464
|
+
"https:": 443
|
465
|
+
})[location.protocol] + ')?$'), "") !== location.host) return true;
|
466
|
+
|
467
|
+
return false;
|
468
|
+
}
|
469
|
+
}, {
|
470
|
+
key: '_error',
|
471
|
+
value: function _error(message) {
|
472
|
+
console.error(message);
|
473
|
+
this._containerToUse().html(message);
|
474
|
+
this._resize(300, 300);
|
475
|
+
return this;
|
476
|
+
}
|
477
|
+
}, {
|
478
|
+
key: '_preloadImageByIndex',
|
479
|
+
value: function _preloadImageByIndex(startIndex, numberOfTimes) {
|
480
|
+
|
481
|
+
if (!this._$galleryItems) return;
|
482
|
+
|
483
|
+
var next = $(this._$galleryItems.get(startIndex), false);
|
484
|
+
if (typeof next == 'undefined') return;
|
485
|
+
|
486
|
+
var src = next.attr('data-remote') || next.attr('href');
|
487
|
+
if (next.attr('data-type') === 'image' || this._isImage(src)) this._preloadImage(src, false);
|
488
|
+
|
489
|
+
if (numberOfTimes > 0) return this._preloadImageByIndex(startIndex + 1, numberOfTimes - 1);
|
490
|
+
}
|
491
|
+
}, {
|
492
|
+
key: '_preloadImage',
|
493
|
+
value: function _preloadImage(src, $containerForImage) {
|
494
|
+
var _this4 = this;
|
495
|
+
|
496
|
+
$containerForImage = $containerForImage || false;
|
497
|
+
|
498
|
+
var img = new Image();
|
499
|
+
if ($containerForImage) {
|
500
|
+
(function () {
|
501
|
+
|
502
|
+
// if loading takes > 200ms show a loader
|
503
|
+
var loadingTimeout = setTimeout(function () {
|
504
|
+
$containerForImage.append(_this4._config.loadingMessage);
|
505
|
+
}, 200);
|
506
|
+
|
507
|
+
img.onload = function () {
|
508
|
+
if (loadingTimeout) clearTimeout(loadingTimeout);
|
509
|
+
loadingTimeout = null;
|
510
|
+
var image = $('<img />');
|
511
|
+
image.attr('src', img.src);
|
512
|
+
image.addClass('img-fluid');
|
513
|
+
$containerForImage.html(image);
|
514
|
+
if (_this4._$modalArrows) _this4._$modalArrows.css('display', ''); // remove display to default to css property
|
515
|
+
|
516
|
+
_this4._resize(img.width, img.height);
|
517
|
+
_this4._toggleLoading(false);
|
518
|
+
return _this4._config.onContentLoaded.call(_this4);
|
519
|
+
};
|
520
|
+
img.onerror = function () {
|
521
|
+
_this4._toggleLoading(false);
|
522
|
+
return _this4._error(_this4._config.strings.fail + (' ' + src));
|
523
|
+
};
|
524
|
+
})();
|
525
|
+
}
|
526
|
+
|
527
|
+
img.src = src;
|
528
|
+
return img;
|
529
|
+
}
|
530
|
+
}, {
|
531
|
+
key: '_resize',
|
532
|
+
value: function _resize(width, height) {
|
533
|
+
|
534
|
+
height = height || width;
|
535
|
+
this._wantedWidth = width;
|
536
|
+
this._wantedHeight = height;
|
537
|
+
|
538
|
+
// if width > the available space, scale down the expected width and height
|
539
|
+
var widthBorderAndPadding = this._padding.left + this._padding.right + this._border.left + this._border.right;
|
540
|
+
var maxWidth = Math.min(width + widthBorderAndPadding, this._config.doc.body.clientWidth);
|
541
|
+
if (width + widthBorderAndPadding > maxWidth) {
|
542
|
+
height = (maxWidth - widthBorderAndPadding) / width * height;
|
543
|
+
width = maxWidth;
|
544
|
+
} else width = width + widthBorderAndPadding;
|
545
|
+
|
546
|
+
var headerHeight = 0,
|
547
|
+
footerHeight = 0;
|
548
|
+
|
549
|
+
// as the resize is performed the modal is show, the calculate might fail
|
550
|
+
// if so, default to the default sizes
|
551
|
+
if (this._footerIsShown) footerHeight = this._$modalFooter.outerHeight(true) || 55;
|
552
|
+
|
553
|
+
if (this._titleIsShown) headerHeight = this._$modalHeader.outerHeight(true) || 67;
|
554
|
+
|
555
|
+
var borderPadding = this._padding.top + this._padding.bottom + this._border.bottom + this._border.top;
|
556
|
+
|
557
|
+
//calculated each time as resizing the window can cause them to change due to Bootstraps fluid margins
|
558
|
+
var margins = parseFloat(this._$modalDialog.css('margin-top')) + parseFloat(this._$modalDialog.css('margin-bottom'));
|
559
|
+
|
560
|
+
var maxHeight = Math.min(height, $(window).height() - borderPadding - margins - headerHeight - footerHeight);
|
561
|
+
if (height > maxHeight) {
|
562
|
+
// if height > the available height, scale down the width
|
563
|
+
var factor = Math.min(maxHeight / height, 1);
|
564
|
+
width = Math.ceil(factor * width);
|
565
|
+
}
|
566
|
+
|
567
|
+
this._$lightboxContainer.css('height', maxHeight);
|
568
|
+
this._$modalDialog.css('width', 'auto').css('maxWidth', width);
|
569
|
+
|
570
|
+
this._$modal.modal('_handleUpdate');
|
571
|
+
return this;
|
572
|
+
}
|
573
|
+
}], [{
|
574
|
+
key: '_jQueryInterface',
|
575
|
+
value: function _jQueryInterface(config) {
|
576
|
+
var _this5 = this;
|
577
|
+
|
578
|
+
config = config || {};
|
579
|
+
return this.each(function () {
|
580
|
+
var $this = $(_this5);
|
581
|
+
var _config = $.extend({}, Lightbox.Default, $this.data(), typeof config === 'object' && config);
|
582
|
+
|
583
|
+
new Lightbox(_this5, _config);
|
584
|
+
});
|
585
|
+
}
|
586
|
+
}]);
|
587
|
+
|
588
|
+
return Lightbox;
|
589
|
+
})();
|
590
|
+
|
591
|
+
$.fn[NAME] = Lightbox._jQueryInterface;
|
592
|
+
$.fn[NAME].Constructor = Lightbox;
|
593
|
+
$.fn[NAME].noConflict = function () {
|
594
|
+
$.fn[NAME] = JQUERY_NO_CONFLICT;
|
595
|
+
return Lightbox._jQueryInterface;
|
596
|
+
};
|
597
|
+
|
598
|
+
return Lightbox;
|
599
|
+
})(jQuery);
|
600
|
+
//# sourceMappingURL=ekko-lightbox.js.map
|
601
|
+
|
602
|
+
}(jQuery);
|