luv-assets 1.2.9 → 1.2.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/js/cart.min.js +1 -1
- package/dist/js/p/header.min.js +1 -1
- package/package.json +1 -1
package/dist/js/cart.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function updateQty(item_id,up_type,qty=null){var data={item_id:item_id,up_type:up_type};if(qty!==null)data.qty=qty;data[csrfName]=csrfVal;$.ajax({url:updateCartInfoUrl,type:"POST",dataType:"json",data:data,success:function(response){if(response.status==="success"){if(up_type==="remove"){$('.cart-item-js[data-item-id="'+item_id+'"]').fadeOut(300,function(){$(this).remove();updateCheckoutButton()})}else{if(!isMobile){var price=$('.cart-item-js[data-item-id="'+item_id+'"]').find(".item-checkbox-js").data("price");var qty=$("#qty-js-"+item_id).val();var row_total=price*qty;const currency=currency_info.code;$('.cart-item-js[data-item-id="'+item_id+'"]').find(".row-product-total-js").text(I18nHelper.formatCurrency(row_total,currency))}updateCheckoutButton()}}else{alert(response.message||"Update failed")}},error:function(){alert("Network error")}})}function updateCheckoutButton(){const $checkedItems=$(".item-checkbox-js:checked");const checkedCount=$checkedItems.length;let product_total=0;let total=0;$checkedItems.each(function(){const price=parseFloat($(this).data("price"))||0;const qty=parseInt($("#qty-js-"+$(this).val()).val())||0;product_total+=price*qty});const discount=$("#coupon-cost-js").data("cost")||0;total=product_total-discount;const currency=currency_info.code;$("#total-price-js").text(I18nHelper.formatCurrency(total,currency));$("#checkout-count-js").text(checkedCount);$("#btn-checkout-js").prop("disabled",checkedCount===0);if(!isMobile){$("#product-total-js").text(I18nHelper.formatCurrency(product_total,currency))}const allChecked=$(".item-checkbox-js").length>0&&$checkedItems.length===$(".item-checkbox-js").length;$("#check-all-js").prop("checked",allChecked)}function paypalBuynowCreatePayment(){if(!paypal_client_id)return;$("#paypal-button-container").empty();var fundingSources=[paypal.FUNDING.PAYPAL];fundingSources.forEach(function(fundingSource){var button=paypal.Buttons({fundingSource:fundingSource,style:{height:38,label:"buynow"},onClick:function(){const total=parseFloat($("#total-price-js").
|
|
1
|
+
function updateQty(item_id,up_type,qty=null){var data={item_id:item_id,up_type:up_type};if(qty!==null)data.qty=qty;data[csrfName]=csrfVal;$.ajax({url:updateCartInfoUrl,type:"POST",dataType:"json",data:data,success:function(response){if(response.status==="success"){if(up_type==="remove"){$('.cart-item-js[data-item-id="'+item_id+'"]').fadeOut(300,function(){$(this).remove();updateCheckoutButton()})}else{if(!isMobile){var price=$('.cart-item-js[data-item-id="'+item_id+'"]').find(".item-checkbox-js").data("price");var qty=$("#qty-js-"+item_id).val();var row_total=price*qty;const currency=currency_info.code;$('.cart-item-js[data-item-id="'+item_id+'"]').find(".row-product-total-js").text(I18nHelper.formatCurrency(row_total,currency))}updateCheckoutButton()}}else{alert(response.message||"Update failed")}},error:function(){alert("Network error")}})}function updateCheckoutButton(){const $checkedItems=$(".item-checkbox-js:checked");const checkedCount=$checkedItems.length;let product_total=0;let total=0;$checkedItems.each(function(){const price=parseFloat($(this).data("price"))||0;const qty=parseInt($("#qty-js-"+$(this).val()).val())||0;product_total+=price*qty});const discount=$("#coupon-cost-js").data("cost")||0;total=product_total-discount;const currency=currency_info.code;$("#total-price-js").text(I18nHelper.formatCurrency(total,currency)).data("grand-total",total);$("#checkout-count-js").text(checkedCount);$("#btn-checkout-js").prop("disabled",checkedCount===0);if(!isMobile){$("#product-total-js").text(I18nHelper.formatCurrency(product_total,currency)).data("product-total",product_total)}const allChecked=$(".item-checkbox-js").length>0&&$checkedItems.length===$(".item-checkbox-js").length;$("#check-all-js").prop("checked",allChecked)}function paypalBuynowCreatePayment(){if(!paypal_client_id)return;$("#paypal-button-container").empty();var fundingSources=[paypal.FUNDING.PAYPAL];fundingSources.forEach(function(fundingSource){var button=paypal.Buttons({fundingSource:fundingSource,style:{height:38,label:"buynow"},onClick:function(){const total=parseFloat($("#total-price-js").data("grand-total"));if(isNaN(total)||total<=0){showToast(translations.itemRequired,"#toast-js");return false}return true},createOrder:function(data,actions){return fetch(paypalCreateOrderUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({[csrfName]:csrfVal})}).then(function(res){return res.json()}).then(function(order){if(order.id==="-1")throw new Error(order.message);return order.id})},onCancel:data=>{},onApprove:function(data,actions){return fetch(paypalCaptureOrderUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Object.assign(data,{[csrfName]:csrfVal}))}).then(function(res){return res.json()}).then(function(orderData){const order_sn=orderData.order_sn;if(order_sn=="-1"){if(!orderData.is_local){if(orderData.error_issue==="INSTRUMENT_DECLINED"){alert(orderData.message);return actions.restart()}throw new Error(orderData.message)}else{}}actions.redirect(`${paypalFinishOrderUrl}?order_sn=${order_sn}`)}).catch(function(error){alert(error)})},onError:function(err){alert(err.toString())}});if(button.isEligible()){button.render("#paypal-button-container")}})}$(document).ready(function(){$(document).on("change",".item-checkbox-js",function(){var item_id=$(this).val();var checked=$(this).is(":checked")?1:0;var data={item_id:item_id,checked:checked};data[csrfName]=csrfVal;$.ajax({url:selectOneProductUrl,type:"POST",dataType:"json",data:data,success:function(response){if(response.status==="success"){updateCheckoutButton()}}})});$("#check-all-js").on("change",function(){var checked=$(this).is(":checked")?1:0;var data={checked:checked};data[csrfName]=csrfVal;$.ajax({url:selectAllProductUrl,type:"POST",dataType:"json",data:data,success:function(response){if(response.status==="success"){$(".item-checkbox-js").prop("checked",checked);updateCheckoutButton()}}})});$(document).on("click",".item-plus-js",function(){var $input=$("#qty-js-"+$(this).data("item-id"));var qty=parseInt($input.val())||1;if(qty<max_qty){$input.val(qty+1);updateQty($(this).data("item-id"),"add_one")}});$(document).on("click",".item-minus-js",function(){var $input=$("#qty-js-"+$(this).data("item-id"));var qty=parseInt($input.val())||1;if(qty>1){$input.val(qty-1);updateQty($(this).data("item-id"),"less_one")}});$(document).on("change input",'[id^="qty-js-"]',function(){var item_id=$(this).attr("id").replace("qty-js-","");var qty=parseInt($(this).val())||1;qty=Math.max(1,Math.min(max_qty,qty));$(this).val(qty);updateQty(item_id,"set_num",qty)});var pendingDeleteItemId=null;$("#removeDialog").on("show.bs.modal",function(event){var button=$(event.relatedTarget);pendingDeleteItemId=button.data("item-id")});$("#removeDialog .btn-primary").on("click",function(){if(pendingDeleteItemId){updateQty(pendingDeleteItemId,"remove");$("#removeDialog").modal("hide");pendingDeleteItemId=null}});$("#btn-checkout-js").on("click",function(){if($(this).prop("disabled")){return}$(this).prop("disabled",true);const selectedCount=$(".item-checkbox-js:checked").length;if(selectedCount===0){$(this).prop("disabled",false);showToast(translations.itemRequired,"#toast-js");return false}$(this).prop("disabled",true).text(translations.checkoutIng);window.location.href=checkoutUrl});if(paypal_client_id!==""&&has_product){if(typeof paypal==="undefined"){webLoadScript(paypalSdkUrl,function(){paypalBuynowCreatePayment()})}else{paypalBuynowCreatePayment()}}});
|
package/dist/js/p/header.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function renderSearchHistory(){const $list=$("#search-history-items-js");const history=SearchHistory.getKeywords();if(history.length===0){$("#search-history-js").addClass("d-none");return}$("#search-history-js").removeClass("d-none");$list.empty();history.forEach(keyword=>{const $item=$(`<li><a href="${searchUrl}?q=${encodeURIComponent(keyword)}" class="badge bg-light text-dark text-decoration-none">${keyword}</a></li>`);$list.append($item)})}$(document).ready(function(){$(".luv-nav-item").hover(function(){$(this).addClass("active");$(this).find(".nav-link").addClass("active")},function(){$(this).removeClass("active");$(this).find(".nav-link").removeClass("active")});const $qInput=$("#keywords");const $searchSuggestions=$("#search-suggestions-js");const $searchForm=$("#search-form-js");$qInput.on("focus",function(){SearchHistory.pullFromServer(pullSearchHistoryUrl);renderSearchHistory();$searchSuggestions.removeClass("d-none");$qInput.attr("aria-expanded","true")});$searchForm.on("submit",function(){const q=$input.val().trim();if(!q){e.preventDefault();$input.focus();return false}SearchHistory.save(q,saveSearchHistoryUrl)});$(document).on("click",function(e){if(!$searchForm[0].contains(e.target)){$searchSuggestions.addClass("d-none");$qInput.attr("aria-expanded","false")}});$qInput.on("keydown",function(e){if(e.key==="Escape"){$searchSuggestions.addClass("d-none");$qInput.attr("aria-expanded","false");$qInput.blur()}});$("#removeSearchDialog .btn-primary").click(function(){SearchHistory.clear(removeHistoryUrl);location.reload()});$searchSuggestions.on("click","a",function(e){const q=new URL(this.href).searchParams.get("q");if(q)SearchHistory.save(q,saveSearchHistoryUrl)})
|
|
1
|
+
function renderSearchHistory(){const $list=$("#search-history-items-js");const history=SearchHistory.getKeywords();if(history.length===0){$("#search-history-js").addClass("d-none");return}$("#search-history-js").removeClass("d-none");$list.empty();history.forEach(keyword=>{const $item=$(`<li><a href="${searchUrl}?q=${encodeURIComponent(keyword)}" class="badge bg-light text-dark text-decoration-none">${keyword}</a></li>`);$list.append($item)})}$(document).ready(function(){$(".luv-nav-item").hover(function(){$(this).addClass("active");$(this).find(".nav-link").addClass("active")},function(){$(this).removeClass("active");$(this).find(".nav-link").removeClass("active")});const $qInput=$("#keywords");if($qInput.length>0){const $searchSuggestions=$("#search-suggestions-js");const $searchForm=$("#search-form-js");$qInput.on("focus",function(){SearchHistory.pullFromServer(pullSearchHistoryUrl);renderSearchHistory();$searchSuggestions.removeClass("d-none");$qInput.attr("aria-expanded","true")});$searchForm.on("submit",function(){const q=$input.val().trim();if(!q){e.preventDefault();$input.focus();return false}SearchHistory.save(q,saveSearchHistoryUrl)});$(document).on("click",function(e){if(!$searchForm[0].contains(e.target)){$searchSuggestions.addClass("d-none");$qInput.attr("aria-expanded","false")}});$qInput.on("keydown",function(e){if(e.key==="Escape"){$searchSuggestions.addClass("d-none");$qInput.attr("aria-expanded","false");$qInput.blur()}});$("#removeSearchDialog .btn-primary").click(function(){SearchHistory.clear(removeHistoryUrl);location.reload()});$searchSuggestions.on("click","a",function(e){const q=new URL(this.href).searchParams.get("q");if(q)SearchHistory.save(q,saveSearchHistoryUrl)})}$(".lang_currency_submit").on("click",function(){var changeStore=$(".currentLangSelect").val();var currentCurrency=$(".currentCurrencySelect").val();$.ajax({url:"<?= Yii::$service->url->getUrl('cms/home/changecurrency') ?>?currency="+currentCurrency,async:false});var currentUrl=window.location.href;var currentStore=$(".current_lang").val();var redirectUrl=currentUrl.replace("://"+currentStore,"://"+changeStore);redirectUrl=redirectUrl.split("#")[0];window.location.href=redirectUrl})});
|