File: /home/zwafgyp/dodolodge-net/wp-content/themes/hotel-wp-child/js/main.js
jQuery(document).ready(function($) {
//Keep only the first Two leters
jQuery('span.wpml-ls-native.icl_lang_sel_native').each(function() {
let $this = jQuery(this);
let str = $this.text();
const myArr = str.substr(0, 2)
$this.text(myArr);
});
if(jQuery(".wppcr_rating").length > 0){
var modal_content=jQuery(".wppcr_rating").detach();
modal_content.insertAfter("#commentform .comment-form-comment");
}
if(jQuery(".gglcptch_v2 ").length > 0 && jQuery(".wppcr_rating").length > 0){
var gglcptch_recaptcha=jQuery(".gglcptch_v2 ").detach();
gglcptch_recaptcha.insertBefore("#commentform .form-submit");
}
if(jQuery("#comments_carousel_shortcode").length > 0){
$('.comments_carousel').slick({
infinite: false,
slidesToShow: 1,
slidesToScroll: 1,
dots:true,
});
}
if(jQuery("#selectByOrderby").length > 0){
$(".description_comment").each( function(){
var rating = $(this).find('.wpcr_author_stars').attr('data-rating');
$(this).attr('data-rating-star',rating);
});
var divList = $(".comment-list li");
divList.sort(function(a, b){
return $(b).data("comment-date")-$(a).data("comment-date");
});
$(".comment-list").html(divList);
}
if(jQuery("#selectByOrderby").length > 0){
$('#selectByOrderby').on('change', function() {
if(this.value == "date_desc" ){
//jQuery('ul.comment-list').removeClass('comment_desc')
var divList = $(".comment-list li");
divList.sort(function(a, b){
return $(b).data("comment-date")-$(a).data("comment-date");
});
$(".comment-list").html(divList);
}else if(this.value == "rating" ){
//jQuery('ul.comment-list').removeClass('comment_desc')
var divList = $(".comment-list li");
divList.sort(function(a, b){
return $(b).data("rating-star")-$(a).data("rating-star")
});
$(".comment-list").html(divList);
}else{
//jQuery('ul.comment-list').addClass('comment_desc')
var divList = $(".comment-list li");
divList.sort(function(a, b){
return $(a).data("comment-date")-$(b).data("comment-date");
});
$(".comment-list").html(divList);
}
});
}
//Equal Height Sections
setTimeout(function() {
jQuery('.equal_sections').each(function() {
var maxHeight = 0;
$this = jQuery(this);
$this.each(function() {
if ($this.outerHeight() > maxHeight) {
maxHeight = $this.outerHeight();
}
});
$this.css('min-height', maxHeight);
});
}, 700);
});
jQuery(window).load(function() {
portfoliosLimit=20;
/*ShowMore ShowLess*/
if (jQuery("#gallerie-souvenirs").length) {
var portfoliosCount = jQuery('#gallerie-souvenirs .modula-item').length;
//var protfilioShowed = portfoliosCount >= portfoliosLimit ? portfoliosLimit : jQuery('#gallerie-souvenirs .modula-item').length;
//var multiPagesPortfolios = portfoliosCount > portfoliosLimit;
var portfoliosPagesCount = parseInt(portfoliosCount / portfoliosLimit);
if (portfoliosCount % portfoliosLimit > 0) {
portfoliosPagesCount += 1;
}
var portfolioCurrentPage = 1;
if (portfoliosPagesCount == 1) {
jQuery('a.load-more-btn').hide();
} else if (portfoliosPagesCount > 1) {
jQuery('a.load-more-btn').show();
} else {
jQuery('a.load-more-btn').hide();
}
setTimeout(function() {
jQuery('#gallerie-souvenirs .modula-item').each(function(key, value) {
if (key >= portfoliosLimit) {
jQuery(this).hide();
}
else {
jQuery(this).show();
}
});}, 700);
jQuery('a.load-more-btn').click(function(ev) {
ev.stopPropagation();
ev.preventDefault();
portfolioCurrentPage += 1;
console.log(portfolioCurrentPage);
//var tempItem = null;
jQuery('#gallerie-souvenirs .modula-item').each(function(key, value) {
if (key <= (((portfolioCurrentPage) * portfoliosLimit) - 1)) {
jQuery(this).show();
}
if (key == ((portfolioCurrentPage - 1) * portfoliosLimit)) {
//tempItem = jQuery(this);
jQuery("html, body").animate({ scrollTop: jQuery('a.load-more-btn').offset().top - 100 }, 500);
}
});
if (portfolioCurrentPage == 1) {
if (portfolioCurrentPage != portfoliosPagesCount) {
jQuery('a.load-more-btn').show();
} else {
jQuery('#gallerie-souvenirs a.load-more-btn').hide();
}
} else if (portfolioCurrentPage == portfoliosPagesCount) {
jQuery('a.load-more-btn').hide();
} else {
jQuery('a.load-more-btn').show();
}
});
}
/*ShowMore ShowLess*/
});
jQuery(window).resize(function() {
setTimeout(function() {
//Equal Height Sections
jQuery('.equal_sections').each(function() {
var maxHeight = 0;
$this = jQuery(this);
$this.each(function() {
if ($this.outerHeight() > maxHeight) {
maxHeight = $this.outerHeight();
}
});
$this.css('min-height', maxHeight);
});
}, 700);
});
jQuery(document).ready(function() {
// grab the initial top offset of the navigation
var stickyNavTop = jQuery('#masthead').offset().top;
// our function that decides weather the navigation bar should have "fixed" css position or not.
var stickyNav = function(){
var scrollTop = jQuery(window).scrollTop(); // our current vertical position from the top
// if we've scrolled more than the navigation, change its position to fixed to stick to top,
// otherwise change it back to relative
if (scrollTop > stickyNavTop) {
jQuery('#masthead').addClass('sticky');
} else {
jQuery('#masthead').removeClass('sticky');
}
};
stickyNav();
// and run it again every time you scroll
jQuery(window).scroll(function() {
stickyNav();
});
jQuery( ".wpcr_author_stars" ).each(function() {
// Get the value
var val = jQuery(this).data("rating");
// Make sure that the value is in 0 - 5 range, multiply to get width
var size = Math.max(0, (Math.min(5, val))) * 30;
// Create stars holder
var $span = jQuery('<span />').width(size);
// Replace the numerical value with stars
jQuery(this).html($span);
});
jQuery( ".wpcr_averageStars" ).each(function() {
// Get the value
var val1 = jQuery(this).data("wpcravg");
//alert(val1);
// Make sure that the value is in 0 - 5 range, multiply to get width
var size1 = Math.max(0, (Math.min(5, val1))) * 30;
// Create stars holder
var $span1 = jQuery('<span />').width(size1);
// Replace the numerical value with stars
jQuery(this).html($span1);
});
});