PageSourceSearch

https://www.castellodioviglio.it/wp-content/themes/hotel-xenia/assets/js/theme.js?ver=5.7.20

js castellodioviglio.it collected 2026-10-08 03:42:45 UTC 21,958 bytes, 620 lines download raw bytes

1  
2/*!
3 ______ _____   _______ _______ _______ _______ ______ _______ 
4|   __ \     |_|    ___|_     _|   |   |       |   __ \   _   |
5|    __/       |    ___| |   | |       |   -   |      <       |
6|___|  |_______|_______| |___| |___|___|_______|___|__|___|___|
7
8P L E T H O R A T H E M E S . C O M               (c) 2013-2015
9                        
10Theme Name: HOTEL XENIA
11File Version: 1.0
12This file contains the necessary Javascript for the theme to function properly.
13
14*/
15
16//========================== PLETHORA HELPER FUNCTIONS ==============================================
17
18(function( window, doc, $ ){
19
20  "use strict";
21
22  /*** POLYFILLS ***/
23
24  // SHIM POLYFILL FOR: requestAnimationFrame
25  window.requestAnimationFrame = window.requestAnimationFrame || window.webkitRequestAnimationFrame ||
26                                 window.mozRequestAnimationFrame || window.oRequestAnimationFrame ||
27                                 window.msRequestAnimationFrame || function (cb){window.setTimeout(cb,1000/60);};
28
29  var _p = _p || {};
30
31  /*** OBJECT EXTEND: By @toddmotto ***/
32
33  _p.extend = function( target, source ) {
34      var merged = Object.create(target);
35      Object.keys(source).map(function (prop) {  prop in merged && (merged[prop] = source[prop]);  });
36      return merged;
37  };
38
39  /*** MULTI SLICE ***/
40
41  _p.slice = function(){
42    return [].slice.call.apply( [].slice, arguments );
43  }
44
45  /*** BOOLEAN OPERATOR CHECK ***/
46
47  _p.checkBool = function(val){
48      return ({1:1,true:1,on:1,yes:1}[(((typeof val !=="number")?val:(val>0))+"").toLowerCase()])?true:false;
49  };
50
51  /*** DEBUGGING CONSOLE ***/
52
53  _p.debugLog = function(){
54    themeConfig && themeConfig.debug && console.log.apply( console, arguments );
55  }
56
57  /*** DETECT INTERNET EXPLORER ***/
58
59  _p.isIE = function() {
60    var myNav = navigator.userAgent.toLowerCase();
61    return (myNav.indexOf('msie') != -1) ? parseInt(myNav.split('msie')[1]) : false;
62  }
63
64  /*** SVG CREATION UTILITY FUNCTION ***/
65
66  _p.SVGMold  = function( type, options ){
67  var molding = doc.createElementNS('http://www.w3.org/2000/svg', type );
68  for (var key in options) options.hasOwnProperty(key) && molding.setAttribute( key, options[key]);
69    return molding;
70  }
71
72  /*** PUBSUB ***/
73
74  _p.PubSub = {};
75
76  (function(q) {
77      var topics = {}, subUid = -1;
78      q.subscribe = function(topic, func) {
79          if (!topics[topic]) {
80              topics[topic] = [];
81          }
82          var token = (++subUid).toString();
83          topics[topic].push({
84              token: token,
85              func: func
86          });
87          return token;
88      };
89
90      q.publish = function(topic, args) {
91          if (!topics[topic]) {
92              return false;
93          }
94          setTimeout(function() {
95              var subscribers = topics[topic],
96                  len = subscribers ? subscribers.length : 0;
97
98              while (len--) {
99                  subscribers[len].func(topic, args);
100              }
101          }, 0);
102          return true;
103
104      };
105
106      q.unsubscribe = function(token) {
107          for (var m in topics) {
108              if (topics[m]) {
109                  for (var i = 0, j = topics[m].length; i < j; i++) {
110                      if (topics[m][i].token === token) {
111                          topics[m].splice(i, 1);
112                          return token;
113                      }
114                  }
115              }
116          }
117          return false;
118      };
119  }(_p.PubSub));
120
121  /*** SCROLL ON CLICK ***/
122
123   $(window).bind( 'hashchange', function(e) {
124    console.log(parseInt(window.location.hash.replace("#", ""))); 
125   });
126
127  $.extend( $.easing, { easeOutQuart: function (x, t, b, c, d) { return -c * ((t=t/d-1)*t*t*t - 1) + b; }, });
128
129  _p.scrollOnClick = function(e){
130
131    var HeaderHeight = $('.header').outerHeight();
132
133    _p.debugLog("Scrolled...");
134    e.preventDefault();                   // PREVENT DEFAULT ANCHOR CLICK BEHAVIOR
135    var hash        = this.hash;          // STORE HASH
136    var hashElement = $(this.hash);       // CACHE $.SELECTOR
137     if ( hashElement.length > 0 ){
138       $('html, body').animate({ scrollTop: Math.round(hashElement.offset().top) - HeaderHeight }, themeConfig["GENERAL"]["onePagerScrollSpeed"],'easeOutQuart', 
139        function(){  
140          /*** ADD HASH TO URL WHEN FINISHED [v1.3] | Thank you @LeaVerou! ***/
141          if ( history.pushState ) history.pushState( null, null, hash ); // Old Method: window.location.hash = hash 
142        });
143     }
144
145  }
146
147  return window._p = _p;
148
149}( window, document, jQuery ));
150
151//END---------------------------------------------------------------------- PLETHORA HELPER FUNCTIONS
152
153//========================== HEADER VARIATIONS ======================================================
154
155(function($){
156
157  "use strict";
158
159    // Declaring some vars
160    var header_height = $('.header').height();
161    var window_height = $(window).height();
162    var usable_height = window_height - header_height;
163    var scroll_offset_trigger = themeConfig["GENERAL"].scroll_offset_trigger;
164
165    // 1. Sticky Header always on Top. You have to add class "sticky_header" to the .header element
166    
167    if( $('.header.sticky_header:not(".transparent")').length ) { 
168
169      var $body = $('body');
170      $body.css( 'margin-top', header_height );
171      $(window).on( 'load resize', function(){
172        var header_height = $('.header').height();
173        $body.css( 'margin-top', header_height );
174      });
175
176    }
177
178    // 2. Sticky Header Bottom. You have to add class "bottom_sticky_header" to the .header element
179
180    // 3. Appearing from Top Sticky Header. You have to add class "appearing_sticky_header" to the .header element
181
182    if( $('.header.appearing_sticky_header').length ) {
183      
184      var $sticky_nav = $('.header.appearing_sticky_header');
185
186      $(window).scroll(function () {
187        if ($(this).scrollTop() > scroll_offset_trigger) {
188            $sticky_nav.addClass("stuck");
189        } else {
190            $sticky_nav.removeClass("stuck");
191        }
192      }); 
193    
194      var window_top = $(window).scrollTop();
195
196      if (window_top > scroll_offset_trigger) {
197          $sticky_nav.addClass("stuck");
198      } else {
199          $sticky_nav.removeClass("stuck");
200      } 
201
202    }    
203    
204    // 4. Starting on Bottom and sticking on top. You have to add class "bottom_to_top_sticky_header" to the header.header element
205
206    if( $('.header.bottom_to_top_sticky_header').length ) {
207    
208      var traveling_nav = $('.header.bottom_to_top_sticky_header');
209      
210      $(window).scroll(function () {
211          if ($(this).scrollTop() > usable_height) {
212              traveling_nav.addClass("stuck");
213          } else {
214              traveling_nav.removeClass("stuck");
215          }
216      }); 
217      
218      var window_top = $(window).scrollTop();
219      if (window_top > usable_height) {
220          traveling_nav.addClass("stuck");
221      } else {
222          traveling_nav.removeClass("stuck");
223      }
224
225    }
226
227    // Alternative Sticky Header
228
229    if( $('body.sticky_header_alt').length ) {
230
231      var alternative_sticky_header = $('body.sticky_header_alt .header');
232
233      //================================================================================
234
235      if( $('.header:not(.bottom_to_top_sticky_header)').length ) {
236
237        $(window).scroll(function () {
238          if ($(this).scrollTop() > scroll_offset_trigger) {
239              alternative_sticky_header.addClass("alt_header_triggered");
240          } else {
241              alternative_sticky_header.removeClass("alt_header_triggered");
242          }
243        });       
244        var window_top = $(window).scrollTop();
245        if (window_top > scroll_offset_trigger) {
246            alternative_sticky_header.addClass("alt_header_triggered");
247        } else {
248            alternative_sticky_header.removeClass("alt_header_triggered");
249        }
250
251      }
252
253      //================================================================================
254
255      if( $('.header.bottom_to_top_sticky_header').length ) {
256    
257        var traveling_nav = $('.header.bottom_to_top_sticky_header');
258        
259        $(window).scroll(function () {
260            if ($(this).scrollTop() > usable_height) {
261                traveling_nav.addClass("stuck alt_header_triggered");
262            } else {
263                traveling_nav.removeClass("stuck alt_header_triggered");
264            }
265        }); 
266        
267        var window_top = $(window).scrollTop();
268        if (window_top > usable_height) {
269            traveling_nav.addClass("stuck alt_header_triggered");
270        } else {
271            traveling_nav.removeClass("stuck alt_header_triggered");
272        }
273
274      }
275
276      //================================================================================
277
278    }
279
280
281}(jQuery));
282
283//END----------------------------------------------------------------------------- HEADER VARIATIONS 
284
285//========================== PRIMARY MENU CONSTRUCTOR ===============================================
286
287(function($){
288
289  "use strict";
290
291    // Set the collapsing width for the header menu and the tools on the header
292    var menu_collapsing_width = themeConfig["GENERAL"].menu_switch_to_mobile;
293    var tools_collapsing_width = themeConfig["GENERAL"].minitools_switch_to_mobile;
294
295    // If there are dropdowns on the primary nav, go on
296    if ($('.header nav.primary_nav ul > li > ul').length) {
297
298        // Add the appropriate classes to the primary nav
299        $('.header nav.primary_nav ul > li > ul').addClass('menu-dropdown-content');        
300        var lihaschildren = $('.header nav.primary_nav ul > li > ul').parent();
301        lihaschildren.addClass('lihaschildren menu-dropdown');
302        var atoggledropdown = $('.lihaschildren > a');
303        atoggledropdown.addClass('menu-dropdown-toggle');
304        
305        // Click Menu Functionality (.click_menu class on .header)
306        $('.click_menu a.menu-dropdown-toggle').on("click" , function(e) {
307            $(this).parent('li').siblings('li').children('ul.open').removeClass('open');
308            $(this).parent('li').siblings('li').children('ul').children('li').children('ul.open').removeClass('open');
309            $(this).siblings('ul').children('li').children('ul.open').removeClass('open');
310            $(this).siblings().toggleClass('open');
311            e.stopPropagation();
312        });
313
314        // When we have a Click Menu and an item has both children and a link, then onClick don't serve the link, show the children. Basic UX Stuff.
315        $('.click_menu a.menu-dropdown-toggle').attr( 'onclick' , 'return false');
316
317        // Close Dropdown when clicking elsewhere
318        $(document.body).on('click', function(){
319            $('.menu-dropdown-content').removeClass('open');
320        });
321
322    };
323
324    // Centered in Menu Inline Logo Feature (.header_centered and .logo_centered_in_menu on .header)
325    if ( $('.header.logo_centered_in_menu').length ) {
326
327      // Count the number of top level menu elements
328      var count_of_lis = $('.primary_nav ul.nav > li').length;
329
330      if (count_of_lis % 2 === 0 ) {
331        // If count is even, target the middle li
332        var center_of_lis = count_of_lis / 2;
333        var li = $('.primary_nav ul.nav > li:nth-child(' + center_of_lis + ')')
334      } else {
335        // else if count is odd, add a fake li to make them even and target the middle li
336        $('.primary_nav ul.nav').prepend('<li class="fake"></li>');
337        var center_of_lis = count_of_lis / 2 + 0.5;
338        var li = $('.primary_nav ul.nav > li:nth-child(' + center_of_lis + ')')
339      }
340
341      var logo_div = $(".logo");
342      var maxWidth = 0;
343      var elemWidth = 0;
344      
345      // Make all 1st-level elements of the menu, equal width
346      /*$('.primary_nav ul.nav > li').each(function() {
347          elemWidth = parseInt($(this).css('width'));
348          if (parseInt($(this).css('width')) > maxWidth) {
349              maxWidth = elemWidth;
350          }
351      });
352      $('.primary_nav ul.nav > li').each(function() {
353          $(this).css('width', maxWidth + "px");
354      });*/
355
356      // Insert the logo in the middle of the menu
357      logo_div.insertAfter(li).wrap('<li class="logo_in_nav"></li>');
358
359    };
360
361    // Collapser from the mainbar of the header to the secondary widgetized area and vice versa
362    $(window).on("load resize" , function() { 
363
364        //var window_width = $(window).width(); // This includes the scrollbars
365        function viewport() {
366            var e = window, a = 'inner';
367            if (!('innerWidth' in window )) {
368                a = 'client';
369                e = document.documentElement || document.body;
370            }
371            return { width : e[ a+'Width' ] , height : e[ a+'Height' ] };
372        }
373        var window_width = viewport().width; // This should match your media query
374        var mainbar_container = $(".header .mainbar").children('[class^=container]');
375        var primary_nav = $(".header nav.primary_nav");
376        var primary_in_secondary_nav = $(".secondary_nav_widgetized_area nav.primary_nav");
377        var header_container = $(".header .mainbar").children('[class^=container]');
378        var nav_wrapper = $(".header .mainbar").children('[class^=container]').children(".main_nav_wrapper");
379        var header_container_width = header_container.width();
380        var rest_width = (window_width - header_container_width) * 0.5;
381        var toggler_and_tools_div = $('div.toggler_and_tools');
382        var tools_div = $('div.header_tools');
383        var tools_div_in_secondary_nav = $(".secondary_nav_widgetized_area div.header_tools");
384        //var logo_div = $(".logo");
385        var logo_in_nav = $("li.logo_in_nav .logo");
386        var header_not_centered = $('.header').not('.header_centered').not('.nav_centered').not('.nav_left').not('.logo_centered_in_menu');
387        var header_centered_with_logo = $('.header.logo_centered_in_menu');
388
389        // On mobile states move the primary menu in the secondary widgetized area and vice versa. Also handle the centered-logo-in-menu functionality.
390        if (window_width <= menu_collapsing_width) {
391          if (header_centered_with_logo.length) {
392            logo_in_nav.unwrap().prependTo(mainbar_container);
393          }  
394          primary_nav.prependTo(".secondary_nav_widgetized_area");
395        } else {
396            if ( primary_in_secondary_nav.length ) {
397              primary_in_secondary_nav.prependTo(nav_wrapper);
398              if (header_centered_with_logo.length) {  
399                logo_div.insertAfter(li).wrap('<li class="logo_in_nav"></li>');
400              }  
401            }
402        };
403
404        // On mobile states move the tools in the secondary widgetized area and vice versa
405        if (window_width <= tools_collapsing_width) {
406            tools_div.prependTo(".secondary_nav_widgetized_area");
407        } else {
408            if ( tools_div_in_secondary_nav.length ) {
409                tools_div_in_secondary_nav.prependTo(toggler_and_tools_div);
410            }
411        };
412
413        // The toggler of the secondary & mobile menu along with the tools rests always on the right and pushes the rest of the header elements accordingly when it comes close to them on resize
414        var toggler_and_tools_width = $(".toggler_and_tools").outerWidth();
415        var min_position_width = rest_width - toggler_and_tools_width;
416        // If tools exist on header make them target of the pushing, else push the primary navigation.
417        //if ( tools_div.length ) {
418        //    var padding_target = tools_div;
419        //} else {
420        var padding_target = primary_nav;
421        //}
422        // Apply this functionality only when the header is not centered
423        if ( header_not_centered.length ) {
424          if (min_position_width <= 15) {
425              padding_target.css("padding-right", -min_position_width + 15);
426          };
427        };
428
429    });
430
431    // Open and close the secondary widgetized area that holds the mobile nav menu
432    $(window).on("load" , function() {
433
434      var header_height = $('.header').height();
435
436      $("a.menu-toggler").on("click",function() {  
437          $(this).toggleClass( "active" );
438          $(".secondary_nav_widgetized_area").toggleClass( "secondary_nav_is_open" );
439          $(".main").toggleClass( "secondary_nav_is_open" );
440          $(".header").toggleClass( "secondary_nav_is_open" );
441          //$(".head_panel").toggleClass( "secondary_nav_is_open" );
442          $("footer").toggleClass( "secondary_nav_is_open" );
443          $(".copyright").toggleClass( "secondary_nav_is_open" );
444          if ( $(this).hasClass("active") ) {
445            $(".secondary_nav_widgetized_area").css('padding-top' , header_height);
446          } else {
447            
448            $(".secondary_nav_widgetized_area").css('padding-top' , '0');
449          }
450          
451      });
452
453      // When clicking on a nav link of the secondary widgetized area, close the area
454      $(".secondary_nav_widgetized_area nav a").on("click",function() {  
455          $("a.menu-toggler").toggleClass( "active" );
456          $(".secondary_nav_widgetized_area").toggleClass( "secondary_nav_is_open" );
457          $(".main").toggleClass( "secondary_nav_is_open" );
458          $(".header").toggleClass( "secondary_nav_is_open" );
459          //$(".head_panel").toggleClass( "secondary_nav_is_open" );
460          $("footer").toggleClass( "secondary_nav_is_open" );
461          $(".copyright").toggleClass( "secondary_nav_is_open" );
462          $(".secondary_nav_widgetized_area").css('padding-top' , '0');
463      });
464
465    }); 
466
467    // Now that everything is set, make the primary nav visible
468    $(document).ready(function() {
469      $('.header nav.primary_nav').css('visibility' , 'visible');
470    });  
471    // $(window).on("resize" , function() {
472    //   $('.header nav.primary_nav').css('visibility' , 'visible');
473    // });        
474
475}(jQuery));
476
477//END----------------------------------------------------------------------- PRIMARY MENU CONSTRUCTOR   
478
479//========================== FADE OUT HEADER OnSCROLL EFFECT ========================================
480
481(function($){
482
483  "use strict";
484
485  if ( $('.head_panel.fade_on_scroll').length ) {
486
487    $(window).on('scroll', function() {
488      var element = $('.head_panel');
489      var ft = $(this).scrollTop();
490      element.css({ 'opacity' : (1 - ft/400) });
491    });
492
493  }  
494
495}(jQuery));
496
497//END------------------------------------------------------------- FADE OUT HEADER OnSCROLL EFFECT
498
499//========================== LOADER ==============================================================
500
501(function($) {
502
503  "use strict";
504
505  $(window).load(function(){
506    setTimeout(function(){
507      $('.loading').addClass("hidden");
508      $('.loader-logo').addClass("slideOutUp");
509      $('.loader').addClass("slideOutUp");
510      $('body').addClass("body-animated");
511    }, 10);
512  });
513  
514}(jQuery));
515
516//END-------------------------------------------------------------------------------------- LOADER
517
518//========================= SCROLL ON CLICK OF A HASH-LINK init ==================================
519
520(function($){
521
522  $(".header, .head_panel, .main")
523      .find('a[href^="#"], button[href^="#"]')
524      .add("a.scrollify")
525      .on('click', _p.scrollOnClick );
526
527})(jQuery);
528
529//END--------------------------------------------------------- SCROLL ON CLICK OF A HASH-LINK init
530
531//========================= PARALLAX for Head Panel ==============================================
532
533(function($){
534
535  $('.parallax-window').each(function(){
536
537    var bg_image = $(this).css("background-image").replace('url(','').replace(')','').replace(/\"/g, '').replace(/\'/g, '');
538    $(this).addClass("transparent").css("background-image","none").attr("data-parallax", "scroll").attr("data-image-src", bg_image).attr("data-position", "center top");
539
540  }); 
541
542}(jQuery));
543
544//END--------------------------------------------------------------------- PARALLAX for Head Panel
545
546//========================= WOW (REVEAL ON SCROLL INIT FOR NO-TOUCH DEVICES) =====================
547
548(function($){
549
550  if ($('.no-touch').length) {
551    var wow = new WOW({
552      animateClass : 'animated',
553      offset       :       100
554    });
555    wow.init();
556  }
557
558})(jQuery);
559
560//END-------------------------------------------- WOW (REVEAL ON SCROLL INIT FOR NO-TOUCH DEVICES)
561
562//=================== SECTION SEPARATORS =========================================================
563
564  (function($){
565
566    var $separator_top    = $(".separator_top");
567    var $separator_bottom = $(".separator_bottom");
568
569    if ($separator_top.length) {
570      $separator_top.each(function(){
571        $(this).prepend( "<div class='separator_top'><div>" );
572      }); 
573    }
574    if ($separator_bottom.length) {
575      $separator_bottom.each(function(){
576        $(this).append( "<div class='separator_bottom'><div>" );
577      }); 
578    }
579
580  }(jQuery));
581
582//END------------------------------------------------------------------------------SECTION SEPERATORS 
583
584//========================== SELECT TAG ARROW STYLING ===============================================
585
586(function($){
587
588  "use strict";
589
590  $('select:not([multiple=multiple])').wrap( "<div class='select_wrapper'></div>" );
591
592}(jQuery));
593
594//END----------------------------------------------------------------------- SELECT TAG ARROW STYLING
595
596//========================== FORM INPUT=NUMBER STYLING ==============================================
597
598(function($){
599
600  "use strict";
601
602  $('input[type="number"]').not('.cart_item input[type="number"]').before(function() {
603      return $('<span />', {
604          'class': 'spinner',
605          text: '-'
606      }).on('click', {input : this}, function(e) {
607          e.data.input.value = (+e.data.input.value) - 1;
608      });
609  }).after(function() {
610      return $('<span />', {
611          'class': 'spinner',
612          text: '+'
613      }).on('click', {input : this}, function(e) {
614          e.data.input.value = (+e.data.input.value) + 1;
615      });
616  });
617
618}(jQuery));
619
620//END---------------------------------------------------------------------- FORM INPUT=NUMBER STYLING

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.