Eshop-Laravel/public/js/script.js
2019-10-18 12:25:37 +03:00

93 lines
1.6 KiB
JavaScript

String.prototype.permalink = function (){
return this.toString().trim().toLowerCase().replace(/\s/g ,'-');
};
$('.origin_text').on('keyup',function (){
$('.target-text').val($(this).val().permalink());
})
$('div.sm-box').delay(3000).slideUp();
var q = $('.quantity-no').attr('value');
var size = 'small';
// var currentPrice = $('span._current').text();
function getDay(data) {
alert(data)
}
$('.add-to-cart-btn').on('click', function() {
var quantity = $('.quantity-no').attr('value');
if (quantity) {
var _id = $(this).data('id');
$.ajax({
url: BASE_URL + "shop/add-to-cart",
type: "GET",
dataType: "html",
data: {
id: _id,
quantity: quantity,
size: size
},
success: function(data) {
location.reload();
}
});
} else {
return
}
});
//
$('.bs-select').change(function() {
size = $(this).find(':selected').text();
console.log(size);
});
$('.update-cart').on('click', function() {
$.ajax({
url: BASE_URL + "shop/update-cart",
type: "GET",
dataType: "html",
data: {
id: $(this).data('id'),
op: $(this).val()
},
success: function(data) {
location.reload();
}
});
});
$('.icon-close').click(function() {
$('.quantity-no').attr('value', 1);
console.log('here');
})
$('.dec-btn').click(function() {
if (q > 0) {
q--;
$('.quantity-no').attr("value", q);
console.log($('.quantity-no').attr('value'));
}
})
$('.inc-btn').on('click', function() {
++q;
$('.quantity-no').attr("value", q);
console.log($('.quantity-no').attr('value'));
})