Skip to content

Commit 85f35c2

Browse files
committed
Update main.js
Signed-off-by: raja2576 <164044997+raja2576@users.noreply.github.com>
1 parent 209ade5 commit 85f35c2

File tree

1 file changed

+28
-15
lines changed

1 file changed

+28
-15
lines changed

js/main.js

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@
99

1010
var cfg = {
1111
scrollDuration: 800, // smoothscroll duration
12-
mailChimpURL: 'https://facebook.us8.list-manage.com/subscribe/post?u=cdb7b577e41181934ed6a6a44&amp;id=e6957d85dc' // mailchimp url
12+
//mailChimpURL: 'https://facebook.us8.list-manage.com/subscribe/post?u=cdb7b577e41181934ed6a6a44&amp;id=e6957d85dc' // mailchimp url
13+
// post should be post-json for AJAX requests, as noted in the plugin doc.
14+
15+
mailChimpURL: 'https://facebook.us8.list-manage.com/subscribe/post-json?u=cdb7b577e41181934ed6a6a44&id=e6957d85dc&c=?'
16+
1317
},
1418

1519
$WIN = $(window);
@@ -108,16 +112,20 @@
108112
// get items
109113
$folioItems.each(function (i) {
110114

111-
var $folio = $(this),
112-
$thumbLink = $folio.find('.thumb-link'),
113-
$title = $folio.find('.item-folio__title'),
114-
$caption = $folio.find('.item-folio__caption'),
115-
$titleText = '<h4>' + $.trim($title.html()) + '</h4>',
116-
$captionText = $.trim($caption.html()),
117-
$href = $thumbLink.attr('href'),
118-
$size = $thumbLink.data('size').split('x'),
119-
$width = $size[0],
120-
$height = $size[1];
115+
var $folio = $(this);
116+
var $thumbLink = $folio.find('.thumb-link');
117+
var $title = $folio.find('.item-folio__title');
118+
var $caption = $folio.find('.item-folio__caption');
119+
var $titleText = '<h4>' + $.trim($title.html()) + '</h4>';
120+
var $captionText = $.trim($caption.html());
121+
var $href = $thumbLink.attr('href');
122+
123+
var sizeAttr = $thumbLink.data('size');
124+
if (!sizeAttr) return; // safely skip if data-size is missing
125+
126+
var $size = sizeAttr.split('x');
127+
var $width = $size[0];
128+
var $height = $size[1];
121129

122130
var item = {
123131
src: $href,
@@ -143,8 +151,11 @@
143151
}
144152

145153
// initialize PhotoSwipe
146-
var lightBox = new clPhotoswipe($pswp, PhotoSwipeUI_Default, items, options);
147-
lightBox.init();
154+
// var lightBox = new clPhotoswipe($pswp, PhotoSwipeUI_Default, items, options);
155+
//clPhotoswipe is being recursively called inside itself instead of using PhotoSwipe constructor.
156+
var lightBox = new PhotoSwipe($pswp, PhotoSwipeUI_Default, items, options);
157+
158+
lightBox.init();
148159
});
149160

150161
});
@@ -348,8 +359,10 @@
348359
success: function (msg) {
349360

350361
// Message was sent
351-
if (msg == 'OK') {
352-
sLoader.slideUp("slow");
362+
// if (msg == 'OK') { //This is not a reliable check. Server messages should ideally return a JSON structure with a status.
363+
var res = JSON.parse(msg); // Fix (if backend can be adjusted):
364+
if (res.status === 'success') {
365+
sLoader.slideUp("slow");
353366
$('.message-warning').fadeOut();
354367
$('#contactForm').fadeOut();
355368
$('.message-success').fadeIn();

0 commit comments

Comments
 (0)