PageSourceSearch

https://rusticisoftware.com/wp-content/themes/rustici/_/js/functions.js?b79e2

js rusticisoftware.com collected 2026-10-03 21:11:36 UTC 12,593 bytes, 400 lines download raw bytes

1// Browser detection for when you get desparate. A measure of last resort.
2// http://rog.ie/post/9089341529/html5boilerplatejs
3
4// var b = document.documentElement;
5// b.setAttribute('data-useragent',  navigator.userAgent);
6// b.setAttribute('data-platform', navigator.platform);
7
8// sample CSS: html[data-useragent*='Chrome/13.0'] { ... }
9
10// remap jQuery to $
11(function($) {
12  /* trigger when page is ready */
13  $(document).ready(function() {
14    /* ---------------------------------------------------- */
15
16    $("iframe[src*='vimeo'], iframe[src*='youtube']").wrap(
17      "<div class='video-wrap'></div>"
18    );
19    $(".video-wrap").fitVids();
20
21    /* Cookie notice */
22    // $("#cookie-agree").click(function() {
23    //   $.cookie("rustici-cookie-agree", "agreed", { expires: 365, path: "/" });
24    //   $(".desktop #cookie-notice").slideUp("fast");
25    //   $(".mobile #cookie-notice, .tablet #cookie-notice").remove();
26    //   //$("body").removeClass("cookie-bar-active");
27    //   return false;
28    // });
29
30    /* Magnific popups */
31    /* ------------------------------------------- */
32
33    $("#search-launch").magnificPopup({
34      type: "inline",
35      mainClass: "mfp-fade search-pop-up",
36      preloader: false,
37      focus: "#q",
38      closeBtnInside: true,
39      //disableOn: 300,
40
41      // When elemened is focused, some mobile browsers in some cases zoom in
42      // It doesn't look nice, so we disable it:
43      callbacks: {
44        beforeOpen: function() {
45          if ($(window).width() < 700) {
46            this.st.focus = false;
47          } else {
48            this.st.focus = "#q";
49          }
50        }
51      }
52    });
53
54    $(".image-gallery").each(function() {
55      // the containers for all your galleries
56      $(this).magnificPopup({
57        delegate: "li a", // the selector for gallery item
58        type: "image",
59        mainClass: "mfp-fade",
60        image: {
61          verticalFit: true
62        },
63        gallery: {
64          enabled: true
65        }
66      });
67    });
68
69    // Blog images
70
71    $(
72      ".single-post article a[href$='.jpg'],.single-post article a[href$='.png'],.single-post article a[href$='.gif']"
73    ).magnificPopup({
74      type: "image",
75      mainClass: "mfp-fade",
76      image: {
77        verticalFit: true
78      },
79      gallery: {
80        enabled: false
81      }
82    });
83
84    $(".popup-image").magnificPopup({
85      type: "image",
86      //closeOnContentClick: true,
87      //closeBtnInside: false,
88      //fixedContentPos: true,
89      //mainClass: 'mfp-no-margins mfp-with-zoom', // class to remove default margin from left and right side
90      mainClass: "mfp-fade",
91      image: {
92        verticalFit: true
93      },
94      gallery: {
95        enabled: true
96      }
97      /*
98zoom: {
99			enabled: true,
100			duration: 300 // don't foget to change the duration also in CSS
101		}
102*/
103    });
104
105
106    $(".popup-modal").magnificPopup({
107      type: "inline",
108      mainClass: "mfp-fade"
109    });
110
111    $(".popup-youtube").magnificPopup({
112      disableOn: 700,
113      type: "iframe",
114      mainClass: "mfp-fade",
115      removalDelay: 160,
116      preloader: false,
117
118      fixedContentPos: false
119    });
120
121    $(".popup-person").magnificPopup({
122      type: "inline",
123
124      // fixedContentPos: false,
125      // fixedBgPos: true,
126      //
127      // overflowY: "auto",
128      //
129      // closeBtnInside: true,
130      // preloader: false,
131      //
132      // midClick: true,
133      // removalDelay: 300
134      gallery: {
135        enabled: true,
136        removalDelay: 400,
137        arrowMarkup:
138          '<button title="%title%" type="button" class="arrow arrow-%dir%">%title%</button>', // markup of an arrow button
139        tPrev: "Previous", // title for left button
140        tNext: "Next" // title for right button
141        //navigateByImgClick: true,
142        //preload: [0,1] // Will preload 0 - before current, and 1 after the current image
143      },
144      callbacks: {
145        buildControls: function() {
146          // re-appends controls inside the main container
147          this.contentContainer.addClass("show-arrows");
148          this.contentContainer.append(this.arrowLeft.add(this.arrowRight));
149        },
150
151        beforeOpen: function() {
152          this.st.mainClass = this.st.el.attr("data-effect");
153        },
154        change: function() {
155          //  alert("change yo");
156          this.wrap.addClass("mfp-person");
157          // if (this.isOpen) {
158          //   this.wrap.addClass("mfp-person");
159          // }
160        }
161      },
162      mainClass: "mfp-fade mfp-person"
163    });
164
165
166
167
168    $('[for="nav-trigger"]').click(function() {
169      if ($("body").hasClass("nav-open")) {
170        $("body").removeClass("nav-open");
171      } else {
172        $("body").addClass("nav-open");
173      }
174    });
175
176    // ---- SLIDERS
177
178    $(".slider--logos").slick({
179      arrows: true,
180      dots: false,
181      slidesToShow: 5,
182      slidesToScroll: 1,
183      prevArrow:
184        '<button type="button" class="slick-prev"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="48px" height="48px" viewBox="0 0 48 48" stroke-width="2"><g stroke-width="2" transform="translate(0, 0)"><polyline fill="none" stroke="#444444" stroke-width="2" stroke-linecap="square" stroke-miterlimit="10" points="34,4 14,24 34,44 " stroke-linejoin="miter"></polyline></g></svg></button>',
185      nextArrow:
186        '<button type="button" class="slick-next"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="48px" height="48px" viewBox="0 0 48 48" stroke-width="2"><g stroke-width="2" transform="translate(0, 0)"><polyline fill="none" stroke="#444444" stroke-width="2" stroke-linecap="square" stroke-miterlimit="10" points="14,4 34,24 14,44 " stroke-linejoin="miter"></polyline></g></svg></button>',
187
188      responsive: [
189        {
190          breakpoint: 700,
191          settings: {
192            slidesToShow: 3,
193            slidesToScroll: 1
194          }
195        }
196        // You can unslick at a given breakpoint now by adding:
197        // settings: "unslick"
198        // instead of a settings object
199      ]
200    });
201
202    $(".slider--product-summary").slick({
203      arrows: true,
204      dots: false,
205      slidesToShow: 1,
206      slidesToScroll: 1,
207      prevArrow:
208        '<button type="button" class="slick-prev"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="48px" height="48px" viewBox="0 0 48 48" stroke-width="2"><g stroke-width="2" transform="translate(0, 0)"><polyline fill="none" stroke="#444444" stroke-width="2" stroke-linecap="square" stroke-miterlimit="10" points="34,4 14,24 34,44 " stroke-linejoin="miter"></polyline></g></svg></button>',
209      nextArrow:
210        '<button type="button" class="slick-next"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="48px" height="48px" viewBox="0 0 48 48" stroke-width="2"><g stroke-width="2" transform="translate(0, 0)"><polyline fill="none" stroke="#444444" stroke-width="2" stroke-linecap="square" stroke-miterlimit="10" points="14,4 34,24 14,44 " stroke-linejoin="miter"></polyline></g></svg></button>'
211    });
212
213    // ----
214
215    // https://www.bignerdranch.com/blog/web-accessibility-skip-navigation-links/
216    // bind a click event to the 'skip' link
217    $(".skip").click(function(event) {
218      // strip the leading hash and declare
219      // the content we're skipping to
220      var skipTo = "#" + this.href.split("#")[1];
221
222      // Setting 'tabindex' to -1 takes an element out of normal
223      // tab flow but allows it to be focused via javascript
224      $(skipTo)
225        .attr("tabindex", -1)
226        .on("blur focusout", function() {
227          // when focus leaves this element,
228          // remove the tabindex attribute
229          $(this).removeAttr("tabindex");
230        })
231        .focus(); // focus on the content container
232    });
233
234    /* Hover intent */
235    /* ------------------------------------------- */
236
237    // function mousein_trigger() {
238    //   $(this)
239    //     .addClass("active")
240    //     .find("ul.sub-menu")
241    //     .slideToggle("fast");
242    // }
243    //
244    // function mouseout_trigger() {
245    //   $(this)
246    //     .removeClass("active")
247    //     .find("ul.sub-menu")
248    //     .slideToggle("fast");
249    // }
250    //
251    // var navconfig = {
252    //   over: mousein_trigger,
253    //   timeout: 400,
254    //   out: mouseout_trigger
255    // };
256    //
257    // // target main nav - not mobile menu
258    // $(".main-menu ul.sub-menu")
259    //   .parent()
260    //   .hoverIntent(navconfig);
261
262    // click show hide
263    // replace with addClass ?
264    $("li.menu-item-has-children > a").click(function() {
265      $(this).data('clicked', true);
266
267      var $this = $(this);
268      $("li.menu-item-has-children > a").not($this).removeClass("active");
269
270      if ($(window).width() > 1070) {
271        $(".fade-focus").toggleClass("fade-focus-active");
272      }
273
274      $(this).toggleClass("active");
275      return false;
276    });
277
278
279    // If you click the fade focs layer - hide menus
280    $(".fade-focus").click(function() {
281      //$("body").toggleClass("menu-active");
282      $(".fade-focus").toggleClass("fade-focus-active");
283      $(".menu a.active").toggleClass("active");
284    });
285
286    // History / tabs show/hide
287    $("#tabs-show-hide, .tab-widget__item").click(function() {
288      // $('#show-content').toggleClass('active');
289
290      if ($("body").hasClass("show-tabs-active")) {
291        $("body").removeClass("show-tabs-active");
292      } else {
293        $("body").addClass("show-tabs-active");
294      }
295    });
296
297    // FacetWP laoding
298    // https://facetwp.com/fade-template-content-during-refresh/
299    // $(document).on("facetwp-refresh", function() {
300    //   $(".facetwp-template").animate({ opacity: 0 }, 250);
301    // });
302    // $(document).on("facetwp-loaded", function() {
303    //   $(".facetwp-template").animate({ opacity: 1 }, 250);
304    // });
305
306    // NAV
307    // Move regular menu drop down caption
308    $(
309      ".main-menu li.menu-item-has-children > a > .menu-link-wrapper > .menu-link-caption"
310    )
311      .detach()
312      .prependTo($(this).find(".sub-menu"));
313
314    /* ---------------------------------------------------- */
315  });
316
317  $(window).load(function() {
318    $(function() {
319      $(".icon-list li, .double-panel__panel, .content-panels h2").matchHeight();
320      $(".desktop .footer__col").matchHeight();
321    });
322  });
323
324  // Smooth scroll to name attribute
325  $(function() {
326    $('a[href*="#"]:not([href="#"]):not(.noZensmooth)').click(function() {
327      if (
328        location.pathname.replace(/^\//, "") ==
329          this.pathname.replace(/^\//, "") &&
330        location.hostname == this.hostname
331      ) {
332        var target = $(this.hash);
333        target = target.length
334          ? target
335          : $("[name=" + this.hash.slice(1) + "]");
336        if (target.length) {
337
338          $("html, body").animate(
339            {
340              scrollTop: target.offset().top
341            },
342            500
343          );
344          // show the hash in the URL
345          window.location.hash = this.hash.slice(1);
346          return false;
347        }
348      }
349    });
350  });
351
352
353  var sections = document.querySelectorAll(`section[name]`);
354  var navItems = document.querySelectorAll(".page-nav ul li a");
355  var onScroll = function() {
356    var scrollPos = window.scrollY;
357    var vh = window.innerHeight;
358    for(var s = 0; s < sections.length; s++) {
359      var section = sections[s];
360      var id = section.getAttribute("name");
361      var navItem = document.querySelectorAll(`a[href="#${id}"]`)[0];
362      var offset = section.offsetTop;
363      var height = section.offsetHeight;
364      var next = sections[s + 1] !== undefined ? sections[s + 1].offsetTop - vh/2 : document.documentElement.clientHeight;
365      var activeItem = document.querySelector(".page-nav ul li a.is-active");
366
367      if(navItem !== undefined) {
368        if (scrollPos > (offset - vh/2) && scrollPos < next && navItem !== activeItem) {
369          navItems.forEach(function(item) {
370            item.classList.remove("is-active");
371          });
372          navItem.classList.add("is-active");
373        }
374      }
375    };
376  }
377
378  onScroll();
379  ["mousewheel", "DOMMouseScroll"].forEach(function(evt) {
380    window.addEventListener(evt, onScroll);
381  })
382  navItems.forEach(function(link) {
383    link.addEventListener("click", function() {
384     navItems.forEach(function(item) {
385        item.classList.remove("is-active");
386      });
387      link.classList.add("is-active");
388    });
389  });
390
391  /* optional triggers
392
393
394
395	$(window).resize(function() {
396
397	});
398
399	*/
400})(window.jQuery);

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.