|
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 |
| - |
| 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 | 9 | 'use strict';
|
10 | 10 |
|
11 | 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; }; })();
|
@@ -34,6 +34,9 @@ var Lightbox = (function ($) {
|
34 | 34 | fail: 'Failed to load image:',
|
35 | 35 | type: 'Could not detect remote target type. Force the type using data-type'
|
36 | 36 | },
|
| 37 | + dataSrc: 'data-remote', |
| 38 | + titleSrc: 'data-title', |
| 39 | + footerSrc: 'data-footer', |
37 | 40 | doc: document, // if in an iframe can specify top.document
|
38 | 41 | onShow: function onShow() {},
|
39 | 42 | onShown: function onShown() {},
|
@@ -261,6 +264,17 @@ var Lightbox = (function ($) {
|
261 | 264 |
|
262 | 265 | return type;
|
263 | 266 | }
|
| 267 | + }, { |
| 268 | + key: '_getAttr', |
| 269 | + value: function _getAttr(element, attr) { |
| 270 | + if (typeof attr === 'function') { |
| 271 | + return attr.call(element); |
| 272 | + } else if (0 === attr.toString().indexOf("data-")) { |
| 273 | + return $(element).data(attr.replace("data-", "")); |
| 274 | + } else { |
| 275 | + return $(element).attr(attr); |
| 276 | + } |
| 277 | + } |
264 | 278 | }, {
|
265 | 279 | key: '_isImage',
|
266 | 280 | value: function _isImage(string) {
|
@@ -296,8 +310,9 @@ var Lightbox = (function ($) {
|
296 | 310 | var $toUse = this._containerToUse();
|
297 | 311 | this._updateTitleAndFooter();
|
298 | 312 |
|
299 |
| - var currentRemote = this._$element.attr('data-remote') || this._$element.attr('href'); |
300 |
| - var currentType = this._detectRemoteType(currentRemote, this._$element.attr('data-type') || false); |
| 313 | + var currentRemote = this._getAttr(this._$element, this._config.dataSrc) || this._getAttr(this._$element, 'href'); |
| 314 | + |
| 315 | + var currentType = this._detectRemoteType(currentRemote, this._getAttr(this._$element, 'data-type') || false); |
301 | 316 |
|
302 | 317 | if (['image', 'youtube', 'vimeo', 'instagram', 'video', 'url'].indexOf(currentType) < 0) return this._error(this._config.strings.type);
|
303 | 318 |
|
@@ -388,8 +403,8 @@ var Lightbox = (function ($) {
|
388 | 403 | }, {
|
389 | 404 | key: '_updateTitleAndFooter',
|
390 | 405 | value: function _updateTitleAndFooter() {
|
391 |
| - var title = this._$element.data('title') || ""; |
392 |
| - var caption = this._$element.data('footer') || ""; |
| 406 | + var title = this._getAttr(this._$element, this._config.titleSrc) || ""; |
| 407 | + var caption = this._getAttr(this._$element, this._config.footerSrc) || ""; |
393 | 408 |
|
394 | 409 | this._titleIsShown = false;
|
395 | 410 | if (title || this._config.alwaysShowClose) {
|
@@ -519,8 +534,8 @@ var Lightbox = (function ($) {
|
519 | 534 | var next = $(this._$galleryItems.get(startIndex), false);
|
520 | 535 | if (typeof next == 'undefined') return;
|
521 | 536 |
|
522 |
| - var src = next.attr('data-remote') || next.attr('href'); |
523 |
| - if (next.attr('data-type') === 'image' || this._isImage(src)) this._preloadImage(src, false); |
| 537 | + var src = this._getAttr(next, this._config.dataSrc) || this._getAttr(next, 'href'); |
| 538 | + if (this._getAttr(next, 'data-type') === 'image' || this._isImage(src)) this._preloadImage(src, false); |
524 | 539 |
|
525 | 540 | if (numberOfTimes > 0) return this._preloadImageByIndex(startIndex + 1, numberOfTimes - 1);
|
526 | 541 | }
|
@@ -663,6 +678,6 @@ var Lightbox = (function ($) {
|
663 | 678 |
|
664 | 679 | return Lightbox;
|
665 | 680 | })(jQuery);
|
666 |
| -//# sourceMappingURL=ekko-lightbox.js.map |
667 |
| - |
668 |
| -}(jQuery); |
| 681 | +//# sourceMappingURL=ekko-lightbox.js.map |
| 682 | + |
| 683 | +}(jQuery); |
0 commit comments