PageSourceSearch

https://atomicpestcontrol.com/wp-content/plugins/dg-carousel/scripts/frontend.js?ver=5.1.0

js atomicpestcontrol.com collected 2026-09-29 13:09:27 UTC 14,963 bytes, 415 lines download raw bytes

1// This script is loaded both on the frontend page and in the Visual Builder.
2jQuery(function($) {
3	function parseDatasetJson(value, fallback, context) {
4		if (typeof value !== 'string') {
5			return fallback;
6		}
7
8		const normalizedValue = value.trim();
9
10		if (
11			'' === normalizedValue ||
12			'undefined' === normalizedValue ||
13			'null' === normalizedValue
14		) {
15			return fallback;
16		}
17
18		try {
19			return JSON.parse(normalizedValue);
20		} catch (error) {
21			if (window.console && typeof window.console.warn === 'function') {
22				window.console.warn('Divi Carousel: invalid JSON dataset payload.', {
23					context,
24					value: normalizedValue,
25					error,
26				});
27			}
28
29			return fallback;
30		}
31	}
32	if(window.location.hash) {
33		let hash = window.location.hash.substring(1);
34		// alert (hash);
35	}
36	
37    $('.dica_divi_carousel').each(function(index, element){
38		let active_index = 0;
39	    // Limit Content
40	    textExcerptController(element);
41	    window.addEventListener('resize', function(){
42		    textExcerptController(element);
43	    })
44      let selector            =   element.querySelector('.swiper-container');
45      let container           =   element.querySelector('.dica-container');
46      let data                =   parseDatasetJson(
47                                  container && container.dataset ? container.dataset.props : null,
48                                  null,
49                                  'dica-container[data-props]'
50                                );
51      if (!data) {
52        return;
53      }
54      let dataSpeed           =   Number(data.speed);
55      let dataDesktop         =   Number(data.desktop);
56      let dataTablet          =   Number(data.tablet);
57      let dataMobile          =   Number(data.mobile);
58      let dataArrow           =   data.arrow;
59      let dataDots            =   data.dots;
60      let dataAutoPlay        =   data.autoplay;
61      let dataAutoPlaySpeed   =   Number(data.autoSpeed);
62      let dataloop            =   data.loop;
63      let itemSpace           =   Number(data.item_spacing.replace(/[^0-9.]/g, ""));
64      let centerMode          =   data.center_mode;
65      let sliderEffect        =   data.slider_effec;
66      let pausehover          =   data.pause_onhover;
67      let multislide          =   data.multislide;
68      let cfshadow            =   data.cfshadow;
69      let order               =   data.order;
70      let lazyload            =   data.lazyload == 'on' ? 
71                                  {loadedClass : 'swiper-lazy-loaded'} : false;
72      let scroller_effect     =   ('on' === dataAutoPlay) ? data.scroller_effect : 'off';
73      let scrollSpeed         =   Number(data.scroller_speed);
74      let autoWidth           =   data.autowidth;
75      let item_spacing_tablet =  Number(data.item_spacing_tablet.replace(/[^0-9.]/g, ""));
76      let item_spacing_phone  =  Number(data.item_spacing_phone.replace(/[^0-9.]/g, ""));
77
78      dataAutoPlaySpeed = 'on' !== scroller_effect ? dataAutoPlaySpeed : 1;
79      
80      if (data.lazybefore == 'on') {
81        lazyload.loadOnTransitionStart = true ;
82      } else {
83        lazyload.loadOnTransitionStart = false;
84      }
85
86      let nav_object          =   (dataArrow == "on") ? { nextEl: '.dica-next-btn-'+order, prevEl: '.dica-prev-btn-'+order } : false;
87      let pagination_opject   =   (dataDots == 'on') ? {el: '.dica-paination-'+order,clickable: true} : false;
88      let rotate              =   Number(parseInt(data.cover_rotate));   
89      rotate = isNaN(rotate) ? 0 : rotate;
90
91	    if (data.hashNavigation === 'on') {
92		    $(element)
93			    .find('.dica_divi_carouselitem')
94			    .each(function () {
95				    const dicaItem = this.querySelector('.dica-item');
96				    if (dicaItem) {
97					    this.dataset.hash = dicaItem.dataset.hash || '';
98				    }
99			    });
100	    }
101
102      let diviCarousel = new Swiper (selector, {
103        slidesPerView: 'on' !== autoWidth ? dataDesktop : 'auto',
104        slidesPerGroup : ( multislide == 'on' && 'on' !== autoWidth && 'on' !== scroller_effect ) ? Number(dataDesktop) : 1,
105	    slidesPerColumn: parseInt ( data.slide_row, 10 ),
106	    slidesPerColumnFill: "row",
107        navigation: nav_object,
108        pagination: pagination_opject,
109        spaceBetween: itemSpace,
110        autoplay: (dataAutoPlay == 'on')? {enabled: false, delay: dataAutoPlaySpeed, disableOnInteraction: false} : false,
111        speed       : (scroller_effect !== 'on' && dataAutoPlay !== 'on') ? dataSpeed : scrollSpeed,
112        slideClass :   'dica_divi_carouselitem',
113        loop       :   (dataloop == 'on') ? true : false,
114        centeredSlides: (centerMode == 'on') ? true : false,
115	      // direction: 'horizontal',
116        effect: (sliderEffect == '1')? 'slide' : sliderEffect,
117        coverflowEffect: {
118          rotate: rotate,
119          stretch: 0,
120          depth: 100,
121          modifier: 1,
122          slideShadows : (cfshadow !== "off")? true: false,
123        },
124        // setWrapperSize      : true,
125        observer            : true,
126        observeParents      : true,
127        observeSlideChildren: true,
128        preloadImages: data.lazyload == 'on' ? false : true,
129        watchSlidesVisibility: true,
130        preventClicks : true,
131        preventClicksPropagation: true,
132        slideToClickedSlide: false,
133        touchMoveStopPropagation : true,
134        // for preventing slide on click
135        threshold: 15,
136        // cache : true,
137        lazy: lazyload,
138        // hashNavigation 
139        hashNavigation: data.hashNavigation === 'on' ? {
140          watchState: true,
141	      replaceState: true,
142
143        } : false,
144        // Responsive breakpoints
145        breakpoints: {
146            // when window width is >= 981px / desktop
147            981: {
148              slidesPerView: 'on' !== autoWidth ? dataDesktop : 'auto',
149              slidesPerGroup : ( multislide == 'on' && 'on' !== autoWidth && 'on' !== scroller_effect ) ? Number(dataDesktop) : 1,
150              spaceBetween : itemSpace,
151	            slidesPerColumn: parseInt ( data.slide_row, 10 ),
152	            slidesPerColumnFill: "row",
153            },
154            // when window width is >= 768px / tablet
155            768: {
156              slidesPerView: 'on' !== autoWidth ? dataTablet : 'auto',
157              slidesPerGroup : ( multislide == 'on' && 'on' !== autoWidth && 'on' !== scroller_effect ) ? Number(dataTablet) : 1,
158              spaceBetween : item_spacing_tablet,
159	            slidesPerColumn: parseInt ( data.slide_row_tablet, 10 ),
160	            slidesPerColumnFill: "row",
161            },
162            // when window width is >= 1px / mobile
163            1: {
164              slidesPerView: 'on' !== autoWidth ? dataMobile : 'auto',
165              slidesPerGroup : ( multislide == 'on' && 'on' !== autoWidth && 'on' !== scroller_effect ) ? Number(dataMobile) : 1,
166              spaceBetween : item_spacing_phone,
167	            slidesPerColumn: parseInt ( data.slide_row_phone, 10 ),
168	            slidesPerColumnFill: "row",
169            },
170            
171        },
172        // update since 2.0.22
173	    keyboard: { enabled: ('on' === data.keyboard), onlyInViewport: !1 },
174	    mousewheel: { enabled: ('on' === data.mousewheel), invert: true },
175        simulateTouch: data.simulatetouch === 'on'? false : true,
176        allowTouchMove: data.allowtouchmove === 'on'? false : true,
177      });
178      
179      // smooth scroller effect ( fix the speed at first load )
180      if('on' === scroller_effect &&  'on' === dataAutoPlay ) {
181        diviCarousel.freeMode = true;
182        diviCarousel.autoplay.stop();
183		//
184        // setTimeout(start_autoplay, 1000);
185		//
186        // function start_autoplay(){
187        //   diviCarousel.autoplay.start()
188        // }
189        
190      }
191      // if the carousel in a tab module
192      if('on' !== scroller_effect) {
193        diviCarousel.on('observerUpdate', function (e) {
194          if(dataAutoPlay == 'on') {
195            diviCarousel.autoplay.paused = false;
196            diviCarousel.translate = 0;
197          }
198          diviCarousel.update();
199        })
200      } 
201      // pause on hover
202      if ( pausehover === 'on' && dataAutoPlay === 'on') {
203        selector.addEventListener("mouseover", function(){
204          diviCarousel.autoplay.stop();
205        })
206        selector.addEventListener("mouseout", function(){
207          diviCarousel.autoplay.start();
208        })
209      }    
210      // lazy loading effect
211      if(data.lazyload == 'on') {
212        diviCarousel.on("lazyImageReady", function(slideEl, imageEl){
213          slideEl.querySelector('.dica-item').classList.remove('loading');
214        })
215      }
216
217	  // Autoplay with Waypoint
218	  if ('on' === dataAutoPlay) {
219		if (typeof Waypoint === "undefined") {
220		  diviCarousel.autoplay.start();
221		} else {
222		  new Waypoint({
223			element: element,
224			handler: function () {
225				setTimeout(start_autoplay, 1000);
226
227				function start_autoplay(){
228				  diviCarousel.autoplay.start()
229				}
230			  this.destroy();
231			},
232			offset: data.autoplay_viewport
233		  });
234		}
235	  }
236      
237      // click functionality for the link option
238      $(this).find('.dica_divi_carouselitem .et_pb_module_inner').on('click', function(e) {
239        let link = $(this).find('.dica-item')[0].dataset.link;
240
241        if ( link ) {
242            if(link.indexOf("#") != -1) {
243                et_pb_smooth_scroll();
244            } else {
245                e.stopPropagation();
246                let _target = $(this).find('.dica-item')[0].dataset.target;
247                if ( undefined !== link ) {
248                  if ( _target === '_blank') {
249                    window.open(link);
250                  } else {
251                    window.location = link;
252                  }
253                }
254            }
255        }
256          
257      })
258  })
259
260  // Image light box feature
261  let lightbox = $('body').append('<div class="dg-carousel-lightbox"><div class="lightbox-header"><button class="close-btn">&#9587;</button></div><div class="image-wrapper"><span><img src="" /></span></div></div>');
262	$( '.dica-image-container a[data-lightbox]' ).each( function ( index, ele ) {
263		const $this = $( this );
264		const lightbox_type = $this.attr( 'data-lightbox_type' );
265		const lightbox_target = $this.attr( 'data-lightbox_target' );
266		const $image_link = $this.attr( 'data-src' );
267		const lightbox_con = $( '.dg-carousel-lightbox' );
268
269		$this.click( function ( e ) {
270			const image_wrapper = lightbox_con.find( ".image-wrapper" ).empty();
271			if ( 'video' === lightbox_type ) {
272				if ( 'off' === lightbox_target ) {
273					e.preventDefault();
274					lightbox_con.addClass( 'open' );
275					image_wrapper.append(
276						`<span>
277						<iframe 
278							frameborder="0" 
279							allowfullscreen 
280							src="${$image_link}?autoplay=1" 
281							allow="autoplay"
282						></iframe>
283					</span>`
284					);
285				}
286			} else {
287				e.preventDefault();
288				lightbox_con.addClass( 'open' );
289				const $image_caption = $this.attr( 'data-caption' );
290				image_wrapper.append( `<span><img class="" src="${$image_link}" alt=""></span>` );
291				if ( $image_caption.length > 0 ) {
292					image_wrapper.append( `<span class="dg_caption">${$image_caption}</span>` );
293				}
294			}
295
296		} )
297	} )
298  $('.dg-carousel-lightbox .close-btn').click(function(){
299	  $(this).parent().parent().find('.image-wrapper').empty();
300	  $(this).parent().parent().removeClass('open');
301  })
302  $('.dg-carousel-lightbox .image-wrapper').click(function(e){
303    if(e.target.tagName !== 'IMG') {
304	    $(this).empty();
305	    $(this).parent().removeClass('open');
306    }
307  })
308
309
310	function textExcerptController(element) {
311		const contentWrapper = element.querySelectorAll('.content');
312		if (contentWrapper.length > 0) {
313			contentWrapper.forEach(wrapper => {
314				if (!wrapper.dataset.settings) return;
315				const settings = parseDatasetJson(wrapper.dataset.settings, null, '.content[data-settings]');
316				if (!settings) return;
317				if ('true' === settings.status){
318					wrapper.innerHTML = "";
319					const readMoreText = (settings.text_more);
320					const showlessText = (settings.text_less);
321					let setLength = parseInt(settings.limit);
322					if ( $(window).width() < 981 && 'on' === settings.responsive ) {
323						setLength = parseInt(settings.limit_tablet);
324					}
325					if ( $(window).width() < 768 && 'on' === settings.responsive ) {
326						setLength = parseInt(settings.limit_phone);
327					}
328					const storageContentWrapper = $(wrapper).parent().find('noscript.content_storage');
329					const content = (storageContentWrapper[0].innerHTML).trim();
330					const maxLength = content.length;
331					let limitContent = "";
332					let ReadMore = "";
333					let hideContent = "";
334
335					let tempDiv = document.createElement('div');
336					tempDiv.innerHTML = content;
337					if(tempDiv.textContent.trim().length <= setLength){
338						limitContent = content;
339					}else{
340						limitContent = truncateHTML(content, setLength);
341						hideContent = '<div class="dg_hide_content">' + content.substring(maxLength, setLength) + '</div>';
342						ReadMore = '<span><a class="dg_expand_content" href="javascript:void(0)">' + readMoreText + '</a></span>';
343					}
344
345					wrapper.innerHTML = limitContent + hideContent + ReadMore;
346
347					if(hideContent.length > 0){
348						const readMoreBtn = wrapper.querySelector('.dg_expand_content');
349
350						readMoreBtn.addEventListener('click', function () {
351							const isActive = $(this).hasClass('active');
352							$(this).toggleClass("active");
353							this.innerText = isActive ? readMoreText : showlessText;
354
355							wrapper.innerHTML = isActive ? limitContent + hideContent : content;
356							!isActive && $(wrapper).hasClass('dg_enable_content_limit')
357								? $(wrapper).removeClass('dg_enable_content_limit')
358								: $(wrapper).addClass('dg_enable_content_limit');
359							wrapper.appendChild(this);
360						})
361					}
362				}
363
364			});
365		}
366	}
367
368
369	function truncateHTML(html, maxLength) {
370		let tempDiv = document.createElement('div');
371		tempDiv.innerHTML = html;
372
373		// Function to truncate text nodes
374		let remaining = maxLength;
375		function truncateTextNodes(node) {
376			if (remaining <= 0) {
377				// Remove all child nodes if maxLength is zero or negative
378				while (node.firstChild) {
379					node.removeChild(node.firstChild);
380				}
381				node.remove()
382				return;
383			}
384
385			if (node.nodeType === Node.TEXT_NODE) {
386				// // If the node is a text node, truncate its content
387				let text = node.textContent.trim();
388				if (text.length > remaining) {
389					node.textContent = text.slice(0, remaining);
390				}else{
391					node.textContent = text + " "
392				}
393				remaining -= text.length;
394			} else {
395				// If the node is an element node, traverse its children
396				for (let i = 0; i < node.childNodes.length; i++) {
397					truncateTextNodes(node.childNodes[i]);
398					if (remaining <= 0) {
399						// Remove remaining child nodes if no more length is allowed
400						while (node.childNodes.length > i + 1) {
401							node.removeChild(node.childNodes[i + 1]);
402						}
403						break;
404					}
405				}
406			}
407		}
408		if(tempDiv.textContent.length > maxLength){
409			truncateTextNodes(tempDiv)
410		}
411
412		return tempDiv.innerHTML;
413	}
414
415});

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.