Preview: chef.js
Size: 8.29 KB
/home/justbyquicklly-old/justbyquicklly/www/js/chef.js
'use strict';
(function ($) {
//<------------------------------- recipe list page -------------------------------------->
// popup start
$(".main_banner_chef a#myBtn").click(function (e) {
e.preventDefault();
$('#popupoffer1').show();
$('body').toggleClass('modal-open');
});
$('body').on('click', '.popupclose1', function (e) {
e.preventDefault();
$('body').toggleClass('modal-open');
$('#popupoffer1').hide();
});
// popup end
$("#search").on("keyup", function(){
//$("span.close").css("display", "block")
});
$('.close').click(function(){
console.log('test');
$(this).closest('div').find('#search').val('');
$("#recipe_filter").load(" #recipe_filter > *");
$(this).css("display", "none");
//$("#searchBtn").css("display", "block");
$(this).closest('div').find('#search').removeAttr("style"); // .css("background-image", "block");
});
// scroll how it works
$(".step_level").click(function(e) {
e.preventDefault();
var aid = $(this).attr("href");
$('html,body').animate({scrollTop: $(aid).offset().top},'slow');
$(".stepListingsection").css({"padding-top":"100px"})
});
// scroll how it works
//slider start
$(".single-item").slick({
infinite: false,
autoplay:true,
// initialSlide: 1,
slidesToShow: 4,
slidesToScroll: 1,
// centerMode: true,
prevArrow: '<img src="images/food/food_image/slide_left.svg" class="left" style="width:42px;">',
nextArrow: '<img src="images/food/food_image/slide_right.svg" class="right" style="width:42px;">',
responsive: [
{
breakpoint: 1180,
settings: {
slidesToShow: 4
}
},
{
breakpoint: 850,
settings: {
slidesToShow: 2
}
},
{
breakpoint: 550,
prevArrow: false,
nextArrow: false,
settings: {
slidesToShow: 1.5
}
}
]
});
//slider end
//qty change
$('.minus').click(function () {
if ($(this).siblings('input').val() > $(this).data("min")) {
var $input = $(this).siblings('input');
var count = parseInt($input.val()) - 1;
count = count < 1 ? 1 : count;
$input.val(count);
$input.change();
return false;
}else{
swal({ text: "You cannot add less than 1 Quantity.",
showCloseButton: true
});
}
});
$('.plus').click(function () {
if ($(this).siblings('input').val() < $(this).data("max")) {
var $input = $(this).siblings('input');
$input.val(parseInt($input.val()) + 1);
$input.change();
return false;
}else{
swal({ text: "You cannot add more than 20 Quantity.",
showCloseButton: true
});
}
});
// qty change
// serving qty change
$('.add').click(function () {
if ($(this).prev().val() < 20) {
$(this).prev().val(+$(this).prev().val() + 1);
}else{
$('.add').attr('disabled','disabled');
}
});
$('.sub').click(function () {
if ($(this).next().val() > 1) {
$(this).next().val(+$(this).next().val() - 1);
$(".add").removeAttr("disabled");
}
});
// serving qty change
var i = 0;
$(".ingredientsListsub").each(function(i){
if(i%2==0){
$(this).addClass("redBox");
}
i++;
});
// Shop Ingregient button
$(".shopbtn").click(function(e) {
e.preventDefault();
var count = $(".countdata").attr('data-count');
if(count < 1){
swal({ text: "We are not delivering in this zipcode.",
showCloseButton: true
});
}else{
var aid = $(this).attr("href");
$('html,body').animate({scrollTop: $(aid).offset().top},'slow');
$(".productListSection").css({"margin-top":"100px"})
}
});
// Shop Ingregient button
// checkbox check
$(document).on('click', "#addchekListprodct", function() {
var prodList=[];
$('input.listChckPrdt:checkbox:checked').each(function(){
var prdId = $(this).attr('data-ChkPid');
prodList.push(prdId);
});
var i;
for(i=0; i< prodList.length;i++){
$("#prd_"+prodList[i])[0].click();
}
//window.location.href = window.location.href;
})
// checkbox check
// input change qty
$('.qty').on('change', function(){
var proId = $(this).attr('data-qChkPid');
var price = $(this).attr('data-sell');
var qty = $(this).val();
var total = qty*price;
$("#"+proId).attr('data-qty',qty);
// $("#"+proId).attr('data-price',total);
});
//input change qty
//logic for user n shop qty and unit match
$('.add').click(function(e){
var servingQty = $('.qtyS').val();
$(".productListMicro").each(function(){
var row_data = $(this).data("aid");
// var user_qty = $(this).data("userqty");
var list_size = $(this).data("listsize");
var single = $(this).data("single");
var qmulti = $('.qtyAdd').val();
var tQty = servingQty* single;
var qqty = Math.ceil(tQty / list_size);
if(tQty > list_size){
if(qqty >= 20){
$("[data-aid*="+row_data+"] .qtyAdd").val(20);
$("#"+row_data).attr('data-qty',20);
}else{
$("[data-aid*="+row_data+"] .qtyAdd").val(qqty);
$("#"+row_data).attr('data-qty',qqty);
}
}
});
})
$('.sub').click(function(e){
var servingQty = $('.qtyS').val();
console.log(servingQty);
$(".productListMicro").each(function(){
var row_data = $(this).data("aid");
// var user_qty = $(this).data("userqty");
var list_size = $(this).data("listsize");
var single = $(this).data("single");
var qmulti = $('.qtyAdd').val();
var tQty = servingQty* single;
// alert(tQty);
var qqty = Math.ceil(tQty / list_size);
// alert(qqty);
if(qqty>20){
qqty=20;
}
if(tQty > list_size){
$("[data-aid*="+row_data+"] .qtyAdd").val(qqty);
$("#"+row_data).attr('data-qty',qqty);
}else if(tQty < list_size){
$("[data-aid*="+row_data+"] .qtyAdd").val(1);
$("#"+row_data).attr('data-qty',1);
}
});
})
//logic for user n shop qty and unit match
/// checkbox count
$(".form-check-input").click(function(){
var x = $(".form-check-input:checked").length;
document.getElementById("count_selected").innerHTML = x;
});
/// checkbox count
//<------------------------------- recipe details page -------------------------------------->
})(jQuery);
Directory Contents
Dirs: 1 × Files: 76