UNPKG

lightgallery

Version:

lightGallery is a feature-rich, modular JavaScript gallery plugin for building beautiful image and video galleries for the web and the mobile

2 lines (1 loc) • 4.8 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).lgComment=t()}(this,function(){"use strict";const e={comment:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" fill="currentColor"><path transform="translate(0, 960) scale(1, -1)" d="M938.667 448.128v21.205c0 0.725-0.043 1.621-0.085 2.475-5.803 99.755-47.488 190.336-112.725 258.176-68.352 71.125-162.731 117.419-268.843 123.264-0.683 0.043-1.536 0.085-2.347 0.085h-20.864c-59.947 0.683-122.965-13.227-181.931-43.008-52.181-26.496-97.749-63.488-133.931-108.16-56.405-69.717-89.899-158.080-89.941-253.696-0.597-54.4 10.795-111.36 35.157-165.419l-75.605-226.859c-2.816-8.363-3.072-17.835 0-26.965 7.467-22.357 31.616-34.432 53.973-26.965l226.731 75.563c49.493-22.485 105.984-35.243 165.376-35.115 58.539 0.384 115.797 13.141 168.149 36.949 81.579 37.163 151.040 101.248 193.749 186.667 27.477 53.291 43.307 115.84 43.136 181.803zM853.333 447.872c0.128-52.267-12.459-101.333-33.664-142.464-34.176-68.352-88.832-118.827-153.259-148.139-41.387-18.859-86.827-28.971-133.376-29.269-52.096-0.128-101.163 12.459-142.293 33.664-10.624 5.504-22.528 6.059-33.067 2.56l-162.261-54.101 54.101 162.261c3.755 11.221 2.56 22.912-2.389 32.725-23.552 46.677-34.304 96.171-33.792 142.421 0.043 76.331 26.411 145.92 70.955 200.917 28.629 35.371 64.768 64.725 106.24 85.76 46.592 23.552 96.085 34.304 142.336 33.792h19.456c83.712-4.565 158.037-41.003 212.011-97.152 51.285-53.376 84.139-124.416 89.003-202.795z"/></svg>',commentClose:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" fill="currentColor"><path transform="translate(0, 960) scale(1, -1)" d="M810 664.667l-238-238 238-238-60-60-238 238-238-238-60 60 238 238-238 238 60 60 238-238 238 238z"/></svg>'},t="lgBeforeSlide",o="lgAfterSlide",s={commentBox:!1,fbComments:!1,disqusComments:!1,disqusConfig:{title:void 0,language:"en"},commentsMarkup:'<div id="lg-comment-box" class="lg-comment-box lg-fb-comment-box"><div class="lg-comment-header"><h3 class="lg-comment-title">Leave a comment.</h3><span class="lg-comment-close lg-icon"></span></div><div class="lg-comment-body"></div></div>'};var n=Object.defineProperty,i=Object.getOwnPropertySymbols,l=Object.prototype.hasOwnProperty,c=Object.prototype.propertyIsEnumerable,r=(e,t,o)=>t in e?n(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,m=(e,t)=>{for(var o in t||(t={}))l.call(t,o)&&r(e,o,t[o]);if(i)for(var o of i(t))c.call(t,o)&&r(e,o,t[o]);return e};return class{constructor(e,t){return this.core=e,this.$LG=t,this.settings=m(m({},s),this.core.settings),this}init(){this.core.registerDefaultIcons(e),this.settings.commentBox&&(this.setMarkup(),this.toggleCommentBox(),this.settings.fbComments?this.addFbComments():this.settings.disqusComments&&this.addDisqusComments())}setMarkup(){var e,t;this.core.outer.append(this.settings.commentsMarkup+'<div class="lg-comment-overlay"></div>');const o=`<button type="button" aria-label="${null!=(t=null==(e=this.settings.commentPluginStrings)?void 0:e.toggleComments)?t:this.core.settings.strings.toggleComments}" class="lg-comment-toggle lg-icon"></button>`;this.core.$toolbar.append(o)}toggleCommentBox(){this.core.outer.find(".lg-comment-toggle").first().on("click.lg.comment",()=>{this.core.outer.toggleClass("lg-comment-active")}),this.core.outer.find(".lg-comment-overlay").first().on("click.lg.comment",()=>{this.core.outer.removeClass("lg-comment-active")}),this.core.outer.find(".lg-comment-close").first().on("click.lg.comment",()=>{this.core.outer.removeClass("lg-comment-active")})}addFbComments(){const e=this;this.core.LGel.on(`${t}.comment`,e=>{const t=this.core.galleryItems[e.detail.index].fbHtml;this.core.outer.find(".lg-comment-body").html(t)}),this.core.LGel.on(`${o}.comment`,function(){try{FB.XFBML.parse()}catch(t){e.$LG(window).on("fbAsyncInit",function(){FB.XFBML.parse()})}})}addDisqusComments(){const e=this.$LG("#disqus_thread");e.remove(),this.core.outer.find(".lg-comment-body").append('<div id="disqus_thread"></div>'),this.core.LGel.on(`${t}.comment`,()=>{e.html("")}),this.core.LGel.on(`${o}.comment`,e=>{const{index:t}=e.detail,o=this;setTimeout(function(){try{DISQUS.reset({reload:!0,config:function(){this.page.identifier=o.core.galleryItems[t].disqusIdentifier,this.page.url=o.core.galleryItems[t].disqusUrl,this.page.title=o.settings.disqusConfig.title,this.language=o.settings.disqusConfig.language}})}catch(e){console.error("lightGallery: make sure you have included the Disqus JavaScript code in your document. See https://www.lightgalleryjs.com/docs/settings/#comment-box-plugin")}},o.core.lGalleryOn?0:1e3)})}destroy(){this.core.LGel.off(".lg.comment"),this.core.LGel.off(".comment")}}});