$(document).ready(function(){ init(); }); function pleaseValidate(event){ var $this = event, $validate = $this.find('.validate'), $validateEmail = $this.find('.validate_email'), $validateTel = $this.find('.validate_tel'), $validateSelect = $this.find('.validate_select'), checkEmail = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/, checkTel = /[0-9 -()+]+$/; /*$('body').on('submit', $this, function() {*/ var error = '', signup_name = $this.find('.signup_name').val(), signup_email = $this.find('.signup_email').val(), signup_postal = $this.find('.signup_postal').val(), signup_form = $this.find('.signup_form').val(); $validate.each(function() { var value = $(this).val(); checking(value.length === 0, $(this)); }); $validateEmail.each(function() { var value = $(this).val(); checking(checkEmail.test(value) === false, $(this)); }); $validateTel.each(function() { var value = $(this).val(); checking(value.length < 7 || (!checkTel.test(value)), $(this)); }); $validateSelect.each(function() { var value = $(this).val(); checking(value == '0', $(this)); }) function checking(check, $this) { if (check) { error++; $this.addClass('validate_error'); } else { $this.removeClass('validate_error'); } } if (error) { $('.error.toast').toast(); return false; } else { if (signup_form == 1){ signin(signup_name,signup_email,signup_postal); } } /*}); */ } function signin(signup_name,signup_email,signup_postal){ $.ajax({ /*url: 'https://madmimi.com/signups/subscribe/203516',*/ url: 'ajax_signup.php', type: 'POST', data: 'signup[name]='+signup_name+'&signup[email]='+signup_email+'&signup[postal_code]='+signup_postal+'&form_id=203516', success: function(data, textStatus, xhr){ if (data == 1){ //console.log(xhr.status); loading('templates/signup_thank_you.php?a='); } else { console.log('ERROR'); } } }); } function init() { var tm = TweenMax, $body = $('body'), $window = $(window), $footer = $('footer'), $header = $('header'), $heightHeader = $('header').outerHeight(), $aspectRatio = window.screen.availWidth / window.screen.availHeight, $differentRatio = false; console.log($aspectRatio); if ($aspectRatio > 1.77 && $aspectRatio < 1.95) { $differentRatio = true; } if ($aspectRatio > 0.55 && $aspectRatio < 0.57) { $differentRatio = true; } if ($differentRatio) { console.log('16:9'); var head = document.getElementsByTagName('head')[0]; var link = document.createElement('link'); document.getElementById('normalCSS').remove(); link.id = 'differentRatioCss'; link.rel = 'stylesheet'; link.type = 'text/css'; link.href = '/css/main_16-9.css'; link.media = 'all'; head.appendChild(link); } $.fn.dialog = function() { var $this = $(this), $dialogWrapper = $('.dialog_wrapper'), $dialog = $('.dialog'), $dialogBg = $('.dialog_bg'), $dialogClose = $('.dialog_close'), wPosSet = $window.scrollTop(), wPosGet = $body.attr('data-scroll'); $dialogWrapper.show(); $dialogBg.show(); $this.show(); $body.addClass('dialog_opened'); $body.css('top', - wPosSet+'px'); $body.attr('data-scroll', wPosSet); if ($this.height() > $dialogWrapper.height()) { $body.addClass('dialog_scrollable'); } else { $body.addClass('dialog_scrollable'); } if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) { $body.addClass('dialog_scrollable_mobile'); } $dialogClose.on('click', function() { $dialog.hide(); $dialogBg.hide(); $dialogWrapper.hide(); $body.removeClass('dialog_opened', 'dialog_scrollable_mobile'); $window.scrollTop(wPosSet); closeNoResults(); }); }; $.fn.toast = function() { var $this = $(this), tl = new TimelineMax(); if (!$this.hasClass('active')) { tl.fromTo($this, 0.3, {display: 'none', y: '100%', autoAlpha: 0}, {display: 'block', y: '0%', autoAlpha: 1, ease: Back.easeOut}). to($this, 0.3, {display: 'none', y: '100%', autoAlpha: 0, ease: Back.easeIn, delay: 3, onComplete: function() { $this.removeClass('active'); }}); } $this.addClass('active'); }; var timeOut; $(document).on('touchstart touchmove touchend', function () { clearTimeout(timeOut); timeOut = setTimeout(function () { $('#loading > *').remove(); $('#loading').load('templates/splash_.php?a=').hide().fadeIn(600); }, 60000) }); } function loading(template){ // $('#loading').load(template).hide().fadeIn(600); //---------------------------------------- // $('#loader').show(); // $("#loading").load(template, function () { // $('#loader').hide(); // }); $('#loading > *').remove(); $('#loading').load(template, function(){initInput();}).hide().fadeIn(600); initInput(); }; function initInput(){ $('.input').on('focus',function(){ $('body').addClass('scrolling'); }); $('.input').on('blur',function(){ $('body').removeClass('scrolling'); }); }