Loading...
// section filter product js
$('#filter_range .input-group .input-group-text').text('تا');
// filter section js code
$("#filter_brand >label").click(function(){
$(this).toggleClass("show-ul");
$(".brands_list").slideToggle("fast");
});
$("#filter_pages >label").click(function(){
$(this).toggleClass("show-ul");
$(".filter_pages").slideToggle("fast");
});
$(".filter_status >label").click(function(){
$(this).toggleClass("show-ul");
$(".radio_list").slideToggle("fast");
});
$('.mode_mobile .search-mob').on("click", function() {
$(this).toggleClass('active');
});
$(".filter-custom >div >label").click(function(){
$(this).toggleClass("show-ul");
$(this).siblings("div .checkboxes ").slideToggle("slow");
});
$(".mode_mobile #filter_search >label").click(function(){
$(this).toggleClass("show-ul");
$(".mode_mobile #filter_search .form-control").slideToggle("fast");
});
$(".mode_mobile #filter_range label").click(function(){
$(this).toggleClass("show-ul");
$(".mode_mobile #filter_range div:nth-child(2)").slideToggle("fast");
});
new WOW().init();
$("#gotop").click(function(event) {
event.preventDefault();
window.scroll({ top: 0, left: 0, behavior: 'smooth' });
// $("html,body").stop().animate({ scrollTop: "0" }, 1000);
});
var n = $(window).width();
$(window).scroll(function() {
var t = 800 > n && $(window).scrollTop() + $(window).height() >= $(document).height() - 90;
$(window).scrollTop() >= 600 && !t ? $("#gotop").addClass("active").removeClass("deactive").fadeIn(500) : $("#gotop").addClass("deactive").removeClass("active").fadeOut(500);
});
var current_request = null;
var search_ms = 0;
var search_min_length = 2;
var timer;
$(".live-search").after("").keyup(function() {
clearTimeout(timer);
var keyword = this.value;
if (keyword.length >= search_min_length) {
current_request = $.ajax({
type: "get",
url: '/api/system/livesearch',
cache:true,
data: {q:keyword,ajax:1} ,
beforeSend : function() {
if(current_request != null) {
current_request.abort();
}
},
success: function(data){
$('.live-result').html('');
var results = jQuery.parseJSON(data);
$(results).each(function(key, value) {
img = (value.image) ? "
":"";
$('.live-result').append(''+img+"" + (value.type ? value.type+": ":"") + '' + value.title +'');
});
$('.live-result li a').click(function() {
if($(this).attr('href') != '#'){
loading(1);
$('.live-search').val($(this).text());
}
});
}
});
} else {
$('.live-result').html('');
}
}).blur(function(){
$(".live-result").fadeOut(500);
}).focus(function() {
$(".live-result").show();
});
$(document).on("click",'.user-toggle',function (event) {
$('.user-menu').slideToggle('fast').toggleClass('active');
$('.basket-menu').slideUp('fast').removeClass('active');
}).on("click","html",function (event) {
if($('.user-menu').hasClass('active')){
$('.user-menu').slideToggle('fast').removeClass('active');
}
}).on("click",".user-menu,.user-toggle",function (event) {
event.stopPropagation();;
});
var rating_nano = 'https://mahfamobile.ir/nano/comment';
$('.rating').rating({
// theme: 'krajee-fa',
filledStar: '',
emptyStar: '',
// clearButton: '',
'min':1,
'max':5,
'step':1,
'stars': 5,
'showClear': false,
'showCaption': false
}).on('rating:change', function(event, value, caption) {
// console.log(value);
var _this = $(this);
var rate_id = $(this).data('id');
loading(1);
$.ajax({
type: 'POST',
url: rating_nano,
data: {
rate_post:rate_id,
rate:value
},
success: function(data){
loading(0);
if(data.error > 0){
if(data.disable === true){
_this.rating('refresh', {
disabled: true
});
}
alert(data.message);
return false;
}
_this.rating('update', data.rate).rating('refresh', {
disabled: true
});
alert(data.message);
}
});
});
$(document.body).on('click', '.btn-wishlist' , function() {
loading(1);
$.ajax({
type: 'POST',
url: 'https://mahfamobile.ir/nano/comment',
data: {wishlist:$(this).attr('data-id')},
success: function(data){
eval(data);
loading(0);
},
error: function( objAJAXRequest, strError ){
alert(strError);
loading(0);
}
});
});
if(typeof tooltip === "function"){
$('[data-toggle="tooltip"]').tooltip();
}
$(document).on("click",'.btn-dialog',function (event) {
event.preventDefault();
var _this = $(this);
if(_this.hasClass('is-loading')){
return;
}else{
_this.addClass('is-loading');
}
loading(1);
$.ajax({
type: "GET",
url: $(this).attr('href'),
data:{dialog:true, _go:'https://mahfamobile.ir/other-accessories/travel-equipment?page=12'},
success: function(data){
eval(data);
setTimeout(() => {
_this.removeClass('is-loading');
}, 100);
loading(0);
}
});
});
});