require('hc-offcanvas-nav/dist/hc-offcanvas-nav'); function CopyToClipboard(containerid) { if (window.getSelection) { if (window.getSelection().empty) { // Chrome window.getSelection().empty(); } else if (window.getSelection().removeAllRanges) { // Firefox window.getSelection().removeAllRanges(); } } else if (document.selection) { // IE? document.selection.empty(); } if (document.selection) { var range = document.body.createTextRange(); range.moveToElementText(document.getElementById(containerid)); range.select().createTextRange(); document.execCommand("copy"); } else if (window.getSelection) { var range = document.createRange(); range.selectNode(document.getElementById(containerid)); window.getSelection().addRange(range); document.execCommand("copy"); } alertify.success('کپی شد'); } function commafy(num) { var str = num.toString().split('.'); if (str[0].length >= 4) { str[0] = str[0].replace(/(\d)(?=(\d{3})+$)/g, '$1,'); } if (str[1] && str[1].length >= 4) { str[1] = str[1].replace(/(\d{3})/g, '$1,'); } return str.join('.'); } let qnn, images, sizes; jQuery(function ($) { try { var Nav = new hcOffcanvasNav('#main-nav', { disableAt: 300000, customToggle: '.toggle', navTitle: document.title, levelTitles: true, rtl: true, position: 'right', levelTitleAsBack: true }); } catch(e) { console.log(e.message); } try { $(".xzoom, .xzoom-gallery").xzoom({tint: '#333', Xoffset: 15}); } catch(e) { console.log(e.message); } $(window).on('load', function () { setTimeout(function () { $('#preloader').slideUp(700); let max = 150 ; for( const b of $(".box")) { if ($(b).height() > max ){ max= $(b).height(); } } $('.box').height(max); $("#favs .box").removeAttr('style'); }, 100); }); setTimeout(function () { $('#preloader').slideUp(700); }, 100); setTimeout(function () { $('#preloader').slideUp(700); }, 10000); $("#toggle-side").bind('click', function () { $('aside > div').slideToggle(300); }); $('.owl1').owlCarousel({ loop: true, margin: 0, responsiveClass: true, // autoplay: true, autoplayTimeout: 5000, autoplayHoverPause: true, item: 5, responsive: { 0: { nav: false, items: 2, }, 600: { items: 2, nav: false, loop: false }, 1000: { items: 3, nav: false, loop: false }, 1300: { items: 5, nav: false, loop: false } } }); $('#owl2').owlCarousel({ loop: true, margin: 0, responsiveClass: true, autoplay: true, autoplayTimeout: 5000, autoplayHoverPause: true, items: 1, }); $('#thumbs').owlCarousel({ loop: false, margin: 4, responsiveClass: true, autoplay: true, autoplayTimeout: 5000, autoplayHoverPause: true, items: 4, // nav: true, }); $('#owlx1').owlCarousel({ loop: true, margin: 15, responsiveClass: true, autoplay: true, autoplayTimeout: 5000, autoplayHoverPause: true, responsive: { 0: { nav: false, items: 1, }, 600: { items: 2, nav: false, loop: false }, 1000: { items: 3, nav: false, loop: false }, 1300: { items: 4, nav: false, loop: false } } }); $('#owl3').owlCarousel({ loop: false, margin: 0, responsiveClass: true, autoplay: true, autoplayTimeout: 5000, autoplayHoverPause: true, items: 1, }); $('.owl-sq').owlCarousel({ loop: true, margin: 0, responsiveClass: true, autoplay: true, autoplayTimeout: 5000, responsive: { 0: { items: 2, nav: false }, 600: { items: 2, }, 1000: { items: 3, }, 1300: { items: 6, } } }); $("#cp-deteail").bind('click',function () { CopyToClipboard('tab-analyze'); }); var axiosError = function (err) { if (err.response.status == 401) { alertify.error('Authenticnation Error'); // window.location.href = '/#/login'; } else if (err.response.status == 422) { // console.log(err.response.data.errors); for (const k in err.response.data.errors) { let er = err.response.data.errors[k]; console.log(er); alertify.error(k + ' : ' + er[0]); } } else { alertify.error('Error' + err.response.status + ': ' + err.response.data.message); } } $("#filtering .btn").bind('click', function () { $("#filtering .btn").removeClass('active'); $(this).addClass('active'); let cls = $(this).data('cat'); if (cls == 'all') { $("#da-thumbs .item").slideDown(900); } else { $("#da-thumbs .item").slideUp(600, function () { setTimeout(function () { $("#da-thumbs .item." + cls).slideDown(513); }, 100); }); } }); $(".fav").bind('click',function () { let url = $("#fav-toggle").val()+'/'+$(this).data('id'); let self = this; axios.get(url).then(function (e) { if (e.data.OK){ alertify.success(e.data.msg); if (e.data.liked){ $(self).addClass('liked'); }else{ $(self).removeClass('liked'); } }else{ alertify.error(e.data.msg); } }); }); $("#question-send").bind('click', function () { let data = {}; for (const d of $("#question-form").serializeArray()) { data[d.name] = d.value; } axios.post($(this).data('url'), data).then(function (e) { if (e.data.OK) { alertify.success(e.data.msg); $(".comment-containerx").text(e.data.msg); } }).catch(function (e) { axiosError(e); }); }); $(".xsumbmiter").submit(function () { $(this).attr('action', $("#smt").val()); }); $(".comment-reply").click(function () { $('#reply').remove(); var pid = $(this).data('id'); $("#comment-form-body").append("")); $("#comment-message").focus(); }); $(".add-to-card").click(function (e) { e.preventDefault(); axios.get($(this).attr('href')).then(function (e) { $("#card-count").text(e.data.data); window.alertify.message(e.data.msg); if (e.data.data > 0) { $("#card-info").fadeIn(400); } }); }); $(".add-to-card-q").click(function (e) { e.preventDefault(); axios.get($(this).attr('href') + '/' + $("#qn").val()+'/'+$("#single-count").val()).then(function (e) { $("#card-count").text(e.data.data); window.alertify.message(e.data.msg); if (e.data.data > 0) { $("#card-info").fadeIn(400); } }); }); $("#addon-wrapping").bind('click', function () { let q = $("#searching").val(); window.location.href = $("#searching").data('url') + '?q=' + q; return true; }); $("#searching").bind('keyup', function (e) { let q = $(this).val(); if (e.key === 'Enter') { window.location.href = $(this).data('url') + '?q=' + q; return true; } if (q.length < 3) { return 0; } let offset = $(this).offset(); offset.width = ($(this).width() + 85) + 'px'; offset.left -= 50; offset.top += 45; $("#search-list").css(offset).slideDown(100); let text = ''; let self = this; $("#search-list").html(text + '