$(function(){ let box_n = 1 const objTwo = { 0: { items: 2 }, 480: { items: 3 }, 576: { items: 1 }, 768: { items: 2 }, 992: { items: 3 }, 1200: { items: 4 }, } const objThree = { 0: { items: 2 }, 480: { items: 3 }, 576: { items: 4 }, 768: { items: 1 }, 992: { items: 2 }, } const objFour = { 0: { items: 2 }, 480: { items: 3 }, 576: { items: 1 }, 768: { items: 2 }, 992: { items: 1 }, 1200: { items: 2 }, } function owlOption(resObj) { const optionReturn = { margin: 10, dots: false, nav: true, navText: ['', ''], responsive: resObj } return optionReturn } if($('.twobox').length){ box_n=4; $('.twobox .orderSlideRGP').each(function(i, ele) { $(ele).owlCarousel(owlOption(objTwo)) }) } if($('.fourbox').length) { box_n=3; $('.fourbox .orderSlideRGP').each(function(i, ele) { $(ele).owlCarousel(owlOption(objFour)) }) } if($('.threebox').length) { box_n=3; $('.threebox .orderSlideRGP').each(function(i, ele) { $(ele).owlCarousel(owlOption(objThree)) }) }; $('.user-orderBox').on('click', '.delete', function(e){ e.preventDefault() const targetOwl = $(this).parents('.orderSlideRGP') const delitem = $(this).parents('.owl-item'); delitem.find('.title').remove(); delitem.animate({'opacity':0},300).animate({'width':0},300); setTimeout(function(){ targetOwl.trigger('remove.owl.carousel',delitem.index()) .trigger('refresh.owl.carousel'); if(!targetOwl.find('.owl-item').length){ var html = '
'; targetOwl.trigger('to.owl.carousel',[0,0,true]) .trigger('add.owl.carousel',[$(html),0]) .trigger('refresh.owl.carousel'); } }, 700); }); $('article').on('click','.button5',function(){ $('.user-orderBox').removeClass('none'); const img = $(this).parents('.productBox') const img_src = img.find('.productImg').find('img').eq(0).attr('src') const img_title = img.find('.productTitle').find('.title').text() const img_spec = img.find('.color-select').find('option:selected').text() const img_price = _jsLang.Language_Currency + img.find('.productTitle').find('.font-big').text() const img_amount = img.find('.num-select').val() const add_array = new Array() add_array[0] = 0; const matchRegex = /\b(red|blue|green|orange)Box/g function SelectPair(clickThis, selector, boxAmount, imgAmount) { const clickTarget = `#${$(clickThis).parents('.productBox').attr('class').match(matchRegex)[0]}` const picBg = $(selector).find('.pic-bg') const slideWrap = $(selector).find('.orderSlideRGP') if(picBg.length === 1) { slideWrap.trigger('remove.owl.carousel', picBg.parents('.owl-item').index()) .trigger('refresh.owl.carousel'); } $(`.orderBox-tag[href="${clickTarget}"]`).trigger('click') const smailBox = $(`.user-orderBox ${selector} .owl-stage-outer`) const smailBox_top = smailBox.offset().top const smailBox_left = smailBox.offset().left + 20 const smailBox_width = smailBox.width() / boxAmount const smailBox_height = smailBox.height() for($i = 0; $i < imgAmount; $i++){ const html = `