1 line
2.8 KiB
JavaScript
Executable File
1 line
2.8 KiB
JavaScript
Executable File
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).lgVimeoThumbnail=e()}(this,function(){"use strict";var e=function(){return(e=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function t(t,l,a,s){return new(a=a||Promise)(function(n,e){function o(t){try{r(s.next(t))}catch(t){e(t)}}function i(t){try{r(s.throw(t))}catch(t){e(t)}}function r(t){var e;t.done?n(t.value):((e=t.value)instanceof a?e:new a(function(t){t(e)})).then(o,i)}r((s=s.apply(t,l||[])).next())})}function i(o,i){var r,l,a,s={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},t={next:e(0),throw:e(1),return:e(2)};return"function"==typeof Symbol&&(t[Symbol.iterator]=function(){return this}),t;function e(n){return function(t){var e=[n,t];if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,l&&(a=2&e[0]?l.return:e[0]?l.throw||((a=l.return)&&a.call(l),0):l.next)&&!(a=a.call(l,e[1])).done)return a;switch(l=0,(e=a?[2&e[0],a.value]:e)[0]){case 0:case 1:a=e;break;case 4:return s.label++,{value:e[1],done:!1};case 5:s.label++,l=e[1],e=[0];continue;case 7:e=s.ops.pop(),s.trys.pop();continue;default:if(!(a=0<(a=s.trys).length&&a[a.length-1])&&(6===e[0]||2===e[0])){s=0;continue}if(3===e[0]&&(!a||e[1]>a[0]&&e[1]<a[3])){s.label=e[1];break}if(6===e[0]&&s.label<a[1]){s.label=a[1],a=e;break}if(a&&s.label<a[2]){s.label=a[2],s.ops.push(e);break}a[2]&&s.ops.pop(),s.trys.pop();continue}e=i.call(o,s)}catch(t){e=[6,t],l=0}finally{r=a=0}if(5&e[0])throw e[1];return{value:e[0]?e[1]:void 0,done:!0}}}}var n="lgInit",o={showVimeoThumbnails:!0,showThumbnailWithPlayButton:!1};function r(t){return this.core=t,this.settings=e(e({},o),this.core.settings),this}return r.prototype.init=function(){var e=this;this.settings.showVimeoThumbnails&&this.core.LGel.on(n+".vimeothumbnails",function(t){t=t.detail.instance;t.$container.find(".lg-thumb-outer").get()&&e.setVimeoThumbnails(t)})},r.prototype.setVimeoThumbnails=function(o){return t(this,void 0,void 0,function(){var e,n;return i(this,function(t){switch(t.label){case 0:e=0,t.label=1;case 1:return e<o.galleryItems.length?(n=o.galleryItems[e],(n.__slideVideoInfo||{}).vimeo?[4,fetch("https://vimeo.com/api/oembed.json?url="+encodeURIComponent(n.src))]:[3,4]):[3,5];case 2:return[4,t.sent().json()];case 3:n=t.sent(),o.$container.find(".lg-thumb-item").eq(e).find("img").attr("src",this.settings.showThumbnailWithPlayButton?n.thumbnail_url_with_play_button:n.thumbnail_url),t.label=4;case 4:return e++,[3,1];case 5:return[2]}})})},r.prototype.destroy=function(){this.core.LGel.off(".lg.vimeothumbnails"),this.core.LGel.off(".vimeothumbnails")},r}); |