/** * modalEffects.js v1.0.0 * http://www.codrops.com * * Licensed under the MIT license. * http://www.opensource.org/licenses/mit-license.php * * Copyright 2013, Codrops * http://www.codrops.com */ var ModalEffects=(function(){function init(){var overlay=document.querySelector('.md-overlay');[].slice.call(document.querySelectorAll('.md-trigger')).forEach(function(el,i){var modal=document.querySelector('#'+el.getAttribute('data-modal')),close=modal.querySelector('.md-close');function removeModal(hasPerspective){ if(el.getAttribute('data-modal')=='modal-12' || el.getAttribute('data-modal')=='modal-14'){ anime({targets:[modal.querySelector('.md-action-btn-handle'),modal.querySelector('.md-close-btn-handle')],duration:100,easing:'easeOutSine',opacity:0,translateX:(target,index)=>{return index!==1?[0,'-50%']:[0,'50%'];},complete:()=>{classie.remove(modal,'md-show');if(hasPerspective){classie.remove(document.documentElement,'md-perspective');}}}); }else{anime({targets:modal.querySelector('.md-close-btn-handle'),duration:100,easing:'easeOutSine',opacity:0,complete:()=>{classie.remove(modal,'md-show');}});}} function removeModalHandler(){removeModal(classie.has(el,'md-setperspective'));} function open(){ $(".md-content .content.dialog-info").html("") $('.md-content #name:input').val(''); $('.md-content #phone:input').val(''); $('.md-content #name-feed:input').val(''); $('.md-content #phone-feed:input').val(''); $('.md-content #feedbacktextarea').val(''); $(".md-content .content.dialog-form, .md-content .anyQuestion, .md-content .politica").show(); $(".dialog-button").removeClass('disabled'); modal.querySelector('.md-close-btn-handle').style.opacity=0;classie.add(modal,'md-show');anime({targets:modal.querySelector('.md-close-btn-handle'),duration:300,easing:'easeOutSine',opacity:1,translateY:['50%',0],delay:200});} function open12(){ $(".md-content .content.dialog-info").html("") $('.md-content #name:input').val(''); $('.md-content #phone:input').val(''); $('.md-content #name-feed:input').val(''); $('.md-content #phone-feed:input').val(''); $('.md-content #feedbacktextarea').val(''); $(".md-content .content.dialog-form, .md-content .anyQuestion, .md-content .politica").show(); $(".dialog-button").removeClass('disabled'); modal.querySelector('.md-action-btn-handle').style.opacity=0;modal.querySelector('.md-close-btn-handle').style.opacity=0;classie.add(modal,'md-show');anime({targets:[modal.querySelector('.md-action-btn-handle'),modal.querySelector('.md-close-btn-handle')],duration:300,easing:'easeOutSine',opacity:1,translateX:(target,index)=>{return index!==1?['-50%',0]:['50%',0];},delay:200});} function fill(){modal.querySelector('#dialog-title').innerHTML=el.getAttribute('data-title');modal.querySelector('#dialogyatarget').value=el.getAttribute('data-yatarget');modal.querySelector('#dialoggatarget').value=el.getAttribute('data-gatarget');modal.querySelector('#dialog-subtitle').innerHTML=el.getAttribute('data-subtitle');modal.querySelector('.dialog-button').innerHTML=el.getAttribute('data-button');} function fill14(){ modal.querySelector('#dialog-title-feed').innerHTML=el.getAttribute('data-title');modal.querySelector('#dialogyatarget').value=el.getAttribute('data-yatarget');modal.querySelector('#dialoggatarget').value=el.getAttribute('data-gatarget');modal.querySelector('#dialog-subtitle').innerHTML=el.getAttribute('data-subtitle');modal.querySelector('.dialog-button').innerHTML=el.getAttribute('data-button');} el.addEventListener('click',function(ev){ if(el.getAttribute('data-modal')=='modal-12'){ fill(); open12(); } else if(el.getAttribute('data-modal')=='modal-14'){ fill14(); open12(); } else{ open(); } overlay.removeEventListener('click',removeModalHandler);overlay.addEventListener('click',removeModalHandler);if(classie.has(el,'md-setperspective')){setTimeout(function(){classie.add(document.documentElement,'md-perspective');},25);}});close.addEventListener('click',function(ev){ev.stopPropagation();removeModalHandler();});});} return init;})();