1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 | var __assign = function() {
|
24 | __assign = Object.assign || function __assign(t) {
|
25 | for (var s, i = 1, n = arguments.length; i < n; i++) {
|
26 | s = arguments[i];
|
27 | for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
28 | }
|
29 | return t;
|
30 | };
|
31 | return __assign.apply(this, arguments);
|
32 | };
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 | var lGEvents = {
|
40 | afterAppendSlide: 'lgAfterAppendSlide',
|
41 | init: 'lgInit',
|
42 | hasVideo: 'lgHasVideo',
|
43 | containerResize: 'lgContainerResize',
|
44 | updateSlides: 'lgUpdateSlides',
|
45 | afterAppendSubHtml: 'lgAfterAppendSubHtml',
|
46 | beforeOpen: 'lgBeforeOpen',
|
47 | afterOpen: 'lgAfterOpen',
|
48 | slideItemLoad: 'lgSlideItemLoad',
|
49 | beforeSlide: 'lgBeforeSlide',
|
50 | afterSlide: 'lgAfterSlide',
|
51 | posterClick: 'lgPosterClick',
|
52 | dragStart: 'lgDragStart',
|
53 | dragMove: 'lgDragMove',
|
54 | dragEnd: 'lgDragEnd',
|
55 | beforeNextSlide: 'lgBeforeNextSlide',
|
56 | beforePrevSlide: 'lgBeforePrevSlide',
|
57 | beforeClose: 'lgBeforeClose',
|
58 | afterClose: 'lgAfterClose',
|
59 | rotateLeft: 'lgRotateLeft',
|
60 | rotateRight: 'lgRotateRight',
|
61 | flipHorizontal: 'lgFlipHorizontal',
|
62 | flipVertical: 'lgFlipVertical',
|
63 | autoplay: 'lgAutoplay',
|
64 | autoplayStart: 'lgAutoplayStart',
|
65 | autoplayStop: 'lgAutoplayStop',
|
66 | };
|
67 |
|
68 | var commentSettings = {
|
69 | commentBox: false,
|
70 | fbComments: false,
|
71 | disqusComments: false,
|
72 | disqusConfig: {
|
73 | title: undefined,
|
74 | language: 'en',
|
75 | },
|
76 | 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>',
|
77 | commentPluginStrings: {
|
78 | toggleComments: 'Toggle Comments',
|
79 | },
|
80 | };
|
81 |
|
82 |
|
83 |
|
84 |
|
85 |
|
86 |
|
87 |
|
88 |
|
89 |
|
90 |
|
91 |
|
92 | var CommentBox = (function () {
|
93 | function CommentBox(instance, $LG) {
|
94 |
|
95 | this.core = instance;
|
96 | this.$LG = $LG;
|
97 |
|
98 | this.settings = __assign(__assign({}, commentSettings), this.core.settings);
|
99 | return this;
|
100 | }
|
101 | CommentBox.prototype.init = function () {
|
102 | if (!this.settings.commentBox) {
|
103 | return;
|
104 | }
|
105 | this.setMarkup();
|
106 | this.toggleCommentBox();
|
107 | if (this.settings.fbComments) {
|
108 | this.addFbComments();
|
109 | }
|
110 | else if (this.settings.disqusComments) {
|
111 | this.addDisqusComments();
|
112 | }
|
113 | };
|
114 | CommentBox.prototype.setMarkup = function () {
|
115 | this.core.outer.append(this.settings.commentsMarkup +
|
116 | '<div class="lg-comment-overlay"></div>');
|
117 | var commentToggleBtn = "<button type=\"button\" aria-label=\"" + this.settings.commentPluginStrings['toggleComments'] + "\" class=\"lg-comment-toggle lg-icon\"></button>";
|
118 | this.core.$toolbar.append(commentToggleBtn);
|
119 | };
|
120 | CommentBox.prototype.toggleCommentBox = function () {
|
121 | var _this_1 = this;
|
122 | this.core.outer
|
123 | .find('.lg-comment-toggle')
|
124 | .first()
|
125 | .on('click.lg.comment', function () {
|
126 | _this_1.core.outer.toggleClass('lg-comment-active');
|
127 | });
|
128 | this.core.outer
|
129 | .find('.lg-comment-overlay')
|
130 | .first()
|
131 | .on('click.lg.comment', function () {
|
132 | _this_1.core.outer.removeClass('lg-comment-active');
|
133 | });
|
134 | this.core.outer
|
135 | .find('.lg-comment-close')
|
136 | .first()
|
137 | .on('click.lg.comment', function () {
|
138 | _this_1.core.outer.removeClass('lg-comment-active');
|
139 | });
|
140 | };
|
141 | CommentBox.prototype.addFbComments = function () {
|
142 | var _this_1 = this;
|
143 |
|
144 | var _this = this;
|
145 | this.core.LGel.on(lGEvents.beforeSlide + ".comment", function (event) {
|
146 | var html = _this_1.core.galleryItems[event.detail.index].fbHtml;
|
147 | _this_1.core.outer.find('.lg-comment-body').html(html);
|
148 | });
|
149 | this.core.LGel.on(lGEvents.afterSlide + ".comment", function () {
|
150 | try {
|
151 | FB.XFBML.parse();
|
152 | }
|
153 | catch (err) {
|
154 | _this.$LG(window).on('fbAsyncInit', function () {
|
155 | FB.XFBML.parse();
|
156 | });
|
157 | }
|
158 | });
|
159 | };
|
160 | CommentBox.prototype.addDisqusComments = function () {
|
161 | var _this_1 = this;
|
162 | var $disqusThread = this.$LG('#disqus_thread');
|
163 | $disqusThread.remove();
|
164 | this.core.outer
|
165 | .find('.lg-comment-body')
|
166 | .append('<div id="disqus_thread"></div>');
|
167 | this.core.LGel.on(lGEvents.beforeSlide + ".comment", function () {
|
168 | $disqusThread.html('');
|
169 | });
|
170 | this.core.LGel.on(lGEvents.afterSlide + ".comment", function (event) {
|
171 | var index = event.detail.index;
|
172 |
|
173 | var _this = _this_1;
|
174 |
|
175 | setTimeout(function () {
|
176 | try {
|
177 | DISQUS.reset({
|
178 | reload: true,
|
179 | config: function () {
|
180 | this.page.identifier =
|
181 | _this.core.galleryItems[index].disqusIdentifier;
|
182 | this.page.url =
|
183 | _this.core.galleryItems[index].disqusURL;
|
184 | this.page.title =
|
185 | _this.settings.disqusConfig.title;
|
186 | this.language =
|
187 | _this.settings.disqusConfig.language;
|
188 | },
|
189 | });
|
190 | }
|
191 | catch (err) {
|
192 | console.error('Make sure you have included disqus JavaScript code in your document. Ex - https://lg-disqus.disqus.com/admin/install/platforms/universalcode/');
|
193 | }
|
194 | }, _this.core.lGalleryOn ? 0 : 1000);
|
195 | });
|
196 | };
|
197 | CommentBox.prototype.destroy = function () {
|
198 | this.core.LGel.off('.lg.comment');
|
199 | this.core.LGel.off('.comment');
|
200 | };
|
201 | return CommentBox;
|
202 | }());
|
203 |
|
204 | export default CommentBox;
|
205 |
|