diff --git a/change-log.txt b/change-log.txt index d230e24..36d3912 100644 --- a/change-log.txt +++ b/change-log.txt @@ -1,3 +1,6 @@ += 0.2.24 - 2024-08-29 = +* Changes for search form conditional fields - CHANGED + = 0.2.23 - 2024-08-08 = * Conditional field set default value changes - CHANGED diff --git a/composer.json b/composer.json index a10e49f..1ee4f18 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "ayecode/wp-ayecode-ui", - "version": "0.2.21", + "version": "0.2.24", "type": "library", "description": "A Bootstrap UI for WordPress plugins and themes.", "keywords": ["bootstrap","boot","ayecode"], diff --git a/example-plugin.php b/example-plugin.php index 85d3d2c..996396a 100644 --- a/example-plugin.php +++ b/example-plugin.php @@ -3,7 +3,7 @@ Plugin Name: AyeCode UI Plugin URI: https://ayecode.io/ Description: This is an example plugin to test AyeCode UI Quickly. -Version: 1.0.0 +Version: 0.2.24 Author: AyeCode Ltd Author URI: https://userswp.io License: GPL-2.0+ @@ -11,7 +11,7 @@ Text Domain: ayecode-ui Domain Path: /languages Requires at least: 4.9 -Tested up to: 5.4 +Tested up to: 6.6 */ // If this file is called directly, abort. diff --git a/includes/ayecode-ui-settings.php b/includes/ayecode-ui-settings.php index 7d93120..de9d2e0 100644 --- a/includes/ayecode-ui-settings.php +++ b/includes/ayecode-ui-settings.php @@ -35,7 +35,7 @@ class AyeCode_UI_Settings { * * @var string */ - public $version = '0.2.23'; + public $version = '0.2.24'; /** * Class textdomain. @@ -2975,30 +2975,30 @@ function aui_cf_field_reset_default_value($el, bHide, setVal) { $el.find('select').val(setVal); } else { jQuery.each(setVal, function(i, v) { - $el.find('select').find('option[value="' + v + '"]').attr('selected', true); + $el.find('select').find('option[value="' + v + '"]').prop('selected', true); }); } $el.find('select').trigger('change'); break; case 'checkbox': if ($el.find('input[type="checkbox"]:checked').length >= 1) { - $el.find('input[type="checkbox"]:checked').prop('checked', false); - if (Array.isArray(setVal)) { - jQuery.each(setVal, function(i, v) { - $el.find('input[type="checkbox"][value="' + v + '"]').attr('checked', true); - }); - } else { - $el.find('input[type="checkbox"][value="' + setVal + '"]').attr('checked', true); - } + $el.find('input[type="checkbox"]:checked').prop('checked', false).removeAttr('checked'); + } + if (Array.isArray(setVal)) { + jQuery.each(setVal, function(i, v) { + $el.find('input[type="checkbox"][value="' + v + '"]').prop('checked', true); + }); + } else { + $el.find('input[type="checkbox"][value="' + setVal + '"]').prop('checked', true); } break; case 'radio': - if ($el.find('input[type="radio"]:checked').length >= 1) { - setTimeout(function() { - $el.find('input[type="radio"]:checked').prop('checked', false); - $el.find('input[type="radio"][value="' + setVal + '"]').attr('checked', true); - }, 100); - } + setTimeout(function() { + if ($el.find('input[type="radio"]:checked').length >= 1) { + $el.find('input[type="radio"]:checked').prop('checked', false).removeAttr('checked'); + } + $el.find('input[type="radio"][value="' + setVal + '"]').prop('checked', true); + }, 100); break; default: jQuery(document.body).trigger('aui_cf_field_reset_default_value', type, $el, field); @@ -3050,27 +3050,27 @@ function aui_cf_field_in_array(find, item, exact, match) { * App the field condition action. */ function aui_cf_field_apply_action($el, rule, isTrue) { - var $destEl = jQuery('[data-rule-key="' + rule.key + '"]'); + var $destEl = jQuery('[data-rule-key="' + rule.key + '"]'), $inputEl = (rule.key && $destEl.find('[name="' + rule.key + '"]').length) ? $destEl.find('[name="' + rule.key + '"]') : null; if (rule.action === 'show' && isTrue) { - if ($destEl.is(':hidden') && !$destEl.hasClass('aui-cf-skip-reset')) { + if ($destEl.is(':hidden') && !($destEl.hasClass('aui-cf-skip-reset') || ($inputEl && $inputEl.hasClass('aui-cf-skip-reset')))) { aui_cf_field_reset_default_value($destEl); } aui_cf_field_show_element($destEl); } else if (rule.action === 'show' && !isTrue) { - if ((!$destEl.is(':hidden') || ($destEl.is(':hidden') && ($destEl.hasClass('aui-cf-force-reset') || ($destEl.closest('.aui-cf-use-parent').length && $destEl.closest('.aui-cf-use-parent').is(':hidden'))))) && !$destEl.hasClass('aui-cf-skip-reset')) { - var _setVal = $destEl.hasClass('aui-cf-force-empty') ? '' : null; + if ((!$destEl.is(':hidden') || ($destEl.is(':hidden') && ($destEl.hasClass('aui-cf-force-reset') || ($inputEl && $inputEl.hasClass('aui-cf-skip-reset')) || ($destEl.closest('.aui-cf-use-parent').length && $destEl.closest('.aui-cf-use-parent').is(':hidden'))))) && !($destEl.hasClass('aui-cf-skip-reset') || ($inputEl && $inputEl.hasClass('aui-cf-skip-reset')))) { + var _setVal = $destEl.hasClass('aui-cf-force-empty') || ($inputEl && $inputEl.hasClass('aui-cf-force-empty')) ? '' : null; aui_cf_field_reset_default_value($destEl, true, _setVal); } aui_cf_field_hide_element($destEl); } else if (rule.action === 'hide' && isTrue) { - if ((!$destEl.is(':hidden') || ($destEl.is(':hidden') && ($destEl.hasClass('aui-cf-force-reset') || ($destEl.closest('.aui-cf-use-parent').length && $destEl.closest('.aui-cf-use-parent').is(':hidden'))))) && !$destEl.hasClass('aui-cf-skip-reset')) { - var _setVal = $destEl.hasClass('aui-cf-force-empty') ? '' : null; + if ((!$destEl.is(':hidden') || ($destEl.is(':hidden') && ($destEl.hasClass('aui-cf-force-reset') || ($inputEl && $inputEl.hasClass('aui-cf-skip-reset')) || ($destEl.closest('.aui-cf-use-parent').length && $destEl.closest('.aui-cf-use-parent').is(':hidden'))))) && !($destEl.hasClass('aui-cf-skip-reset') || ($inputEl && $inputEl.hasClass('aui-cf-skip-reset')))) { + var _setVal = $destEl.hasClass('aui-cf-force-empty') || ($inputEl && $inputEl.hasClass('aui-cf-force-empty')) ? '' : null; aui_cf_field_reset_default_value($destEl, true, _setVal); } aui_cf_field_hide_element($destEl); } else if (rule.action === 'hide' && !isTrue) { - if ($destEl.is(':hidden') && !$destEl.hasClass('aui-cf-skip-reset')) { + if ($destEl.is(':hidden') && !($destEl.hasClass('aui-cf-skip-reset') || ($inputEl && $inputEl.hasClass('aui-cf-skip-reset')))) { aui_cf_field_reset_default_value($destEl); } aui_cf_field_show_element($destEl);