From b179aa9afcd1469ba3af339b870d4ce33b7be13d Mon Sep 17 00:00:00 2001 From: Ryan Cramer Date: Wed, 31 Jul 2019 09:36:19 -0400 Subject: [PATCH] Various improvements to asmSelect jQuery plugin, including better parent/child option support with technical improvements (now works with Safari too), and some code and documentation improvements as well. --- .../InputfieldAsmSelect.module | 2 +- .../asmselect/jquery.asmselect.css | 12 +- .../asmselect/jquery.asmselect.js | 575 +++++++++++++----- .../asmselect/jquery.asmselect.min.js | 2 +- 4 files changed, 419 insertions(+), 172 deletions(-) diff --git a/wire/modules/Inputfield/InputfieldAsmSelect/InputfieldAsmSelect.module b/wire/modules/Inputfield/InputfieldAsmSelect/InputfieldAsmSelect.module index aadeb187..63be1313 100644 --- a/wire/modules/Inputfield/InputfieldAsmSelect/InputfieldAsmSelect.module +++ b/wire/modules/Inputfield/InputfieldAsmSelect/InputfieldAsmSelect.module @@ -13,7 +13,7 @@ class InputfieldAsmSelect extends InputfieldSelectMultiple implements Inputfield public static function getModuleInfo() { return array( 'title' => __('asmSelect', __FILE__), - 'version' => 122, + 'version' => 200, 'summary' => __('Multiple selection, progressive enhancement to select multiple', __FILE__), // Module Summary 'permanent' => true, ); diff --git a/wire/modules/Inputfield/InputfieldAsmSelect/asmselect/jquery.asmselect.css b/wire/modules/Inputfield/InputfieldAsmSelect/asmselect/jquery.asmselect.css index 8ec11865..93addaf5 100644 --- a/wire/modules/Inputfield/InputfieldAsmSelect/asmselect/jquery.asmselect.css +++ b/wire/modules/Inputfield/InputfieldAsmSelect/asmselect/jquery.asmselect.css @@ -15,8 +15,10 @@ .asmHighlight { /* the highlight span */ padding: 0; - margin: 0 0 0 1em; + margin: 0 0 0 0.5em; display: inline; + font-size: smaller; + opacity: 0.7; } .asmList { @@ -148,6 +150,10 @@ span.asmFieldsetIndent { font-weight: bold; } -option.asmChild { - display: none; +@media screen and (max-width: 767px) { + /* do not show asmHighlight elements on small viewports */ + .asmHighlight { + display: none !important; + } } + diff --git a/wire/modules/Inputfield/InputfieldAsmSelect/asmselect/jquery.asmselect.js b/wire/modules/Inputfield/InputfieldAsmSelect/asmselect/jquery.asmselect.js index cd467817..5bcb3f86 100644 --- a/wire/modules/Inputfield/InputfieldAsmSelect/asmselect/jquery.asmselect.js +++ b/wire/modules/Inputfield/InputfieldAsmSelect/asmselect/jquery.asmselect.js @@ -1,8 +1,8 @@ /* - * Alternate Select Multiple (asmSelect) 1.4 - jQuery Plugin + * Alternate Select Multiple (asmSelect) 2.0 - jQuery Plugin * https://processwire.com * - * Copyright (c) 2009-2019 by Ryan Cramer - http://www.ryancramer.com + * Copyright (c) 2009-2019 by Ryan Cramer * * Licensed under the MIT license. * @@ -14,77 +14,103 @@ var options = { - listType: 'ol', // Ordered list 'ol', or unordered list 'ul' - sortable: false, // Should the list be sortable? - addable: true, // Can items be added to selection? - deletable: true, // Can items be removed from selection? - highlight: false, // Use the highlight feature? - fieldset: false, // Use fieldset support? (for PW Fieldset types) - animate: false, // Animate the the adding/removing of items in the list? - addItemTarget: 'bottom', // Where to place new selected items in list: top or bottom - hideWhenAdded: false, // Hide the option when added to the list? works only in FF - hideWhenEmpty: false, // Hide the when there are no items available to select? + debugMode: false, // Debug mode keeps original select visible + jQueryUI: true, // use jQuery UI? + hideDeleted: true, // Hide items when deleted. If false, items remain but are marked for deletion + deletedOpacity: 0.5, // opacity of deleted item, set to 1.0 to disable opacity adjustment (applicable only if hideDeleted=true) + deletedPrepend: '-', // Deleted item values are prepended with this character in the form submission (applicable only if hideDeleted=true) + useSelect2: true, // use a separate select for unselected child options? (required by Safari) + removeWhenAdded: false, // no longer used (was a separate select that contained removed items) + highlightTag: '', // Tag to use for highlight element highlight option is in use - // sortLabel: '', // sortable handle/icon + // Labels sortLabel: '', // sortable handle/icon - // removeLabel: 'remove', // Text used in the "remove" link removeLabel: '×', // Text used in the "remove" link - highlightAddedLabel: 'Added: ', // Text that precedes highlight of added item - highlightRemovedLabel: 'Removed: ', // Text that precedes highlight of removed item + highlightAddedLabel: 'Added: ', // Text that precedes highlight of added item + highlightRemovedLabel: 'Removed: ', // Text that precedes highlight of removed item - containerClass: 'asmContainer', // Class for container that wraps this widget - selectClass: 'asmSelect', // Class for the newly created + optionDisabledClass: 'asmOptionDisabled', // Class for items that are already selected / disabled + listClass: 'asmList', // Class for the list ($ol) + listSortableClass: 'asmListSortable', // Another class given to the list when it is sortable + listItemClass: 'asmListItem', // Class for the
  • list items + listItemLabelClass: 'asmListItemLabel', // Class for the label text that appears in list items + listItemDescClass: 'asmListItemDesc', // Class for optional description text, set a data-desc attribute on the
  • from an