jQuery.support.placeholder = (function(){ var i = document.createElement('input'); return 'placeholder' in i; })(); (function ($) { Drupal.behaviors.dab_theme = { attach: function (context, settings) { if(typeof drupalSettings.dab_faq_send_event !== "undefined"){ if(drupalSettings.dab_faq_send_event.all_categories){ ga("send", "event", "Faq", "products", "All"); } } function removeLabel(){ if($.support.placeholder){ var forms = ['.user-register-form']; $.each(forms, function (index, val) { $(val + ' input[type=text],' + val + ' input[type=tel], ' + val + ' input[type=password], ' + val + ' select, ' + val + ' input[type=email], ' + val + ' textarea').each(function (index, elem) { var eId = $(elem).attr("id"); var label = null; if (eId == "edit-field-address-0-organization") { elem.required = true; } var requireSymbol = elem.required ? " *" : ""; if (eId && (label = $(elem).parents("form").find("label[for=" + eId + "]")).length == 1) { $(elem).attr("placeholder", $(label).text().replace(/\s\s/g, '') + requireSymbol); $(label).hide(); } }); }); } else { $('[placeholder]').focus(function () { var input = $(this); if (input.val() == input.attr('placeholder')) { input.val(''); input.removeClass('placeholder'); } }).blur(function () { var input = $(this); if (input.val() == '' || input.val() == input.attr('placeholder')) { input.addClass('placeholder'); input.val(input.attr('placeholder')); } }).blur(); $('[placeholder]').parents('form').submit(function () { $(this).find('[placeholder]').each(function () { var input = $(this); if (input.val() == input.attr('placeholder')) { input.val(''); } }) }); } }; function removeLabelsales() { if ($.support.placeholder) { var forms = ['.contact-message-sales-form-form']; $.each(forms, function (index, val) { $(val + ' input[type=text], ' + val + ' input[type=password], ' + val + ' select, ' + val + ' input[type=email], ' + val + ' textarea').each(function (index, elem) { var eId = $(elem).attr("id"); var label = null; if (eId && (label = $(elem).parents("form").find("label[for=" + eId + "]")).length == 1) { $(elem).attr("placeholder", $(label).text()); $(label).hide(); $('span.form-required').hide(); } }); }); } else { $('[placeholder]').focus(function () { var input = $(this); if (input.val() == input.attr('placeholder')) { input.val(''); input.removeClass('placeholder'); } }).blur(function () { var input = $(this); if (input.val() == '' || input.val() == input.attr('placeholder')) { input.addClass('placeholder'); input.val(input.attr('placeholder')); } }).blur(); $('[placeholder]').parents('form').submit(function () { $(this).find('[placeholder]').each(function () { var input = $(this); if (input.val() == input.attr('placeholder')) { input.val(''); } }) }); } }; function removeLabelCustomerForm() { if ($.support.placeholder) { var forms = ['.contact-message-customer-service-form-form']; $.each(forms, function (index, val) { $(val + ' input[type=text], ' + val + ' input[type=password], ' + val + ' select, ' + val + ' input[type=email], ' + val + ' textarea').each(function (index, elem) { var eId = $(elem).attr("id"); var label = null; if (eId && (label = $(elem).parents("form").find("label[for=" + eId + "]")).length == 1) { $(elem).attr("placeholder", $(label).text()); $(label).hide(); $('span.form-required').hide(); } }); }); } else { $('[placeholder]').focus(function () { var input = $(this); if (input.val() == input.attr('placeholder')) { input.val(''); input.removeClass('placeholder'); } }).blur(function () { var input = $(this); if (input.val() == '' || input.val() == input.attr('placeholder')) { input.addClass('placeholder'); input.val(input.attr('placeholder')); } }).blur(); $('[placeholder]').parents('form').submit(function () { $(this).find('[placeholder]').each(function () { var input = $(this); if (input.val() == input.attr('placeholder')) { input.val(''); } }) }); } }; function closeButton() { $('.button-close a', context).once("firstTime").click(function () { var link = $(this); link.hide('fade'); link.find('span').hide(); $('.home-page-extra-element').slideToggle('slow', function () { var link_more = $('.home-page-extra-element').height(); var link_push = $('#footer-push').height(); var html_height = $('html').height(); var window_height = $(window).height(); var diff_height = window_height - html_height; if ($(this).is(':visible')) { link.text(Drupal.t('Close')); link.append(' '); var height_push = link_push - (link_more) - 30; $('#home-page-extra-close-id').removeClass('closed-element') } else { link.text(Drupal.t('more about DAB Pumps')); link.append(' '); $('#home-page-extra-close-id').addClass('closed-element') if (diff_height > link_more) { var height_push = link_push - (-link_more) - (-30); } } $('#footer-push').css('height', height_push + 'px'); link.show('fade'); }); }) } $('.open').click(function () { var link = $(this); $('.showpanel').slideToggle('slow', function () { if ($(this).is(':visible')) { link.text(Drupal.t('close')); } else { link.text(Drupal.t('open')); } }); }); $(document).ready(function () { removeLabel(); removeLabelsales(); removeLabelCustomerForm(); closeButton(); $('.form-item-field-business-area label input.form-radio.form-dab').change(function () { $('div.form-item-field-business-area label.selected').removeClass('selected'); if ($(this).is(':checked')) $(this).parent().addClass('selected'); else $(this).parent().removeClass('selected') }); $('.form-item-field-job-title label input.form-radio.form-dab').change(function () { $('div.form-item-field-job-title label.selected').removeClass('selected'); if ($(this).is(':checked')) $(this).parent().addClass('selected'); else $(this).parent().removeClass('selected') }); // on change if radio deselect an select $("form.views-exposed-form.news-form .js-form-type-radio").change(function (ev) { $('label.control-label.option').removeClass('selected'); $("label[for=" + ev.target.id + "]").addClass('selected'); $("input[id=" + ev.target.id + "]").prop('checked', true) }); // if checked set selected on label: FOR ALL RADIO $("input.form-radio.form-dab[type='radio']:checked").each(function () { var idVal = $(this).attr("id"); $("label[for=" + idVal + "]").addClass('selected'); }); $('.menu.block-taxonomymenu__submenu').hide(); }); // social news toggler $(".news-social-button").click(function () { $(this).siblings(".news-social-div1").toggle(); }); $(window).resize(function () { // }); $(".view-product-references").on("DOMSubtreeModified", function () { setTimeout(function () { $('.ajax-progress-fullscreen').remove(); }, 2000); }); } } })(jQuery);