/* Moria */ $(document).ready(function() { moria.initCountry(); moria.initVar() moria.init(); if ( moria.amount_in_valid == '1' ){ moria.btnRender(); } amounts.init(); }); var moria = { options : options, translations : translations, geolocCountry : '', redirections : redirections, step1reassurance :step1reassurance, step2reassurance :step2reassurance, step3reassurance :step3reassurance, step1reassuranceTitle :step1reassuranceTitle, step2reassuranceTitle :step2reassuranceTitle, step3reassuranceTitle :step3reassuranceTitle, initCountry : function(){ $.getScript('https://services.iraiser.eu/geoip/api/v1/geoip.jsonp', function( data, textStatus, jqxhr ) { moria.geolocCountry = abGeoIp.countryCode; console.log('moria.geolocCountry : '+moria.geolocCountry); if( moria.geolocCountry != 'null' ){ // on a une geoloc de trouvée par l'API // moria.redirections[sophia.geolocCountry] if ( typeof moria.redirections[moria.geolocCountry] != 'undefined' ){ moria.goToRedirections(moria.redirections[moria.geolocCountry].url); } }else { //No geoloc trouvé return false; } }); }, initVar : function(){ if(moria.step1reassurance == false){moria.step1reassurance = ''}; if(moria.step2reassurance == false){moria.step2reassurance = ''}; if(moria.step3reassurance == false){moria.step3reassurance = ''}; if(moria.step1reassuranceTitle == false){moria.step1reassuranceTitle = ''}; if(moria.step2reassuranceTitle == false){moria.step2reassuranceTitle = ''}; if(moria.step3reassuranceTitle == false){moria.step3reassuranceTitle = ''}; if( typeof amount_in_valid_text != 'undefined' && amount_in_valid_text != ''){ moria.amount_btn_text = amount_in_valid_text; }else { if (typeof Step3 != 'undefined') { moria.amount_btn_text = Step3.select('.payment-submit .button').first().val(); } } if(typeof amount_in_valid != 'undefined' ){ moria.amount_in_valid = amount_in_valid; } }, init : function(){ console.log('FUNCTION init'); //console.log('amount is : '+Common.getDonation().amount); moria.stepsRender(); //moria.initAmount(); moria.step1(); moria.step2(); moria.step3(); moria.stepInfos(); moria.amountsRender(); if( typeof Step1 != 'undefined' && typeof Step1.getDonation().frequency != 'undefined' ){ var frequency = Step1.getDonation().frequency; var tabs_first = $('.tabs ul li:first-child').attr('aria-controls'); //console.log( frequency ); //console.log( tabs_first ); if( frequency != tabs_first ){ $('.tabs').tabs({ active: 1 }); } } moria.changeAMount() $('body').bind('change_amount', moria.changeAMount); /* custo client */ if( $('html').attr('lang') == 'de_DE' ){ $('#footer').load('/libs.iraiser.eu/users/irc/ircBlackFooter_GERMANY.html #import_html', function(){ var footerHeight = $('#footer').outerHeight(); $('#container').css('padding-bottom', footerHeight) }); } if( $('html').attr('lang') == 'se_SE' ){ $('#footer').load('/libs.iraiser.eu/users/irc/ircBlackFooter_SWEDEN.html #import_html', function(){ var footerHeight = $('#footer').outerHeight(); $('#container').css('padding-bottom', footerHeight) }); } /* end custo client */ var footerHeight = $('#footer').outerHeight(); $('#container').css('padding-bottom', footerHeight); if( typeof Steps != 'undefined'){ Steps.adaptHeight(); } }, initAmount : function(){ console.log('FUNCTION initAmount'); //console.log('amount is : '+Common.getDonation().amount); var tempAmount = Common.getDonation().amount; console.log('amount = '+tempAmount) defaultRegularAmount = $('[name=amount-regular]:eq( -2 )').val(); defaultOnceAmount = $('[name=amount-once]:eq( -2 )').val(); if ( Common.getDonation().amount == 0 && Common.getDonation().frequency == 'regular'){ console.log(' regular no amount !'); Step1.set_donation({ amount: defaultRegularAmount, frequency: 'regular' }); } if ( Common.getDonation().amount == 0 && Common.getDonation().frequency == 'once'){ console.log(' once no amount !'); Step1.set_donation({ amount: defaultOnceAmount, frequency: 'once' }); } }, changeAMount : function(){ console.log('FUNCTION changeAmount'); //console.log('amount is : '+Common.getDonation().amount); if( typeof Steps != 'undefined'){ Steps.adaptHeight(); } }, goToRedirections : function(url){ console.log('URL DE REDIRECTION : '+url); document.location.href = url; }, stepsRender : function(){ if( moria.options['header'] == 2 ){ $('body').addClass('header-banner'); } $('body:not(#type-a):not(#type-b) #header').wrapInner('
'); $('#header_wrapinner').append('

'+moria.translations['form_title']+'

'); //radio & checkbox $('[name=iscompany]').after(''); $('[type=checkbox][name^=reserved_]').each(function(index, el) { $(this).after(''); $(this).attr('id', $(this).attr('name')); }); $('input[type=radio]').each(function(index, el) { var id = $(this).parent().attr('for'); $(this).attr('id', id); }); //placeholder $('#step-1 label').each(function(index, el) { var parent = $(this).parent(); console.log($(parent).data('ira-placeholder')); if( $(parent).data('ira-placeholder') != false ) { var input = $(this).next(':input'); $(this).find('.help').remove(); if (input.attr('type') == 'text') { input.attr('placeholder', $(this).text().trim()); $(this).hide(); } }else { $(this).show(); } }); $('#step-2 label').each(function(index, el) { var parent = $(this).parent(); console.log($(parent).data('ira-placeholder')); if( $(parent).data('ira-placeholder') != false ) { var input = $(this).next(':input'); $(this).find('.help').hide(); if (input.attr('type') == 'text' || input.is('textarea') ) { input.attr('placeholder', $(this).text().trim().replace(/\t/g, '').replace(/(\r\n|\n|\r)/gm,'')); //$(this).hide(); } if (input.attr('type') == 'date') { input.attr('placeholder', $(this).text().trim()); //$(this).hide(); } if ($(this).attr('for') == 'civility'){ $('[name=civility] option').first().text($(this).text().trim()); $(this).hide(); } if ($(this).attr('for') == 'email'){ $(this).html(''); } }else { $(this).show(); } }); $('#step-2 .intl-tel-input').each(function(index, el) { input = $(this).find('input'); input.attr('placeholder', $(this).siblings('label').text().trim()); $(this).siblings('label').hide(); }); // select2 // changer les intitulés if( typeof moria.translations['card_month'] != 'undefined' && typeof Step3 != 'undefined' ){ Step3.select('#cardmonth').each(function(){ $(this).find('option:first').text(moria.translations['card_month']); }) } if( typeof moria.translations['card_year'] != 'undefined' && typeof Step3 != 'undefined' ){ Step3.select('#cardyear').each(function(){ $(this).find('option:first').text(moria.translations['card_year']); }) } $.getScript( 'https://libs.iraiser.eu/libs/forms/select2/js/select2.full.min.js', function( data, textStatus, jqxhr ) { if (typeof Step3 != 'undefined') { Step3.select('#cardmonth, #cardyear').select2({ minimumResultsForSearch: Infinity }); } $('#step-2 select').select2({ minimumResultsForSearch: Infinity }); $('#step-1 select').select2({ minimumResultsForSearch: Infinity }); }); if ( $('[name=lang]') ) { $('[name=lang] option').each(function(index, el) { var label = $(this).text(); var link = $(this).val(); $('#lang').append(''+label+' '); }); $('[name=lang]').hide(); }; $('#main').after('
'); if( $('#greetings').length < 1 ){ if( typeof moria.translations['form_description'] != 'undefined'){ $('#type-b #main').after('
'+moria.translations['form_description']+'
'); } } }, step1 : function(){ if( typeof Step1 != 'undefined'){ $('#step-1 .bloc' ).wrapAll('
'); $('.tabs').prepend(''); $('#step-1 .bloc h3').each(function(index, el) { var frequency = $(this).parents('.bloc').attr('id'); if(index == 0){ $(this).appendTo('.tabs ul.tabs_menu').wrap('
  • '); }else { $(this).appendTo('.tabs ul.tabs_menu').wrap('
  • '); } }); moria.tabs(); $('#step-1 #or').siblings('.unit ').hide(); $('#step-1 #or').remove(); if (Step1.active_tax_reduction < 1){ $('.tax-info').hide(); } $('#step-1 .height_adaptor').append('
    '); } }, step2 : function(){ /*$('#c-addr2, #c-pcode, #c-city, #c-country').hide(); if( $('[name=address1]').val() != '' ){ $('#c-addr2, #c-pcode, #c-city, #c-country').show(); } $('[name=address1]').keyup(function(event) { if( $('[name=address1]').val() != '' ){ $('#c-addr2, #c-pcode, #c-city, #c-country').slideDown(); Steps.adaptHeight(); } }); */ $('#security-info').html('\

    \ '+moria.translations['security_info']+'\

    '); $('#security-info').appendTo('#step-3 .height_adaptor') }, step3 : function(){ if( typeof Step3 != 'undefined'){ Step3.select('[name=cardtype]').after(''); Step3.select('#card-type').append('
    '); /* typeA hack*/ $('#type-a [name=cardtype]').after(''); $('#type-a #card-type').append('
    '); Step3.select('[name=cardtype]').change(function(event) { $('#card-type li').removeClass('selected'); $(this).parents('li').addClass('selected'); }); /* typeA hack*/ $('#type-a [name=cardtype]').change(function(event) { $('#card-type li').removeClass('selected'); $(this).parents('li').addClass('selected'); }); /* Step3.select('#card-scode').each(function(index, el) { $(this).after($(this).find('.help')); }); */ /*placeholder*/ Step3.select('#card-number label, #card-scode label, #card-expiry label, #iban-input label, #bic-input label').each(function(index, el) { var input = $(this).next(':input'); $(this).find('.help').remove(); if (input.attr('type') == 'text') { input.attr('placeholder', $(this).text()); $(this).hide(); } }); Step3.select('#gocardless_autogiro_sin label, #gocardless_autogiro_branch label, #gocardless_autogiro_account label, #swish_account_number label').each(function(index, el) { var input = $(this).next(':input'); var el = $(this).clone(); el.find('span').remove(); var text = el.text(); var labelText = text.trim() $(this).find('.help').remove(); if (input.attr('type') == 'text') { input.attr('placeholder', labelText+' *'); $(this).hide(); } }); //Step3.select('#payment_mode-swish_account .payment_mode_title').html(''); /* typeA hack*/ $('#type-a #card-number label').each(function(index, el) { var input = $(this).next(':input'); $(this).find('.help').remove(); if (input.attr('type') == 'text') { input.attr('placeholder', $(this).text()); $(this).hide(); } }); Step3.select('.payment_body').hide(); if ( typeof Step1 != 'undefined'){ $('.payment_mode h4',Step1['payment_modes_regular']).each(function(index, el) { $(this).click(function(event) { if ($(this).siblings('.payment_body').is(':visible')){ return; }else { $('.payment_body',Step1['payment_modes_regular']).slideUp(); $('.payment_mode h4',Step1['payment_modes_regular']).removeClass('active'); $(this).siblings('.payment_body').slideDown(); $(this).addClass('active'); } }); }); $('.payment_mode h4',Step1['payment_modes_once']).each(function(index, el) { $(this).click(function(event) { if ($(this).siblings('.payment_body').is(':visible')){ return; }else { $('.payment_body',Step1['payment_modes_once']).slideUp(); $('.payment_mode h4',Step1['payment_modes_once']).removeClass('active'); $(this).siblings('.payment_body').slideDown(); $(this).addClass('active'); } }); }); } Step3.select('#payment_mode-paypal .payment_head').each(function(index, el) { $(this).find('.payment_mode_title').html(''); }); Step3.select('#payment_mode-apple_pay .payment_head').each(function(index, el) { $(this).find('.payment_mode_title').html(''); }); /* on garde tout fermé pour IRC mais en fait non ou ouvre le premier */ Step3.select('.payment_mode:first-of-type h4').click(); /* lol */ /*clear*/ $('#step-3 .step-content').append('
    '); } if( typeof moria.translations['privacy_text'] != 'undefined'){ $('#step-2 #fieldset-step2').after('

    '+moria.translations['privacy_text']+'

    '); } if( typeof moria.translations['payment_text'] != 'undefined'){ $('#step-3 .payment').after('

    '+moria.translations['payment_text']+'

    '); } if( typeof moria.translations['swish_text'] != 'undefined' && typeof Step3 != 'undefined' ){ Step3.select('#payment_mode-swish_account').after('

    '+moria.translations['swish_text']+'

    '); } if( typeof moria.translations['autogiro_text'] != 'undefined' && typeof Step3 != 'undefined' ){ Step3.select('#payment_mode-gocardless_autogiro').after('

    '+moria.translations['autogiro_text']+'

    '); } }, stepInfos : function(){ // IRC moria.options = {'footer':1}; if( moria.options['footer'] == 1 ){ $('body').addClass('footer-detach') $('#step-1 .step-info').appendTo('#bottom .container').addClass('step-info-1'); $('#step-2 .step-info').appendTo('#bottom .container').addClass('step-info-2'); $('#step-3 .step-info').appendTo('#bottom .container').addClass('step-info-3'); $('#bottom').append('
    '); /* remove then add again ... but only step3*/ if( $('#greetings').length > 0 ){ $('#bottom .container').append('
    '); $('#bottom .container').append('
    '); $('#bottom .container').append('
    \

    '+moria.step3reassuranceTitle+'

    \
    '+moria.step3reassurance+'
    \
    '); } } if( moria.options['footer'] == 2 ){ $('body').addClass('footer-column'); } }, amountsRender : function(){ $('.amount .radio-desc').each(function(index, el) { var id = $(this).attr('id'); var parent = $(this).parent(); $(this).find('li').each(function(index, el) { $(this).find('div').removeClass('size1of2'); $(this).attr('data-detail', 'tabs_'+index); var image = $(this).find('img').attr('src'); if( typeof image != 'undefined'){ image = image.replace('pricelist_item','origin'); $(this).find('img').remove(); var text = $(this).find('p').html(); $(this).find('p').remove(); if(text.length >0){ text = '

    '+text+'

    '; } var block = '
    '+text+'
    '; if( parent.siblings('.free-amount').length > 0) { parent.siblings('.free-amount').after(block); }else{ parent.after(block); } //$(this).append(block); }else { console.log('ICI'); var text = $(this).find('p').text(); $(this).find('p').remove(); if(text.length >0){ text = '

    '+text+'

    '; } var block = '
    '+text+'
    '; if( parent.siblings('.free-amount').length > 0) { parent.siblings('.free-amount').after(block); }else{ parent.after(block); } } }); }); $('.free-amount').each(function(index, el) { var el = $(this).find('label').clone(); el.find('span').remove(); var text = el.text(); $(this).find('input[name^=famount]').attr('placeholder', text); }); }, btnRender :function() { moria.btnChange(); $('body').bind('change_amount', moria.btnChange); }, btnChange : function(){ console.log('function : btnChange'); if (typeof Step1 != 'undefined'){ var amount = Step1.getDonation().amount; }else{ var amount = ''; } if (typeof Step3 != 'undefined'){ Step3.select('.payment-submit .button').val(moria.amount_btn_text +' '+ amount/100 +' €'); } }, tabs : function(){ console.log('FUNCTION tabs'); console.log('amount is : '+Common.getDonation().amount); console.log('frequency is : '+Common.getDonation().frequency); var frequency = Common.getDonation().frequency; console.log('sofia.tabs : '+frequency); defaultRegularAmount = $('[name=amount-regular]:eq( -2 )').val(); defaultOnceAmount = $('[name=amount-once]:eq( -2 )').val(); if ( Common.getDonation().amount == 0 && frequency == 'regular'){ Step1.set_donation({ amount: defaultRegularAmount, frequency: 'regular' }); } if ( Common.getDonation().amount == 0 && frequency == 'once'){ Step1.set_donation({ amount: defaultOnceAmount, frequency: 'once' }); } $('.tabs').tabs({ create: function(){ console.log('-- CREATE -- montant :'+Common.getDonation().amount+' | fréquence :'+Common.getDonation().frequency); }, beforeActivate: function( event, ui ) { console.log('-- BEFORE ACTIVATE -- montant :'+Common.getDonation().amount+' | fréquence :'+Common.getDonation().frequency); }, activate: function( event, ui ) { console.log('-- ACTIVATE -- montant :'+Common.getDonation().amount+' | fréquence :'+Common.getDonation().frequency); var item = ui.newTab; ui.newPanel.addClass('active-panel'); ui.oldPanel.removeClass('active-panel'); ui.oldPanel.addClass('inactive-panel'); ui.newPanel.removeClass('inactive-panel'); ui.newPanel.removeClass('inactive-panel'); /* passage du montant*/ /* defaultRegularAmount = $('[name=amount-regular]:eq( -2 )').val(); defaultOnceAmount = $('[name=amount-once]:eq( -2 )').val(); if(item.attr('id') == 'regular-item'){ console.log('case regular') if ( Common.getDonation().amount == 0 ){ amount = defaultRegularAmount; } Step1.set_donation({amount: amount, frequency: 'regular'}); }else if(item.attr('id') == 'once-item'){ console.log('case once') if ( Common.getDonation().amount == 0 ){ amount = defaultOnceAmount; } Step1.set_donation({amount: amount, frequency: 'once'}); } Steps.adaptHeight(); */ if (item.attr('id') == 'regular-item') { console.log('set regular') Step1.set_donation({ amount: defaultRegularAmount, frequency: 'regular' }); console.log('amount is : '+Common.getDonation().amount); } else if (item.attr('id') == 'once-item') { console.log('set once') Step1.set_donation({ amount: defaultOnceAmount, frequency: 'once' }); console.log('amount is : '+Common.getDonation().amount); } Steps.adaptHeight(); } }); /* recupération des montants en param */ /* var amount = Step1.getDonation().amount; var frequency = Step1.getDonation().frequency; if( amount != '0'){ if( $('.tabs .ui-tabs-panel:first').attr('id') == frequency ){ $('.tabs').tabs('option', 'active', 0 ); }else { $('.tabs').tabs('option', 'active', 1 ); } } */ } } var amounts = { init : function(){ if (typeof Step1 == 'undefined'){ return }else { //console.log('----init'); amounts.donationInit(); amounts.donationWatch(); amounts.donationControl(); } }, donationInit : function(){ //console.log('----donationInit'); amounts.donationRender(); }, donationRender : function(){ //console.log('----donationRender'); amounts.donationRenderReset(); var amount = Step1.getDonation().amount; var frequency = Step1.getDonation().frequency; if ( frequency == 'once'){ amounts.donationRenderOnce(); }else { amounts.donationRenderRegular(); } // free amounts $('[name^=famount-]').each(function(index, el) { if ( $(this).val() > 0 ){ $(this).addClass('active'); $(this).parent().addClass('active'); } }); // grilles de dons $('#once .amount [type=radio]:checked').siblings('span').addClass('active'); $('#regular .amount [type=radio]:checked').siblings('span').addClass('active'); $('#once .amount [type=radio]:checked').parent().addClass('active'); $('#regular .amount [type=radio]:checked').parent().addClass('active'); $('#once .amount [type=radio]:checked').parents('li').addClass('active'); $('#regular .amount [type=radio]:checked').parents('li').addClass('active'); // show description $('.detail[id='+$('.amount [type=radio]:checked').parents('li').attr('data-detail')+']').show(); }, donationWatch : function(){ //console.log('----donationWatch'); $('body').bind('change_amount', amounts.donationChangeAmount); }, donationChangeAmount : function(){ //console.log('----donationChangeAmount'); amounts.donationRender(); }, donationRenderReset : function(){ //console.log('----donationRenderReset'); $('.free-amount label, [name^=famount-], .amount [name^=amount-], .amount ul li label, .amount ul li span, .amount ul li').removeClass('active inactive'); $('.detail').hide(); }, donationRenderOnce : function(){ //console.log('----donationRenderOnce'); $('#once').addClass('active-panel').removeClass('inactive-panel'); $('#regular').addClass('inactive-panel').removeClass('active-panel'); $('body').removeClass('ira-regular').addClass('ira-once'); }, donationRenderRegular : function(){ //console.log('----donationRenderRegular'); $('#regular').addClass('active-panel').removeClass('inactive-panel'); $('#once').addClass('inactive-panel').removeClass('active-panel'); $('body').removeClass('ira-once').addClass('ira-regular'); }, donationControl : function(){ //console.log('----donationControl'); $('[name^=famount-] , .amount [name^=amount-], .amount ul li label, .amount ul li span').click(function(event) { /* Act on the event */ console.log('click detected'); amounts.donationRender(); }); } }