$(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({
loop : true,
items : 1,
});
}
$('.filterbox').ontouchmove = function(event){
event.preventDefault();
}
var _window = $(window);
var _body = $('body');
var change_1023 = 0;
var productSlidebox = $(".productSlidebox");
$('#viewMode .view-three').on('click',function(){
// console.log('message');
$('#viewMode .view-three').addClass('now');
$('#viewMode .view-four').removeClass('now');
$('main').removeClass('view-four').addClass('view-three hide-back');
setTimeout(function(){
$('main').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');
},150);
});
$('#viewMode .view-four').on('click',function(){
$('#viewMode .view-four').addClass('now');
$('#viewMode .view-three').removeClass('now');
$('main').removeClass('view-three').addClass('view-four hide-back');
setTimeout(function(){
$('main').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');
},150);
});
$(".newbox").find(function(){
$(".newitem").parents("#newlist").prevAll("#newTitle").removeAttr('checked')
})
//排序 顯示數量等
$(document).on("click", ".select-now", function(){
let wrapper = $(this).parents(".select-wrapper")
if(wrapper.hasClass("open")){
wrapper.removeClass("open")
}else{
wrapper.addClass("open")
}
$(document).on("click", disposableClick)
function disposableClick(){
wrapper.removeClass("open")
$(document).off("click", disposableClick)
}
})
$(document).on("click", ".select-group .select-item", function(){
let wrapper = $(this).parents(".select-wrapper"),
text = $(this).text()
if(!$(this).hasClass("checked")){
wrapper.find(".checked").removeClass("checked")
if($(this).data("val")){
$(this).addClass("checked")
}
}
wrapper.find(".select-now").text(text)
})
//開啟快速購物彈窗
$('#Main_Content').on('click','.galleryButton,.Add_Button1,.index-buyButton,.selectbox-button',function(){
var pty = $(this).attr('pty');
var sid = $(this).attr('SID');
var flag=1;
if(pty == 3 || pty == 4){
$.ajax({
url:"/ajax/ajax_act_check.php",
type:"POST",
data:{sid:sid},
dataType: 'json',
async: false,
error:function(d){
// alert('網路連線過慢,網頁請重新整理');
},
success:function(d){
if(d.Status == "OK"){
flag = '2';
window.location.href=d.Url;
}
}
});
}
});
//手機版上方操作橫欄
let backWrapper = $(".toptitle-popup-wrapper"),
toptitleBtnM = $(".toptitle-mobile-btn"),
targetOrder = $("#topTitle #viewControl"),
targetBrand = $("#topTitle #menuList"),
body = $("body")
function toptitleMobileClose(){
body.removeClass("overflow-hidden")
backWrapper.removeClass("open")
toptitleBtnM.removeClass("open")
targetOrder.removeClass("open")
targetBrand.removeClass("open")
}
toptitleBtnM.on("click", function(){
let index = $(this).data("index")
if($(this).hasClass("open")){
toptitleMobileClose()
}else{
body.addClass("overflow-hidden")
backWrapper.addClass("open")
toptitleBtnM.removeClass("open")
$(this).addClass("open")
if(index == "order"){
targetBrand.removeClass("open")
targetOrder.addClass("open")
}else if(index == "brands"){
targetOrder.removeClass("open")
targetBrand.addClass("open")
}
}
})
backWrapper.on("click", function(e){
if($(e.target).hasClass("toptitle-popup-wrapper")){
toptitleMobileClose()
}
})
$(".filterbox-check-btn").on("click", function(){
toptitleMobileClose()
})
});