jQuery(document).ready(function($){ $("#jivo").on("click", function(e){ e.preventDefault(); jivo_api.open(); }); $(".node-service .body-more").on("click", function(e){ e.preventDefault(); var body = $(".node-service .right-side .field-name-body .field-item"); if(!body.hasClass("opened")) { body.addClass("opened"); body.css("height", "auto"); $(this).text("Скрыть"); $(".node-service .right-side .field-name-body .field-item").addClass("hidden-after"); } else { body.removeClass("opened"); body.css("height", "110px"); $(this).text("Показать полностью"); $(".node-service .right-side .field-name-body .field-item").removeClass("hidden-after"); } }); if ($.browser.msie && $.browser.version < 11) { $("#block-custom-towns .towns.world ul").columnize({ //columns: 2 width: 150 }); $("#block-custom-towns .towns.rus ul").columnize({ //columns: 6 width: 120 }); } /*$("#block-custom-towns .towns.world ul").columnize({ //columns: 2 width: 150 }); $("#block-custom-towns .towns.rus ul").columnize({ //columns: 6 width: 120 });*/ $(".view-sevice-faq .views-field-title a, .view-sevice-faq .hide-link").on("click", function(e){ e.preventDefault(); var parent = $(this).closest(".views-row"); if(!parent.hasClass("open")) { $(".view-sevice-faq .views-row.open .views-field-body").slideUp(300).closest(".open").removeClass("open"); parent.addClass("open"); parent.find(".views-field-body").slideDown(300); } else { parent.removeClass("open"); parent.find(".views-field-body").slideUp(300); } }); $("#block-custom-razdel .content > ul > li.expanded > a").on("click", function(e){ if(!$(this).parent().children("ul").find("a.active").length || $(this).closest("ul").find("> li > a.active").length) { if(!$(this).parent().hasClass("opened")) { e.preventDefault(); $("#block-custom-razdel .content > ul > li.expanded.opened ul").slideUp(200).parent().removeClass("opened"); $(this).next().slideDown(200); $(this).parent().addClass("opened"); } else { /*$(this).next().slideUp(200); $(this).parent().removeClass("opened");*/ } } }); $(".view-faq-a .views-row .accordion2 .field-content").append('
'); $(".view-faq-a .views-row .views-field-name a").on("click", function(e){ e.preventDefault(); var row = $(this).closest(".views-row"); if(!$(this).hasClass("opened")) { $(".view-faq-a .views-row .views-field-name a.opened").removeClass("opened").closest(".views-row").children(".accordion2").slideUp(300); $(this).addClass("opened"); row.children(".accordion2").slideDown(300); } else { $(this).removeClass("opened"); row.find(".accordion2 h3 a").removeClass("opened"); row.find(".accordion2 .field-content").slideUp(300); row.children(".accordion2").slideUp(300); } /*if(row.find(".accordion2 h3 a").is(":visible")) { row.find(".accordion2 h3 a").on("click", function(e){ e.preventDefault(); if(!$(this).hasClass("opened")){ $(this).addClass("opened"); $(this).parent().next().slideDown(300); } else { $(this).removeClass("opened"); $(this).parent().next().slideUp(300); } }); } $(".hide-link").on("click", function(){ $(this).parent().prev().find("a").removeClass("opened"); $(this).parent().slideUp(300); });*/ }); $(".view-faq-a .views-row .accordion2 h3 a").on("click", function(e){ e.preventDefault(); if(!$(this).hasClass("opened")){ $(".view-faq-a .views-row .accordion2 h3 a.opened").removeClass("opened").parent().next().slideUp(300); $(this).addClass("opened"); $(this).parent().next().slideDown(300); } else { $(this).removeClass("opened"); $(this).parent().next().slideUp(300); } }); $(".view-faq-a .hide-link").on("click", function(){ $(this).parent().prev().find("a").removeClass("opened"); $(this).parent().slideUp(300); }); $("#block-custom-razdel a.active").siblings("ul").css("display", "block"); $("#block-custom-razdel ul ul a.active").closest("ul").css("display", "block"); var allPhotosLink = $( ".view-photo-do-serv .view-header a" ).attr("href"); $( "#block-views-photo-do-serv-block-1 h3.block-title, #block-views-photo-do-serv-block-2 h3.block-title" ) .after( "Посмотреть все фотографии" ); var photosLength = $(".view-photo-do-serv .views-row").length; var totalWidth = (photosLength * 280) + ((photosLength-1) * 72); $(".view-photo-do-serv .view-content").css("width", totalWidth+"px"); if(photosLength > 3) { $(function() { //scrollpane parts var scrollPane = $( ".view-photo-do-serv" ), scrollContent = $( ".view-photo-do-serv .view-content" ); //build slider var scrollbar = $( ".scroll-bar" ).slider({ slide: function( event, ui ) { if ( scrollContent.width() > scrollPane.width() ) { scrollContent.css( "margin-left", Math.round( ui.value / 100 * ( scrollPane.width() - scrollContent.width() ) ) + "px" ); } else { scrollContent.css( "margin-left", 0 ); } } }); //append icon to handle var handleHelper = scrollbar.find( ".ui-slider-handle" ) .mousedown(function() { scrollbar.width( handleHelper.width() ); }) .mouseup(function() { scrollbar.width( "100%" ); }) .append( "" ) .wrap( "" ).parent(); //change overflow to hidden now that slider handles the scrolling scrollPane.css( "overflow", "hidden" ); //size scrollbar and handle proportionally to scroll distance function sizeScrollbar() { var remainder = scrollContent.width() - scrollPane.width(); var proportion = remainder / scrollContent.width(); var handleSize = scrollPane.width() - ( proportion * scrollPane.width() ); scrollbar.find( ".ui-slider-handle" ).css({ width: handleSize, "margin-left": -handleSize / 2 }); handleHelper.width( "" ).width( scrollbar.width() - handleSize ); } //reset slider value based on scroll content position function resetValue() { var remainder = scrollPane.width() - scrollContent.width(); var leftVal = scrollContent.css( "margin-left" ) === "auto" ? 0 : parseInt( scrollContent.css( "margin-left" ) ); var percentage = Math.round( leftVal / remainder * 100 ); scrollbar.slider( "value", percentage ); } //if the slider is 100% and window gets larger, reveal content function reflowContent() { var showing = scrollContent.width() + parseInt( scrollContent.css( "margin-left" ), 10 ); var gap = scrollPane.width() - showing; if ( gap > 0 ) { scrollContent.css( "margin-left", parseInt( scrollContent.css( "margin-left" ), 10 ) + gap ); } } //change handle position on window resize $( window ).resize(function() { resetValue(); sizeScrollbar(); reflowContent(); }); //init scrollbar size setTimeout( sizeScrollbar, 10 );//safari wants a timeout }); } else { $(".view-photo-do-serv .view-footer").hide(); $("#block-views-photo-do-serv-block-1 .view-photo-do-serv .views-row").css({ "min-height": "207px", "height": "auto" }); } $(".view-do-i-posle-nodes.view-display-id-attachment_1 .view-header a").on("click", function(e){ e.preventDefault(); var content = $(this).closest(".view-do-i-posle-nodes.view-display-id-attachment_1").find(".view-content"); var footer = $(this).closest(".view-do-i-posle-nodes.view-display-id-attachment_1").find(".view-footer"); if(!content.hasClass("opened")) { content.slideDown(300).addClass("opened"); footer.show(); $(this).text("Свернуть все фотографии"); } else { content.slideUp(300).removeClass("opened"); footer.hide(); $(this).text("Показать все фотографии"); } }); $(".view-do-i-posle-nodes.view-display-id-attachment_1 .view-footer a").on("click", function(e){ e.preventDefault(); $(this).closest(".view-do-i-posle-nodes.view-display-id-attachment_1").find(".view-content").slideUp(300).removeClass("opened"); $(this).closest(".view-footer").hide(); $(this).closest(".view-do-i-posle-nodes.view-display-id-attachment_1").find(".view-header a").text("Показать все фотографии"); }); $(".node-client .item .text a.more").on("click", function(e){ e.preventDefault(); var body = $(this).siblings(".body"); if(!body.hasClass("opened")) { body.addClass("opened"); body.css("max-height", "none"); $(this).text("Скрыть"); body.addClass("hidden-after"); } else { body.removeClass("opened"); body.css("max-height", "125px"); $(this).text("Показать полностью"); body.removeClass("hidden-after"); } }); /*$(".view-serv-comment.view-display-id-page_1 .body, #block-views-serv-comment-block-1 .body").each(function(){ var length = 0; var max = 540; var pos = -1; if($(this).find("p").text().length > max) { $(this).find("p").each(function(){ if(length < max && ((length+$(this).text().length - max) < 150)) { pos += 1; length += $(this).text().length; } else return false; }); $(this).find("p").eq(pos).addClass("last").after("Показать полностью"); $(this).find("p").eq(pos).nextAll("p").addClass("hide"); } });*/ var prevIndex; $(".view-serv-comment.view-display-id-page_1 .body a.more, #block-views-serv-comment-block-1 .body a.more").on("click", function(e){ e.preventDefault(); var body = $(this).closest(".body"); if(!body.hasClass("opened")) { prevIndex = body.find("a.more").prev().index(); body.find("p.last").removeClass("last"); body.find("p.hide").removeClass("hide"); body.addClass("opened"); body.find("p:last").addClass("last"); body.find("a.more").text("Скрыть").appendTo(body.last()); } else { body.find("a.more").text("Показать полностью").insertAfter(body.find("p").eq(prevIndex)); body.find("p.last").removeClass("last"); body.find("p").eq(prevIndex).addClass("last").nextAll("p").addClass("hide"); body.removeClass("opened"); } }); if(parseInt($(".node-client .item .text .body").css("height")) < parseInt($(".node-client .item .text .body").css("max-height"))){ $(".node-client .item .text .body").siblings("a.more").hide(); $(".node-client .item .text .body").addClass("short"); } });