PageSourceSearch

https://bodymindpain.com/wp-content/themes/mts_schema/js/customscript.js?ver=7.1.2

js bodymindpain.com collected 2026-10-04 07:20:26 UTC 18,188 bytes, 520 lines download raw bytes

1jQuery.fn.exists = function(callback) {
2  var args = [].slice.call(arguments, 1);
3  if (this.length) {
4    callback.call(this, args);
5  }
6  return this;
7};
8
9/*----------------------------------------------------
10/* Show/hide Scroll to top
11/*--------------------------------------------------*/
12jQuery(document).ready(function($) {
13    //move-to-top arrow
14    jQuery("body").prepend("<a id='move-to-top' class='animate ' href='#blog'><i class='fa fa-angle-double-up'></i></a>");
15    
16    var scrollDes = 'html,body';  
17    /*Opera does a strange thing if we use 'html' and 'body' together so my solution is to do the UA sniffing thing*/
18    if(navigator.userAgent.match(/opera/i)){
19        scrollDes = 'html';
20    }
21    //show ,hide
22    jQuery(window).scroll(function () {
23        if (jQuery(this).scrollTop() > 160) {
24            jQuery('#move-to-top').addClass('filling').removeClass('hiding');
25        } else {
26            jQuery('#move-to-top').removeClass('filling').addClass('hiding');
27        }
28    });
29    /*----------------------------------------------------
30     /* Detect new tabs
31    /*--------------------------------------------------*/
32    // grab hostname and isolate
33    let hostname = window.location.host;
34    let fresh_array = [];
35
36    if( hostname.includes('www') ) {
37      fresh_array = window.location.host.split('.');
38      fresh_array.shift();
39      hostname = fresh_array[0];
40    } else {
41      hostname = window.location.host.split('.');
42      hostname = hostname[0];
43    }
44    //hostname = hostname.substr(0, hostname.indexOf('.')); 
45    
46    // get all a tags on the page
47    let allATags = document.body.querySelectorAll("a")
48    allATags.forEach(function(entry) {
49      if( entry.href.includes('http') ) {
50        if( entry.href.includes(hostname) ) {
51          // sillence is golden
52        } else {
53          entry.rel = 'noreferrer noopener';
54          if( entry.target != '_blank' ) {
55            entry.target = '_blank';
56          }
57        }
58      }
59    });
60    /*----------------------------------------------------
61    /* Add alt to images
62    /*--------------------------------------------------*/
63    let pageImages = document.body.querySelectorAll("img");
64    let pageTitle = document.title;
65    
66    if( jQuery('.page-title').length > 0 ) {
67      pageTitle = document.getElementsByClassName('page-title');
68      pageTitle = pageTitle[0].textContent;
69    } 
70
71    if( jQuery('img').length > 0 ) {
72      pageImages.forEach(function(entry) {
73         if( entry.alt == '' || entry.alt == ' ' ) {
74           entry.alt = pageTitle;
75         }
76      });
77    }
78});
79
80
81/*----------------------------------------------------
82/* Make all anchor links smooth scrolling
83/*--------------------------------------------------*/
84jQuery(document).ready(function($) {
85 // scroll handler
86  var scrollToAnchor = function( id, event ) {
87    // grab the element to scroll to based on the name
88    var elem = $("a[name='"+ id +"']");
89    // if that didn't work, look for an element with our ID
90    if ( typeof( elem.offset() ) === "undefined" ) {
91      elem = $("#"+id);
92    }
93    // if the destination element exists
94    if ( typeof( elem.offset() ) !== "undefined" ) {
95      // cancel default event propagation
96      event.preventDefault();
97
98      // do the scroll
99      // also hide mobile menu
100      var scroll_to = elem.offset().top;
101      $('html, body').removeClass('mobile-menu-active').animate({
102              scrollTop: scroll_to
103      }, 600, 'swing', function() { if (scroll_to > 46) window.location.hash = id; } );
104    }
105  };
106  // bind to click event
107  $("a").click(function( event ) {
108    // only do this if it's an anchor link
109    var href = $(this).attr("href");
110    if ( href && href.match("#") && href !== '#' ) {
111      // scroll to the location
112      var parts = href.split('#'),
113        url = parts[0],
114        target = parts[1];
115      if ((!url || url == window.location.href.split('#')[0]) && target)
116        scrollToAnchor( target, event );
117    }
118  });
119});
120
121/*----------------------------------------------------
122/* Check for item number
123/*--------------------------------------------------*/
124function check_menu_items() {
125  jQuery('.sub-menu').each(function() {
126    // check how many items he has
127    var li_number = $('> li',this).length    
128    if( li_number > 7 ) {
129      jQuery(this).addClass('wda-long-menu');
130    }
131  });
132}
133
134/*----------------------------------------------------
135/* Responsive Navigation
136/*--------------------------------------------------*/
137if (mts_customscript.responsive && mts_customscript.nav_menu != 'none') {
138    jQuery(document).ready(function($){
139        $('#secondary-navigation').append('<div id="mobile-menu-overlay" />');
140        // merge if two menus exist
141        if (mts_customscript.nav_menu == 'both' && !$('.navigation.mobile-only').length) {
142            $('.navigation').not('.mobile-menu-wrapper').find('.menu').clone().appendTo('.mobile-menu-wrapper').hide();
143        }
144        $('nav').find('.header-social-icons').clone().appendTo('.mobile-menu-wrapper').hide();
145        $('nav').find('.mts-cart').clone().appendTo('.mobile-menu-wrapper').hide();
146    
147        $('.toggle-mobile-menu').click(function(e) {
148            e.preventDefault();
149            e.stopPropagation();
150            $('body').toggleClass('mobile-menu-active');
151
152            if ( $('body').hasClass('mobile-menu-active') ) {
153                if ( $(document).height() > $(window).height() ) {
154                    var scrollTop = ( $('html').scrollTop() ) ? $('html').scrollTop() : $('body').scrollTop();
155                    $('html').addClass('noscroll').css( 'top', -scrollTop );
156                }
157                $('#mobile-menu-overlay').fadeIn();
158            } else {
159                var scrollTop = parseInt( $('html').css('top') );
160                $('html').removeClass('noscroll');
161                $('html,body').scrollTop( -scrollTop );
162                $('#mobile-menu-overlay').fadeOut();
163            }
164        });
165        jQuery('nav.navigation a').click(function() {
166          //console.log( jQuery(this).text() );
167          if( jQuery(this).attr('href') == undefined ) {
168            // sillence is golden
169          } else {
170            closeMenu();
171          }
172        });
173        jQuery('#mobile-menu-overlay').click(function() {
174          closeMenu();
175        });
176    });
177    function closeMenu() {
178      var $target = jQuery(event.target);
179        if ( ( $target.hasClass("fa") && $target.parent().hasClass("toggle-caret") ) ||  $target.hasClass("toggle-caret") ) {// allow clicking on menu toggles
180            return;
181        }
182        jQuery('body').removeClass('mobile-menu-active');
183        jQuery('html').removeClass('noscroll');
184        jQuery('#mobile-menu-overlay').fadeOut();
185    }  
186     
187    
188    /* old way
189    jQuery(document).on('click', function(event) {
190        var $target = jQuery(event.target);
191        if ( ( $target.hasClass("fa") && $target.parent().hasClass("toggle-caret") ) ||  $target.hasClass("toggle-caret") ) {// allow clicking on menu toggles
192            return;
193        }
194        jQuery('body').removeClass('mobile-menu-active');
195        jQuery('html').removeClass('noscroll');
196        jQuery('#mobile-menu-overlay').fadeOut();
197    });
198    */
199}
200
201/*----------------------------------------------------
202/*  Dropdown menu
203/* ------------------------------------------------- */
204jQuery(document).ready(function($) {
205    
206    function mtsDropdownMenu() {
207        var wWidth = $(window).width();
208        if(wWidth > 865) {
209            /*$('.navigation ul.sub-menu, .navigation ul.children').hide();
210            var timer;
211            var delay = 100;
212            $('.navigation li').hover( 
213              function() {
214                var $this = $(this);
215                timer = setTimeout(function() {
216                    $this.children('ul.sub-menu, ul.children').slideDown('fast');
217                }, delay);
218                
219              },
220              function() {
221                $(this).children('ul.sub-menu, ul.children').hide();
222                clearTimeout(timer);
223              }
224            );*/
225        } else {
226            $('.navigation li').unbind('hover');
227            $('.navigation li.active > ul.sub-menu, .navigation li.active > ul.children').show();
228        }
229    }
230
231    mtsDropdownMenu();
232
233    $(window).resize(function() {
234        mtsDropdownMenu();
235    });
236});
237
238/*---------------------------------------------------
239/*  Vertical menus toggles
240/* -------------------------------------------------*/
241jQuery(document).ready(function($) {
242
243    $('.widget_nav_menu, .navigation .menu').addClass('toggle-menu');
244    $('.toggle-menu ul.sub-menu, .toggle-menu ul.children').addClass('toggle-submenu');
245    $('.toggle-menu ul.sub-menu').parent().addClass('toggle-menu-item-parent');
246
247    $('.toggle-menu .toggle-menu-item-parent').append('<span class="toggle-caret"><i class="fa fa-plus"></i></span>');
248
249    $('.toggle-caret').click(function(e) {
250        e.preventDefault();
251        $(this).parent().toggleClass('active').children('.toggle-submenu').slideToggle('fast');
252    });
253});
254
255/*----------------------------------------------------
256/* Lazy load avatars
257/*---------------------------------------------------*/
258var wda_mute;
259/*----------------------------------------------------
260/* Add Video Play Audio
261/*--------------------------------------------------*/
262wda_mute = function(videoclass) {
263  // delcate muted/show
264  var className = videoclass,
265      videoTarget = jQuery('.'+className+' video')[0];
266      
267  // add class for style
268  jQuery('.'+className).addClass('wda_video_style');  
269  jQuery('<div class="buttonToAuto"><a class="btn" href="javascript:void(null)" id="wdapvideo"> <i class="fa fa-volume-up"></i> Play Audio</a></div>').click(function() {
270    if(  videoTarget.muted == false ) {
271      videoTarget.muted = true;
272      videoTarget.currentTime = 0
273      jQuery('.buttonToAuto a').html('<i class="fa fa-volume-up"></i> Play Audio');
274    } else {
275      videoTarget.muted = false;
276      videoTarget.currentTime = 0
277      jQuery('.buttonToAuto a').html('<i class="fa fa-volume-down"></i> Mute Audio');
278    }
279  }).appendTo('.'+className);
280}
281wda_check_distance = function() {
282  // check on load
283  jQuery('.sub-menu').each(function() {
284    var distanceElement = jQuery(window).width() - (jQuery(this).offset().left + jQuery(this).width());
285    if( distanceElement < jQuery(this).width() ) {
286      jQuery(this).addClass('moveLeft');
287    }
288  });
289  jQuery(window).resize(function() {
290      jQuery('.sub-menu').each(function() {
291        var distanceElement = jQuery(window).width() - (jQuery(this).offset().left + jQuery(this).width());
292        if( distanceElement < jQuery(this).width() ) {
293          jQuery(this).addClass('moveLeft');
294        } else {
295          jQuery(this).removeClass('moveLeft');
296        }
297      });
298  });
299};
300
301// popupuser
302wda_popup_function = function() {
303    // gather all infos
304    // data-dm-pop="pop" id="dm-1"
305
306    // wrap all data popups with an container
307    jQuery('[data-dm-popup]').each(function() {
308      jQuery(this).wrapInner('<div class="dm-popup-wrapper">');
309    });
310
311    jQuery('[data-dm-popup] .dm-popup-wrapper').prepend('<button><i class="fa fa-times"></i></button>').click(function() {
312      jQuery(this).parent().removeClass('show-dm-modal');
313      jQuery('.dm-modal-backdrop').removeClass('show-dm-drop');
314    });
315
316    jQuery('[data-dm-category=pop]').click(function(e) {
317        // get trigger
318        e.preventDefault();
319        let id_selector = jQuery(this).attr('id');
320        jQuery('[data-dm-popup = '+id_selector+']').addClass('show-dm-modal');
321
322        // append backdrop
323        jQuery('.dm-modal-backdrop').addClass('show-dm-drop');
324        
325    });
326}
327// append backdrop
328wda_backdrop = function() {
329  let backdrop = document.createElement('div');
330      backdrop.className = 'dm-modal-backdrop';
331      document.body.appendChild(backdrop);
332}
333jQuery(document).ready(function($){
334    //
335    if( jQuery('.dm-masonry').length ) {
336      var target = 'blockquote',
337          gap = 10;
338      if( jQuery('.dm-masonry').attr('data-target') != '' ) {
339        var target = jQuery('.dm-masonry').attr('data-target');
340      }
341      if( jQuery('.dm-masonry').attr('data-gap') != '' ) {
342        var gap = jQuery('.dm-masonry').attr('data-gap');
343        gap = parseInt(gap);
344      }
345      
346      jQuery('.dm-mason-container').masonry({
347        columnWidth: gap,
348        itemSelector: target
349      });
350    }
351    // slide
352    if( jQuery('.dm-slide').length ) {
353      jQuery('.dm-slide > img').each(function() {
354        jQuery(this).wrap('<div>');
355      });
356      jQuery('.dm-slide > br').each(function() {
357        jQuery(this).detach();
358      });
359      jQuery('.dm-slide').slick({
360        autoplay: true,
361        dots: false,
362        arrows: false
363      });
364    }
365    // faqs
366    // faqs
367    if( jQuery('.contentfaqs').length ) {
368      // add h4 i tag
369      jQuery('.contentfaqs h4').each(function() {
370        jQuery(this).append('<i class="fa fa-plus"></i>');
371      });
372      // click to expand
373      jQuery('.contentfaqs h4').click(function() {
374        jQuery(this).next().slideToggle('fast');
375        jQuery('i', this).toggleClass('fa-minus');
376      });
377
378      // wrap all p tags as questions
379       jQuery(".contentfaqs h4").each(function () {
380        var $this = jQuery(this);
381        var content = $this.nextUntil("h4"); 
382        if (content.length) {
383          content.wrapAll("<div class='dm_faq_item'></div>");
384        }
385      });
386    }
387
388    // gtag
389    jQuery('a').click(function() {
390      var event_category = 'Desktop',
391          href = jQuery(this).attr('href');
392
393      if (typeof gtag === "function") { 
394       
395        if( jQuery(window).width() < 1024 ) {
396          event_category = 'Mobile'
397        }
398
399        if (href.toLowerCase().indexOf('tel:') === 0) {
400            gtag('event', 'Call Us', { event_category: event_category, value: 25});
401        }
402        if (href.toLowerCase().indexOf('/appointments/') === 0) {
403          gtag('event', 'Appointment', { event_category: event_category, value: 35});
404        }
405        if ((this.protocol === 'http:' || this.protocol === 'https:') && this.hostname.indexOf(document.location.hostname) === -1) {
406            gtag('event', 'Outbound', { event_category: event_category, value: 50});
407        }
408        if (href.toLowerCase().indexOf('mailto:') === 0) {
409            gtag('event', 'Mailto', { event_category: event_category, value: 100});
410        }
411      } 
412    });
413
414    // popup caller
415    let class_checker = document.querySelectorAll('.dm-classic-pop');
416    if( class_checker.length > 0 ) {
417
418      // append backdrop
419      wda_backdrop();
420
421      // applyvisiublity fix
422      jQuery('#page').addClass('fix-visio');
423
424      // call popup function
425      wda_popup_function();
426    }
427
428    // lightbox
429    if( $('.dm-lightbox').length ) {   
430        let pageHead = 'Gallery';
431        if( $('.page-header h1').length ) {
432          pageHead = $('.page-header h1').text();
433        }
434
435        $('.dm-lightbox img').each(function() {
436          let imgSrc = $(this).attr('src');
437          if( $(this).parent('a').length > 0) {
438            $(this).parent().attr('data-lightbox',pageHead);
439          } else {
440            $(this).wrap('<a href="'+imgSrc+'" data-lightbox="'+pageHead+'"></a>');
441          }
442        });
443    }
444
445    // dm-readmore
446    if( $('.dm-modal').length > 0 ) {
447      wda_backdrop();
448      $('.dm-modal').prepend('<button><i class="fa fa-times"></i></button>').click(function() {
449        $(this).closest('.dm-modal').removeClass('show-dm-modal');
450        $('.dm-modal-backdrop').removeClass('show-dm-drop');
451      });
452    }
453    $('.dm_read_more').click(function(e) {
454      e.preventDefault();
455      if( $(this).closest('.dm-readmore').children('.dm-readmore-wrapper').hasClass('dm-modal') ) {
456        $(this).closest('.dm-readmore').children('.dm-modal').addClass('show-dm-modal');
457        $('.dm-modal-backdrop').addClass('show-dm-drop');
458      } else {
459        if( $(this).closest('.dm-readmore').children('.dm-readmore-wrapper').is(':visible') ) {
460          $(this).closest('.dm-readmore').children('.dm-readmore-wrapper').slideUp('slow');
461          $(this).text('read more');
462        } else {
463          $(this).closest('.dm-readmore').children('.dm-readmore-wrapper').slideDown('slow');
464          $(this).text('read less');
465        }
466      }
467    });
468
469    // dm-modal outside of readmore
470    $('.dm_classic_modal').click(function(e) {
471      e.preventDefault();
472      let target_modal = $(this).attr('id');
473      $('[data-modal-counter='+target_modal+']').children('.dm-readmore').children('.dm-modal').addClass('show-dm-modal');
474      $('.dm-modal-backdrop').addClass('show-dm-drop');
475    });
476
477    // fix for ADA
478    var fontSize = 16;
479    jQuery('.wah-action-button.larger').click(function() {
480       fontSize++;
481       $('html *').css('font-size', fontSize+'px');
482    });
483    jQuery('.wah-action-button.smaller').click(function() {
484       fontSize--;
485       $('html *').css('font-size', fontSize+'px');
486    });
487    jQuery('#greyscale').click(function() {
488        $('html').toggleClass('active_greyscale');
489    });
490    
491    var lazyloadAvatar = function(){
492        $('.comment-author .avatar').each(function(){
493            var distanceToTop = $(this).offset().top;
494            var scroll = $(window).scrollTop();
495            var windowHeight = $(window).height();
496            var isVisible = distanceToTop - scroll < windowHeight;
497            if( isVisible ){
498                var hashedUrl = $(this).attr('data-src');
499                if ( hashedUrl ) {
500                    $(this).attr('src',hashedUrl).removeClass('loading');
501                }
502            }
503        });
504    };
505    if ( $('.comment-author .avatar').length > 0 ) {
506        $('.comment-author .avatar').each(function(i,el){
507            $(el).attr('data-src', el.src).removeAttr('src').addClass('loading');
508        });
509        $(function(){
510            $(window).scroll(function(){
511                lazyloadAvatar();
512            });
513        });
514        lazyloadAvatar();
515    }
516    // check for length of li items
517    check_menu_items();
518    // check for distance
519    wda_check_distance();
520});

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.