PageSourceSearch

https://gsconstructioninc.com/wp-content/plugins/sfs-gallery/js/sfs-gallery.js?ver=1.0.0

js gsconstructioninc.com collected 2026-10-04 02:35:19 UTC 18,205 bytes, 384 lines download raw bytes

1/*
2* SFS Gallery Display Script
3*/
4
5jQuery(document).ready(function () {
6    //lazyloads elements with default selector as '.lazyload'
7    //lazyload();  
8
9    /*
10    * Slice List by Value
11    * Show and Hide Load More Button
12    */
13    function gallery_loadmore(value) {
14        jQuery('.sfs-custom-gallery').each(function() {
15            var ths         = jQuery(this);
16            var ths_galcont = ths.find(value);
17
18            jQuery(ths_galcont).each(function() {
19                var img_item    = jQuery(this).find('.sfs-image-item');
20                var morebtn     = jQuery(this).find('.sfs-loadmore');
21                var show        = morebtn.attr('data-show');
22                var r_more      = img_item.length;
23
24                if ( r_more <= show  ) {
25                    jQuery(morebtn).hide();
26                } else {
27                    jQuery(morebtn).show();
28                }
29
30                jQuery(img_item).slice(0, show).show().css('display', 'block');
31                jQuery(morebtn).on('click', function (e) {
32                    var btn_parent  = jQuery(this).parent();
33                    var new_load    = jQuery(this).attr('data-load');
34                    var hidden      = btn_parent.find('.sfs-image-item:hidden');
35                    var last        = btn_parent.find('.sfs-image-item:last');
36
37                    e.preventDefault();
38                    jQuery(hidden).slice(0, new_load).slideDown().css('display', 'block').addClass('to-show');
39                    if (jQuery(hidden).length == 0) {
40                        jQuery(morebtn).fadeOut('slow');
41                    }
42
43                    if ( jQuery(last).hasClass('to-show') ) {
44                        jQuery(morebtn).hide();
45                    }
46                });
47            });
48        });
49    }
50    gallery_loadmore('.sfs-grid-images');
51    gallery_loadmore('.sfs-category-images');
52    gallery_loadmore('.sfs-album-images');
53    gallery_loadmore('.sfs-album-category-images');
54
55
56
57
58    /*
59    * Gallery AjAx Load
60    */
61    jQuery('.sfs-custom-gallery').each(function() {
62        var ths         = jQuery(this);
63        var nav         = jQuery(this).find('.sfs-category-navigation');
64        var nav_list    = nav.find('.category-item');
65        var image_list  = jQuery(this).find('.sfs-category-gallery');
66        var img_cat     = ths.find('.sfs-category-images .container');
67        var img_loader  = ths.find('.sfs-gallery-loader');
68        var cta_imgs    = img_cat.find('.sfs-image-item');
69        var data_col    = ths.find('.sfs-category-images').attr('data-col');
70        var pop_cont    = ths.find('.gallery-item-image-popup');
71        var gallery_id  = image_list.attr('gallery_id');
72        var data_title  = image_list.attr('data_title');
73        var alb_cont    = ths.find('.sfs-album-category-images .container');
74        var alb_data_col    = ths.find('.sfs-album-category-images').attr('data-col');
75        var alb_image_list  = jQuery(this).find('.sfs-album-category-gallery');
76        var alb_gallery_id  = alb_image_list.attr('gallery_id');
77
78        jQuery(nav_list).on('click', function() {
79            var clk     = jQuery(this);
80            var cat     = jQuery(this).attr('data-cat');
81            var id      = jQuery(this).attr('data-id');
82            var type    = jQuery(this).attr('gallery-type');
83            var size    = jQuery(this).attr('data-img-size');
84
85            jQuery.ajax({
86                url: ajax_object.ajax_url,
87                type: 'POST',
88                dataType: 'json',
89                data: ({
90                    action: 'gallery_ajax_request',
91                    id : id,
92                    category : cat,
93                    type : type,
94                    size : size,
95                }),
96                beforeSend: function() {
97                    jQuery(img_cat).empty();
98                    jQuery(alb_cont).empty();
99                    jQuery(img_loader).append('<span class="loader"><img src="/wp-content/plugins/sfs-gallery/images/ajax_loader.gif"></span>');
100                  },
101                success: function(result){
102                    //console.log(result);
103                    jQuery(img_loader).empty();
104
105                    if ( type == 'category_gallery') {
106                        jQuery(img_cat).empty();
107                        jQuery(pop_cont).empty();
108
109                        jQuery.each(result, function() {
110                            var count = Object.keys(result).length;
111                            jQuery(img_loader).empty();
112                            jQuery(img_cat).append('<div class="sfs-image-item '+data_col+'"><div class="sfs-image-item-container"><div class="sfs-gallery-image" data-id="image_result_'+this.counter+'_'+gallery_id+'"><img src="'+this.image+'" alt="'+this.alt+'" title="'+this.alt+'"></div>'+ ( data_title == 'true' ? '<div class="sfs-image-title">'+this.alt+'</div>' : '' ) +'</div></div>')
113                                .slideDown(1000);
114                            jQuery(pop_cont).append('<div class="sfs-gallery-popup-image" id="image_result_'+this.counter+'_'+gallery_id+'" rel="category_image"><img src="'+this.full+'" alt="'+this.alt+'" title="'+this.alt+'"><div class="sfs-image-count">'+this.counter+' / '+count+'</div></div>')
115                                .slideDown(1000);
116                        });
117
118                        // popup image
119                        jQuery('.sfs-custom-gallery').each(function() {
120                            var new_ths = jQuery(this);
121                            var new_list = new_ths.find('.sfs-image-item');
122                            var new_cont = new_ths.find('.gallery-item-image-popup');
123                            jQuery(new_list).click(function() {
124                                var data_id = jQuery(this).find('.sfs-gallery-image').attr('data-id');
125
126                                jQuery(new_ths).find('.gallery-image-popup').css('display', 'block');
127                                jQuery('.sfs-gallery-popup-image').removeClass('active');
128                                jQuery(new_cont).css('display', 'block');
129                                jQuery('#'+data_id).addClass('active');
130                            });
131                        });
132
133                    } else {
134                        //console.log(result);
135                        jQuery(alb_cont).empty();
136
137                        jQuery.each(result, function() {
138                            jQuery(img_loader).empty();
139                            jQuery(alb_cont).append('<div class="sfs-image-item '+alb_data_col+'"><div class="sfs-image-item-container"><div class="sfs-gallery-image" data-id="'+this.alb_title_lower+'_album_category_'+alb_gallery_id+'_1"><img src="'+this.image+'" alt="'+this.alt+'" title="'+this.alt+'"></div>'+ ( this.enable_title == 'true' ? '<div class="sfs-album-title">'+this.album_title+'</div>' : '' ) +''+ ( this.enable_title == 'true' ? '<div class="sfs-album-description">'+this.album_desc+'</div>' : '' ) +'</div></div></div>')
140                                .slideDown(1000);
141                        });
142
143                        jQuery('.sfs-custom-gallery').each(function() {
144                            var alb_ths = jQuery(this);
145                                alb_new_list = alb_ths.find('.sfs-image-item');
146                                alb_new_cont = alb_ths.find('.gallery-item-image-popup');
147
148                                jQuery(alb_new_list).click(function() {
149                                    var data_id = jQuery(this).find('.sfs-gallery-image').attr('data-id');
150                                    var data_prt    = jQuery('#'+data_id).parent();
151
152                                    //console.log(data_prt);
153
154                                    jQuery('.gallery-item-image-popup').css('display', '');
155                                    jQuery(data_prt).css('display', 'block');
156                                    jQuery(alb_ths).find('.gallery-image-popup').css('display', 'block');
157                                    jQuery('.sfs-gallery-popup-image').removeClass('active');
158                                    jQuery('#'+data_id).addClass('active');
159                                });
160                        });
161
162                    }
163
164                    // loadmore image
165                    jQuery('.sfs-custom-gallery').each(function() {
166                        var new_ths         = jQuery(this);
167                        var new_img_item    = jQuery(new_ths).find('.sfs-image-item');
168                        var new_clk         = jQuery(new_ths).find('.sfs-loadmore');
169                        var new_data_show   = jQuery(new_ths).find('.sfs-loadmore').attr('data-show');
170                        var new_data_load   = jQuery(new_ths).find('.sfs-loadmore').attr('data-load');
171                        var new_r_more      = new_img_item.length;
172
173                        if ( new_r_more <= new_data_show  ) {
174                            jQuery(new_clk).hide();
175                        } else {
176                            jQuery(new_clk).show();
177                        }
178
179                        jQuery(new_img_item).slice(0, new_data_show).show().css('display', 'block');
180                        
181                    });
182
183                }
184            });
185        });
186    });
187
188
189    /*
190    * Gallery Slide JS
191    */
192    function create_slide_gallery(container) {
193        jQuery(container).each(function() {
194            var ths                     = jQuery(this);
195            var breakpoint              = ths.find('.gallery-item-container')
196            let toSlick                 = ths.find('.container');
197            let toSlick_Preview         = ( ths.find('.preview-gallery')[0] ? ths.find('.preview-gallery') : '' );
198            let to_show                 = parseInt(ths.attr('data-sli
198deshow'));
199            let to_roll                 = parseInt(ths.attr('data-slideroll'));
200            let control_left            = ths.find('.left-control');
201            let control_right           = ths.find('.right-control');
202            let control_left_prev       = ths.find('.left-control-nav-prev');
203            let control_right_prev      = ths.find('.right-control-nav-prev');
204            let slide_speed             = parseInt(ths.attr('data-speed'));
205            let slide_autoplay_speed    = parseInt(ths.attr('data-autoplay-speed'));
206            let slide_autoplay          = ( ths.attr('data-auto-play') == 'false' ? false : true );
207            let slide_pauseonhover      = ( ths.attr('data-pausehover') == 'false' ? false : true );
208            let st_br_points            = parseInt(breakpoint.attr('data-stwidth'));
209            let nd_br_points            = parseInt(breakpoint.attr('data-ndwidth'));
210            let rd_br_points            = parseInt(breakpoint.attr('data-rdwidth'));
211            let st_br_show              = parseInt(breakpoint.attr('data-stshow'));
212            let nd_br_show              = parseInt(breakpoint.attr('data-ndshow'));
213            let rd_br_show              = parseInt(breakpoint.attr('data-rdshow'));
214            let st_br_scroll            = parseInt(breakpoint.attr('data-stscroll'));
215            let nd_br_scroll            = parseInt(breakpoint.attr('data-ndscroll'));
216            let rd_br_scroll            = parseInt(breakpoint.attr('data-rdscroll'));
217
218            jQuery(toSlick).slick({
219                dots: false,
220                infinite: true,
221                fade: false,
222                slidesToShow: to_show,
223                slidesToScroll: to_roll,
224                autoplay: slide_autoplay,
225                pauseOnHover: slide_pauseonhover,
226                autoplaySpeed: slide_autoplay_speed,
227                speed: slide_speed,
228                prevArrow: control_left,
229                nextArrow: control_right,
230                asNavFor: toSlick_Preview,
231                focusOnSelect: true,
232                responsive: [
233                    {
234                      breakpoint: st_br_points,
235                      settings: {
236                        slidesToShow: st_br_show,
237                        slidesToScroll: st_br_scroll,
238                      }
239                    },
240                    {
241                      breakpoint: nd_br_points,
242                      settings: {
243                        slidesToShow: nd_br_show,
244                        slidesToScroll: nd_br_scroll,
245                      }
246                    },
247                    {
248                      breakpoint: rd_br_points,
249                      settings: {
250                        slidesToShow: rd_br_show,
251                        slidesToScroll: rd_br_scroll,
252                      }
253                    }
254                ]
255            });
256
257            jQuery(toSlick_Preview).slick({
258                dots: false,
259                infinite: true,
260                fade: false,
261                slidesToShow: 1,
262                slidesToScroll: 1,
263                autoplay: slide_autoplay,
264                pauseOnHover: slide_pauseonhover,
265                autoplaySpeed: slide_autoplay_speed,
266                speed: slide_speed,
267                prevArrow: control_left_prev,
268                nextArrow: control_right_prev,
269                adaptiveHeight: true,
270                asNavFor: toSlick,
271            });
272        });
273    }
274    create_slide_gallery('.sfs-slide-images');
275    create_slide_gallery('.sfs-navigation-images');
276    create_slide_gallery('.sfs-album_slide-images');
277
278
279    /*
280    * Display Popup
281    */
282    function sfs_gallery_popup_result_image() {
283        jQuery('.sfs-custom-gallery').each(function() {
284
285            var new_ths = jQuery(this);
286            var new_list = new_ths.find('.sfs-image-item');
287            var clk_list = new_list.find('.sfs-gallery-image');
288            var clk_title = new_list.find('.sfs-image-title');
289            var clk_title_album = new_list.find('.sfs-album-title');
290            var new_cont = new_ths.find('.gallery-item-image-popup');
291            var right_control           = new_ths.find('.popup-slide-control .right-slide');
292            var left_control            = new_ths.find('.popup-slide-control .left-slide');
293
294            jQuery(clk_list).click(function() {
295                var data_id     = jQuery(this).attr('data-id');
296                var data_prt    = jQuery('#'+data_id).parent();
297
298                jQuery('.gallery-item-image-popup').css('display', '');
299                jQuery(data_prt).css('display', 'block');
300                jQuery(new_ths).find('.gallery-image-popup').css('display', 'block');
301                jQuery('.sfs-gallery-popup-image').removeClass('active');
302                jQuery('#'+data_id).addClass('active');
303            });
304            
305            jQuery(clk_title_album).click(function() {
306                var img_ths     = jQuery(this);
307                var img_parent  = jQuery(img_ths).parent();
308                var img_cont    = jQuery(img_parent).find('.sfs-gallery-image');
309                var data_id     = jQuery(img_cont).attr('data-id');
310                var data_prt    = jQuery('#'+data_id).parent();
311
312                jQuery('.gallery-item-image-popup').css('display', '');
313                jQuery(data_prt).css('display', 'block');
314                jQuery(new_ths).find('.gallery-image-popup').css('display', 'block');
315                jQuery('.sfs-gallery-popup-image').removeClass('active');
316                jQuery('#'+data_id).addClass('active');
317            });
318            
319            jQuery(clk_title).click(function() {
320                var img_ths     = jQuery(this);
321                var img_parent  = jQuery(img_ths).parent();
322                var img_cont    = jQuery(img_parent).find('.sfs-gallery-image');
323                var data_id     = jQuery(img_cont).attr('data-id');
324                var data_prt    = jQuery('#'+data_id).parent();
325
326                jQuery('.gallery-item-image-popup').css('display', '');
327                jQuery(data_prt).css('display', 'block');
328                jQuery(new_ths).find('.gallery-image-popup').css('display', 'block');
329                jQuery('.sfs-gallery-popup-image').removeClass('active');
330                jQuery('#'+data_id).addClass('active');
331            });
332
333            jQuery('.sfs-popup-close').click(function() {
334                jQuery('.sfs-gallery-popup-image').removeClass('active');
335                jQuery('.gallery-image-popup').css('display', '');
336                jQuery('.gallery-item-image-popup').css('display', '');
337            });
338
339            jQuery(right_control).click(function() {
340                let current_active          = jQuery(".sfs-gallery-popup-image.active");
341                let last_element_active     = jQuery(".sfs-gallery-popup-image.active").is(":last-child");
342                let popup_items_parent      = current_active.parent();
343
344                if ( last_element_active ) {
345                    current_active.removeClass("active");
346                    popup_items_parent.children(':first').addClass('active');
347                }else {
348                    current_active.removeClass("active").next().addClass("active");
349                }
350
351            });
352
353            jQuery(left_control).click(function() {
354                let current_active          = jQuery(".sfs-gallery-popup-image.active");
355                let first_element_active    = jQuery(".sfs-gallery-popup-image.active").is(":first-child");
356                let popup_items_parent      = current_active.parent();
357
358                if ( first_element_active ) {
359                    current_active.removeClass("active");
360                    popup_items_parent.children(':last').addClass('active');
361                }else {
362                    current_active.removeClass("active").prev().addClass("active");
363                }
364
365            });
366        });   
367    }
368    sfs_gallery_popup_result_image();
369
370
371
372    /*
373    * Gallery Category Active
374    */
375    jQuery('.sfs-category-navigation .category-item').each(function() {
376        jQuery('.sfs-category-navigation .category-item').addClass('active');
377        jQuery(this).click(function() {
378            jQuery('.sfs-category-navigation .category-item').removeClass('active');
379            jQuery(this).addClass('active');
380        });
381    });
382
383
384});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.