plugin updates

This commit is contained in:
Tony Volpe
2024-06-17 15:33:26 -04:00
parent 3751a5a1a6
commit e4e274a9a7
2674 changed files with 0 additions and 507851 deletions

View File

@@ -1,704 +0,0 @@
/* eslint-env jquery */
(function ($) {
$(window).on('load', function () {
$(
'.aiosrs-pro-custom-field.aiosrs-pro-custom-field-repeater .aiosrs-pro-repeater-table-wrap'
).hide();
$(
'.aiosrs-pro-custom-field.aiosrs-pro-custom-field-repeater .bsf-repeater-add-new-btn'
).hide();
$(
'.aiosrs-pro-custom-field.aiosrs-pro-custom-field-repeater-target .aiosrs-pro-repeater-table-wrap'
).hide();
$(
'.aiosrs-pro-custom-field.aiosrs-pro-custom-field-repeater-target .bsf-repeater-add-new-btn'
).hide();
});
$(document).ready(function () {
const { __ } = wp.i18n;
$('#wpsp-reset-dialog-confirmation').dialog({
dialogClass: 'wp-dialog',
autoOpen: false,
modal: true,
});
// Added support to repeater validation.
$(
'.wpsp-custom-field-connect, .wpsp-field-close, .bsf-aiosrs-schema-meta-field, image-field-wrap, .aiosrs-pro-custom-field, .wpsp-custom-field-connect'
).on('click focus change', function () {
$('.wpsp-local-fields').each(function (index, repeater) {
let fieldValue = $(repeater)
.find('.wpsp-default-hidden-value')
.val();
const requiredPath = $(repeater)
.parents('.bsf-aiosrs-schema-row-content')
.prev();
fieldValue = fieldValue.trim();
if (fieldValue) {
if ($('body').hasClass('block-editor-page')) {
if (
!$(repeater).find('.wpsp-required-error-field')
.length
) {
let metaField;
switch (fieldValue) {
case 'post_title':
metaField = $(
'.editor-post-title__input'
).val();
break;
case 'post_content':
metaField =
$(
'p.block-editor-rich-text__editable'
).text().length > 1
? $(
'p.block-editor-rich-text__editable'
).text()
: '';
break;
case 'post_excerpt':
metaField = $(
'.components-textarea-control__input'
).val();
break;
case 'featured_img':
if (
'Set featured image' ===
$(
'.editor-post-featured-image__toggle'
).text()
) {
metaField = '';
} else {
metaField = $(
'.components-responsive-wrapper__content'
).attr('src');
}
break;
default:
requiredPath.removeClass(
'wpsp-required-error-field'
);
}
if (undefined !== metaField) {
if ('' !== metaField) {
requiredPath.removeClass(
'wpsp-required-error-field'
);
} else if (
requiredPath.find('.required').length
) {
requiredPath.addClass(
'wpsp-required-error-field'
);
}
}
}
} else {
requiredPath.removeClass('wpsp-required-error-field');
}
} else if (requiredPath.find('.required').length) {
requiredPath.addClass('wpsp-required-error-field');
}
});
});
$('.wpsp-show-repeater-field').click(function () {
const parent = $(this).parents(
'.aiosrs-pro-custom-field-repeater'
);
parent.find('.aiosrs-pro-repeater-table-wrap').show();
parent.find('.bsf-repeater-add-new-btn').show();
parent.find('.wpsp-show-repeater-field').addClass('bsf-hidden');
parent
.find('.wpsp-hide-repeater-field')
.removeClass('bsf-hidden');
});
$('.wpsp-hide-repeater-field').click(function () {
const parent = $(this).parents(
'.aiosrs-pro-custom-field-repeater'
);
parent.find('.aiosrs-pro-repeater-table-wrap').hide();
parent.find('.bsf-repeater-add-new-btn').hide();
parent.find('.wpsp-hide-repeater-field').addClass('bsf-hidden');
parent
.find('.wpsp-show-repeater-field')
.removeClass('bsf-hidden');
});
$('.wpsp-show-repeater-target-field').click(function () {
const parent = $(this).parents(
'.aiosrs-pro-custom-field-repeater-target'
);
parent.find('.aiosrs-pro-repeater-table-wrap').show();
parent.find('.bsf-repeater-add-new-btn').show();
parent
.find('.wpsp-show-repeater-target-field')
.addClass('bsf-hidden');
parent
.find('.wpsp-hide-repeater-target-field')
.removeClass('bsf-hidden');
});
$('.wpsp-hide-repeater-target-field').click(function () {
const parent = $(this).parents(
'.aiosrs-pro-custom-field-repeater-target'
);
parent.find('.aiosrs-pro-repeater-table-wrap').hide();
parent.find('.bsf-repeater-add-new-btn').hide();
parent
.find('.wpsp-hide-repeater-target-field')
.addClass('bsf-hidden');
parent
.find('.wpsp-show-repeater-target-field')
.removeClass('bsf-hidden');
});
$('input[type="checkbox"].wpsp-enable-schema-toggle__input').on(
'click',
function () {
const parent = $(this).parents(
'.wpsp-enable-schema-markup'
);
const thisVal = $(this).val();
const togglebtn = parent.find('.wpsp-enable-schema-toggle');
const togglehid = parent.find(
'.wpsp-enable-schema-toggle__input-hidden'
);
const isChecked = togglebtn.hasClass('is-checked');
if (!isChecked && '1' === thisVal) {
togglehid.attr('value', '1');
togglebtn.addClass('is-checked');
} else {
togglehid.attr('value', 'disabled');
togglebtn.removeClass('is-checked');
}
}
);
$(document).on('change click', function () {
$('.wpsp-local-fields')
.find('select, textarea, input')
.on('change keyup', function (event) {
if (
event.isTrigger &&
!$(this).hasClass('wpsp-specific-field') &&
!$(this).hasClass('wpsp-date-field')
) {
return false;
}
const parent = $(this).parents('.wpsp-local-fields');
parent
.find('.wpsp-default-hidden-value')
.val($(this).val());
parent
.find('.wpsp-default-hidden-fieldtype')
.val(
$(this)
.parents('.wpsp-parent-field')
.attr('data-type')
);
if (
$(this).is('select') &&
$(this).parent().hasClass('wpsp-connect-field')
) {
const selectedOption = $(this).val();
if (
'create-field' === selectedOption ||
'specific-field' === selectedOption
) {
if ('create-field' === selectedOption) {
displayCustomField(parent);
parent
.find('.wpsp-default-hidden-fieldtype')
.val('custom-field');
}
if ('specific-field' === selectedOption) {
displaySpecificField(parent);
parent
.find('.wpsp-default-hidden-fieldtype')
.val('specific-field');
}
parent
.find('.wpsp-default-hidden-value')
.val('');
}
}
});
$('select.bsf-aiosrs-schema-meta-field').change(function () {
const parent = $(this).parents('.wpsp-local-fields');
const label = parent.find('select option:selected').html();
const selectedOption = $(this).val();
if (
'none' === selectedOption ||
'create-field' === selectedOption ||
'specific-field' === selectedOption
) {
parent
.find('.bsf-aiosrs-schema-heading-help')
.attr(
'title',
'Please connect any field to apply in the Schema Markup!'
);
} else {
parent
.find('.bsf-aiosrs-schema-heading-help')
.attr(
'title',
'The ' +
label +
' value in this field will be added to the schema markup of this particular post/page.'
);
}
});
function displaySpecificField(parent) {
parent.find('.wpsp-connect-field,.wpsp-custom-field').hide();
parent
.find('.wpsp-specific-field')
.removeClass('bsf-hidden')
.show()
.find('select, textarea, input')
.val('');
}
function displayCustomField(parent) {
parent
.find('.wpsp-connect-field,.wpsp-specific-field')
.hide();
parent
.find('.wpsp-custom-field')
.removeClass('bsf-hidden')
.show()
.find('select, textarea, input')
.val('');
}
$(document).on('click', '.wpsp-field-close', function () {
const parent = $(this).parents('.wpsp-local-fields');
const select = parent
.find('.wpsp-connect-field')
.removeClass('bsf-hidden')
.show()
.find('select')
.removeAttr('disabled');
const selectVal = select.val();
if ('specific-field' === selectVal) {
parent.find('.wpsp-default-hidden-value').val('');
parent
.find('.wpsp-default-hidden-fieldtype')
.val('specific-field');
displaySpecificField(parent);
return;
}
parent.find('.wpsp-default-hidden-value').val('');
parent
.find('.wpsp-default-hidden-fieldtype')
.val('custom-field');
displayCustomField(parent);
});
$(document).on(
'click',
'.wpsp-specific-field-connect, .wpsp-custom-field-connect',
function () {
const parent = $(this).parents('.wpsp-local-fields');
const select = parent
.find('.wpsp-connect-field')
.removeClass('bsf-hidden')
.show()
.find('select')
.removeAttr('disabled');
let selectVal = select.val();
if (
'create-field' === selectVal ||
'specific-field' === selectVal
) {
selectVal = 'none';
}
parent
.find('.wpsp-default-hidden-value')
.val(selectVal);
parent
.find('.wpsp-default-hidden-fieldtype')
.val('global-field');
parent
.find('.wpsp-custom-field, .wpsp-specific-field')
.hide();
}
);
});
$(document).on('change input', '.bsf-rating-field', function () {
const starWrap = $(this).next('.aiosrs-star-rating-wrap'),
value = $(this).val();
let filled = value > 5 ? 5 : parseInt(value);
if (value > 5) {
filled = 5;
} else if (value < 0) {
filled = 0;
} else {
filled = parseInt(value);
}
const half = value === filled || value > 5 || value < 0 ? 0 : 1;
starWrap.find('span').each(function (index) {
$(this).removeClass(
'dashicons-star-filled dashicons-star-half dashicons-star-empty'
);
if (index < filled) {
$(this).addClass('dashicons-star-filled');
} else if (index === filled && half === 1) {
$(this).addClass('dashicons-star-half');
} else {
$(this).addClass('dashicons-star-empty');
}
});
});
$(document).on(
'click',
'.aiosrs-star-rating-wrap:not(.disabled) > .aiosrs-star-rating',
function (e) {
e.preventDefault();
const index = $(this).data('index');
const starWrap = $(this).parent();
const parent = $(this).parents('.wpsp-local-fields');
starWrap.prev('.bsf-rating-field').val(index);
parent.find('.wpsp-default-hidden-value').val(index);
starWrap.find('.aiosrs-star-rating').each(function (i) {
$(this).removeClass(
'dashicons-star-filled dashicons-star-half dashicons-star-empty'
);
if (i < index) {
$(this).addClass('dashicons-star-filled');
} else {
$(this).addClass('dashicons-star-empty');
}
});
}
);
$(document).on(
'change',
'#aiosrs-pro-custom-fields .aiosrs-pro-custom-field-checkbox input[type="checkbox"]',
function (e) {
e.preventDefault();
const siblings = $(this)
.closest('tr.row')
.siblings('tr.row');
if ($(this).prop('checked')) {
siblings.show();
} else {
siblings.hide();
}
}
);
$(
'#aiosrs-pro-custom-fields .aiosrs-pro-custom-field-checkbox input[type="checkbox"]'
).trigger('change');
$(document.body).on(
'change',
'#aiosrs-pro-custom-fields .wpsp-enable-schema-markup input[type="checkbox"].wpsp-enable-schema-toggle__input',
function (e) {
e.preventDefault();
const parent = $(this).parents(
'.wpsp-enable-schema-markup'
);
if ($(this).prop('checked')) {
parent
.find('.wpsp-enable-schema-toggle')
.addClass('is-checked');
parent
.find('.wpsp-enable-schema-toggle__input-hidden')
.attr('value', '1');
} else {
parent
.find('.wpsp-enable-schema-toggle')
.removeClass('is-checked');
parent
.find('.wpsp-enable-schema-toggle__input-hidden')
.attr('value', 'disabled');
}
}
);
$(
'#aiosrs-pro-custom-fields .wpsp-enable-schema-markup input[type="checkbox"].wpsp-enable-schema-toggle__input'
).trigger('change');
$(document).on('click', '.aiosrs-reset-rating', function (e) {
e.preventDefault();
const thisObj = $(this);
const parent = thisObj.closest('.aiosrs-pro-custom-field-rating');
const ajaxData = {
action: 'aiosrs_reset_post_rating',
post_id: thisObj.data('post-id'),
schema_id: thisObj.data('schema-id'),
nonce: thisObj.data('nonce'),
};
$('#wpsp-reset-dialog-confirmation').dialog({
resizable: false,
title: __('Confirmation Required!', 'wp-schema-pro'),
height: 'auto',
width: 400,
modal: true,
open() {
$(this)
.closest('.ui-dialog')
.find('.ui-dialog-titlebar-close')
.hide();
const markup =
'<p><span class="dashicons dashicons-trash"></span> Do you really want to reset current post rating?</p>';
$(this).html(markup);
},
buttons: {
Yes() {
thisObj.addClass('reset-disabled');
parent.find('.spinner').addClass('is-active');
jQuery
.ajax({
url: ajaxurl,
type: 'post',
dataType: 'json',
data: ajaxData,
})
.success(function (response) {
if (
'undefined' !== typeof response.success &&
response.success === true
) {
const avgRating = response['rating-avg'],
reviewCount =
response['review-count'];
parent
.find('.aiosrs-rating')
.text(avgRating);
parent
.find('.aiosrs-rating-count')
.text(reviewCount);
parent
.find(
'.aiosrs-star-rating-wrap > .aiosrs-star-rating'
)
.removeClass(
'dashicons-star-filled dashicons-star-half dashicons-star-empty'
)
.addClass('dashicons-star-empty');
} else {
thisObj.removeClass('reset-disabled');
}
parent
.find('.spinner')
.removeClass('is-active');
});
$(this).dialog('close');
},
Cancel() {
$(this).dialog('close');
},
},
});
$('#wpsp-reset-dialog-confirmation').dialog('open');
});
$(document).on('change', '.multi-select-wrap select', function () {
const multiselectWrap = $(this).closest('.multi-select-wrap'),
selectWrap = multiselectWrap.find('select'),
inputField = multiselectWrap.find('input[type="hidden"]'),
value = selectWrap.val();
if (
'undefined' !== typeof value &&
null !== value &&
value.length > 0
) {
inputField.val(value.join(','));
} else {
inputField.val('');
}
});
// Verticle Tabs
$(document).on(
'click',
'.aiosrs-pro-meta-fields-tab',
function (e) {
e.preventDefault();
const id = $(this).data('tab-id');
$(this)
.siblings('.aiosrs-pro-meta-fields-tab')
.removeClass('active');
$(this).addClass('active');
$('#aiosrs-pro-custom-fields')
.find('.aiosrs-pro-meta-fields-wrap')
.removeClass('open');
$('#aiosrs-pro-custom-fields')
.find('.' + id)
.addClass('open');
}
);
// Toggle Js for Enable Schema Markup.
$(document.body).on(
'change',
'#aiosrs-pro-custom-fields .wpsp-enable-schema-markup .wpsp-enable-schema-toggle',
function () {
const parent = $(this).parents(
'.aiosrs-pro-meta-fields-tab'
);
const parents = $(this).parents('.inside');
const id = parent.data('tab-id');
const hasClass = parents
.find('.aiosrs-pro-meta-fields-wrapper')
.find('.' + id)
.hasClass('is-enable-schema-markup');
const isChecked = parent
.find('.wpsp-enable-schema-toggle')
.hasClass('is-checked');
if (!hasClass && !isChecked) {
parents
.find('.aiosrs-pro-meta-fields-wrapper')
.find('.' + id)
.addClass('is-enable-schema-markup');
}
}
);
$(
'#aiosrs-pro-custom-fields .wpsp-enable-schema-markup .wpsp-enable-schema-toggle'
).trigger('change');
$('.wpsp-enable-schema-toggle').on('click', function () {
const parent = $(this).parents('.aiosrs-pro-meta-fields-tab');
const parents = $(this).parents('.inside');
const id = parent.data('tab-id');
parents
.find('.aiosrs-pro-meta-fields-wrapper')
.find('.' + id)
.toggleClass('is-enable-schema-markup');
});
// Call Tooltip
$('.bsf-aiosrs-schema-heading-help').tooltip({
content() {
return $(this).prop('title');
},
tooltipClass: 'bsf-aiosrs-schema-ui-tooltip',
position: {
my: 'center top',
at: 'center bottom+10',
},
hide: {
duration: 200,
},
show: {
duration: 200,
},
});
let fileFrame;
window.inputWrapper = '';
$(document.body).on(
'click',
'.image-field-wrap .aiosrs-image-select',
function (e) {
e.preventDefault();
window.inputWrapper = $(this).closest(
'.bsf-aiosrs-schema-custom-text-wrap, .aiosrs-pro-custom-field-image'
);
// Create the media frame.
fileFrame = wp.media({
button: {
text: 'Select Image',
close: false,
},
states: [
new wp.media.controller.Library({
title: __('Select Custom Image', 'wp-schema-pro'),
library: wp.media.query({ type: 'image' }),
multiple: false,
}),
],
});
// When an image is selected, run a callback.
fileFrame.on('select', function () {
const attachment = fileFrame
.state()
.get('selection')
.first()
.toJSON();
const image = window.inputWrapper.find(
'.image-field-wrap img'
);
if (image.length === 0) {
window.inputWrapper
.find('.image-field-wrap')
.append(
'<a href="#" class="aiosrs-image-select img"><img src="' +
attachment.url +
'" /></a>'
);
} else {
image.attr('src', attachment.url);
}
window.inputWrapper
.find('.image-field-wrap')
.addClass('bsf-custom-image-selected');
window.inputWrapper
.find('.single-image-field')
.val(attachment.id);
const parent = window.inputWrapper.parents(
'.wpsp-local-fields'
);
parent
.find('.wpsp-default-hidden-value')
.val(attachment.id);
parent
.find('.wpsp-default-hidden-fieldtype')
.val(
window.inputWrapper
.parents('.wpsp-parent-field')
.attr('data-type')
);
fileFrame.close();
});
fileFrame.open();
}
);
$(document).on('click', '.aiosrs-image-remove', function (e) {
e.preventDefault();
const parent = $(this).closest(
'.bsf-aiosrs-schema-custom-text-wrap, .aiosrs-pro-custom-field-image'
);
parent
.find('.image-field-wrap')
.removeClass('bsf-custom-image-selected');
parent.find('.single-image-field').val('');
parent.find('.image-field-wrap img').removeAttr('src');
});
window.inputWrapper = '';
});
})(jQuery);

View File

@@ -1,147 +0,0 @@
/* eslint-env jquery */
(function ($) {
/**
* AIOSRS Frontend
*
* @class WPSchemaProFrontend
* @since 1.0
*/
const WPSchemaProFrontend = {
/**
* Initializes a AIOSRS Frontend.
*
* @since 1.0
* @function init
*/
container: '',
init() {
const self = this;
jQuery(document).on(
'click',
'.aiosrs-rating-wrap .aiosrs-star-rating',
function (e) {
e.preventDefault();
self.star_rating(this);
}
);
jQuery(document).on(
'mouseover',
'.aiosrs-rating-wrap .aiosrs-star-rating',
function (e) {
e.preventDefault();
self.hover_star_rating(this);
}
);
jQuery(document).on(
'mouseout',
'.aiosrs-rating-wrap .aiosrs-star-rating-wrap',
function (e) {
e.preventDefault();
if (!$(this).hasClass('disabled')) {
const index = $(this)
.parent()
.find('.aiosrs-rating')
.text();
self.update_stars($(this), index);
}
}
);
},
hover_star_rating(field) {
const self = this,
parent = $(field).closest('.aiosrs-star-rating-wrap'),
index = $(field).data('index');
if (!parent.hasClass('disabled')) {
self.update_stars(parent, index);
}
},
update_stars(wrap, rating) {
let filled = rating > 5 ? 5 : parseInt(rating);
if (rating > 5) {
filled = 5;
} else if (rating < 0) {
filled = 0;
} else {
filled = parseInt(rating);
}
const half = rating === filled || rating > 5 || rating < 0 ? 0 : 1;
wrap.find('span').each(function (index) {
$(this).removeClass(
'dashicons-star-filled dashicons-star-half dashicons-star-empty'
);
if (index < filled) {
$(this).addClass('dashicons-star-filled');
} else if (index === filled && half === 1) {
$(this).addClass('dashicons-star-empty');
} else {
$(this).addClass('dashicons-star-empty');
}
});
},
star_rating(field) {
const self = this,
schemaId = $(field)
.closest('.aiosrs-rating-wrap')
.data('schema-id'),
parent = $(field).closest('.aiosrs-star-rating-wrap'),
index = $(field).data('index');
if (!parent.hasClass('disabled')) {
self.update_stars(parent, index);
parent.addClass('disabled');
$.ajax({
url: AIOSRS_Frontend.ajaxurl,
type: 'POST',
data: {
action: 'aiosrs_user_rating',
rating: index,
schemaId,
post_id: AIOSRS_Frontend.post_id,
nonce: AIOSRS_Frontend.user_rating_nonce,
},
}).success(function (response) {
if (response.success === true) {
const summaryWrap = parent.next(
'.aiosrs-rating-summary-wrap'
),
rating = response.rating,
avgRating = response['rating-avg'],
reviewCount = response['review-count'];
summaryWrap.find('.aiosrs-rating').text(avgRating);
summaryWrap
.find('.aiosrs-rating-count')
.text(reviewCount);
if (parent.next('.success-msg').length === 0) {
parent.after(
'<span class="success-msg">' +
AIOSRS_Frontend.success_msg +
'</span>'
);
}
setTimeout(function () {
parent.parent().find('.success-msg').remove();
parent.removeClass('disabled');
}, 5000);
self.update_stars(parent, rating);
}
});
}
},
};
/* Initializes the AIOSRS Frontend. */
$(function () {
WPSchemaProFrontend.init();
});
})(jQuery);

View File

@@ -1,26 +0,0 @@
/* eslint-env jquery */
jQuery( document ).ready( function () {
jQuery( '#aiosrs-pro-license-form-btn' ).on( 'click', function ( e ) {
e.preventDefault();
jQuery( '#aiosrs-pro-license-form' ).show();
jQuery( 'body' ).addClass( 'aiosrs-pro-license-form-open' );
} );
jQuery( '#aiosrs-pro-license-form-close-btn' ).on( 'click', function ( e ) {
e.preventDefault();
jQuery( '#aiosrs-pro-license-form' ).hide();
jQuery( 'body' ).removeClass( 'aiosrs-pro-license-form-open' );
} );
jQuery( '#aiosrs-pro-license-form .aiosrs-pro-license-form-overlay' ).on(
'click',
function ( e ) {
e.preventDefault();
jQuery( '#aiosrs-pro-license-form' ).hide();
jQuery( 'body' ).removeClass( 'aiosrs-pro-license-form-open' );
}
);
} );

View File

@@ -1,783 +0,0 @@
/* eslint-env jquery */
(function ($) {
/**
* AIOSRS Schema
*
* @class AIOSRSSchema
* @since 1.0
*/
const AIOSRSSchema = {
/**
* Initializes a AIOSRS Schema.
*
* @since 1.0
* @function init
*/
container: '',
init() {
const self = this;
self.container = $(
'#aiosrs-schema-settings, #aiosrs-pro-custom-fields'
);
// Init backgrounds.
$(document).ready(function () {
$('.select2-class').select2();
const selectOption = ['Site Meta', 'Post Meta (Basic Fields)'];
const customOptionGroup = $('#bsf-aiosrs-schema-type').val();
if ('custom-markup' === customOptionGroup) {
for (let i = 0; i < selectOption.length; i++) {
$(
'#bsf-aiosrs-custom-markup-custom-markup optgroup[label="' +
selectOption[i] +
'"]'
).remove();
}
}
const customMarkupSchemId = $(
'#custom-schema-schema-field'
).val();
if (customMarkupSchemId) {
for (let i = 0; i < selectOption.length; i++) {
$(
'#custom-markup-' +
customMarkupSchemId +
'-custom-markup-connected optgroup[label="' +
selectOption[i] +
'"]'
).remove();
}
}
});
self.container.on(
'change',
'select.bsf-aiosrs-schema-meta-field',
function () {
const selfFun = $(this),
parent = selfFun.parent(),
value = selfFun.val();
const textwrapperCustom = parent.find(
'.bsf-aiosrs-schema-custom-text-wrap'
);
if ('custom-text' === value) {
textwrapperCustom.removeClass('bsf-hidden-field');
} else if (
!textwrapperCustom.hasClass('bsf-hidden-field')
) {
textwrapperCustom.addClass('bsf-hidden-field');
}
const textWrapperFixed = parent.find(
'.bsf-aiosrs-schema-fixed-text-wrap'
);
if ('fixed-text' === value) {
textWrapperFixed.removeClass('bsf-hidden-field');
} else if (!textWrapperFixed.hasClass('bsf-hidden-field')) {
textWrapperFixed.addClass('bsf-hidden-field');
}
const specificMetaWrapper = parent.find(
'.bsf-aiosrs-schema-specific-field-wrap'
);
if ('specific-field' === value) {
specificMetaWrapper.removeClass('bsf-hidden-field');
} else if (
!specificMetaWrapper.hasClass('bsf-hidden-field')
) {
specificMetaWrapper.addClass('bsf-hidden-field');
}
}
);
self.container.on(
'change',
'.bsf-aiosrs-schema-row-rating-type select.bsf-aiosrs-schema-meta-field',
function (e) {
e.preventDefault();
$(this)
.closest('.bsf-aiosrs-schema-table')
.find('.bsf-aiosrs-schema-row')
.css('display', '');
if ('accept-user-rating' === $(this).val()) {
const reviewCountWrap = $(this)
.closest('.bsf-aiosrs-schema-row')
.next('.bsf-aiosrs-schema-row'),
name = reviewCountWrap
.find('.bsf-aiosrs-schema-meta-field')
.attr('name');
const selectedSchemaType = jQuery(
'.bsf-aiosrs-review-schema-type'
).val();
if (selectedSchemaType) {
const prepareName =
'bsf-aiosrs-review[' +
selectedSchemaType +
'-review-count]';
if (name.indexOf(prepareName) >= 0) {
reviewCountWrap.hide();
}
}
if (name.indexOf('[review-count]') >= 0) {
reviewCountWrap.hide();
}
}
}
);
self.container
.find('select.bsf-aiosrs-schema-meta-field')
.trigger('change');
$('select.bsf-aiosrs-schema-select2').each(function (index, el) {
self.init_target_rule_select2(el);
});
self.container.on(
'click',
'.bsf-repeater-add-new-btn',
function (event) {
event.preventDefault();
self.add_new_repeater($(this));
self.prepare_event_schmea_fields();
}
);
self.container.on('click', '.bsf-repeater-close', function (event) {
event.preventDefault();
self.add_remove_repeater($(this));
});
self.schemaTypeDependency();
self.bindTooltip();
if (!$('body').hasClass('post-type-aiosrs-schema')) {
self.field_validation();
}
},
field_validation() {
$(
'.wpsp-custom-field-connect, .wpsp-field-close, .bsf-aiosrs-schema-meta-field, image-field-wrap, .aiosrs-pro-custom-field, .wpsp-custom-field-connect'
).on('click focus change', function () {
$('.bsf-aiosrs-schema-type-wrap').each(function (
index,
repeater
) {
let fieldValue = $(repeater)
.find('.wpsp-default-hidden-value')
.val();
const requiredPath = $(repeater)
.parents('.bsf-aiosrs-schema-row-content')
.prev();
if (undefined !== fieldValue) {
fieldValue = fieldValue.trim();
if (fieldValue) {
if ($('body').hasClass('block-editor-page')) {
if (
!$(repeater).find(
'.wpsp-required-error-field'
).length
) {
let metaField;
switch (fieldValue) {
case 'post_title':
metaField = $(
'.editor-post-title__input'
).val();
break;
case 'post_content':
metaField =
$(
'p.block-editor-rich-text__editable'
).text().length > 1
? $(
'p.block-editor-rich-text__editable'
).text()
: '';
break;
case 'post_excerpt':
metaField = $(
'.components-textarea-control__input'
).val();
break;
case 'featured_img':
if (
'Set featured image' ===
$(
'.editor-post-featured-image__toggle'
).text()
) {
metaField = '';
} else {
metaField = $(
'.components-responsive-wrapper__content'
).attr('src');
}
break;
default:
requiredPath.removeClass(
'wpsp-required-error-field'
);
requiredPath
.find('label')
.removeClass(
'wpsp-required-error-field'
);
}
if (undefined !== metaField) {
if ('' !== metaField) {
requiredPath.removeClass(
'wpsp-required-error-field'
);
requiredPath
.find('label')
.removeClass(
'wpsp-required-error-field'
);
} else if (
requiredPath.find('.required')
.length
) {
requiredPath
.find('label')
.addClass(
'wpsp-required-error-field'
);
}
}
} else {
requiredPath.removeClass(
'wpsp-required-error-field'
);
requiredPath
.find('label')
.removeClass(
'wpsp-required-error-field'
);
}
} else {
requiredPath.removeClass(
'wpsp-required-error-field'
);
requiredPath
.find('label')
.removeClass('wpsp-required-error-field');
}
} else if (requiredPath.find('.required').length) {
requiredPath
.find('label')
.addClass('wpsp-required-error-field');
}
}
});
});
},
hide_review_count() {
$(this)
.closest('.bsf-aiosrs-schema-table')
.find('.bsf-aiosrs-schema-row')
.css('display', '');
if ('accept-user-rating' === $(this).val()) {
const reviewCountWrap = $(this)
.closest('.bsf-aiosrs-schema-row')
.next('.bsf-aiosrs-schema-row'),
name = reviewCountWrap
.find('.bsf-aiosrs-schema-meta-field')
.attr('name');
const selectedSchemaType = jQuery(
'.bsf-aiosrs-review-schema-type'
).val();
if (selectedSchemaType) {
const prepareName =
'bsf-aiosrs-review[' +
selectedSchemaType +
'-review-count]';
if (name.indexOf(prepareName) >= 0) {
reviewCountWrap.hide();
}
}
if (name.indexOf('[review-count]') >= 0) {
reviewCountWrap.hide();
}
}
},
add_new_repeater(selector) {
const self = this,
parentWrap = selector.closest('.bsf-aiosrs-schema-type-wrap'),
totalCount = parentWrap.find('.aiosrs-pro-repeater-table-wrap')
.length,
template = parentWrap
.find('.aiosrs-pro-repeater-table-wrap')
.first()
.clone();
template
.find(
'.bsf-aiosrs-schema-custom-text-wrap, .bsf-aiosrs-schema-specific-field-wrap'
)
.each(function () {
if (!$(this).hasClass('bsf-hidden-field')) {
$(this).addClass('bsf-hidden-field');
}
});
template
.find('select.bsf-aiosrs-schema-meta-field')
.each(function () {
$(this).val('none');
const fieldName =
'undefined' !== typeof $(this).attr('name')
? $(this)
.attr('name')
.replace('[0]', '[' + totalCount + ']')
: '',
fieldClass =
'undefined' !== typeof $(this).attr('class')
? $(this)
.attr('class')
.replace('-0-', '-' + totalCount + '-')
: '',
fieldId =
'undefined' !== typeof $(this).attr('id')
? $(this)
.attr('id')
.replace('-0-', '-' + totalCount + '-')
: '';
$(this).attr('name', fieldName);
$(this).attr('class', fieldClass);
$(this).attr('id', fieldId);
});
template
.find(
'input, textarea, select:not(.bsf-aiosrs-schema-meta-field)'
)
.each(function () {
$(this).val('');
const fieldName =
'undefined' !== typeof $(this).attr('name')
? $(this)
.attr('name')
.replace('[0]', '[' + totalCount + ']')
: '',
fieldClass =
'undefined' !== typeof $(this).attr('class')
? $(this)
.attr('class')
.replace('-0-', '-' + totalCount + '-')
: '',
fieldId =
'undefined' !== typeof $(this).attr('id')
? $(this)
.attr('id')
.replace('-0-', '-' + totalCount + '-')
: '';
$(this).attr('name', fieldName);
$(this).attr('class', fieldClass);
$(this).attr('id', fieldId);
});
template.find('span.select2-container').each(function () {
$(this).remove();
});
template.insertBefore(selector);
template
.find('select.bsf-aiosrs-schema-select2')
.each(function (index, el) {
self.init_target_rule_select2(el);
});
AIOSRSSchema.init_date_time_fields();
},
add_remove_repeater(selector) {
const parentWrap = selector.closest('.bsf-aiosrs-schema-type-wrap'),
repeaterCount = parentWrap.find(
'> .aiosrs-pro-repeater-table-wrap'
).length;
if (repeaterCount > 1) {
selector.closest('.aiosrs-pro-repeater-table-wrap').remove();
if ('aiosrs-pro-custom-fields' === this.container.attr('id')) {
// Reset index to avoid duplicate names.
parentWrap
.find('> .aiosrs-pro-repeater-table-wrap')
.each(function (wrapIndex, repeaterWap) {
$(repeaterWap).each(function (
elementIndex,
element
) {
$(element)
.find(
'input, textarea, select:not(.bsf-aiosrs-schema-meta-field)'
)
.each(function (elIndex, el) {
const fieldName =
'undefined' !==
typeof $(el).attr('name')
? $(el)
.attr('name')
.replace(
/\[\d+]/,
'[' +
wrapIndex +
']'
)
: '';
$(el).attr('name', fieldName);
});
});
});
}
}
},
bindTooltip() {
// Call Tooltip
$('.bsf-aiosrs-schema-heading-help').tooltip({
content() {
return $(this).prop('title');
},
tooltipClass: 'bsf-aiosrs-schema-ui-tooltip',
position: {
my: 'center top',
at: 'center bottom+10',
},
hide: {
duration: 200,
},
show: {
duration: 200,
},
});
},
schemaTypeDependency() {
const container = this.container;
this.container.on(
'change',
'select[name="bsf-aiosrs-schema-type"]',
function () {
container
.find('.bsf-aiosrs-schema-meta-wrap')
.css('display', 'none');
const schemaType = $(this).val();
if (
'undefined' !== typeof schemaType &&
'' !== schemaType
) {
container
.find('#bsf-' + schemaType + '-schema-meta-wrap')
.css('display', '');
}
}
);
},
init_target_rule_select2(selector) {
$(selector).select2({
placeholder: 'Search Fields...',
ajax: {
url: ajaxurl,
dataType: 'json',
method: 'post',
delay: 250,
data(params) {
return {
nonce_ajax: AIOSRS_Rating.specified_field,
q: params.term, // search term
page: params.page,
action: 'bsf_get_specific_meta_fields',
};
},
processResults(data) {
return {
results: data,
};
},
cache: true,
},
minimumInputLength: 2,
});
},
get_review_item_type_html(itemType) {
jQuery
.post({
url: ajaxurl,
data: {
action: 'fetch_item_type_html',
itemType,
nonce: AIOSRS_Rating.security,
post_id: jQuery('#post_ID').val(),
},
})
.done(function (response) {
$('.bsf-review-item-type-field').remove();
$(response).insertAfter(
jQuery('#bsf-aiosrs-review-schema-type')
.parent()
.parent()
.closest('tr')
);
$('select.bsf-aiosrs-schema-select2').each(function (
index,
el
) {
AIOSRSSchema.init_target_rule_select2(el);
});
const itemSpecificType =
'.bsf-aiosrs-review-' + itemType + '-rating';
$(itemSpecificType).each(function () {
$(this)
.closest('.bsf-aiosrs-schema-table')
.find('.bsf-aiosrs-schema-row')
.css('display', '');
if ('accept-user-rating' === $(this).val()) {
const reviewCountWrap = $(this)
.closest('.bsf-aiosrs-schema-row')
.next('.bsf-aiosrs-schema-row'),
name = reviewCountWrap
.find('.bsf-aiosrs-schema-meta-field')
.attr('name');
const selectedSchemaType = jQuery(
'.bsf-aiosrs-review-schema-type'
).val();
if (selectedSchemaType) {
const prepareName =
'bsf-aiosrs-review[' +
selectedSchemaType +
'-review-count]';
if (name.indexOf(prepareName) >= 0) {
reviewCountWrap.hide();
}
}
if (name.indexOf('[review-count]') >= 0) {
reviewCountWrap.hide();
}
}
});
AIOSRSSchema.init_date_time_fields();
AIOSRSSchema.prepare_event_schmea_fields();
})
.fail(function () { });
},
prepare_event_schmea_fields() {
$(
'.wpsp-dropdown-event-status, .wpsp-dropdown-bsf-aiosrs-event-event-status'
).change(function () {
const parent = $(this).parents(
'.bsf-aiosrs-schema-meta-wrap, .aiosrs-pro-meta-fields-wrap'
);
parent
.find(
'td.wpsp-event-status-rescheduled, td.bsf-aiosrs-review-bsf-aiosrs-event-previous-date'
)
.hide();
if (!this.value) {
this.value = 'EventScheduled';
}
if ('EventRescheduled' === this.value) {
parent
.find(
'td.wpsp-event-status-rescheduled, td.bsf-aiosrs-review-bsf-aiosrs-event-previous-date'
)
.show();
}
const eventStatus = $(
'.wpsp-dropdown-event-attendance-mode, .wpsp-dropdown-bsf-aiosrs-event-event-attendance-mode'
).val();
if (
'EventMovedOnline' === this.value ||
'OfflineEventAttendanceMode' !== eventStatus
) {
parent.find('td.wpsp-event-status-offline').hide();
parent.find('td.wpsp-event-status-online').show();
parent.find('td.wpsp-online-event-timezone').show();
parent
.find(
'.wpsp-dropdown-event-attendance-mode, .wpsp-dropdown-bsf-aiosrs-event-event-attendance-mode'
)
.val('OnlineEventAttendanceMode');
} else {
parent.find('td.wpsp-event-status-offline').show();
parent.find('td.wpsp-event-status-online').hide();
parent.find('td.wpsp-online-event-timezone').hide();
}
});
$(
'.wpsp-dropdown-event-attendance-mode, .wpsp-dropdown-bsf-aiosrs-event-event-attendance-mode'
).change(function () {
const parent = $(this).parents(
'.bsf-aiosrs-schema-meta-wrap, .aiosrs-pro-meta-fields-wrap'
);
parent.find('td.wpsp-event-status-rescheduled').hide();
const eventStatus = $(
'.wpsp-dropdown-event-status, .wpsp-dropdown-bsf-aiosrs-event-event-status'
).val();
if ('EventMovedOnline' !== eventStatus) {
parent.find('td.wpsp-event-status-offline').show();
parent.find('td.wpsp-event-status-online').hide();
parent.find('td.wpsp-online-event-timezone').hide();
}
if ('OfflineEventAttendanceMode' !== this.value) {
parent.find('td.wpsp-event-status-offline').hide();
parent.find('td.wpsp-event-status-online').show();
parent.find('td.wpsp-online-event-timezone').show();
}
if ('MixedEventAttendanceMode' === this.value) {
parent.find('td.wpsp-event-status-offline').show();
parent.find('td.wpsp-event-status-online').show();
parent.find('td.wpsp-online-event-timezone').show();
}
});
$(
'.wpsp-dropdown-event-attendance-mode, .wpsp-dropdown-bsf-aiosrs-event-event-attendance-mode'
).trigger('change');
},
init_date_time_fields() {
$(
'.wpsp-datetime-local-field, .wpsp-date-field, .wpsp-time-duration-field'
).each(function () {
$(this).removeClass('hasDatepicker');
});
const startDateSelectors =
'.wpsp-date-published-date, .wpsp-datetime-local-event-start-date, .wpsp-date-start-date, .wpsp-datetime-local-start-date';
const endDateSelectors =
'.wpsp-date-modified-date, .wpsp-datetime-local-event-end-date, .wpsp-date-end-date, .wpsp-datetime-local-end-date';
$(document).on('focus', '.wpsp-time-duration-field', function () {
$(this).timepicker({
timeFormat: 'HH:mm:ss',
hourMin: 0,
hourMax: 99,
oneLine: true,
currentText: 'Clear',
onSelect() {
updateTimeFormat(this);
},
});
});
$(document).on(
'focus',
'.wpsp-datetime-local-field, .wpsp-date-field',
function () {
$(this).datetimepicker({
dateFormat: 'yy-mm-dd',
timeFormat: 'hh:mm TT',
changeMonth: true,
changeYear: true,
showOn: 'focus',
showButtonPanel: true,
closeText: 'Done',
currentText: 'Clear',
yearRange: '-100:+10', // last hundred year
onClose(dateText, inst) {
const thisEle = '#' + inst.id;
if (jQuery(thisEle).is(startDateSelectors)) {
$(endDateSelectors).datetimepicker(
'option',
'minDate',
new Date(dateText)
);
} else if (jQuery(thisEle).is(endDateSelectors)) {
$(startDateSelectors).datetimepicker(
'option',
'maxDate',
new Date(dateText)
);
}
jQuery(thisEle)
.parents('.wpsp-local-fields')
.find('.wpsp-default-hidden-value')
.val(dateText);
},
});
}
);
$.datepicker._gotoToday = function (id) {
$(id).datepicker('setDate', '').datepicker('hide').blur();
};
function updateTimeFormat(thisEle) {
const durationWrap = $(thisEle).closest(
'.aiosrs-pro-custom-field-time-duration'
);
const inputField = durationWrap.find('.time-duration-field');
let value = $(thisEle).val();
value = value.replace(/:/, 'H');
value = value.replace(/:/, 'M');
value = 'PT' + value + 'S';
inputField.val(value);
// Post/pages related support.
const parent = $(thisEle).parents('.wpsp-local-fields');
parent.find('.wpsp-default-hidden-value').val(value);
}
},
};
/* Initializes the AIOSRS Schema. */
$(function () {
AIOSRSSchema.init();
if (!$('body').hasClass('aiosrs-pro-setup')) {
AIOSRSSchema.init_date_time_fields();
}
});
$(document).ready(function () {
let parent = $('.aiosrs-pro-meta-fields-wrap');
parent.each(function (index, value) {
let labelMarkup = $(value).find('.wpsp-field-label');
let label = labelMarkup.text();
if ('Image License' === label.trim()) {
labelMarkup.attr('style', 'width:6%');
}
});
$('#bsf-aiosrs-review-schema-type').change(function () {
const itemVal = $(this).val().trim();
if (!itemVal) {
$('.bsf-review-item-type-field').remove();
return;
}
AIOSRSSchema.get_review_item_type_html(itemVal);
});
$('#bsf-aiosrs-review-schema-type').change();
AIOSRSSchema.prepare_event_schmea_fields();
});
})(jQuery);

View File

@@ -1,415 +0,0 @@
/* eslint-env jquery */
(function ($) {
const { __ } = wp.i18n;
const temp = {
person: __('Website Owner Name'),
organization: __('Organization Name', 'wp-schema-pro'),
Webshop: __('Webshop Name', 'wp-schema-pro'),
personblog: __('Website Owner Name', 'wp-schema-pro'),
Smallbusiness: __('Blog Website Name', 'wp-schema-pro'),
Otherbusiness: __('Business Name', 'wp-schema-pro'),
};
/**
* AIOSRS Frontend
*
* @class WPSchemaProSettings
* @since 1.0
*/
const WPSchemaProSettings = {
init() {
const self = this;
this.customFieldDependecy();
this.customImageSelect();
this.initRepeater();
this.toolTips();
this.regenerateSchema();
$('select.wp-select2').each(function (index, el) {
self.init_target_rule_select2(el);
});
},
regenerateSchema() {
$('#wpsp-regenerate-schema').click(function () {
$(this).next('span.spinner').addClass('is-active');
jQuery
.ajax({
url: ajaxurl,
type: 'post',
dataType: 'json',
data: {
action: 'regenerate_schema',
nonce: $(this).data('nonce'),
},
})
.success(function () {
$('#wpsp-regenerate-schema')
.next('span.spinner')
.removeClass('is-active');
$('#wpsp-regenerate-notice')
.show()
.delay(2000)
.fadeOut();
});
});
},
toolTips() {
$(document).on(
'click',
'.wp-schema-pro-tooltip-icon',
function (e) {
e.preventDefault();
$('.wp-schema-pro-tooltip-wrapper').removeClass('activate');
$(this).parent().addClass('activate');
}
);
$(document).on('click', function (e) {
if (
!$(e.target).hasClass(
'wp-schema-pro-tooltip-description'
) &&
!$(e.target).hasClass('wp-schema-pro-tooltip-icon') &&
$(e.target).closest('.wp-schema-pro-tooltip-description')
.length === 0
) {
$('.wp-schema-pro-tooltip-wrapper').removeClass('activate');
}
});
},
customImageSelect() {
let fileFrame;
window.inputWrapper = '';
$(document.body).on(
'click',
'.image-field-wrap .aiosrs-image-select',
function (e) {
e.preventDefault();
window.inputWrapper = $(this).closest('td');
// Create the media frame.
fileFrame = wp.media({
button: {
text: 'Select Image',
close: false,
},
states: [
new wp.media.controller.Library({
title: 'Select Custom Image',
library: wp.media.query({ type: 'image' }),
multiple: false,
}),
],
});
// When an image is selected, run a callback.
fileFrame.on('select', function () {
const attachment = fileFrame
.state()
.get('selection')
.first()
.toJSON();
const image = window.inputWrapper.find(
'.image-field-wrap img'
);
if (image.length === 0) {
window.inputWrapper
.find('.image-field-wrap')
.append(
'<a href="#" class="aiosrs-image-select img"><img src="' +
attachment.url +
'" /></a>'
);
} else {
image.attr('src', attachment.url);
}
window.inputWrapper
.find('.image-field-wrap')
.addClass('bsf-custom-image-selected');
window.inputWrapper
.find('.single-image-field')
.val(attachment.id);
fileFrame.close();
});
fileFrame.open();
}
);
$(document).on('click', '.aiosrs-image-remove', function (e) {
e.preventDefault();
const parent = $(this).closest('td');
parent
.find('.image-field-wrap')
.removeClass('bsf-custom-image-selected');
parent.find('.single-image-field').val('');
parent.find('.image-field-wrap img').removeAttr('src');
});
window.inputWrapper = '';
},
customFieldDependecy() {
jQuery(document).on(
'change',
'#post-body-content .wp-schema-pro-custom-option-select, .aiosrs-pro-setup-wizard-content.general-setting-content-wrap .wp-schema-pro-custom-option-select',
function () {
const customWrap = jQuery(this).next(
'.custom-field-wrapper'
);
customWrap.css('display', 'none');
if ('custom' === jQuery(this).val()) {
customWrap.css('display', '');
}
}
);
jQuery(document).on(
'change',
'select[name="wp-schema-pro-general-settings[site-represent]"]',
function () {
const wrapper = jQuery(this).closest('table'),
logoWrap = wrapper.find(
'.wp-schema-pro-site-logo-wrap'
),
companyNameWrap = wrapper.find(
'.wp-schema-pro-site-name-wrap'
),
personNameWrap = wrapper.find(
'.wp-schema-pro-person-name-wrap'
);
companyNameWrap.css('display', 'none');
personNameWrap.css('display', 'none');
if ('' !== jQuery(this).val()) {
if (
'organization' === jQuery(this).val() ||
'Webshop' === jQuery(this).val() ||
'Smallbusiness' === jQuery(this).val() ||
'Otherbusiness' === jQuery(this).val()
) {
logoWrap.css('display', '');
companyNameWrap.css('display', '');
} else {
personNameWrap.css('display', '');
logoWrap.css('display', '');
}
}
}
);
jQuery(document).on(
'change',
'select[name="wp-schema-pro-general-settings[site-represent]"]',
function () {
const organizationType = jQuery(this).val();
if ('' !== jQuery(this).val()) {
if (organizationType in temp) {
$('.wpsp-organization-label').text(
temp[organizationType]
);
}
}
}
);
jQuery(document).on(
'change',
'select[name="wp-schema-pro-corporate-contact[contact-type]"]',
function () {
const wrapper = jQuery(this).closest('table'),
contactPointWrap = wrapper.find(
'.wp-schema-pro-other-wrap'
);
contactPointWrap.css('display', 'none');
if ('' !== jQuery(this).val()) {
if ('other' === jQuery(this).val()) {
contactPointWrap.css('display', '');
}
}
}
);
$('#add-row').on('click', function () {
const row = $('.empty-row.screen-reader-text').clone(true);
row.removeClass('empty-row screen-reader-text');
row.insertBefore('#repeatable-fieldset-one >tr:last');
return false;
});
$('.remove-row').on('click', function () {
$(this).parents('tr').remove();
return false;
});
},
initRepeater() {
$(document).on(
'click',
'.bsf-repeater-add-new-btn',
function (event) {
event.preventDefault();
const selector = $(this),
parentWrap = selector.closest(
'.bsf-aiosrs-schema-type-wrap'
),
totalCount = parentWrap.find(
'.aiosrs-pro-repeater-table-wrap'
).length,
template = parentWrap
.find('.aiosrs-pro-repeater-table-wrap')
.first()
.clone();
template.find('input, textarea, select').each(function () {
$(this).val('');
const fieldName =
'undefined' !== typeof $(this).attr('name')
? $(this)
.attr('name')
.replace(
'[0]',
'[' + totalCount + ']'
)
: '',
fieldClass =
'undefined' !== typeof $(this).attr('class')
? $(this)
.attr('class')
.replace(
'-0-',
'-' + totalCount + '-'
)
: '',
fieldId =
'undefined' !== typeof $(this).attr('id')
? $(this)
.attr('id')
.replace(
'-0-',
'-' + totalCount + '-'
)
: '';
$(this).attr('name', fieldName);
$(this).attr('class', fieldClass);
$(this).attr('id', fieldId);
});
template.insertBefore(selector);
}
);
$(document).on('click', '.bsf-repeater-close', function (event) {
event.preventDefault();
const selector = $(this),
parentWrap = selector.closest(
'.bsf-aiosrs-schema-type-wrap'
),
repeaterCount = parentWrap.find(
'> .aiosrs-pro-repeater-table-wrap'
).length;
if (repeaterCount > 1) {
selector
.closest('.aiosrs-pro-repeater-table-wrap')
.remove();
}
});
},
init_target_rule_select2(selector) {
$(selector).select2({
placeholder: 'Search Fields...',
ajax: {
url: ajaxurl,
dataType: 'json',
method: 'post',
delay: 250,
data(params) {
return {
nonce_ajax: AIOSRS_search.search_field,
q: params.term, // search term
page: params.page,
action: 'bsf_get_specific_pages',
};
},
processResults(data) {
return {
results: data,
};
},
cache: true,
},
minimumInputLength: 2,
});
},
};
const loadDefaultValues = function () {
const field = jQuery(
'select[name="wp-schema-pro-general-settings[site-represent]"]'
),
wrapper = field.closest('table'),
logoWrap = wrapper.find('.wp-schema-pro-site-logo-wrap'),
companyNameWrap = wrapper.find('.wp-schema-pro-site-name-wrap'),
personNameWrap = wrapper.find('.wp-schema-pro-person-name-wrap');
companyNameWrap.css('display', 'none');
personNameWrap.css('display', 'none');
if ('' !== field.val()) {
if (
'organization' === field.val() ||
'Webshop' === field.val() ||
'Smallbusiness' === field.val() ||
'Otherbusiness' === field.val()
) {
logoWrap.css('display', '');
companyNameWrap.css('display', '');
} else {
personNameWrap.css('display', '');
logoWrap.css('display', '');
}
}
};
const loadDefaultOrganizationLabel = function () {
const field = jQuery(
'select[name="wp-schema-pro-general-settings[site-represent]"]'
),
organizationType = field.val();
if ('' !== field) {
if (organizationType in temp) {
$('.wpsp-organization-label').text(temp[organizationType]);
}
}
};
$(document).ready(function () {
$('.wp-select2').select2();
$('.wpsp-setup-configuration-settings').select2();
loadDefaultValues();
loadDefaultOrganizationLabel();
$('#add-row').on('click', function () {
const row = $('.empty-row.screen-reader-text').clone(true);
row.removeClass('empty-row screen-reader-text');
row.insertBefore('#repeatable-fieldset-one tbody>tr:last');
return false;
});
$('.remove-row').on('click', function () {
$(this).parents('tr').remove();
return false;
});
});
/* Initializes the AIOSRS Frontend. */
$(function () {
WPSchemaProSettings.init();
});
})(jQuery);

View File

@@ -1,32 +0,0 @@
/* eslint-env jquery */
/**
* File setup-wizard.js
*
* Handles Color Picker
*
* @package
*/
( function ( $ ) {
jQuery( document ).ready( function () {
$( document ).on(
'click',
'.aiosrs-pro-schema-temp-wrap',
function ( e ) {
e.preventDefault();
$( '.aiosrs-pro-schema-temp-wrap' ).removeClass( 'selected' );
$( '.aiosrs-pro-setup-actions' )
.find( '.button-next' )
.removeAttr( 'disabled' );
$( this ).addClass( 'selected' );
const type = $( this ).data( 'schema-type' ),
title = $( this ).data( 'schema-title' );
$( document ).find( '.bsf-aiosrs-schema-type' ).val( type );
$( document ).find( '.bsf-aiosrs-schema-title' ).val( title );
}
);
} );
} )( jQuery );

File diff suppressed because one or more lines are too long