$(document).ready(function () { /* 價錢篩選*/ // $('.nstSlider').nstSlider({ // "left_grip_selector": ".leftGrip", // "right_grip_selector": ".rightGrip", // "value_bar_selector": ".bar", // "highlight": { // "grip_class": "gripHighlighted", // "panel_selector": ".highlightPanel" // }, // "value_changed_callback": function(cause, leftValue, rightValue) { // $('.leftLabel').text(leftValue); // $('.rightLabel').text(rightValue); // }, // }); // Call methods and such... // var highlightMin = Math.random() * 20, // highlightMax = highlightMin + Math.random() * 80; // $('.nstSlider').nstSlider('highlight_range', highlightMin, highlightMax); /* 價錢篩選end*/ if($("#picSlides .picItem").length>1){ $("#picSlides").owlCarousel({ autoplay: true, autoplayTimeout: 5000, items : 1, loop : true, responsive: { 0: { dots: false, nav : false, }, 1025: { dots: true, nav : true, }, } }); } $('.filterbox').ontouchmove = function(event){ event.preventDefault(); } var _window = $(window); var _body = $('body'); var change_1023 = 0; var productSlidebox = $(".productSlidebox"); if(_window.width() <= 1023 && change_1023 != 1023){ change_1023 = 1023; $('#filtercontrol-2,#filtercontrol-3,#filtercontrol-4').attr('checked',true); }else if(_window.width() > 1023 && change_1023 != 1200){ change_1023 = 1200; productSlidebox.owlCarousel({ loop : true, items : 1, nav : true, }); } _window.on('resize',function(){ if(_window.width() <= 1023 && change_1023 != 1023){ change_1023 = 1023; $('#filtercontrol-2,#filtercontrol-3,#filtercontrol-4').attr('checked',true); productSlidebox.trigger('destroy.owl.carousel').removeClass('owl-carousel owl-loaded'); productSlidebox.find('.owl-stage-outer').children().unwrap(); }else if(_window.width() > 1023 && change_1023 != 1200){ change_1023 = 1200; productSlidebox.owlCarousel({ loop : true, items : 1, nav : true, }); $('#filtercontrol-2,#filtercontrol-3,#filtercontrol-4').removeAttr('checked'); } }); var clickbutton=0; $('.filter-button,.filterbox .close').on('click',function(){ clickbutton++; if(clickbutton==1){ $('.filterbox').css({'top':'50px'}); } if(clickbutton==2){ $('.filterbox').css({'top':'-100%'}); clickbutton=0; } }); $('#viewMode .view-three').on('click',function(){ // console.log('message'); $('#viewMode .view-three').addClass('now'); $('#viewMode .view-four').removeClass('now'); $('.content').removeClass('view-four').addClass('view-three hide-back'); $('.content .warpper').show(); setTimeout(function(){ $('.content').removeClass('hide-back'); $('#filtercontrol-2,#filtercontrol-3,#filtercontrol-4').attr('checked',true); productSlidebox.trigger('destroy.owl.carousel').removeClass('owl-carousel owl-loaded'); productSlidebox.find('.owl-stage-outer').children().unwrap(); productSlidebox.owlCarousel({ loop : true, items : 1, nav : true, navText:["",""], }); $('#filtercontrol-2,#filtercontrol-3,#filtercontrol-4').removeAttr('checked'); },380); }); $('#viewMode .view-four').on('click',function(){ $('#viewMode .view-four').addClass('now'); $('#viewMode .view-three').removeClass('now'); $('.content').removeClass('view-three').addClass('view-four hide-back'); // $('.content .warpper').hide(); setTimeout(function(){ $('.content').removeClass('hide-back'); $('#filtercontrol-2,#filtercontrol-3,#filtercontrol-4').attr('checked',true); productSlidebox.trigger('destroy.owl.carousel').removeClass('owl-carousel owl-loaded'); productSlidebox.find('.owl-stage-outer').children().unwrap(); productSlidebox.owlCarousel({ loop : true, items : 1, nav : true, navText:["",""], }); $('#filtercontrol-2,#filtercontrol-3,#filtercontrol-4').removeAttr('checked'); },380); }); $(".newbox").find(function(){ $(".newitem").parents("#newlist").prevAll("#newTitle").removeAttr('checked') }) }); ;(function($){ let main = $("main") let body = $("body") $(document).on('click', '.filter-toggle', function(e) { if(main.hasClass("aside-open")){ body.removeClass("overflow-hidden") main.removeClass("aside-open") }else{ body.addClass("overflow-hidden") main.addClass("aside-open") } }) $(document).on('click', '.aside-closer, .left-aside', function(e) { if($(e.target).closest(".aside-closer").length || $(e.target).hasClass("left-aside")){ main.removeClass("aside-open") body.removeClass("overflow-hidden") } }) })($) // ========================================================== // 手機版排序區塊 // ========================================================== ;(function($) { function sortStepCheck(jqElement, step, className) { if(step) { jqElement.addClass(className) } else { jqElement.removeClass(className) } } let sortStep = 0 // 排序功能開關 $('#Main_Content').on('click', '.select-title', function(e) { sortStep = (sortStep + 1) % 2 sortStepCheck($(this).parents('.mobile-select'), sortStep, 'open-click') }) // 排序項目選擇 $('#Main_Content').on('click', '.option-list-item', function(e) { const targetText = $(this).text() const targetValue = $(this).data('value') $(this).parents('.mobile-select').find('.select-title').text(targetText) sortStep = 0 sortStepCheck($('.mobile-select'), sortStep, 'open-click') $('#orderbox').val(targetValue) $(`.option-list-item[data-value="${targetValue}"]`).addClass('in-checked').siblings('.option-list-item').removeClass('in-checked') console.log($('#orderbox').val()) $('#orderbox').val(targetValue); $('#orderbox').trigger('change'); }) })($) // ========================================================== // filter group 開關 // ========================================================== ;(function($) { $('#Main_Content').on('click', '.filter-title', function(e) { $(this).parents('.filter-group:not(.checked-group)').toggleClass('in-open'); }) })($) // ========================================================== // 篩選器挑選功能 // ========================================================== ;(function($) { let deviceType = '' const filterArray = [] function filterCount(array, selector) { const arrayAmount = array.length $(selector).text(arrayAmount) } function filterTags(array, wrapper, className) { $(wrapper).empty() array.forEach((item, i) => { const itemEle = `