PageSourceSearch

https://grappa.no/wp-content/themes/grappa/js/script.js?ver=1.0.0

js grappa.no collected 2026-10-02 05:38:42 UTC 21,326 bytes, 781 lines download raw bytes

1(function($) {
2
3  $.fn.iLightInputNumber = function(options) {
4
5    var inBox = '.input-number-box',
6      newInput = '.input-number',
7      moreVal = '.input-number-more',
8      lessVal = '.input-number-less';
9
10    this.each(function() {
11
12      var el = $(this);
13      $('<div class="' + inBox.substr(1) + '"></div>').insertAfter(el);
14      var parent = el.find('+ ' + inBox);
15      parent.append(el);
16      var classes = el.attr('class');
17      parent.append('<input class="' + newInput.substr(1) + '" type="text">');
18      el.hide();
19      var newEl = el.next();
20      newEl.addClass(classes);
21      var attrValue;
22
23      function setInputAttr(attrName) {
24        if (el.attr(attrName)) {
25          attrValue = el.attr(attrName);
26          newEl.attr(attrName, attrValue);
27        }
28      }
29
30      setInputAttr('value');
31      setInputAttr('placeholder');
32      setInputAttr('min');
33      setInputAttr('max');
34      setInputAttr('step');
35
36      parent.append('<div class=' + moreVal.substr(1) + '>+</div>');
37      parent.append('<div class=' + lessVal.substr(1) + '>-</div>');
38
39    }); //end each
40
41    var value,
42      step;
43
44    var interval = null,
45      timeout = null;
46
47    function ToggleValue(input) {
48      input.val(parseInt(input.val(), 10) + d);
49      console.log(input);
50    }
51
52    $('body').on('mousedown', moreVal, function() {
53      var el = $(this);
54      var input = el.siblings(newInput);
55      moreValFn(input);
56      timeout = setTimeout(function() {
57        interval = setInterval(function() {
58          moreValFn(input);
59        }, 50);
60      }, 200);
61
62    });
63
64    $('body').on('mousedown', lessVal, function() {
65      var el = $(this);
66      var input = el.siblings(newInput);
67      lessValFn(input);
68      timeout = setTimeout(function() {
69        interval = setInterval(function() {
70          lessValFn(input);
71        }, 50);
72      }, 200);
73    });
74
75    $(moreVal + ', ' + lessVal).on("mouseup mouseout", function() {
76      clearTimeout(timeout);
77      clearInterval(interval);
78    });
79
80    function moreValFn(input) {
81      var max = input.attr('max');
82      checkInputAttr(input);
83      var newValue = value + step;
84      if (newValue > max) {
85        newValue = max;
86      }
87      changeInputsVal(input, newValue);
88    }
89
90    function lessValFn(input) {
91      var min = input.attr('min');
92      checkInputAttr(input);
93      var newValue = value - step;
94      if (newValue < min) {
95        newValue = min;
96      }
97      changeInputsVal(input, newValue);
98    }
99
100    function changeInputsVal(input, newValue) {
101      input.val(newValue);
102      var inputNumber = input.siblings(this);
103      inputNumber.val(newValue);
104    }
105
106    function checkInputAttr(input) {
107      if (input.attr('value')) {
108        value = parseFloat(input.attr('value'));
109      } else if (input.attr('placeholder')) {
110        value = parseFloat(input.attr('placeholder'));
111      }
112      if (!($.isNumeric(value))) {
113        value = 0;
114      }
115      if (input.attr('step')) {
116        step = parseFloat(input.attr('step'));
117      } else {
118        step = 1;
119      }
120    }
121
122    $(newInput).change(function() {
123      var input = $(this);
124      var value = parseFloat(input.val());
125      var min = input.attr('min');
126      var max = input.attr('max');
127      if (value < min) {
128        value = min;
129      } else if (value > max) {
130        value = max;
131      }
132      if (!($.isNumeric(value))) {
133        value = '';
134      }
135      input.val(value);
136      input.siblings(this).val(value);
137    });
138
139    $(newInput).keydown(function(e) {
140      var input = $(this);
141      var k = e.keyCode;
142      if (k == 38) {
143        moreValFn(input);
144      } else if (k == 40) {
145        lessValFn(input);
146      }
147    });
148  };
149})(jQuery);
150
151jQuery(function($) {
152  $('.quantity input[type=number]').iLightInputNumber();
153});
154
155
156window.ParsleyValidator.setLocale(unithemeparams.locale);
157
158// uni_popup_message
159var uni_popup_message = function(text, type) {
160  var message_div = jQuery('#uni_popup'),
161    $newsform = jQuery('.newsletterPageContent .uni_form'),
162    uni_top;
163
164  /*  if ($newsform.length > 0) {
165        uni_top = $newsform.offset().top - jQuery(window).scrollTop();
166        console.log($newsform.offset().top);
167        console.log(jQuery(window).scrollTop());
168        message_div.css({'top': uni_top + 'px'});
169    } */
170
171
172  message_text = message_div.text(text);
173
174  if (type == 'success') {
175    message_div.addClass('success-message');
176  }
177  if (type == 'warning') {
178    message_div.addClass('warning-message');
179  }
180  if (type == 'error') {
181    message_div.addClass('error-message');
182  }
183
184
185  if (text !== '') {
186
187    message_div.fadeIn(400).dequeue().animate({
188      left: (screen.width / 2)
189    }, 250, function() {
190      setTimeout(function() {
191        message_div.animate({
192          left: -125
193        }, 250).dequeue().fadeOut(400, function() {
194
195          setTimeout(function() {
196            message_div.removeClass('success-message warning-message error-message');
197          }, 1);
198        });
199      }, 3000);
200    });
201  }
202};
203
204jQuery(document).ready(function($) {
205  'use strict';
206
207  //// ---> Check issue element
208  jQuery.fn.exists = function() {
209    return jQuery(this).length;
210  };
211
212  $(".single-product .product-type-variable .singleProductDesc .singleProductBtn .digitalVersionWrap").each(function() {
213    var formContainer = $(this).closest(".singleProductBtn").find(".variations_button");
214    $(this).appendTo(formContainer);
215  });
216
217  $(".single-product .product-type-simple .singleProductDesc .singleProductBtn .digitalVersionWrap").each(function() {
218    var formContainer = $(this).closest(".singleProductBtn").find("form");
219    $(this).appendTo(formContainer);
220  });
221
222  $('.showMobileMenu').on("click", function(e) {
223    e.preventDefault();
224    $(this).toggleClass('open').closest("body").toggleClass('animated');
225  });
226
227  $(window).scroll(function() {
228    if ($(this).scrollTop() > 100) {
229      $('.scrollToTop').fadeIn(300);
230    } else {
231      $('.scrollToTop').fadeOut(300);
232    }
233  });
234
235  //Click event to scroll to top
236  $('.scrollToTop').click(function() {
237    $('html, body').animate({
238      scrollTop: 0
239    }, 700);
240    return false;
241  });
242
243  $(".thm-custom-dropdown span").on("click", function() {
244    if ($(this).hasClass("clicked")) {
245      $(this).removeClass("clicked").closest(".thm-custom-dropdown").find(".custom-dropdown-popup").slideUp(300);
246    } else {
247      $(".thm-custom-dropdown span.clicked").removeClass("clicked");
248      $(".custom-dropdown-popup").hide();
249      $(this).addClass("clicked").closest(".thm-custom-dropdown").find(".custom-dropdown-popup").slideDown(300);
250    }
251  });
252
253  $(".thm-custom-dropdown.logo-label span a").on("click", function(e) {
254    e.stopImmediatePropagation();
255  });
256
257  $(".qtranxs-lang-menu").on("click", function() {
258    if ($(this).hasClass("clicked")) {
259      $(this).removeClass("clicked").find(".sub-menu").slideUp(300);
260    } else {
261      $(this).addClass("clicked").find(".sub-menu").slideDown(300);
262    }
263  });
264
265
266
267  $(document).on('click', function(e) {
268    if (!$(e.target).parents().hasClass('thm-custom-dropdown')) {
269      $(".custom-dropdown-popup").hide();
270      $(".thm-custom-dropdown span").removeClass("clicked");
271    }
272  });
273
274
275  $('.thm-custom-dropdown').hover(function() {
276    $(this).addClass('orange-hover');
277  }, function() {
278    $(this).removeClass('orange-hover');
279  });
280
281  if ($('#homeTabs').exists()) {
282    $("#homeTabs").tabs();
283  }
284  if ($('#contactPageTabs').exists()) {
285    var activeTab = 0;
286
287    if (window.location.hash) {
288      var hash = window.location.hash,
289        tab = hash.charAt(0) + hash.charAt(1).toUpperCase() + hash.slice(2),
290        $tab = $(tab);
291      activeTab = $('.tabContent').index($tab);
292
293    }
294
295
296    $("#contactPageTabs").tabs({
297      active: activeTab
298    });
299
300
301
302  }
303
304  if ($('#artistPageTabs').exists()) {
305    $("#artistPageTabs").tabs();
306  }
307  
308  if ($('#albumsTabs').exists()) {
309     var albumActiveTab = 0,
310     $albumTab;
311     if (typeof unithemeparams.label_page_tabs !== 'undefined') {
312    $albumTab = $('li').has('a[href="' + unithemeparams.label_page_tabs + '"]');
313      albumActiveTab = $('#albumsTabs .tabs-title li').index($albumTab);
314  }
315  
316
317    $("#albumsTabs").tabs({
318      create: function(event, ui) {
319        init_ias(ui.tab);
320      },
321      activate: function(event, ui) {
322        $.ias().destroy();
323        $('.ias-trigger-next').remove();
324        init_ias(ui.newTab);
325      },
326      active: albumActiveTab
327    });
328
329  }
330  if ($('#singleProductDescTabs').exists()) {
331    $("#singleProductDescTabs").tabs();
332  }
333
334  if ($('.galleryWrap').exists()) {
335var gallery = $('.galleryWrap ul');
336
337    gallery
338    .lightGallery()
339    .bxSlider({
340      controls: false
341    });
342
343    hideTopPanel(gallery);
344
345  }
346
347  if ($('.singleProductGallery').exists()) {
348
349    var gallerySingle = $('.singleProductGallery');
350    gallerySingle.lightGallery();
351
352    hideTopPanel(gallerySingle);
353  }
354
355  function hideTopPanel($element) {
356    $element.on('onBeforeOpen.lg', function() {
357      $('.topPanel').hide();
358    })
359    .on('onBeforeClose.lg', function() {
360      $('.topPanel').show();
361    });
362
363  }
364
365
366
367  if ($(".shopItemsWrap .productDesc p").length > 0) {
368    $(".shopItemsWrap .productDesc p").dotdotdot({
369      wrap: 'letter'
370    });
371  }
372
373  if ($(".shopWrap ul.shopItemsWrap li h3 p").length > 0) {
374    $(".shopWrap ul.shopItemsWrap li h3 p").dotdotdot({
375      wrap: 'letter'
376    });
377  }
378  if ($(".shopWrap ul.shopItemsWrap li h3").length > 0) {
379    $(".shopWrap ul.shopItemsWrap li h3").dotdotdot({
380      wrap: 'letter'
381    });
382  }
383
384
385
386  $(".thmTabs > ul li a").on("click", function() {
387    if ($(".shopItemsWrap .productDesc p").length > 0) {
388      $(".shopItemsWrap .productDesc p").dotdotdot({
389        wrap: 'letter'
390      });
391    }
392  });
393
394  $(".userPurchaseItem h3").on("click", function() {
395    $(this).toggleClass("clicked").closest(".userPurchaseItem").find(".userPurchaseItemWrap").slideToggle(300);
396  });
397
398  $(".viewSwitcher span#blockView").on("click", function() {
399    if (!$(this).hasClass("active")) {
400      $(".viewSwitcher span.active").removeClass("active");
401      $(this).addClass("active").closest(".wrapper").find(".thmTabs").removeClass("inlineViewWrap").addClass("blockViewWrap");
402    }
403  });
404
405  $(".viewSwitcher span#inlineView").on("click", function() {
406    if (!$(this).hasClass("active")) {
407      $(".viewSwitcher span.active").removeClass("active");
408      $(this).addClass("active").closest(".wrapper").find(".thmTabs").removeClass("blockViewWrap").addClass("inlineViewWrap");
409    }
410  });
411
412  $(".digitalVersionWrap span").on("click", function() {
413    $(this).closest(".digitalVersionWrap").find(".downloadDigitalVersionPopup").slideToggle(300);
414  });
415
416
417  if ($('#filterSearchResult').val() == "all-search-results") {
418    $("#artist-search-results, #blogs-search-results, #album-search-results").hide();
419    $("#all-search-results").show();
420  } else if ($('#filterSearchResult').val() == "album-search-results") {
421    $("#artist-search-results, #blogs-search-results, #all-search-results").hide();
422    $("#album-search-results").show();
423  } else if ($('#filterSearchResult').val() == "artist-search-results") {
424    $("#album-search-results, #blogs-search-results, #all-search-results").hide();
425    $("#artist-search-results").show();
426  } else if ($('#filterSearchResult').val() == "blogs-search-results") {
427    $("#album-search-results, #artist-search-results, #all-search-results").hide();
428    $("#blogs-search-results").show();
429  }
430
431  $('#filterSearchResult').on('change', function() {
432    if ($(this).val() == "all-search-results") {
433      $("#artist-search-results, #blogs-search-results, #album-search-results").hide();
434      $("#all-search-results").show();
435    } else if ($(this).val() == "album-search-results") {
436      $("#artist-search-results, #blogs-search-results, #all-search-results").hide();
437      $("#album-search-results").show();
438    } else if ($(this).val() == "artist-search-results") {
439      $("#album-search-results, #blogs-search-results, #all-search-results").hide();
440      $("#artist-search-results").show();
441    } else if ($(this).val() == "blogs-search-results") {
442      $("#album-search-results, #artist-search-results, #all-search-results").hide();
443      $("#blogs-search-results").show();
444    }
445  });
446
447  $("body").on("click", ".uni_input_submit", function(e) {
448    var submit_button = $(this),
449      this_form = submit_button.closest("form");
450    this_form.submit();
451  });
452
453  $("body").on("click", ".uni_input_refresh", function(e) {
454    var refresh_button = $(this),
455      this_form = refresh_button.closest("form");
456    this_form.find('input').each(function() {
457      var $this = $(this);
458      if ($this.attr('type') !== 'button') {
459        $(this).val('');
460      }
461    });
462  });
463
464  $("body").on("submit", ".uni_form", function(e) {
465
466    var submit_button = $(this),
467      this_form = submit_button.closest("form"),
468      action = this_form.attr('action');
469    //console.log(submit_button);
470    var form_valid = this_form.parsley({
471      excluded: '[disabled]'
472    }).validate();
473
474    if (form_valid) {
475      var dataToSend = this_form.serialize();
476
477      $.ajax({
478        type: 'post',
479        url: action,
480        data: dataToSend + '&cheaters_always_disable_js=' + 'true_bro',
481        dataType: 'json',
482        beforeSend: function() {
483          this_form.block({
484            message: null,
485            overlayCSS: {
486              background: '#fff',
487              opacity: 0.6
488            }
489          });
490        },
491        success: function(response) {
492          if (response.status == "success") {
493            uni_popup_message(response.message, "success");
494            this_form.unblock();
495            if (response.recover === true) {
496              $(".uni-recover-pass-step-one").slideUp("fast", function() {
497                $(".uni-recover-pass-step-two").slideDown("slow");
498              });
499              //} else {
500              //uni_popup_message(response.message, "success");
501            }
502
503            if ((typeof response.redirect != 'undefined') && response.redirect.length > 0) {
504              setTimeout(function() {
505                window.location.replace(response.redirect);
506              }, 600);
507            }
508
509          } else if (response.status == "error") {
510            this_form.unblock();
511            uni_popup_message(response.message, "error");
512          }
513        },
514        error: function(response) {
515          this_form.unblock();
516          uni_popup_message("Error!", "warning");
517        },
518        complete: function(response) {
519          console.log(response.responseText);
520        }
521      });
522    }
523    return false;
524  });
525
526  // ajax reload mini cart
527  $("body").on("added_to_cart", function(e) {
528    var container = $(".accountLinks");
529
530    var sendData = {
531      action: 'uni_reload_minicart'
532    };
533    sendData.cheaters_always_disable_js = 'true_bro';
534
535    $.ajax({
536      type: 'post',
537      url: unithemeparams.ajax_url,
538      data: sendData,
539      dataType: 'json',
540      beforeSend: function(response) {
541        container.block({
542          message: null,
543          overlayCSS: {
544            background: '#fff url(' + unithemeparams.loader + ') no-repeat center',
545            backgroundSize: '36px 36px',
546            opacity: 0.6
547          }
548        });
549      },
550      success: function(response) {
551        //console.log(response);
552        if (response.status == "success") {
553          container.unblock();
554          container.empty().html(response.output);
555        } else if (response.status == "error") {
556          container.unblock();
557          uni_popup_message(response.message, "error");
558        }
559      },
560      error: function(response) {
561        container.unblock();
562        uni_popup_message("Error!", "warning");
563      }
564    });
565
566  });
567
568  //***** Social reg / auth ************
569
570  /* helper all ajax calls for social */
571  function uni_social_ajax_call(dataToSend, container) {
572    $.ajax({
573      type: 'post',
574      url: unithemeparams.ajax_url,
575      data: dataToSend,
576      dataType: 'json',
577      beforeSend: function(response) {
578        container.block({
579          message: null,
580          overlayCSS: {
581            background: '#fff url(' + unithemeparams.loader + ') no-repeat center',
582            backgroundSize: '36px 36px',
583            opacity: 0.6
584          }
585        });
586      },
587      success: function(response) {
588
589        console.log('mystatus1', response);
590
591        if (response.status == 'success') {
592          container.unblock();
593          //uni_popup_message(response.message, "success");
594
595          if (response.redirect.length > 0) {
596            setTimeout(function() {
597              window.location.replace(response.redirect);
598            }, 500);
599          }
600        } else if (response.status == 'error') {
601          container.unblock();
602          uni_popup_message(response.message, "error");
603        } else {
604          this_form.unblock();
605        }
606      },
607      error: function(response) {
608        container.unblock();
609        uni_popup_message("Error!", "warning");
610
611      }
612    });
613    return false;
614  }
615
616  // Facebook async code
617  window.fbAsyncInit = function() {
618    FB.init({
619      appId: '1012677512129523',
620      xfbml: true,
621      version: 'v2.5'
622    });
623  };
624
625  (function(d, s, id) {
626    var js, fjs = d.getElementsByTagName(s)[0];
627    if (d.getElementById(id)) {
628      return;
629    }
630    js = d.createElement(s);
631    js.id = id;
632    js.src = "//connect.facebook.net/en_US/sdk.js";
633    fjs.parentNode.insertBefore(js, fjs);
634  }(document, 'script', 'facebook-jssdk'));
635
636  // Auth with Facebook
637  $("body").on("click", ".ms_fb_login", function(e) {
638    e.preventDefault();
639    var container = $(this).closest("form");
640
641    FB.login(function(response) {
642      if (response.authResponse) {
643
644        FB.api('/me', {
645          fields: 'email'
646        }, function(response) {
647
648          var dataToSend = {
649            action: 'unitheme_social_signin',
650            uni_input_social_net: 'fb',
651            uni_input_email: response.email,
652            cheaters_always_disable_js: 'true_bro'
653          };
654
655          uni_social_ajax_call(dataToSend, container);
656
657        });
658      } else {
659        console.log('User cancelled login or did not fully authorize.');
660      }
661    }, {
662      scope: 'email'
663    });
664
665  });
666
667
668  $('.orderAlbum').on('change', function() {
669    $(this).closest('form').submit();
670  });
671
672  var $slider = $('.js-label-slider'),
673    $label = $('.js-label'),
674    left,
675    width = $label.outerWidth(),
676    tabsId;
677
678  if ($slider.length > 0) {
679    $slider.slick({
680      slidesToShow: 8,
681      arrows: false,
682      autoplay: true,
683      autoplaySpeed: 5000
684    });
685
686  }
687
688
689  function init_ias(tab) {
690    var ias = $.ias({
691      container: '#' + tab.attr('aria-controls') + " .shopItemsWrap",
692      item: ".product",
693      pagination: ".woocommerce-pagination",
694      next: ".next"
695    });
696
697    ias.extension(new IASTriggerExtension({
698      text: unithemeparams.lazy_load_more_text,
699      offset: 3
700    }));
701    ias.extension(new IASSpinnerExtension({
702      src: unithemeparams.lazy_loader
703    }));
704    ias.extension(new IASNoneLeftExtension({
705      text: ''
706    }));
707  }
708
709  $('.singleProductBtn').on('hover', '.uni-wishlist-link', function(){
710    //$('.wishlink-title').toggle(1000, 'linear');
711    $('.wishlink-title').animate({width: "toggle"});
712  });
713
714  $('.more').click(function(e){
715    $(this).parents('.teaser').next().slideDown();
716    $(this).parents('.teaser').slideUp();
717    return false;
718  });
719  $('.more-short').click(function(e){
720
721    $(this).parents('.teaser').next().css("display","inline");
722    $(this).remove();
723
724    return false;
725  });
726  
727  function windowPopup(url, width, height) {
728        // Calculate the position of the popup so
729        // it’s centered on the screen.
730        var left = (screen.width / 2) - (width / 2),
731            top = (screen.height / 2) - (height / 2);
732
733        window.open(
734            url,
735            "",
736            "menubar=no,toolbar=no,resizable=yes,scrollbars=yes,width=" + width + ",height=" + height + ",top=" + top + ",left=" + left
737        );
738    }
739    
740    $('.sharingButton').on('click', 'a', function(e) {
741                e.preventDefault();
742
743                windowPopup($(this).attr("href"), 500, 300);
744            });
745  $('.search-check_popup input').on('change',function(e){
746    console.log("Change values.");
747    console.log(e);
748    var $all = $('input#all');
749    var $artist= $('input#artist');
750    var $album = $('input#album');
751    var $song = $('input#song');
752    var $sku = $('input#sku');
753    function allChecked(){
754      return $all.is(":checked");
755    }
756    function typeChecked(){
757      return ($artist.is(":checked") || $album.is(":checked") || $song.is(":checked") || $sku.is(":checked"));
758    }
759    console.log(e.target);
760    if($(e.target).attr('id')==='all'){
761      //The target is all
762      if(allChecked()){
763        //if set to all uncheck everything else
764        $artist.prop('checked',false);
765        $album.prop('checked',false);
766        $song.prop('checked',false);
767        $sku.prop('checked',false);
768      }
769    }
770    else {
771      var targetId=$(e.target).attr('id');
772      //some other, uncheck "all", in case we SET it, not in any case
773      if($("input#"+targetId).is(":checked")){
774        console.log("Uncheck ALL!");
775        $all.prop('checked',false);
776      }
777    }
778
779  });
780
781});

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.