Skip to content

Instantly share code, notes, and snippets.

@tinybeans
Created Apr 16, 2020
Embed
What would you like to do?
MTAppInCats と MTAppTabs の組み合わせの代替案
(function($){
// $.MTAppCategorySwitch({
// selector: {
// 'init': '#title-field',
// 'hide':
// '#text-field,#excerpt-field,#customfield_entryogimage-field,#customfield_entryeyecatch-field,#customfield_entryappendix-field,#customfield_entrycontact-field,#customfield_entrylinkurl-field',
// 'cat49':
// '#title-field,#text-field,#excerpt-field,#customfield_entryogimage-field,#customfield_entryeyecatch-field,#customfield_entryappendix-field,#customfield_entrycontact-field',
// 'cat50':
// '#title-field,#text-field,#excerpt-field,#customfield_entryogimage-field,#customfield_entryeyecatch-field,#customfield_entryappendix-field,#customfield_entrycontact-field',
// 'cat51':
// '#title-field,#text-field,#excerpt-field,#customfield_entryogimage-field,#customfield_entryeyecatch-field,#customfield_entrylinkurl-field',
// }
// });
const $body = $('body');
const $selectedCategory = $('#category-ids');
const noSelectedCategoryClass = 'no-selected-category'
if (mtappVars.selected_category.length === 0) {
$body.addClass(noSelectedCategoryClass);
}
setCookie('categoryType01', 'no', 365);
$('#category-field').on('click', ':checkbox', function () {
window.setTimeout(function () {
const selectedCategories = $selectedCategory.val().split(',');
if (selectedCategories.length === 0 || selectedCategories[0] === '') {
$body.addClass(noSelectedCategoryClass);
}
else {
$body.removeClass(noSelectedCategoryClass);
}
const categoryType01 = getCookie('categoryType01');
if ($.inArray('49', selectedCategories) !== -1 || $.inArray('50', selectedCategories) !== -1) {
if (categoryType01 === 'no') {
$body.addClass('categoryType01');
$.MTAppTabs({
basename: {
"excerpt": "meta description",
"cf_entryogimage": "OGP 画像",
"cf_entryeyecatch": "アイキャッチ画像",
},
pointer: '#text-field',
insert: 'before',
});
$.MTAppTabs({
basename: {
"cf_entryappendix": "解説文",
"cf_entrycontact": "お問い合わせ先"
},
pointer: '#text-field',
insert: 'after',
});
$.MTAppApplyTinyMCE({
target: ['customfield_entryappendix', 'customfield_entrycontact'],
sortable: false
});
setCookie('categoryType01', 'yes', 365);
}
}
else if (categoryType01 === 'yes') {
if (confirm('画面をリフレッシュしてよろしいですか?')) {
location.reload();
}
}
}, 200);
});
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment