(function ($) { const $window = $(window); $(".donate-form, .information-form").on('click', '.form-input-item[type="radio"], .form-input-item[type="checkbox"]', function (e) { $('.form-input-item[type="radio"], .form-input-item[type="checkbox"]').each(function (i, el) { radioClassSwitch(el); }); }); $('.form-input-item[type="radio"], .form-input-item[type="checkbox"]').each(function (i, el) { radioClassSwitch(el); }); // ================================================== // 捐款列表響應 // ================================================== // let nodeStep = 'desktop'; // $window.on('resize', function (e) { // if ($window.width() > 1024 && nodeStep !== "desktop") { // nodeStep = "desktop"; // $('.shopcart-table-wrap > .shopcart-table-cell').unwrap('.shopcart-table-wrap'); // $('.shopcart-editor').each(function (i, item) { // $(item).appendTo($(item).parent('.shopcart-table-row')); // }); // } else if ($window.width() <= 1024 && $window.width() > 768 && nodeStep !== "table") { // nodeStep = "table"; // $('.shopcart-table-row').each(function (i, item) { // const wrapEle = $(document.createElement("span")).addClass('shopcart-table-wrap'); // $(this).children(".shopcart-table-cell:nth-child(-n + 3), .shopcart-editor").wrapAll(wrapEle); // $('.shopcart-table-wrap > .shopcart-gift').unwrap('.shopcart-table-wrap'); // }); // } else if ($window.width() <= 768 && nodeStep !== "phone") { // nodeStep = "phone"; // $('.shopcart-table-row').each(function (i, item) { // const wrapEle = $(document.createElement('span')).addClass('shopcart-table-wrap'); // $(this).children(".shopcart-table-cell:nth-child(-n + 3), .shopcart-editor").wrapAll(wrapEle); // $(this).children(".shopcart-gift").wrapAll(wrapEle); // }); // } // }); // ================================================== // owl carousel 設定 // ================================================== const otherSlider = $('.other-donate'); otherSlider.owlCarousel({ dots: true, margin: 20, nav: true, navText: ['', ''], responsive: { 0: { items: 1 }, 577: { items: 3 }, 769: { items: 4 } } }); $('.photo').owlCarousel({ loop:true, margin:10, dots:true, nav:false, responsive:{ 0:{ items:1 } } }) // ================================================== // 初始化 // ================================================== $window.trigger('resize'); $('.step2_delete').on('click', function(){ var id = $(this).data('id'); var p_id = $(this).data('p_id'); $.ajax({ url:'/ajax/ajax_del_cart.php', type:'POST', cache:false, data:{ID:id}, dataType:'json', error:function(d) { alert('資料庫忙碌中'); }, success:function(d) { if(d.success){ if(d.GA && typeof ga == 'function') { for(var key in d.GA) { ga('ec:addProduct',d.GA[key]); } ga('ec:setAction','remove'); ga('send','event','購物車','移除購物車'); $('#GA_Data').html('["'+(d.GA+'').replace(/[\\"']/g, '\\$&').replace(/\u0000/g, '\\0')+'"]'); } if(d.GA4 && typeof gtag == 'function') { gtag("event","remove_from_cart",{ "items":d.GA4 }); } alert('刪除成功'); if(d.total_count == 0){ window.location.href = '/'+$("#Website_Unit_ID").val()+'/'; return false; }else{ changeCartNum(d.total_count); $('.oc_line_'+id).remove(); if($('.other-donate li').length > 0)$('.other-donate li').last().after('
  • '+$('.temp_other_donate .p_id_'+p_id).html()+'
  • '); else $('.other-donate').html('
  • '+$('.temp_other_donate .p_id_'+p_id).html()+'
  • '); $('.temp_other_donate .p_id_'+p_id).remove(); $('.other-block').show(); otherSlider.owlCarousel('destroy'); otherSlider.owlCarousel({ dots: true, margin: 20, nav: true, navText: ['', ''], responsive: { 0: { items: 1 }, 577: { items: 3 }, 769: { items: 4 } } }); } window.location.reload(); }else{ alert('資料庫忙碌中'); } } }); }); })($); // ========================================================== // radio、checkbox 樣式切換 // ========================================================== function radioPropCheck(selector) { return $(selector).prop('checked'); } function radioClassSwitch(selector) { if (radioPropCheck(selector)) { $(selector).parent('label').addClass('in-checked').parent('.input-flex').addClass('in-checked') } else { $(selector).parent('label').removeClass('in-checked').parent('.input-flex').removeClass('in-checked') } } function radioClassSwitch1(selector) { $("input[name='Gift_Flag'][value='1']").parent('label').removeClass('in-checked').parent('.input-flex').removeClass('in-checked') $("input[name='Gift_Flag'][value='2']").parent('label').removeClass('in-checked').parent('.input-flex').removeClass('in-checked') $("input[name='Gift_Flag'][value='1']").removeAttr('checked'); $("input[name='Gift_Flag'][value='2']").removeAttr('checked'); $(selector).parent('label').addClass('in-checked').parent('.input-flex').addClass('in-checked') $(selector).prop('checked', true); $(selector).attr('checked',''); }