PageSourceSearch

https://careyspennyan.com/js/script.js

js careyspennyan.com collected 2026-10-07 18:38:16 UTC 60,382 bytes, 1,903 lines download raw bytes

1/**
2 * Global variables
3 */
4"use strict";
5
6var userAgent = navigator.userAgent.toLowerCase(),
7    initialDate = new Date(),
8
9    $document = $(document),
10    $window = $(window),
11    $html = $("html"),
12
13    isDesktop = $html.hasClass("desktop"),
14    isIE = userAgent.indexOf("msie") != -1 ? parseInt(userAgent.split("msie")[1]) : userAgent.indexOf("trident") != -1 ? 11 : userAgent.indexOf("edge") != -1 ? 12 : false,
15    isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),
16    isTouch = "ontouchstart" in window,
17    c3ChartsArray = [],
18    onloadCaptchaCallback,
19
20    plugins = {
21      pointerEvents: isIE < 11 ? "js/pointer-events.min.js" : false,
22      bootstrapTooltip: $("[data-toggle='tooltip']"),
23      bootstrapTabs: $(".tabs"),
24      rdParallax: $(".rd-parallax"),
25      rdAudioPlayer: $(".rd-audio"),
26      rdVideoPlayer: $(".rd-video-player"),
27      responsiveTabs: $(".responsive-tabs"),
28      rdGoogleMaps: $("#rd-google-map"),
29      rdInputLabel: $(".form-label"),
30      rdNavbar: $(".rd-navbar"),
31      rdVideoBG: $(".rd-video"),
32      regula: $("[data-constraints]"),
33      stepper: $("input[type='number']"),
34      radio: $("input[type='radio']"),
35      checkbox: $(".checkbox-custom"),
36      toggles: $(".toggle-custom"),
37      textRotator: $(".text-rotator"),
38      owl: $(".owl-carousel"),
39      swiper: $(".swiper-slider"),
40      counter: $(".counter"),
41      photoSwipeGallery: $("[data-photo-swipe-item]"),
42      flickrfeed: $(".flickr"),
43      twitterfeed: $(".twitter"),
44      progressBar: $(".progress-linear"),
45      circleProgress: $(".progress-bar-circle"),
46      isotope: $(".isotope"),
47      countDown: $(".countdown"),
48      stacktable: $("table[data-responsive='true']"),
49      customToggle: $("[data-custom-toggle]"),
50      customWaypoints: $('[data-waypoint-to]'),
51      resizable: $(".resizable"),
52      selectFilter: $("select"),
53      calendar: $(".rd-calendar"),
54      productThumb: $(".product-thumbnails"),
55      imgZoom: $(".img-zoom"),
56      facebookfeed: $(".facebook"),
57      pageLoader: $(".page-loader"),
58      search: $(".rd-search"),
59      searchResults: $('.rd-search-results'),
60      iframeEmbed: $("iframe.embed-responsive-item"),
61      bootstrapDateTimePicker: $("[data-time-picker]"),
62      checkoutRDTabs: $(".checkout-tabs"),
63      higCharts: {
64        charts: $(".higchart"),
65        legend: $(".chart-legend")
66      },
67      d3Charts: $('.d3-chart'),
68      flotCharts: $('.flot-chart'),
69      captcha: $('.recaptcha'),
70      galleryRDTabs: $(".gallery-tabs"),
71      revolution: $("#rev_slider_1"),
72      tilter: $(".tilter")
73    };
74
75/**
76 * Initialize All Scripts
77 */
78$document.ready(function () {
79
80  /**
81   * isScrolledIntoView
82   * @description  check the element whas been scrolled into the view
83   */
84  function isScrolledIntoView(elem) {
85    var $window = $(window);
86    return elem.offset().top + elem.outerHeight() >= $window.scrollTop() && elem.offset().top <= $window.scrollTop() + $window.height();
87  }
88
89
90  /**
91   * initOnView
92   * @description  calls a function when element has been scrolled into the view
93   */
94  function lazyInit(element, func) {
95    var $win = jQuery(window);
96    $win.on('load scroll', function () {
97      if ((!element.hasClass('lazy-loaded') && (isScrolledIntoView(element)))) {
98        func.call(element);
99        element.addClass('lazy-loaded');
100      }
101    });
102  }
103
104  /**
105   * resizeOnImageLoad
106   * @description  calls a resize event when imageloaded
107   */
108  function resizeOnImageLoad(image) {
109    image.onload = function () {
110      $window.trigger("resize");
111    }
112  }
113
114
115  /**
116   * getSwiperHeight
117   * @description  calculate the height of swiper slider basing on data attr
118   */
119  function getSwiperHeight(object, attr) {
120    var val = object.attr("data-" + attr),
121        dim;
122    if (!val) {
123      return undefined;
124    }
125
126    dim = val.match(/(px)|(%)|(vh)$/i);
127
128    if (dim.length) {
129      switch (dim[0]) {
130        case "px":
131          return parseFloat(val);
132        case "vh":
133          return $(window).height() * (parseFloat(val) / 100);
134        case "%":
135          return object.width() * (parseFloat(val) / 100);
136      }
137    } else {
138      return undefined;
139    }
140  }
141
142
143  /**
144   * toggleSwiperInnerVideos
145   * @description  toggle swiper videos on active slides
146   // */
147  function toggleSwiperInnerVideos(swiper) {
148    var videos;
149
150    $.grep(swiper.slides, function (element, index) {
151      var $slide = $(element),
152          video;
153
154      if (index === swiper.activeIndex) {
155        videos = $slide.find("video");
156        if (videos.length) {
157          videos.get(0).play();
158        }
159      } else {
160        $slide.find("video").each(function () {
161          this.pause();
162        });
163      }
164    });
165  }
166
167
168  /**
169   * toggleSwiperCaptionAnimation
170   * @description  toggle swiper animations on active slides
171   */
172  function toggleSwiperCaptionAnimation(swiper) {
173    if (isIE && isIE < 10) {
174      return;
175    }
176
177    var prevSlide = $(swiper.container),
178        nextSlide = $(swiper.slides[swiper.activeIndex]);
179
180    prevSlide
181        .find("[data-caption-animate]")
182        .each(function () {
183          var $this = $(this);
184          $this
185              .removeClass("animated")
186              .removeClass($this.attr("data-caption-animate"))
187              .addClass("not-animated");
188        });
189
190    nextSlide
191        .find("[data-caption-animate]")
192        .each(function () {
193          var $this = $(this),
194              delay = $this.attr("data-caption-delay");
195
196          setTimeout(function () {
197            $this
198                .removeClass("not-animated")
199                .addClass($this.attr("data-caption-animate"))
200                .addClass("animated");
201          }, delay ? parseInt(delay) : 0);
202        });
203  }
204
205  /**
206   * makeParallax
207   * @description  create swiper parallax scrolling effect
208   */
209  function makeParallax(el, speed, wrapper, prevScroll) {
210    var scrollY = window.scrollY || window.pageYOffset;
211
212    if (prevScroll != scrollY) {
213      prevScroll = scrollY;
214      el.addClass('no-transition');
215      el[0].style['transform'] = 'translate3d(0,' + -scrollY * (1 - speed) + 'px,0)';
216      el.height();
217      el.removeClass('no-transition');
218
219      if (el.attr('data-fade') === 'true') {
220        var bound = el[0].getBoundingClientRect(),
221            offsetTop = bound.top * 2 + scrollY,
222            sceneHeight = wrapper.outerHeight(),
223            sceneDevider = wrapper.offset().top + sceneHeight / 2.0,
224            layerDevider = offsetTop + el.outerHeight() / 2.0,
225            pos = sceneHeight / 6.0,
226            opacity;
227        if (sceneDevider + pos > layerDevider && sceneDevider - pos < layerDevider) {
228          el[0].style["opacity"] = 1;
229        } else {
230          if (sceneDevider - pos < layerDevider) {
231            opacity = 1 + ((sceneDevider + pos - layerDevider) / sceneHeight / 3.0 * 5);
232          } else {
233            opacity = 1 - ((sceneDevider - pos - layerDevider) / sceneHeight / 3.0 * 5);
234          }
235          el[0].style["opacity"] = opacity < 0 ? 0 : opacity > 1 ? 1 : opacity.toFixed(2);
236        }
237      }
238    }
239
240    requestAnimationFrame(function () {
241      makeParallax(el, speed, wrapper, prevScroll);
242    });
243  }
244
245  /**
246   * Live Search
247   * @description  create live search results
248   */
249  function liveSearch(options) {
250    $('#' + options.live).removeClass('cleared').html();
251    options.current++;
252    options.spin.addClass('loading');
253    $.get(handler, {
254      s: decodeURI(options.term),
255      liveSearch: options.live,
256      dataType: "html",
257      liveCount: options.liveCount,
258      filter: options.filter,
259      template: options.template
260    }, function (data) {
261      options.processed++;
262      var live = $('#' + options.live);
263      if (options.processed == options.current && !live.hasClass('cleared')) {
264        live.find('> #search-results').removeClass('active');
265        live.html(data);
266        setTimeout(function () {
267          live.find('> #search-results').addClass('active');
268        }, 50);
269      }
270      options.spin.parents('.rd-search').find('.input-group-addon').removeClass('loading');
271    })
272  }
273
274  
275
276  /**
277   * parseJSONObject
278   * @description  return JSON object witch methods
279   */
280  function parseJSONObject(element, attr) {
281    return JSON.parse($(element).attr(attr), function (key, value) {
282      if ((typeof value) === 'string') {
283        if (value.indexOf('function') == 0) {
284          return eval('(' + value + ')');
285        }
286      }
287      return value;
288    });
289  }
290
291  /**
292   * makeUniqueRandom
293   * @description  make random for gallery tabs
294   */
295  function makeUniqueRandom(count) {
296    if (!uniqueRandoms.length) {
297      for (var i = 0; i < count; i++) {
298        uniqueRandoms.push(i);
299      }
300    }
301    var index = Math.floor(Math.random() * uniqueRandoms.length);
302    var val = uniqueRandoms[index];
303    uniqueRandoms.splice(index, 1);
304    return val;
305  }
306
307  /**
308   * makeVisible
309   * @description  set class to gallery tabs to make it visible
310   */
311  function makeVisible(el) {
312    var count = el.length,
313        k = 0,
314        step = 2.5;
315    for (var i = 0; i < count; i++) {
316      timer = setTimeout(function () {
317        var rand = makeUniqueRandom(count);
318        el.eq(rand).addClass('visible');
319      }, k * 35);
320      k += step;
321    }
322    timer2 = setTimeout(function () {
323      el.not('.visible').addClass('visible');
324    }, count * step * 35)
325  }
326
327  /**
328   * makeInVisible
329   * @description  set class to gallery tabs to make it invisible
330   */
331  function makeInvisible() {
332    var el = $('.image.visible');
333    el.removeClass('visible');
334    uniqueRandoms = [];
335    clearTimeout(timer);
336    clearTimeout(timer2);
337  }
338
339  /**
340   * IE Polyfills
341   * @description  Adds some loosing functionality to IE browsers
342   */
343  if (isIE) {
344    if (isIE < 10) {
345      $html.addClass("lt-ie-10");
346    }
347
348    if (isIE < 11) {
349      if (plugins.pointerEvents) {
350        $.getScript(plugins.pointerEvents)
351            .done(function () {
352              $html.addClass("ie-10");
353              PointerEventsPolyfill.initialize({});
354            });
355      }
356    }
357
358    if (isIE === 11) {
359      $("html").addClass("ie-11");
360    }
361
362    if (isIE === 12) {
363      $("html").addClass("ie-edge");
364    }
365  }
366
367
368  /**
369   * Revolution slider
370   * @description  Initialize Revolution slider
371   */
372  if (plugins.revolution.length) {
373    plugins.revolution.show().revolution({
374      delay: 9000,
375      sliderLayout: 'fullscreen',
376      responsiveLevels: [1200, 992, 768, 480],
377      gridwidth: [1200, 992, 768, 480],
378      visibilityLevels: [1200, 992, 768, 480],
379      minHeight:  ['630', '630', '630', '500'],
380      stopLoop: 'on',
381      stopAfterLoops: 0,
382      stopAtSlide: 1,
383      spinner: 'spinner3',
384      extensions: 'js/extensions/',
385      viewPort: {
386        enable: true,
387        outof: 'wait',
388        visible_area: '80%',
389        presize: true
390      },
391      navigation: {
392        arrows: {
393          enable: true,
394          hide_onleave: true,
395          hide_onmobile: true,
396          hide_under: 1360,
397          style: 'uranus',
398        },
399        bullets: {
400          enable: true,
401          style: 'uranus',
402          hide_onleave: false,
403          h_align: 'center',
404          v_align: 'bottom',
405          h_offset: 0,
406          v_offset: 20,
407          space: 10
408        },
409        touch:{
410          touchenabled:"on",						// Enable Swipe Function : on/off
411          swipe_treshold : 75,					// The number of pixels that the user must move their finger by before it is considered a swipe.
412          swipe_min_touches : 1,					// Min Finger (touch) used for swipe
413          drag_block_vertical:false,				// Prevent Vertical Scroll during Swipe
414          swipe_direction:"horizontal"
415        },
416      },
417      parallax: {
418        type: 'scroll',
419        origo:"slidercenter",
420        speed: 1000,
421        levels: [5,10,15,20,25,30,35,40,
422          45,46,47,48,49,50,51,55],
423        disable_onmobile: 'on'
424      },
425    });
426  }
427
428  /**
429   * Tilter
430   */
431  if (plugins.tilter.length) {
432    var tiltSettings = [
433      {},
434      {
435        movement: {
436          lines : {
437            translation : {x: 40, y: 40, z: 0},
438            reverseAnimation : {duration : 1500, easing : 'easeOutElastic'}
439          },
440          caption : {
441            translation : {x: 20, y: 20, z: 0},
442            rotation : {x: 0, y: 0, z: -5},
443            reverseAnimation : {duration : 1000, easing : 'easeOutExpo'}
444          },
445          overlay : {
446            translation : {x: -30, y: -30, z: 0},
447            rotation : {x: 0, y: 0, z: 3},
448            reverseAnimation : {duration : 750, easing : 'easeOutExpo'}
449          },
450          shine : {
451            translation : {x: 100, y: 100, z: 0},
452            reverseAnimation : {duration : 750, easing : 'easeOutExpo'}
453          }
454        }
455      },
456      {
457        movement: {
458          lines : {
459            translation : {x: 40, y: 40, z: 0},
460            reverseAnimation : {duration : 1500, easing : 'easeOutElastic'}
461          },
462          caption : {
463            translation : {x: 20, y: 20, z: 0},
464            rotation : {x: 0, y: 0, z: -5},
465            reverseAnimation : {duration : 1000, easing : 'easeOutExpo'}
466          },
467          overlay : {
468            translation : {x: -30, y: -30, z: 0},
469            rotation : {x: 0, y: 0, z: 3},
470            reverseAnimation : {duration : 750, easing : 'easeOutExpo'}
471          },
472          shine : {
473            translation : {x: 100, y: 100, z: 0},
474            reverseAnimation : {duration : 750, easing : 'easeOutExpo'}
475          }
476        }
477      }];
478
479    plugins.tilter.each(function (pos, el) {
480      var idx = 0;
481      idx = pos % 2 === 0 ? idx + 1 : idx;
482      new TiltFx(el, tiltSettings[idx - 1]);
483    });
484  }
485
486
487  /**
488   * Swiper 3.1.7
489   * @description  Enable Swiper Slider
490   */
491  if (plugins.swiper.length) {
492    plugins.swiper.each(function () {
493      var s = $(this);
494
495      var pag = s.find(".swiper-pagination"),
496          next = s.find(".swiper-button-next"),
497          prev = s.find(".swiper-button-prev"),
498          bar = s.find(".swiper-scrollbar"),
499          h = getSwiperHeight(plugins.swiper, "height"), mh = getSwiperHeight(plugins.swiper, "min-height"),
500          parallax = s.parents('.rd-parallax').length;
501
502      s.find(".swiper-slide")
503          .each(function () {
504            var $this = $(this),
505                url;
506
507            if (url = $this.attr("data-slide-bg")) {
508              $this.css({
509                "background-image": "url(" + url + ")",
510                "background-size": "cover"
511              })
512            }
513
514          })
515          .end()
516          .find("[data-caption-animate]")
517          .addClass("not-animated")
518          .end()
519          .swiper({
520            autoplay: s.attr('data-autoplay') === "true" ? 5000 : false,
521            direction: s.attr('data-direction') ? s.attr('data-direction') : "horizontal",
522            effect: s.attr('data-slide-effect') ? s.attr('data-slide-effect') : "slide",
523            speed: s.attr('data-slide-speed') ? s.attr('data-slide-speed') : 600,
524            keyboardControl: s.attr('data-keyboard') === "true",
525            mousewheelControl: s.attr('data-mousewheel') === "true",
526            mousewheelReleaseOnEdges: s.attr('data-mousewheel-release') === "true",
527            nextButton: next.length ? next.get(0) : null,
528            prevButton: prev.length ? prev.get(0) : null,
529            pagination: pag.length ? pag.get(0) : null,
530            simulateTouch: false,
531            paginationClickable: pag.length ? pag.attr("data-clickable") !== "false" : false,
532            paginationBulletRender: pag.length ? pag.attr("data-index-bullet") === "true" ? function (index, className) {
533              return '<span class="' + className + '">' + (index + 1) + '</span>';
534            } : null : null,
535            scrollbar: bar.length ? bar.get(0) : null,
536            scrollbarDraggable: bar.length ? bar.attr("data-draggable") !== "false" : true,
537            scrollbarHide: bar.length ? bar.attr("data-draggable") === "false" : false,
538            loop: s.attr('data-loop') !== "false",
539            loopAdditionalSlides: 0,
540            loopedSlides: 0,
541            onTransitionStart: function (swiper) {
542              toggleSwiperInnerVideos(swiper);
543            },
544            onTransitionEnd: function (swiper) {
545              toggleSwiperCaptionAnimation(swiper);
546              $(window).trigger("resize");
547            },
548
549            onInit: function (swiper) {
550              if (plugins.pageLoader.length) {
551                var srcFirst = $("#page-loader").attr("data-slide-bg"),
552                    image = document.createElement('img');
553
554                image.src = srcFirst;
555                image.onload = function () {
556                  plugins.pageLoader.addClass("loaded");
557                };
558              }
559              toggleSwiperInnerVideos(swiper);
560              toggleSwiperCaptionAnimation(swiper);
561
562              // Create parallax effect on swiper caption
563              s.find(".swiper-parallax")
564                  .each(function () {
565                    var $this = $(this),
566                        speed;
567
568                    if (parallax && !isIE && !isMobile) {
569                      if (speed = $this.attr("data-speed")) {
570                        makeParallax($this, speed, s, false);
571                      }
572                    }
573                  });
574              $(window).on('resize', function () {
575                swiper.update(true);
576              })
577            },
578            onSlideChangeStart: function (swiper) {
579              var activeSlideIndex, slidesCount, thumbsToShow = 3;
580
581              activeSlideIndex = swiper.activeIndex;
582              slidesCount = swiper.slides.not(".swiper-slide-duplicate").length;
583
584              //If there is not enough slides
585              if (slidesCount < thumbsToShow)
586                return false;
587
588              //Fix index count
589              if (activeSlideIndex === slidesCount + 1) {
590                activeSlideIndex = 1;
591              } else if (activeSlideIndex === 0) {
592                activeSlideIndex = slidesCount;
593              }
594
595              //Lopp that adds background to thumbs
596              for (var i = -thumbsToShow; i < thumbsToShow + 1; i++) {
597                if (i === 0)
598                  continue;
599
600                //Previous btn thumbs
601                if (i < 0) {
602                  //If there is no slides before current
603                  if (( activeSlideIndex + i - 1) < 0) {
604                    $(swiper.container).find('.swiper-button-prev .preview__img-' + Math.abs(i))
605                        .css("background-image", "url(" + swiper.slides[slidesCount + i + 1].getAttribute("data-preview-bg") + ")");
606                  } else {
607                    $(swiper.container).find('.swiper-button-prev .preview__img-' + Math.abs(i))
608                        .css("background-image", "url(" + swiper.slides[activeSlideIndex + i].getAttribute("data-preview-bg") + ")");
609                  }
610
611                  //Next btn thumbs
612                } else {
613                  //If there is no slides after current
614                  if (activeSlideIndex + i - 1 > slidesCount) {
615                    $(swiper.container).find('.swiper-button-next .preview__img-' + i)
616                        .css("background-image", "url(" + swiper.slides[i].getAttribute("data-preview-bg") + ")");
617                  } else {
618                    $(swiper.container).find('.swiper-button-next .preview__img-' + i)
619                        .css("background-image", "url(" + swiper.slides[activeSlideIndex + i].getAttribute("data-preview-bg") + ")");
620                  }
621                }
622              }
623            },
624          });
625
626      $(window)
627          .on("resize", function () {
628            var mh = getSwiperHeight(s, "min-height"),
629                h = getSwiperHeight(s, "height");
630            if (h) {
631              s.css("height", mh ? mh > h ? mh : h : h);
632            }
633          })
634          .load(function () {
635            s.find("video").each(function () {
636              if (!$(this).parents(".swiper-slide-active").length) {
637                this.pause();
638              }
639            });
640          })
641          .trigger("resize");
642    });
643  }
644
645
646  /**
647   * Copyright Year
648   * @description  Evaluates correct copyright year
649   */
650  var o = $("#copyright-year");
651  if (o.length) {
652    o.text(initialDate.getFullYear());
653  }
654
655
656  /**
657   * Circle Progress
658   * @description Enable Circle Progress plugin
659   */
660  if (plugins.circleProgress.length) {
661    var i;
662    for (i = 0; i < plugins.circleProgress.length; i++) {
663      var circleProgressItem = $(plugins.circleProgress[i]);
664      $document
665          .on("scroll", function () {
666            if (!circleProgressItem.hasClass('animated')) {
667
668              var arrayGradients = circleProgressItem.attr('data-gradient').split(",");
669
670              circleProgressItem.circleProgress({
671                value: circleProgressItem.attr('data-value'),
672                size: circleProgressItem.attr('data-size') ? circleProgressItem.attr('data-size') : 175,
673                fill: {gradient: arrayGradients, gradientAngle: Math.PI / 4},
674                startAngle: -Math.PI / 4 * 2,
675                emptyFill: $(this).attr('data-empty-fill') ? $(this).attr('data-empty-fill') : "rgb(245,245,245)"
676
677              }).on('circle-animation-progress', function (event, progress, stepValue) {
678                $(this).find('span').text(String(stepValue.toFixed(2)).replace('0.', '').replace('1.', '1'));
679              });
680              circleProgressItem.addClass('animated');
681            }
682          })
683          .trigger("scroll");
684    }
685  }
686
687
688  /**
689   * Progress bar
690   * @description  Enable progress bar
691   */
692  if (plugins.progressBar.length) {
693    for (i = 0; i < plugins.progressBar.length; i++) {
694      var progressBar = $(plugins.progressBar[i]);
695      $window
696        .on("scroll load", $.proxy(function () {
697          var bar = $(this);
698          if (!bar.hasClass('animated-first') && isScrolledIntoView(bar)) {
699            var end = bar.attr("data-to");
700            bar.find('.progress-bar-linear').css({width: end + '%'});
701            bar.find('.progress-value').countTo({
702              refreshInterval: 40,
703              from: 0,
704              to: end,
705              speed: 500
706            });
707            bar.addClass('animated-first');
708          }
709        }, progressBar));
710    }
711  }
712
713  /**
714   * jQuery Countdown
715   * @description  Enable countdown plugin
716   */
717  if (plugins.countDown.length) {
718    var i, j;
719    for (i = 0; i < plugins.countDown.length; i++) {
720      var countDownItem = plugins.countDown[i],
721          $countDownItem = $(countDownItem),
722          d = new Date(),
723          type = countDownItem.getAttribute('data-type'),
724          time = countDownItem.getAttribute('data-time'),
725          format = countDownItem.getAttribute('data-format'),
726          settings = [];
727
728      d.setTime(Date.parse(time)).toLocaleString();
729      settings[type] = d;
730      settings['format'] = format;
731
732      if ($countDownItem.parents('.countdown-modern').length) {
733        settings['onTick'] = function () {
734          var section = $(this).find(".countdown-section");
735          for (j = 0; j < section.length; j++) {
736            $(section[section.length - j - 1]).append('<span class="countdown-letter">' + format[format.length - j - 1] + '</span>')
737          }
738        }
739      }
740
741      $countDownItem.countdown(settings);
742    }
743  }
744
745 /**
746   * Bootstrap tabs
747   * @description Activate Bootstrap Tabs
748   */
749  if (plugins.bootstrapTabs.length) {
750    var i;
751    for (i = 0; i < plugins.bootstrapTabs.length; i++) {
752      var bootstrapTab = $(plugins.bootstrapTabs[i]);
753
754      bootstrapTab.on("click", "a", function (event) {
755        event.preventDefault();
756        $(this).tab('show');
757      });
758    }
759  }
760
761  /**
762   * Bootstrap Tooltips
763   * @description Activate Bootstrap Tooltips
764   */
765  if (plugins.bootstrapTooltip.length) {
766    plugins.bootstrapTooltip.tooltip();
767  }
768
769  /**
770   * RD Audio player
771   * @description Enables RD Audio player plugin
772   */
773  if (plugins.rdAudioPlayer.length) {
774    var i;
775    for (i = 0; i < plugins.rdAudioPlayer.length; i++) {
776      $(plugins.rdAudioPlayer[i]).RDAudio();
777    }
778    var playlistButton = $('.rd-audio-playlist-button');
779    var playlist = plugins.rdAudioPlayer.find('.rd-audio-playlist-wrap');
780    if (playlistButton.length) {
781      playlistButton.on('click', function (e) {
782        e.preventDefault();
783        plugins.rdAudioPlayer.toggleClass('playlist-show');
784        if (playlist.is(':hidden')) {
785          playlist.slideDown(300);
786        } else {
787          playlist.slideUp(300);
788        }
789      });
790      $document.on('click', function (e) {
791        if (!$(e.target).is(playlist) && playlist.find($(e.target)).length == 0 && !$(e.target).is(playlistButton)) {
792          playlist.slideUp(300);
793        }
794      });
795    }
796  }
797
798
799  /**
800   * RD Video Player
801   * @description Enables RD Video player plugin
802   */
803  function hidePlaylist() {
804    $(".rd-video-player").removeClass("playlist-show");
805  }
806
807  function showPlaylist() {
808    $(".rd-video-player").addClass("playlist-show");
809  }
810
811  if (plugins.rdVideoPlayer.length) {
812    var i;
813    for (i = 0; i < plugins.rdVideoPlayer.length; i++) {
814      var videoItem = $(plugins.rdVideoPlayer[i]);
815
816      $window.on("scroll", $.proxy(function () {
817        var video = $(this);
818        if (isDesktop && !video.hasClass("played") && video.hasClass('play-on-scroll') && isScrolledIntoView(video)) {
819          video.find("video")[0].play();
820          video.addClass("played");
821        }
822      }, videoItem));
823
824      videoItem.RDVideoPlayer({
825        callbacks: {
826          onPlay: hidePlaylist,
827          onPaused: showPlaylist,
828          onEnded: showPlaylist
829        }
830      });
831      $window.on('load', showPlaylist);
832
833      var volumeWrap = $(".rd-video-volume-wrap");
834
835      volumeWrap.on("mouseenter", function () {
836        $(this).addClass("hover")
837      });
838
839      volumeWrap.on("mouseleave", function () {
840        $(this).removeClass("hover")
841      });
842
843      if (isTouch) {
844        volumeWrap.find(".rd-video-volume").on("click", function () {
845          $(this).toggleClass("hover")
846        });
847        $document.on("click", function (e) {
848          if (!$(e.target).is(volumeWrap) && $(e.target).parents(volumeWrap).length == 0) {
849            volumeWrap.find(".rd-video-volume").removeClass("hover")
850          }
851        })
852      }
853    }
854  }
855
856
857  /**
858   * Responsive Tabs
859   * @description Enables Responsive Tabs plugin
860   */
861  if (plugins.responsiveTabs.length) {
862    var i = 0;
863    for (i = 0; i < plugins.responsiveTabs.length; i++) {
864      var $this = $(plugins.responsiveTabs[i]);
865      $this.easyResponsiveTabs({
866        type: $this.attr("data-type"),
867        tabidentify: $this.find(".resp-tabs-list").attr("data-group") || "tab"
868      });
869    }
870  }
871
872
873  /**
874   * RD Google Maps
875   * @description Enables RD Google Maps plugin
876   */
877  if (plugins.rdGoogleMaps.length) {
878    $.getScript("//maps.google.com/maps/api/js?key=AIzaSyAwH60q5rWrS8bXwpkZwZwhw9Bw0pqKTZM&sensor=false&libraries=geometry,places&v=3.7", function () {
879      var head = document.getElementsByTagName('head')[0],
880          insertBefore = head.insertBefore;
881
882      head.insertBefore = function (newElement, referenceElement) {
883        if (newElement.href && newElement.href.indexOf('//fonts.googleapis.com/css?family=Roboto') != -1 || newElement.innerHTML.indexOf('gm-style') != -1) {
884          return;
885        }
886        insertBefore.call(head, newElement, referenceElement);
887      };
888
889      lazyInit(plugins.rdGoogleMaps, function () {
890        var styles = plugins.rdGoogleMaps.attr("data-styles");
891
892        plugins.rdGoogleMaps.googleMap({
893          styles: styles ? JSON.parse(styles) : {},
894          onInit: function (map) {
895            var inputAddress = $('#rd-google-map-address');
896
897            if (inputAddress.length) {
898              var input = inputAddress;
899              var geocoder = new google.maps.Geocoder();
900              var marker = new google.maps.Marker(
901                  {
902                    map: map,
903                    icon: "images/gmap_marker.png",
904                  }
905              );
906              var autocomplete = new google.maps.places.Autocomplete(inputAddress[0]);
907              autocomplete.bindTo('bounds', map);
908              inputAddress.attr('placeholder', '');
909              inputAddress.on('change', function () {
910                $("#rd-google-map-address-submit").trigger('click');
911              });
912
913              $("#rd-google-map-address-submit").on('click', function (e) {
914                e.preventDefault();
915                var address = input.val();
916                geocoder.geocode({'address': address}, function (results, status) {
917                  if (status == google.maps.GeocoderStatus.OK) {
918                    var latitude = results[0].geometry.location.lat();
919                    var longitude = results[0].geometry.location.lng();
920
921                    map.setCenter(new google.maps.LatLng(
922                        parseFloat(latitude),
923                        parseFloat(longitude)
924                    ));
925                    marker.setPosition(new google.maps.LatLng(
926                        parseFloat(latitude),
927                        parseFloat(longitude)
928                    ))
929                  }
930                });
931              });
932            }
933          }
934        })
935      });
936    });
937  }
938
939  /**
940   * RD Flickr Feed
941   * @description Enables RD Flickr Feed plugin
942   */
943  if (plugins.flickrfeed.length > 0) {
944    var i;
945    for (i = 0; i < plugins.flickrfeed.length; i++) {
946      var flickrfeedItem = $(plugins.flickrfeed[i]);
947      flickrfeedItem.RDFlickr({
948        callback: function () {
949          var items = flickrfeedItem.find("[data-photo-swipe-item]");
950
951          if (items.length) {
952            for (var j = 0; j < items.length; j++) {
953              var image = new Image();
954              image.setAttribute('data-index', j);
955              image.onload = function () {
956                items[this.getAttribute('data-index')].setAttribute('data-size', this.naturalWidth + 'x' + this.naturalHeight);
957              };
958              image.src = items[j].getAttribute('href');
959            }
960          }
961        }
962      });
963    }
964  }
965
966  /**
967   * RD Twitter Feed
968   * @description Enables RD Twitter Feed plugin
969   */
970  if (plugins.twitterfeed.length > 0) {
971    var i;
972    for (i = 0; i < plugins.twitterfeed.length; i++) {
973      var twitterfeedItem = plugins.twitterfeed[i];
974      $(twitterfeedItem).RDTwitter({
975        hideReplies: false,
976        localTemplate: {
977          avatar: "images/features/rd-twitter-post-avatar-48x48.jpg"
978        },
979        callback: function () {
980          $window.trigger("resize");
981        }
982      });
983    }
984  }
985
986
987  /**
988   * RD Input Label
989   * @description Enables RD Input Label Plugin
990   */
991  if (plugins.rdInputLabel.length) {
992    plugins.rdInputLabel.RDInputLabel();
993  }
994
995
996  /**
997   * Stepper
998   * @description Enables Stepper Plugin
999   */
1000  if (plugins.stepper.length) {
1001    plugins.stepper.stepper({
1002      labels: {
1003        up: "",
1004        down: ""
1005      }
1006    });
1007  }
1008
1009  /**
1010   * Radio
1011   * @description Add custom styling options for input[type="radio"]
1012   */
1013  if (plugins.radio.length) {
1014    var i;
1015    for (i = 0; i < plugins.radio.length; i++) {
1016      var $this = $(plugins.radio[i]);
1017      $this.addClass("radio-custom").after("<span class='radio-custom-dummy'></span>")
1018    }
1019  }
1020
1021  /**
1022   * Checkbox
1023   * @description Add custom styling options for input[type="checkbox"]
1024   */
1025  if (plugins.checkbox.length) {
1026    var i;
1027    for (i = 0; i < plugins.checkbox.length; i++) {
1028      var $this = $(plugins.checkbox[i]);
1029      $this.after("<span class='checkbox-custom-dummy'></span>")
1030    }
1031  }
1032
1033
1034  /**
1035   * Toggles
1036   * @description Make toggles from input[type="checkbox"]
1037   */
1038  if (plugins.toggles.length) {
1039    var i;
1040    for (i = 0; i < plugins.toggles.length; i++) {
1041      var $this = $(plugins.toggles[i]);
1042      $this.after("<span class='toggle-custom-dummy'></span>")
1043    }
1044  }
1045
1046
1047  /**
1048   * Regula
1049   * @description Enables Regula plugin
1050   */
1051  if (plugins.regula.length) {
1052    attachFormValidator(plugins.regula);
1053  }
1054
1055
1056  /**
1057   * WOW
1058   * @description Enables Wow animation plugin
1059   */
1060  if ($html.hasClass('desktop') && $html.hasClass("wow-animation") && $(".wow").length) {
1061    new WOW().init();
1062  }
1063
1064
1065  /**
1066   * Text Rotator
1067   * @description Enables Text Rotator plugin
1068   */
1069  if (plugins.textRotator.length) {
1070    var i;
1071    for (i = 0; i < plugins.textRotator.length; i++) {
1072      var textRotatorItem = $(plugins.textRotator[i]);
1073      textRotatorItem.rotator();
1074    }
1075  }
1076
1077  /**
1078   * jQuery Count To
1079   * @description Enables Count To plugin
1080   */
1081  if (plugins.counter.length) {
1082    var i;
1083    for (i = 0; i < plugins.counter.length; i++) {
1084      var counterItem = $(plugins.counter[i]);
1085
1086      $window.on("scroll load", $.proxy(function () {
1087        var counter = $(this);
1088        if ((!counter.hasClass("animated-first")) && (isScrolledIntoView(counter))) {
1089          counter.countTo({
1090            refreshInterval: 40,
1091            speed: counter.attr("data-speed") || 1000
1092          });
1093          counter.addClass('animated-first');
1094        }
1095      }, counterItem))
1096    }
1097  }
1098
1099
1100  /**
1101   * Owl carousel
1102   * @description Enables Owl carousel plugin
1103   */
1104  if (plugins.owl.length) {
1105    var k;
1106    for (k = 0; k < plugins.owl.length; k++) {
1107      var c = $(plugins.owl[k]),
1108          responsive = {};
1109
1110      var aliaces = ["-", "-xs-", "-sm-", "-md-", "-lg-"],
1111          values = [0, 480, 768, 992, 1200],
1112          i, j;
1113
1114      for (i = 0; i < values.length; i++) {
1115        responsive[values[i]] = {};
1116        for (j = i; j >= -1; j--) {
1117          if (!responsive[values[i]]["items"] && c.attr("data" + aliaces[j] + "items")) {
1118            responsive[values[i]]["items"] = j < 0 ? 1 : parseInt(c.attr("data" + aliaces[j] + "items"));
1119          }
1120          if (!responsive[values[i]]["stagePadding"] && responsive[values[i]]["stagePadding"] !== 0 && c.attr("data" + aliaces[j] + "stage-padding")) {
1121            responsive[values[i]]["stagePadding"] = j < 0 ? 0 : parseInt(c.attr("data" + aliaces[j] + "stage-padding"));
1122          }
1123          if (!responsive[values[i]]["margin"] && responsive[values[i]]["margin"] !== 0 && c.attr("data" + aliaces[j] + "margin")) {
1124            responsive[values[i]]["margin"] = j < 0 ? 30 : parseInt(c.attr("data" + aliaces[j] + "margin"));
1125          }
1126          if (!responsive[values[i]]["dotsEach"] && responsive[values[i]]["dotsEach"] !== 0 && c.attr("data" + aliaces[j] + "dots-each")) {
1127            responsive[values[i]]["dotsEach"] = j < 0 ? false : parseInt(c.attr("data" + aliaces[j] + "dots-each"));
1128          }
1129        }
1130      }
1131
1132      // Create custom Pagination
1133      if (c.attr('data-dots-custom')) {
1134        c.on("initialized.owl.carousel", function (event) {
1135          var carousel = $(event.currentTarget),
1136              customPag = $(carousel.attr("data-dots-custom")),
1137              active = 0;
1138
1139          if (carousel.attr('data-active')) {
1140            active = parseInt(carousel.attr('data-active'));
1141          }
1142
1143          carousel.trigger('to.owl.carousel', [active, 300, true]);
1144          customPag.find("[data-owl-item='" + active + "']").addClass("active");
1145
1146          customPag.find("[data-owl-item]").on('click', function (e) {
1147            e.preventDefault();
1148            carousel.trigger('to.owl.carousel', [parseInt(this.getAttribute("data-owl-item")), 300, true]);
1149          });
1150
1151          carousel.on("translate.owl.carousel", function (event) {
1152            customPag.find(".active").removeClass("active");
1153            customPag.find("[data-owl-item='" + event.item.index + "']").addClass("active")
1154          });
1155        });
1156      }
1157
1158      // Create custom Navigation
1159      if (c.attr('data-nav-custom')) {
1160        c.on("initialized.owl.carousel", function (event) {
1161          var carousel = $(event.currentTarget),
1162              customNav = $(carousel.attr("data-nav-custom"));
1163
1164          customNav.find("[data-owl-prev]").on('click', function (e) {
1165            e.preventDefault();
1166            carousel.trigger('prev.owl.carousel', [300]);
1167          });
1168
1169          customNav.find("[data-owl-next]").on('click', function (e) {
1170            e.preventDefault();
1171            carousel.trigger('next.owl.carousel', [300]);
1172          });
1173        });
1174      }
1175
1176      c.owlCarousel({
1177        autoplay: c.attr("data-autoplay") === "true",
1178        loop: c.attr("data-loop") === "true",
1179        items: 1,
1180        autoplaySpeed: 600,
1181        autoplayTimeout: 3000,
1182        dotsContainer: c.attr("data-pagination-class") || false,
1183        navContainer: c.attr("data-navigation-class") || false,
1184        mouseDrag: c.attr("data-mouse-drag") === "true",
1185        nav: c.attr("data-nav") === "true",
1186        dots: c.attr("data-dots") === "true",
1187        dotsEach: c.attr("data-dots-each") ? parseInt(c.attr("data-dots-each")) : false,
1188        responsive: responsive,
1189        animateOut: c.attr("data-animation-out") || false,
1190        navText: $.parseJSON(c.attr("data-nav-text")) || [],
1191        navClass: $.parseJSON(c.attr("data-nav-class")) || ['owl-prev', 'owl-next']
1192      });
1193
1194    }
1195  }
1196
1197  /**
1198   * Isotope
1199   * @description Enables Isotope plugin
1200   */
1201  if (plugins.isotope.length) {
1202    var i, j, isogroup = [];
1203    for (i = 0; i < plugins.isotope.length; i++) {
1204      var isotopeItem = plugins.isotope[i],
1205          filterItems = $(isotopeItem).closest('.isotope-wrap').find('[data-isotope-filter]'),
1206          iso = new Isotope(isotopeItem,
1207              {
1208                itemSelector: '.isotope-item',
1209                layoutMode: isotopeItem.getAttribute('data-isotope-layout') ? isotopeItem.getAttribute('data-isotope-layout') : 'masonry',
1210                filter: '*',
1211              }
1212          );
1213
1214      isogroup.push(iso);
1215
1216      filterItems.on("click", function (e) {
1217        e.preventDefault();
1218        var filter = $(this),
1219            iso = $('.isotope[data-isotope-group="' + this.getAttribute("data-isotope-group") + '"]'),
1220            filtersContainer = filter.closest(".isotope-filters");
1221
1222        filtersContainer
1223            .find('.active')
1224            .removeClass("active");
1225        filter.addClass("active");
1226
1227        iso.isotope({
1228          itemSelector: '.isotope-item',
1229          layoutMode: iso.attr('data-isotope-layout') ? iso.attr('data-isotope-layout') : 'masonry',
1230          filter: this.getAttribute("data-isotope-filter") == '*' ? '*' : '[data-filter*="' + this.getAttribute("data-isotope-filter") + '"]'
1231        });
1232
1233        $window.trigger('resize');
1234
1235        // If d3Charts contains in isotop, resize it on click.
1236        if (filtersContainer.hasClass('isotope-has-d3-graphs') && c3ChartsArray != undefined) {
1237          setTimeout(function () {
1238            for (var j = 0; j < c3ChartsArray.length; j++) {
1239              c3ChartsArray[j].resize();
1240            }
1241          }, 500);
1242        }
1243
1244      }).eq(0).trigger("click");
1245    }
1246
1247    $(window).on('load', function () {
1248      setTimeout(function () {
1249        var i;
1250        for (i = 0; i < isogroup.length; i++) {
1251          isogroup[i].element.className += " isotope--loaded";
1252          isogroup[i].layout();
1253        }
1254      }, 600);
1255    });
1256  }
1257
1258
1259  /**
1260   * RD Video
1261   * @description Enables RD Video plugin
1262   */
1263  if (plugins.rdVideoBG.length) {
1264    for (i = 0; i < plugins.rdVideoBG.length; i++) {
1265      var videoItem = $(plugins.rdVideoBG[i]);
1266      videoItem.RDVideo({});
1267    }
1268  }
1269
1270
1271  /**
1272   * RD Navbar
1273   * @description Enables RD Navbar plugin
1274   */
1275  if (plugins.rdNavbar.length) {
1276    plugins.rdNavbar.RDNavbar({
1277      stickUpClone: (plugins.rdNavbar.attr("data-stick-up-clone")) ? plugins.rdNavbar.attr("data-stick-up-clone") === 'true' : false,
1278      stickUpOffset: (plugins.rdNavbar.attr("data-stick-up-offset")) ? plugins.rdNavbar.attr("data-stick-up-offset") : 1,
1279      anchorNavOffset: -78
1280    });
1281    if (plugins.rdNavbar.attr("data-body-class")) {
1282      document.body.className += ' ' + plugins.rdNavbar.attr("data-body-class");
1283    }
1284  }
1285
1286
1287  /**
1288   * PhotoSwipe Gallery
1289   * @description Enables PhotoSwipe Gallery plugin
1290   */
1291  if (plugins.photoSwipeGallery.length) {
1292
1293    // init image click event
1294    $document.delegate("[data-photo-swipe-item]", "click", function (event) {
1295      event.preventDefault();
1296
1297      var $el = $(this),
1298          $galleryItems = $el.parents("[data-photo-swipe-gallery]").find("a[data-photo-swipe-item]"),
1299          pswpElement = document.querySelectorAll('.pswp')[0],
1300          encounteredItems = {},
1301          pswpItems = [],
1302          options,
1303          pswpIndex = 0,
1304          pswp;
1305
1306      if ($galleryItems.length == 0) {
1307        $galleryItems = $el;
1308      }
1309
1310      // loop over the gallery to build up the photoswipe items
1311      $galleryItems.each(function () {
1312        var $item = $(this),
1313            src = $item.attr('href'),
1314            size = $item.attr('data-size').split('x'),
1315            pswdItem;
1316
1317        if ($item.is(':visible')) {
1318          // if we have this image the first time
1319          if (!encounteredItems[src]) {
1320            // build the photoswipe item
1321            pswdItem = {
1322              src: src,
1323              w: parseInt(size[0], 10),
1324              h: parseInt(size[1], 10),
1325              el: $item // save link to element for getThumbBoundsFn
1326            };
1327
1328            // store that we already had this item
1329            encounteredItems[src] = {
1330              item: pswdItem,
1331              index: pswpIndex
1332            };
1333
1334            // push the item to the photoswipe list
1335            pswpItems.push(pswdItem);
1336            pswpIndex++;
1337          }
1338        }
1339      });
1340
1341      options = {
1342        index: encounteredItems[$el.attr('href')].index,
1343
1344        getThumbBoundsFn: function (index) {
1345          var $el = pswpItems[index].el,
1346              offset = $el.offset();
1347
1348          return {
1349            x: offset.left,
1350            y: offset.top,
1351            w: $el.width()
1352          };
1353        }
1354      };
1355
1356      // open the photoswipe gallery
1357      pswp = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, pswpItems, options);
1358      pswp.init();
1359    });
1360  }
1361
1362  /**
1363   * Stacktable
1364   * @description Enables Stacktable plugin
1365   */
1366  if (plugins.stacktable.length) {
1367    var i;
1368    for (i = 0; i < plugins.stacktable.length; i++) {
1369      var stacktableItem = $(plugins.stacktable[i]);
1370      stacktableItem.stacktable();
1371    }
1372  }
1373
1374  /**
1375   * Select2
1376   * @description Enables select2 plugin
1377   */
1378  if (plugins.selectFilter.length) {
1379    var i;
1380    for (i = 0; i < plugins.selectFilter.length; i++) {
1381      var select = $(plugins.selectFilter[i]);
1382
1383      select.select2({
1384        theme: "bootstrap"
1385      }).next().addClass(select.attr("class").match(/(input-sm)|(input-lg)|($)/i).toString().replace(new RegExp(",", 'g'), " "));
1386    }
1387  }
1388
1389  /**
1390   * Product Thumbnails
1391   * @description Enables product thumbnails
1392   */
1393  if (plugins.productThumb.length) {
1394    var i;
1395    for (i = 0; i < plugins.productThumb.length; i++) {
1396      var thumbnails = $(plugins.productThumb[i]);
1397
1398      thumbnails.find("li").on('click', function () {
1399        var item = $(this);
1400        item.parent().find('.active').removeClass('active');
1401        var image = item.parents(".product").find(".product-image-area");
1402        image.removeClass('animateImageIn');
1403        image.addClass('animateImageOut');
1404        item.addClass('active');
1405        setTimeout(function () {
1406          var src = item.find("img").attr("src");
1407          if (item.attr('data-large-image')) {
1408            src = item.attr('data-large-image');
1409          }
1410          image.attr("src", src);
1411          image.removeClass('animateImageOut');
1412          image.addClass('animateImageIn');
1413        }, 300);
1414      })
1415    }
1416  }
1417
1418  /**
1419  RD Calendar
1420  @description Enables RD Calendar plugin
1421  */
1422  if (plugins.calendar.length) {
1423    for (i = 0; i < plugins.calendar.length; i++) {
1424      var calendarItem = $(plugins.calendar[i]);
1425      calendarItem.rdCalendar({ 
1426        days: calendarItem.attr("data-days") ? calendarItem.attr("data-days").split(/\s?,\s?/i) : ['S', 'M', 'T', 'W', 'T', 'F', 'S'], 
1427        months: calendarItem.attr("data-months") ? calendarItem.attr("data-months").split(/\s?,\s?/i) : ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'] 
1428      }
1429      );
1430    }
1431  }
1432
1433  /**
1434   * jQuery elevateZoom
1435   * @description Enables jQuery elevateZoom plugin
1436   */
1437  if (plugins.imgZoom.length) {
1438    for (i = 0; i < plugins.imgZoom.length; i++) {
1439      var zoomItem = $(plugins.imgZoom[i]);
1440
1441      zoomItem.elevateZoom({
1442        zoomType: "inner",
1443        cursor: "crosshair",
1444        zoomWindowFadeIn: 300,
1445        zoomWindowFadeOut: 300,
1446        scrollZoom: true
1447      });
1448    }
1449  }
1450
1451  /**
1452   * RD Facebook
1453   * @description Enables RD Facebook plugin
1454   */
1455  if (plugins.facebookfeed.length > 0) {
1456    for (i = 0; i < plugins.facebookfeed.length; i++) {
1457      var facebookfeedItem = plugins.facebookfeed[i];
1458      $(facebookfeedItem).RDFacebookFeed({
1459        callbacks: {
1460          postsLoaded: function () {
1461            var posts = $('.post-facebook');
1462            var i = 0;
1463            for (i = 0; i < posts.length; i++) {
1464              var $this = $(posts[i]);
1465              var commentBlock = $this.find('.post-comments');
1466              var commentBlockItem = $this.find('.post-comments [data-fb-comment]');
1467              var j = 0;
1468              for (j = 0; j < commentBlockItem.length; j++) {
1469                var commentItem = commentBlockItem[j];
1470                if (commentItem.innerHTML.trim().length == 0) {
1471                  $(commentItem).remove();
1472                }
1473              }
1474              if (commentBlock.find('[data-fb-comment]').length == 0) {
1475                commentBlock.remove();
1476              }
1477            }
1478            $window.trigger("resize");
1479          }
1480        }
1481      })
1482
1483    }
1484  }
1485
1486  /**
1487   * Page loader
1488   * @description Enables Page loader
1489   */
1490  if (plugins.pageLoader.length > 0) {
1491
1492    $window.on("load", function () {
1493      var loader = setTimeout(function () {
1494        plugins.pageLoader.addClass("loaded");
1495        $window.trigger("resize");
1496      }, 200);
1497    });
1498
1499  }
1500
1501  /**
1502   * RD Search
1503   * @description Enables search
1504   */
1505  if (plugins.search.length || plugins.searchResults) {
1506    var handler = "bat/rd-search.php";
1507    var defaultTemplate = '<h5 class="search_title"><a target="_top" href="#{href}" class="search_link">#{title}</a></h5>' +
1508        '<p>...#{token}...</p>' +
1509        '<p class="match"><em>Terms matched: #{count} - URL: #{href}</em></p>';
1510    var defaultFilter = '*.html';
1511
1512    if (plugins.search.length) {
1513
1514      for (i = 0; i < plugins.search.length; i++) {
1515        var searchItem = $(plugins.search[i]),
1516            options = {
1517              element: searchItem,
1518              filter: (searchItem.attr('data-search-filter')) ? searchItem.attr('data-search-filter') : defaultFilter,
1519              template: (searchItem.attr('data-search-template')) ? searchItem.attr('data-search-template') : defaultTemplate,
1520              live: (searchItem.attr('data-search-live')) ? searchItem.attr('data-search-live') : false,
1521              liveCount: (searchItem.attr('data-search-live-count')) ? parseInt(searchItem.attr('data-search-live')) : 4,
1522              current: 0, processed: 0, timer: {}
1523            };
1524
1525        if ($('.rd-navbar-search-toggle').length) {
1526          var toggle = $('.rd-navbar-search-toggle');
1527          toggle.on('click', function () {
1528            if (!($(this).hasClass('active'))) {
1529              searchItem.find('input').val('').trigger('propertychange');
1530            }
1531          });
1532        }
1533
1534        if (options.live) {
1535          searchItem.find('input').on("keyup input propertychange", $.proxy(function () {
1536            this.term = this.element.find('input').val().trim();
1537            this.spin = this.element.find('.input-group-addon');
1538            clearTimeout(this.timer);
1539
1540            if (this.term.length > 2) {
1541              this.timer = setTimeout(liveSearch(this), 200);
1542            } else if (this.term.length == 0) {
1543              $('#' + this.live).addClass('cleared').html('');
1544            }
1545          }, options, this));
1546        }
1547
1548        searchItem.submit($.proxy(function () {
1549          $('<input />').attr('type', 'hidden')
1550              .attr('name', "filter")
1551              .attr('value', this.filter)
1552              .appendTo(this.element);
1553          return true;
1554        }, options, this))
1555      }
1556    }
1557
1558    if (plugins.searchResults.length) {
1559      var regExp = /\?.*s=([^&]+)\&filter=([^&]+)/g;
1560      var match = regExp.exec(location.search);
1561
1562      if (match != null) {
1563        $.get(handler, {
1564          s: decodeURI(match[1]),
1565          dataType: "html",
1566          filter: match[2],
1567          template: defaultTemplate,
1568          live: ''
1569        }, function (data) {
1570          plugins.searchResults.html(data);
1571        })
1572      }
1573    }
1574  }
1575
1576  /**
1577   * Custom Toggles
1578   */
1579  if (plugins.customToggle.length) {
1580    var i;
1581    for (i = 0; i < plugins.customToggle.length; i++) {
1582      var $this = $(plugins.customToggle[i]);
1583      $this.on('click', function (e) {
1584        e.preventDefault();
1585        $("#" + $(this).attr('data-custom-toggle')).add(this).toggleClass('active');
1586      });
1587
1588      if ($this.attr("data-custom-toggle-disable-on-blur") === "true") {
1589        $("body").on("click", $this, function (e) {
1590          if (e.target !== e.data[0] && $("#" + e.data.attr('data-custom-toggle')).find($(e.target)).length == 0 && e.data.find($(e.target)).length == 0) {
1591            $("#" + e.data.attr('data-custom-toggle')).add(e.data[0]).removeClass('active');
1592          }
1593        })
1594      }
1595    }
1596  }
1597
1598  /**
1599   * Custom Waypoints
1600   */
1601  if (plugins.customWaypoints.length) {
1602    var i;
1603    plugins.customWaypoints = $document.find('[data-waypoint-to]');
1604
1605    for(i = 0; i< plugins.customWaypoints.length; i++){
1606      var item = plugins.customWaypoints[i];
1607
1608      $(item).on("click", function (e) {
1609        e.preventDefault();
1610        console.log($(this));
1611        $("body, html").stop().animate({
1612          scrollTop: $($(this).attr('data-waypoint-to')).offset().top
1613        }, 1000, function () {
1614          $(window).trigger("resize");
1615        });
1616      });
1617    }
1618  }
1619
1620  /**
1621   * Bootstrap Date time picker
1622   */
1623  if (plugins.bootstrapDateTimePicker.length) {
1624    var i;
1625    for (i = 0; i < plugins.bootstrapDateTimePicker.length; i++) {
1626      var $dateTimePicker = $(plugins.bootstrapDateTimePicker[i]);
1627      var options = {};
1628
1629      options['format'] = 'dddd DD MMMM YYYY - HH:mm';
1630      if ($dateTimePicker.attr("data-time-picker") == "date") {
1631        options['format'] = 'dddd DD MMMM YYYY';
1632        options['minDate'] = new Date();
1633      } else if ($dateTimePicker.attr("data-time-picker") == "time") {
1634        options['format'] = 'HH:mm';
1635      }
1636
1637      options["time"] = ($dateTimePicker.attr("data-time-picker") != "date");
1638      options["date"] = ($dateTimePicker.attr("data-time-picker") != "time");
1639      options["shortTime"] = true;
1640
1641      $dateTimePicker.bootstrapMaterialDatePicker(options);
1642    }
1643  }
1644
1645  /**
1646   * Checkout RD Material Tabs
1647   */
1648  if (plugins.checkoutRDTabs.length) {
1649    var i, step = 0;
1650    for (i = 0; i < plugins.checkoutRDTabs.length; i++) {
1651      var checkoutTab = $(plugins.checkoutRDTabs[i]);
1652
1653      checkoutTab.RDMaterialTabs({
1654        dragList: true,
1655        dragContent: false,
1656        items: 1,
1657        marginContent: 10,
1658        margin: 0,
1659        responsive: {
1660          480: {
1661            items: 2
1662          },
1663          768: {
1664            dragList: false,
1665            items: 3
1666          }
1667        },
1668        callbacks: {
1669          onChangeStart: function (active, indexTo) {
1670            if (indexTo > step + 1) {
1671              return false;
1672            } else if (indexTo == step + 1) {
1673              for (var j = 0; j < this.$content.find(".rd-material-tab").length; j++) {
1674                if (j <= step) {
1675                  var inputs = this.$content.find(".rd-material-tab").eq(j).find("[data-constraints]");
1676
1677                  if (!isValidated(inputs)) {
1678                    this.setContentTransition(this, this.options.speed)
1679                    this.moveTo(j);
1680                    return false
1681                  }
1682                }
1683              }
1684              if (indexTo > step) step = indexTo;
1685            }
1686
1687          },
1688          onChangeEnd: function () {
1689
1690          },
1691          onInit: function (tabs) {
1692            attachFormValidator(tabs.$element.find("[data-constraints]"));
1693
1694            $('.checkout-step-btn').on("click", function (e) {
1695              e.preventDefault();
1696              var index = this.getAttribute("data-index-to"),
1697                  inputs = tabs.$content.find(".rd-material-tab").eq(index - 1).find("[data-constraints]");
1698
1699              if (isValidated(inputs)) {
1700                tabs.setContentTransition(tabs, tabs.options.speed);
1701                tabs.moveTo(parseInt(index));
1702                if (index > step) step = index;
1703              }
1704            });
1705          }
1706        }
1707      });
1708    }
1709  }
1710
1711
1712  /**
1713   * RD Parallax
1714   * @description Enables RD Parallax plugin
1715   */
1716  if (plugins.rdParallax.length) {
1717    var i;
1718    $.RDParallax();
1719
1720    if (!isIE && !isMobile) {
1721      $(window).on("scroll", function () {
1722        for (i = 0; i < plugins.rdParallax.length; i++) {
1723          var parallax = $(plugins.rdParallax[i]);
1724          if (isScrolledIntoView(parallax)) {
1725            parallax.find(".rd-parallax-inner").css("position", "fixed");
1726          } else {
1727            parallax.find(".rd-parallax-inner").css("position", "absolute");
1728          }
1729        }
1730      });
1731    }
1732
1733    $("a[href='#']").on("click", function (e) {
1734      setTimeout(function () {
1735        $(window).trigger("resize");
1736      }, 300);
1737    });
1738  }
1739
1740  /**
1741   * Highcharts
1742   * @description Enables Highcharts plugin
1743   */
1744  if (plugins.higCharts.charts.length) {
1745    var i,
1746        detailChart,
1747        masterChart;
1748
1749    for (i = 0; i < plugins.higCharts.charts.length; i++) {
1750      var higchartsItem = $(plugins.higCharts.charts[i]),
1751          higChartsItemObject = parseJSONObject(higchartsItem, 'data-graph-object');
1752
1753      if (!higchartsItem.attr('data-parent-chart') && !higchartsItem.attr('data-child-chart')) {
1754        higchartsItem.highcharts(
1755            higChartsItemObject
1756        );
1757      } else {
1758        if (higchartsItem.attr('data-child-chart')) {
1759          var childGraph = higchartsItem.attr('data-child-chart'),
1760              higChartsChildObject = parseJSONObject(childGraph, 'data-graph-object');
1761
1762          masterChart = higchartsItem.highcharts(
1763              higChartsItemObject, function () {
1764                detailChart = $(childGraph).highcharts(
1765                    higChartsChildObject
1766                ).highcharts();
1767              }
1768          ).highcharts();
1769        }
1770      }
1771    }
1772  }
1773
1774  /**
1775   * Highcharts
1776   * @description Enables legends for highcharts plugin
1777   */
1778  if (plugins.higCharts.legend.length) {
1779    var i, j;
1780
1781    for (i = 0; i < plugins.higCharts.legend.length; i++) {
1782      var higchartsLegend = plugins.higCharts.legend[i],
1783          legendId = $(higchartsLegend).attr('data-chart-id'),
1784          legendItems = $(higchartsLegend).find('.legend-item');
1785
1786      for (j = 0; j < legendItems.length; j++) {
1787        var legendItem = $(legendItems[j]),
1788            itemId = legendItem.attr('data-chart-id'),
1789            legend = $(legendId).highcharts().series[itemId],
1790            legendName = legend.name,
1791            legendObj;
1792
1793        if (legendItem.is('input')) {
1794          if (legend.visible) {
1795            legendItem.prop('checked', true);
1796          } else {
1797            legendItem.prop('checked', false);
1798          }
1799        }
1800
1801        legendItem.html(legendName);
1802        legendObj = {
1803          legendItem: legendItem,
1804          legend: legend
1805        };
1806
1807        // assign click handler which toggles legend data
1808        legendItem.on('click', $.proxy(function (e) {
1809          var _this = this;
1810
1811          if (_this.legendItem.attr('href')) {
1812            e.preventDefault();
1813          }
1814          if (_this.legend.visible) {
1815            _this.legend.hide();
1816            _this.legendItem.toggleClass('active');
1817          } else {
1818            _this.legend.show();
1819            _this.legendItem.toggleClass('active');
1820          }
1821        }, legendObj));
1822    }
1823  }
1824}
1825
1826/**
1827* D3 Charts
1828* @description Enables D3 Charts plugin
1829*/
1830if (plugins.d3Charts.length) {
1831  var i;
1832
1833  for (i = 0; i < plugins.d3Charts.length; i++) {
1834      var d3ChartsItem = $(plugins.d3Charts[i]),
1835      d3ChartItemObject = parseJSONObject(d3ChartsItem, 'data-graph-object');
1836      c3ChartsArray.push(c3.generate(d3ChartItemObject));
1837  }
1838}
1839
1840  /**
1841   * Flot Charts
1842   * @description Enables Flot Charts plugin
1843   */
1844  if (plugins.flotCharts.length) {
1845    var i;
1846
1847    for (i = 0; i < plugins.flotCharts.length; i++) {
1848      var flotChartsItem = plugins.flotCharts[i],
1849          flotChartItemObject = parseJSONObject(flotChartsItem, 'data-graph-object'),
1850          gridObject = parseJSONObject(flotChartsItem, 'data-grid-object');
1851
1852      $.plot(flotChartsItem, flotChartItemObject, gridObject);
1853    }
1854  }
1855
1856  /**
1857   * Gallery RD Material Tabs
1858  */
1859  if (plugins.galleryRDTabs.length) {
1860    var uniqueRandoms = [];
1861    var timer = false,
1862        timer2 = false;
1863    plugins.galleryRDTabs.RDMaterialTabs({
1864      responsive: {
1865        0: {
1866          items: 3
1867        },
1868        768: {
1869          margin: 50
1870        },
1871        992: {
1872          margin: 100,
1873          items: 4
1874        },
1875        1200: {
1876          items: 5
1877        },
1878        1600: {
1879          items: 6
1880        }
1881      },
1882      callbacks: {
1883        onInit: function () {
1884          plugins.galleryRDTabs.addClass('loaded');
1885          if ($html.hasClass('desktop')) {
1886            makeVisible(plugins.galleryRDTabs.find('.rd-material-tab:first-child .image'));
1887          }
1888        },
1889        onChangeStart: function () {
1890          if ($html.hasClass('desktop')) {
1891            makeInvisible();
1892          }
1893        },
1894        onChangeEnd: function () {
1895          if ($html.hasClass('desktop')) {
1896            makeVisible(plugins.galleryRDTabs.find('.rd-material-tab-active .image'));
1897          }
1898        }
1899      }
1900    });
1901    $window.trigger("resize");
1902  }
1903});

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.