|
9 | 9 |
|
10 | 10 | var cfg = { |
11 | 11 | scrollDuration: 800, // smoothscroll duration |
12 | | - mailChimpURL: 'https://facebook.us8.list-manage.com/subscribe/post?u=cdb7b577e41181934ed6a6a44&id=e6957d85dc' // mailchimp url |
| 12 | + //mailChimpURL: 'https://facebook.us8.list-manage.com/subscribe/post?u=cdb7b577e41181934ed6a6a44&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 | + |
13 | 17 | }, |
14 | 18 |
|
15 | 19 | $WIN = $(window); |
|
108 | 112 | // get items |
109 | 113 | $folioItems.each(function (i) { |
110 | 114 |
|
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]; |
121 | 129 |
|
122 | 130 | var item = { |
123 | 131 | src: $href, |
|
143 | 151 | } |
144 | 152 |
|
145 | 153 | // 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(); |
148 | 159 | }); |
149 | 160 |
|
150 | 161 | }); |
|
348 | 359 | success: function (msg) { |
349 | 360 |
|
350 | 361 | // 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"); |
353 | 366 | $('.message-warning').fadeOut(); |
354 | 367 | $('#contactForm').fadeOut(); |
355 | 368 | $('.message-success').fadeIn(); |
|
0 commit comments