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

9 lines (7 loc) 3.17 kB
/** * lightgallery | 2.1.7 | July 1st 2021 * http://www.lightgalleryjs.com/ * Copyright (c) 2020 Sachin Neravath; * @license GPLv3 */ !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).lgComment=e()}(this,function(){"use strict";var o=function(){return(o=Object.assign||function(t){for(var e,o=1,n=arguments.length;o<n;o++)for(var i in e=arguments[o])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)},i="lgBeforeSlide",s="lgAfterSlide",n={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>'};function t(t,e){return this.core=t,this.$LG=e,this.settings=o(o({},n),this.core.settings),this}return t.prototype.init=function(){this.settings.commentBox&&(this.setMarkup(),this.toggleCommentBox(),this.settings.fbComments?this.addFbComments():this.settings.disqusComments&&this.addDisqusComments())},t.prototype.setMarkup=function(){this.core.$lgContent.append(this.settings.commentsMarkup+'<div class="lg-comment-overlay"></div>');this.core.$toolbar.append('<button type="button" aria-label="Toggle comments" class="lg-comment-toggle lg-icon"></button>')},t.prototype.toggleCommentBox=function(){var t=this;this.core.outer.find(".lg-comment-toggle").first().on("click.lg.comment",function(){t.core.outer.toggleClass("lg-comment-active")}),this.core.outer.find(".lg-comment-overlay").first().on("click.lg.comment",function(){t.core.outer.removeClass("lg-comment-active")}),this.core.outer.find(".lg-comment-close").first().on("click.lg.comment",function(){t.core.outer.removeClass("lg-comment-active")})},t.prototype.addFbComments=function(){var e=this,o=this;this.core.LGel.on(i+".comment",function(t){t=e.core.galleryItems[t.detail.index].fbHtml;e.core.outer.find(".lg-comment-body").html(t)}),this.core.LGel.on(s+".comment",function(){try{FB.XFBML.parse()}catch(t){o.$LG(window).on("fbAsyncInit",function(){FB.XFBML.parse()})}})},t.prototype.addDisqusComments=function(){var n=this,t=this.$LG("#disqus_thread");t.remove(),this.core.outer.find(".lg-comment-body").append('<div id="disqus_thread"></div>'),this.core.LGel.on(i+".comment",function(){t.html("")}),this.core.LGel.on(s+".comment",function(t){var e=t.detail.index,o=n;setTimeout(function(){try{DISQUS.reset({reload:!0,config:function(){this.page.identifier=o.core.galleryItems[e].disqusIdentifier,this.page.url=o.core.galleryItems[e].disqusURL,this.page.title=o.settings.disqusConfig.title,this.language=o.settings.disqusConfig.language}})}catch(t){console.error("Make sure you have included disqus JavaScript code in your document. Ex - https://lg-disqus.disqus.com/admin/install/platforms/universalcode/")}},o.core.lGalleryOn?0:1e3)})},t.prototype.destroy=function(){this.core.LGel.off(".lg.comment"),this.core.LGel.off(".comment")},t});