diff --git a/ekko-lightbox.js b/ekko-lightbox.js index fa759b3..ab57ade 100644 --- a/ekko-lightbox.js +++ b/ekko-lightbox.js @@ -10,7 +10,7 @@ const Lightbox = (($) => { maxHeight: 9999, showArrows: true, //display the left / right arrows or not wrapping: true, //if true, gallery loops infinitely - type: null, //force the lightbox into image / youtube mode. if null, or not image|youtube|vimeo; detect it + type: null, //force the lightbox into image / youtube mode. if null, or not image|youtube|vimeo|dailymotion; detect it alwaysShowClose: false, //always show the close button, even if there is no title loadingMessage: '
', // http://tobiasahlin.com/spinkit/ leftArrow: '', @@ -259,11 +259,13 @@ const Lightbox = (($) => { type = 'youtube'; if(!type && this._getVimeoId(src)) type = 'vimeo'; + if(!type && this._getDailymotionId(src)) + type = 'dailymotion'; if(!type && this._getInstagramId(src)) type = 'instagram'; - if(type == 'audio' || type == 'video' || (!type && this._isMedia(src))) + if(type === 'audio' || type === 'video' || (!type && this._isMedia(src))) type = 'media'; - if(!type || ['image', 'youtube', 'vimeo', 'instagram', 'media', 'url'].indexOf(type) < 0) + if(!type || ['image', 'youtube', 'vimeo', 'dailymotion', 'instagram', 'media', 'url'].indexOf(type) < 0) type = 'url'; return type; @@ -317,7 +319,7 @@ const Lightbox = (($) => { let currentRemote = this._$element.attr('data-remote') || this._$element.attr('href') let currentType = this._detectRemoteType(currentRemote, this._$element.attr('data-type') || false) - if(['image', 'youtube', 'vimeo', 'instagram', 'media', 'url'].indexOf(currentType) < 0) + if(['image', 'youtube', 'vimeo', 'dailymotion', 'instagram', 'media', 'url'].indexOf(currentType) < 0) return this._error(this._config.strings.type) switch(currentType) { @@ -331,6 +333,9 @@ const Lightbox = (($) => { case 'vimeo': this._showVimeoVideo(this._getVimeoId(currentRemote), $toUse); break; + case 'dailymotion': + this._showDailymotionVideo(this._getDailymotionId(currentRemote), $toUse); + break; case 'instagram': this._showInstagramVideo(this._getInstagramId(currentRemote), $toUse); break; @@ -356,6 +361,10 @@ const Lightbox = (($) => { return string && string.indexOf('vimeo') > 0 ? string : false } + _getDailymotionId(string) { + return string && string.indexOf('dailymotion') > 0 ? string : false + } + _getInstagramId(string) { return string && string.indexOf('instagram') > 0 ? string : false } @@ -442,6 +451,12 @@ const Lightbox = (($) => { return this._showVideoIframe(id + '?autoplay=1', width, height, $containerForElement) } + _showDailymotionVideo(id, $containerForElement) { + let width = this._$element.data('width') || 500 + let height = this._$element.data('height') || width / ( 560/315 ) + return this._showVideoIframe(id + '?autoplay=1', width, height, $containerForElement) + } + _showInstagramVideo(id, $containerForElement) { // instagram load their content into iframe's so this can be put straight into the element let width = this._$element.data('width') || 612 diff --git a/examples/bs3.html b/examples/bs3.html index 70489ce..90d624a 100644 --- a/examples/bs3.html +++ b/examples/bs3.html @@ -255,7 +255,7 @@

Options

type Force the lightbox into image/YouTube mode. - data-type="(image|youtube|vimeo)" + data-type="(image|youtube|vimeo|dailymotion)" @@ -362,24 +362,35 @@

Vimeo

You cannot embed Vimeo videos using the standard url (ie http://vimeo.com/80629469); you must link to the embed source (ie player.vimeo.com/video/80629469). This will mean your link url - if the JavaScript fails, will open the full screen player (try opening the first link below in a new tab); the solution to this is to set the lightbox source directly - the second link below does this.

City Lights - from Colin Rich (using embed link)

-

City Lights - from Colin Rich (with reccommended data-remote setting)

+

City Lights - from Colin Rich (with recommended data-remote setting)

+

Dailymotion

+

You cannot embed Dailymotion videos using the standard url (ie https://dai.ly/x6xailo); you must link + to the embed source (ie https://www.dailymotion.com/embed/video/x6xailo). This will mean your link url - if + the JavaScript fails, will open the full screen player (try opening the first link below in a new + tab); the solution to this is to set the lightbox source directly - the second link below does this.

+
+

Robin des Bois (using embed link)

+

Robin des bois (with recommended data-remote setting) +

+
+

Instagram

-
+

GOtags.co.uk

This also works with photos: GOtags.co.uk

- +

Forcing width

Set the width of the video

-
+

Taylor Swift - Blank Space (standard)

Taylor Swift - Blank Space (640 x 360)

Taylor Swift - Blank Space (1280 x 780)

- + diff --git a/index.html b/index.html index 1d331bb..300394c 100644 --- a/index.html +++ b/index.html @@ -392,21 +392,31 @@

Vimeo

City Lights - from Colin Rich (with reccommended data-remote setting)

+

Dailymotion

+

You cannot embed Dailymotion videos using the standard url (ie https://dai.ly/x6xailo); you must link + to the embed source (ie https://www.dailymotion.com/embed/video/x6xailo). This will mean your link url - if + the JavaScript fails, will open the full screen player (try opening the first link below in a new + tab); the solution to this is to set the lightbox source directly - the second link below does this.

+
+

Robin des Bois (using embed link)

+

Robin des bois (with recommended data-remote setting) +

+

Instagram

-
+

Instagram

This also works with photos: Instagram

- +

Forcing width

Set the width of the video

-
+

Taylor Swift - Blank Space (standard)

Taylor Swift - Blank Space (640 x 360)

Taylor Swift - Blank Space (1280 x 780)

- +