jQuery(function($){
var pageLoaded = false;
$(document).ready(function() {
var $win = $(window),
$body = $('body');
app = function() {
/* jQuery throttle / debounce - v1.1 - 3/7/2010 */
(function(b,c){var $=b.jQuery||b.Cowboy||(b.Cowboy={}),a;$.throttle=a=function(e,f,j,i){var h,d=0;if(typeof f!=="boolean"){i=j;j=f;f=c}function g(){var o=this,m=+new Date()-d,n=arguments;function l(){d=+new Date();j.apply(o,n)}function k(){h=c}if(i&&!h){l()}h&&clearTimeout(h);if(i===c&&m>e){l()}else{if(f!==true){h=setTimeout(i?k:l,i===c?e-m:e)}}}if($.guid){g.guid=j.guid=j.guid||$.guid++}return g};$.debounce=function(d,e,f){return f===c?a(d,e,false):a(d,f,e!==false)}})(this);
// AM I TOUCH?
function is_touch_enabled() {
return ( 'ontouchstart' in window ) ||
( navigator.maxTouchPoints > 0 ) ||
( navigator.msMaxTouchPoints > 0 );
}
if ( is_touch_enabled() ) {
$body.addClass("touch");
} else {
$body.addClass("dt");
}
// ADMIN MENU
$('.admin-btn').click(function() {
$body.toggleClass("a-menu");
});
// SLICK SLIDER STUFF
if ($('.slick-slider').length) {
setTimeout(function() {
$('.slick-slider').slick('setPosition');
}, 150);
$('.slick__slider').append("

");
$('.fs-btn').click(function() {
$body.toggleClass("fs-slick");
});
}
// HTML, CONTENT, FIELD, & BUTTON EDITS
if ($('#edit-start-date-datepicker-popup-0').length) $('#edit-start-date-datepicker-popup-0').attr('placeholder', 'Start Date');
$('#roomify-spaces-singleday-book-form .btn.form-submit').text('Booking & Equipment');
$('#bat-type-edit-form .form-item-name label').text('Kitchen Name');
$('body.page-admin-bat-config-property-manage-types .add-type-button').text('Add Kitchen');
if ( $('body.page-admin-bat-config-types-manage').length ) {
$('body.page-admin-bat-config-types-manage #edit-submit').html(" Save Kitchen");
$('body.page-admin-bat-config-types-manage #edit-suspend').text('Suspend Kitchen');
$('body.page-admin-bat-config-types-manage #edit-delete').html(" Delete Kitchen");
}
if ( $('#edit-actions').length ) {
$('#edit-actions > a').each(function() {
if ( $(this).text() == 'Cancel' ) $(this).addClass('btn cancel-btn');
});
}
$('.table').each(function() {
$(this).parent().addClass("table-responsive");
});
$("table.sticky-header").wrap("");
// TABS
if ( $('#main-content > .nav-tabs').length ) {
var tAb = $('#main-content > .nav-tabs > li > a');
tAb.each(function() {
var tAbLink = $(this).text().replace(/\s+/g, '-').replace("(active-tab)", "").toLowerCase();
$(this).parent().addClass("tab-" + tAbLink);
});
}
if ( $('.tabbable').length ) {
var redtab = $('.tabbable > .nav > li > a > span');
redtab.each(function() {
var redtablink = $(this).text().replace(/\s+/g, '-').toLowerCase();
$(this).parent().parent().addClass("redtab" + redtablink);
});
}
// NAVIGATION
$(".navbar-toggle").click(function(e) {
e.preventDefault();
if ($body.hasClass("show-menu")) {
setTimeout(function() {
$('#main-menu').animate({ scrollTop: "0" }, 100);
}, 1000);
}
$body.toggleClass("show-menu");
});
/*
scrollStuff = function() {
var $T = $(window).scrollTop();
if ($T > 150) {
if (!$body.hasClass('scrolled')) $body.addClass('scrolled');
} else {
if ($body.hasClass('scrolled')) $body.removeClass('scrolled');
}
}
if ( $body.hasClass('front') ) $(window).scroll( $.throttle( 250, scrollStuff ) );
*/
/*
var $fh = $('#fancy-header');
if ( $fh.length ) {
var first = true,
running = true;
toggleFH = function() {
setTimeout(function() {
if (first) {
$body.addClass('gfx1').removeClass('gfx2');
first = false;
} else {
$body.addClass('gfx2');
first = true;
}
if (running) toggleFH();
}, 6000);
}
setTimeout(function() {
running = false;
}, 50000);
toggleFH();
}
*/
// BIG TABLES ON SMALL DEVICES GET TO SCROLL
$('.table-responsive').each(function() {
var $stickyhdr = $(this).find('table.sticky-header');
$(this).scroll(function() {
var sL = $(this).scrollLeft();
$stickyhdr.css('left', (-sL + 42) + "px");
});
});
// REGISTRATION FORM CUSTOMIZING
var $regform = $('form#user-register-form');
if ( $regform.length ) {
// default check user/guest
$('#edit-select-roles-234248529').prop("checked", true);
// require guest or host to be checked
var $rolecheckboxes = $('form#user-register-form input[type="checkbox"].form-checkbox');
$rolecheckboxes.click(function() {
$rolecheckboxes.prop("checked", false);
$(this).prop("checked", true);
});
// change language
$regform.find('.form-type-checkboxes > label').html("Account Type
");
}
if ( $('.panel-content-wrapper').length ) {
$('.bootstrap-one-column').addClass('container-fluid').find('.panel-content-wrapper').addClass('row');
}
if ( $('.bootstrap-property-page').length ) {
$('.section-container').addClass('container-fluid').find('.section-row').addClass('row');
}
// STICKY MAP EVENTS
if ( $body.hasClass('front') ) {
var $win = $(window),
$earch = $('#search-frame'),
$iFrameWindow = $earch.get(0).contentWindow,
$$ = $iFrameWindow.jQuery,
$map = $$('#search-map'),
isScrolling;
$win.scroll( function ( event ) {
var $T = $win.scrollTop(),
searchTop = Math.round($earch.offset().top);
if ( ($T - 70) >= searchTop) {
if (!$map.hasClass('pinned')) $map.addClass('pinned');
if ($map.hasClass('unpin')) $map.removeClass('unpin');
if (!$map.hasClass('hidemap')) $map.addClass('hidemap');
$map.css('top', $T - searchTop);
} else {
if ($map.hasClass('pinned')) $map.removeClass('pinned');
if (!$map.hasClass('unpin')) $map.addClass('unpin');
}
window.clearTimeout( isScrolling );
isScrolling = setTimeout(function() {
if ($map.hasClass('hidemap')) $map.removeClass('hidemap');
}, 66);
});
$win.resize(function() {
$win.scroll();
});
}
// MAP SCROLL TO RESULT ON PIN CLICK
if ( $('#search-map').length ) {
var mkrs = $('.leaflet-marker-icon');
setTimeout(function() {
scrollToTeaser = function( selectedTop ) {
searchTop = Math.round( window.parent.jQuery('#search-frame').offset().top );
var offsetSelectedTop = (selectedTop + searchTop) + 55;
if ( is_touch_enabled ) var offsetSelectedTop = offsetSelectedTop - 275;
window.parent.jQuery("html, body").animate({ scrollTop: offsetSelectedTop + "px" }, 600);
}
mkrs.each(function() {
$(this).click(function() {
$body.addClass('autoscroll');
var tsrs = $('.kitchen-teaser'),
loc = $(this).attr("title"),
locations = {};
tsrs.each(function(index) {
var _loc = $(this).find('.location-name').text();
if ( _loc == loc ) {
if ( typeof locations[ _loc ] !== 'undefined' ) return;
var updex = index + 1;
var selectedTop = $('.kitchen-teaser:nth-child('+updex+')').position().top;
scrollToTeaser(selectedTop);
locations[ _loc ] = 1;
}
});
setTimeout(() => $body.removeClass('autoscroll'), 650);
});
});
}, 300);
}
// Remove anchor that comes from tabs.
$('.roomify-agency-dashboard .tabs-processed .ui-tabs-anchor').click(function(e) {
return false;
});
// Same height for some elements.
maxHeight = -1;
$('.view-space-types-index .views-field-space-opening-time').each(function() {
maxHeight = maxHeight > $(this).height() ? maxHeight : $(this).height();
});
$('.view-space-types-index .views-field-space-opening-time').each(function() {
$(this).height(maxHeight);
});
// SITE IS READY
if ( $('body').hasClass('front') ) $("html, body").animate({ scrollTop: "0" });
setTimeout(function() {
$body.addClass("ready");
}, 200);
}
preloader = function() {
setTimeout(function() {
if (!pageLoaded) {
preloader();
} else {
setTimeout(() => { app() }, 100);
}
}, 100);
}
preloader();
});
$(window).on('load', function() {
pageLoaded = true;
});
});