From c322cb98ef0dd871c8139990a326d0c6a7deb42d Mon Sep 17 00:00:00 2001 From: Ryan Cramer Date: Fri, 3 Dec 2021 10:56:59 -0500 Subject: [PATCH] Various minor updates --- .../InputfieldSelector/InputfieldSelector.module | 3 +++ .../Inputfield/InputfieldToggle/InputfieldToggle.js | 2 +- .../Inputfield/InputfieldToggle/InputfieldToggle.min.js | 2 +- .../Process/ProcessPageLister/ProcessPageLister.module | 8 +++++--- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/wire/modules/Inputfield/InputfieldSelector/InputfieldSelector.module b/wire/modules/Inputfield/InputfieldSelector/InputfieldSelector.module index e042eb92..b4a11706 100644 --- a/wire/modules/Inputfield/InputfieldSelector/InputfieldSelector.module +++ b/wire/modules/Inputfield/InputfieldSelector/InputfieldSelector.module @@ -1828,6 +1828,9 @@ class InputfieldSelector extends Inputfield implements ConfigurableModule { throw new WireException('initTemplate must be a Template or null'); } } + if($key === 'limitFields' && !is_array($value)) { + $value = $this->wire()->sanitizer->array($value); + } return parent::set($key, $value); } diff --git a/wire/modules/Inputfield/InputfieldToggle/InputfieldToggle.js b/wire/modules/Inputfield/InputfieldToggle/InputfieldToggle.js index 5a70bfdf..4f6161ab 100644 --- a/wire/modules/Inputfield/InputfieldToggle/InputfieldToggle.js +++ b/wire/modules/Inputfield/InputfieldToggle/InputfieldToggle.js @@ -32,7 +32,7 @@ function InputfieldToggleInit() { // allow for labels as prev sibling of input or label as parent element of input var $label = getLabelFromInput($input); - var $prevInput = $input.closest('.Inputfield').find('input.' + inputCheckedClass); + var $prevInput = $input.closest('.InputfieldToggle').find('input.' + inputCheckedClass); var $prevLabel = $prevInput.length ? getLabelFromInput($prevInput) : null; // check of another item was clicked when an existing selection was in place diff --git a/wire/modules/Inputfield/InputfieldToggle/InputfieldToggle.min.js b/wire/modules/Inputfield/InputfieldToggle/InputfieldToggle.min.js index 312fdc26..045c9a2e 100644 --- a/wire/modules/Inputfield/InputfieldToggle/InputfieldToggle.min.js +++ b/wire/modules/Inputfield/InputfieldToggle/InputfieldToggle.min.js @@ -1 +1 @@ -function InputfieldToggleInit(){var isClick=false;var inputCheckedClass="InputfieldToggleChecked";var labelCheckedClass="InputfieldToggleCurrent";function getLabelFromInput($input){var $label=$input.next("label");if(!$label.length)$label=$input.parent("label");if(!$label.length)$label=$("label[for="+$input.attr("id")+"]");return $label}function getInputFromLabel($label){var $input=$label.prev("input");if(!$input.length)$input=$label.find("input");if(!$input.length)$input=$("input[id="+$label.attr("for")+"]");return $input}function toggleInputEvent($input){var $label=getLabelFromInput($input);var $prevInput=$input.closest(".Inputfield").find("input."+inputCheckedClass);var $prevLabel=$prevInput.length?getLabelFromInput($prevInput):null;if($prevInput.length&&$prevInput.attr("id")!=$input.attr("id")){$prevInput.removeClass(inputCheckedClass).prop("checked",false);if($prevLabel)$prevLabel.removeClass(labelCheckedClass)}if($input.hasClass(inputCheckedClass)&&$input.closest(".InputfieldToggleUseDeselect").length){$input.prop("checked",false).removeClass(inputCheckedClass);$label.removeClass(labelCheckedClass);setTimeout(function(){$input.prop("checked",false).trigger("change")},100)}else{$input.prop("checked",true);$input.addClass(inputCheckedClass);$label.addClass(labelCheckedClass);$input.trigger("change")}}function initEvents(){$(document).on("change",".InputfieldToggle input",function(){if(isClick)return false;toggleInputEvent($(this))}).on("click",".InputfieldToggle label:not(.InputfieldHeader)",function(event){if(isClick)return false;var $label=$(this);var $input=getInputFromLabel($label);if(!$input.length)return;isClick=true;toggleInputEvent($input);setTimeout(function(){isClick=false},200);if($input.closest(".InputfieldToggleGroup").length)return false})}function initColors(){var $button=$(".InputfieldToggleHelper > button");var $input=$(".InputfieldToggleHelper > input");if(!$button.length)$button=$(".InputfieldForm button.ui-priority-secondary:eq(0)");if(!$button.length)$button=$(".InputfieldForm button.ui-button:eq(0)");if(!$button.length)$button=$(".InputfieldForm button[type=submit]");if(!$input.length)$input=$(".InputfieldForm input[type=text]:eq(0)");if(!$button.length||!$input.length)return;InputfieldToggleSetColors({onBg:$button.css("background-color"),on:$button.css("color"),offBg:$input.css("background-color"),off:$input.css("color"),border:$input.css("border-bottom-color")})}initEvents();initColors()}function InputfieldToggleSetColors(customColors){var colors={on:"",onBg:"",off:"",offBg:"",border:"",hoverBg:"",hover:""};$.extend(colors,customColors);if(!colors.hoverBg&&colors.onBg){colors.hoverBg=colors.onBg.replace("rgb(","rgba(").replace(")",",.2)");if(!colors.hover)colors.hover=colors.off}var style="";$("head").append(style)}jQuery(document).ready(function($){InputfieldToggleInit()}); \ No newline at end of file +function InputfieldToggleInit(){var isClick=false;var inputCheckedClass="InputfieldToggleChecked";var labelCheckedClass="InputfieldToggleCurrent";function getLabelFromInput($input){var $label=$input.next("label");if(!$label.length)$label=$input.parent("label");if(!$label.length)$label=$("label[for="+$input.attr("id")+"]");return $label}function getInputFromLabel($label){var $input=$label.prev("input");if(!$input.length)$input=$label.find("input");if(!$input.length)$input=$("input[id="+$label.attr("for")+"]");return $input}function toggleInputEvent($input){var $label=getLabelFromInput($input);var $prevInput=$input.closest(".InputfieldToggle").find("input."+inputCheckedClass);var $prevLabel=$prevInput.length?getLabelFromInput($prevInput):null;if($prevInput.length&&$prevInput.attr("id")!=$input.attr("id")){$prevInput.removeClass(inputCheckedClass).prop("checked",false);if($prevLabel)$prevLabel.removeClass(labelCheckedClass)}if($input.hasClass(inputCheckedClass)&&$input.closest(".InputfieldToggleUseDeselect").length){$input.prop("checked",false).removeClass(inputCheckedClass);$label.removeClass(labelCheckedClass);setTimeout(function(){$input.prop("checked",false).trigger("change")},100)}else{$input.prop("checked",true);$input.addClass(inputCheckedClass);$label.addClass(labelCheckedClass);$input.trigger("change")}}function initEvents(){$(document).on("change",".InputfieldToggle input",function(){if(isClick)return false;toggleInputEvent($(this))}).on("click",".InputfieldToggle label:not(.InputfieldHeader)",function(event){if(isClick)return false;var $label=$(this);var $input=getInputFromLabel($label);if(!$input.length)return;isClick=true;toggleInputEvent($input);setTimeout(function(){isClick=false},200);if($input.closest(".InputfieldToggleGroup").length)return false})}function initColors(){var $button=$(".InputfieldToggleHelper > button");var $input=$(".InputfieldToggleHelper > input");if(!$button.length)$button=$(".InputfieldForm button.ui-priority-secondary:eq(0)");if(!$button.length)$button=$(".InputfieldForm button.ui-button:eq(0)");if(!$button.length)$button=$(".InputfieldForm button[type=submit]");if(!$input.length)$input=$(".InputfieldForm input[type=text]:eq(0)");if(!$button.length||!$input.length)return;InputfieldToggleSetColors({onBg:$button.css("background-color"),on:$button.css("color"),offBg:$input.css("background-color"),off:$input.css("color"),border:$input.css("border-bottom-color")})}initEvents();initColors()}function InputfieldToggleSetColors(customColors){var colors={on:"",onBg:"",off:"",offBg:"",border:"",hoverBg:"",hover:""};$.extend(colors,customColors);if(!colors.hoverBg&&colors.onBg){colors.hoverBg=colors.onBg.replace("rgb(","rgba(").replace(")",",.2)");if(!colors.hover)colors.hover=colors.off}var style="";$("head").append(style)}jQuery(document).ready(function($){InputfieldToggleInit()}); \ No newline at end of file diff --git a/wire/modules/Process/ProcessPageLister/ProcessPageLister.module b/wire/modules/Process/ProcessPageLister/ProcessPageLister.module index adaaacbb..cc5101c4 100644 --- a/wire/modules/Process/ProcessPageLister/ProcessPageLister.module +++ b/wire/modules/Process/ProcessPageLister/ProcessPageLister.module @@ -530,13 +530,15 @@ class ProcessPageLister extends Process implements ConfigurableModule { * */ public function set($key, $value) { - if($key == 'openPageIDs' && is_array($value)) { + if($key === 'openPageIDs' && is_array($value)) { $this->openPageIDs = $value; return $this; - } else if($key == 'parent' && !$value instanceof Page) { - $value = $this->wire('pages')->get($value); + } else if($key === 'parent' && !$value instanceof Page) { + $value = $this->wire()->pages->get($value); } else if($key === 'finalSelector') { $this->finalSelector = $value; + } else if($key === 'limitFields' && !is_array($value)) { + $value = $this->wire()->sanitizer->array($value); } return parent::set($key, $value); }