Files
POST_ORDER_BY_ARCHIVE/js/apop-style.js
T
nobu c8f482a02d WP PLUGIN 修正(ファイル名・JS)
・ファイル名の綴りが間違っていたので修正
・通常ソートのリスト表示位置が、有効/無効切り替えで変わるようJSとテンプレートのPHPファイルを修正
2021-05-13 19:44:10 +09:00

191 lines
7.3 KiB
JavaScript

jQuery(function ($) {
//tab menu
change_tab_menu();
//custom orders
order_list();
//order type
change_sort_box();
//Tax select
select_tax();
//per page
change_search_per_page();
change_tax_per_page();
change_custom_field_sort();
change_normal_field_sort();
function change_tab_menu() {
let submit_type = $('.post-order-box-outer').data('submit_type');
let order_nav_list = $('.post-order-nav li');
let order_box = $('.post-order-box');
order_nav_list.removeClass('en');
order_box.hide();
$('.post-order-nav li:eq(' + submit_type + ')').addClass('en');
$('.post-order-box:eq(' + submit_type + ')').show()
order_nav_list.on('click', function () {
if (!$(this).hasClass('en')) {
let target_index = $(this).index();
order_nav_list.removeClass('en');
$(this).addClass('en');
order_box.hide();
$('.post-order-box:eq(' + target_index + ')').show();
}
});
}
function order_list() {
let cat_ul_count = $('.post-order-list').length; //カテゴリ総数
for (let i = 0; i < cat_ul_count; i++) {
let my_list = $('.post-order-list:eq(' + i + ')');
my_list.sortable(
{
update: function () {
let list_count = $('.product-list', my_list).length;
for (let j = 0; j < list_count; j++) {
let list_order = j + 1;
$('.list_order:eq(' + j + ')', my_list).val(list_order);
$('.list_order:eq(' + j + ')', my_list).siblings('.sort-num-label').text(list_order);
}
}
}
);
my_list.disableSelection();
}
}
function change_sort_box() {
let s_radio = $('.sort_menu');
let sort_menu_size = $('.sort_menu_list').length;
$('.sort_box').hide();
for (let i = 0; i < sort_menu_size; i++) {
let type_index = $('.sort_menu_list:eq(' + i + ')').data('order_target') - 1;
$('.sort_menu_list:eq(' + i + ')').siblings('.sort_box:eq(' + type_index + ')').show();
}
s_radio.on('click', function () {
let target_index = $(this).val() - 1;
$(this).parents('.list-orders-inner').find('.sort_box').hide();
$(this).parents('.list-orders-inner').find('.sort_box:eq(' + target_index + ')').show();
})
}
function select_tax() {
let select_cat_checkbox = $('.select_cat_checkbox');
let input_chk_size = select_cat_checkbox.length;
let i = 0;
for (i; i < input_chk_size; i++) {
let chk = $('.select_cat_checkbox:eq(' + i + '):checked').length;
if (chk == 1) {
$('.select_cat:eq(' + i + ')').siblings('.select_per_page').show();
} else {
$('.select_cat:eq(' + i + ')').siblings('.select_per_page').hide();
}
}
select_cat_checkbox.on('click', function () {
let checked = $(this).prop('checked');
if (checked) {
$(this).parent().parent().siblings('.select_per_page').show(200);
} else {
$(this).parent().parent().siblings('.select_per_page').hide(200);
}
});
}
function change_search_per_page() {
let per_page_cat = $('.per_page_search');
let per_page_input = $('.per_page_search_input');
if (per_page_input.val() == '') {
per_page_input.prop('disabled', true);
} else {
per_page_input.prop('disabled', false);
}
per_page_cat.on('click', function () {
if ($(this).val() != 'default' && $(this).val() != '-1' && $(this).val() != 'all') {
per_page_input.prop('disabled', false);
} else {
per_page_input.val('');
per_page_input.prop('disabled', true);
}
})
}
function change_tax_per_page() {
let set_number = $('.set_number');
let input_chk_size = set_number.length;
for (let i = 0; i < input_chk_size; i++) {
let input_num_box = $('.set_number:eq(' + i + ')').siblings('.per_page_cat_input');
if (input_num_box.val() == '') {
input_num_box.prop('disabled', true);
} else {
input_num_box.prop('disabled', false);
}
}
$('.per_page_cat').on('click', function () {
if ($(this).hasClass('set_number')) {
$(this).siblings('.per_page_cat_input').prop('disabled', false);
} else {
$(this).parents('li').find('.per_page_cat_input').val('').prop('disabled', true);
}
});
}
function change_custom_field_sort() {
let s_box = $('.sort_box');
let custom_field_check = $('.custom_field_check');
s_box.find(custom_field_check).each(function () {
if ($(this).prop('checked') == false) {
$(this).parents('.product-list-sort-type').find('.custom_field_key').prop('disabled', true);
$(this).parents('.product-list-sort-type').find('.custom_field_meta_value').prop('disabled', true);
}
});
custom_field_check.on('click', function () {
if ($(this).prop('checked') == true) {
$(this).parents('.product-list-sort-type').find('.custom_field_key').prop('disabled', false);
$(this).parents('.product-list-sort-type').find('.custom_field_meta_value').prop('disabled', false);
} else {
$(this).parents('.product-list-sort-type').find('.custom_field_key').val('').prop('disabled', true);
$(this).parents('.product-list-sort-type').find('.custom_field_meta_value').prop('disabled', true);
}
})
}
function change_normal_field_sort() {
let s_box = $('.sort_box');
let targets = '.custom_field_check, .sort_date_check, .sort_title_check, .sort_ID_check, .sort_modified_check';
s_box.find(targets).each(function () {
if ($(this).prop('checked') == false) {
$(this).parents('.product-list-sort-type').find('.order_param').prop('disabled', true);
let disable_list = $(this).parents('.sort_box').find('.disable_normal_list');
$(this).parents('li').appendTo(disable_list);
}
});
$(targets).on('click', function () {
if ($(this).prop('checked') == true) {
$(this).parents('.product-list-sort-type').find('.order_param').prop('disabled', false);
let enable_list = $(this).parents('.sort_box').find('.post-order-list');
$(this).parents('li').appendTo(enable_list).removeClass('no_order').hide().fadeIn(200);
} else {
$(this).parents('.product-list-sort-type').find('.order_param').prop('disabled', true);
let disable_list = $(this).parents('.sort_box').find('.disable_normal_list');
$(this).parents('li').appendTo(disable_list).addClass('no_order').hide().fadeIn(200);
}
});
}
});