/** * inputfields.js - JS specific to behavior of ProcessWire Inputfield forms. * * REQUIREMENTS * ============ * - ProcessWire or a module that uses its Inputfield Forms * - One or more form.InputfieldForm elements * - jQuery is used throughout * * PUBLIC API (3.0.144+) * ========== * Note: any 'f' below arguments may be an Inputfield $element, "#id" string, ".class" string or field name. * Many of the functions also support extra arguments such as a callback function, see Inputfields variable * definition for more details on arguments. For functions that show “…” as the arguments, see the full * function definition for details. * * - Inputfields.open(f): Open the given Inputfield if not already open. * - Inputfields.close(f): Close the given Inputfield if not already closed. * - Inputfields.toggle(f): Find and toggle the open/closed state of given Inputfield. * - Inputfields.find(f): Find and highlight the given Inputfield (at any depth, in any tab). * - Inputfields.focus(f): Find the given Inputfield and focus its input element (at any depth, in any tab). * - Inputfields.highlight(f): Temporarily highlight the given Inputfield with a background color. * - Inputfields.reload(f): Force given Inputfield to reload via ajax (if supported). * - Inputfields.redraw(…): Redraw Inputfields after a visibility or width change. * - Inputfields.inView(f): Is the Inputfield currently in the user’s viewable area? * - Inputfields.hidden(f): Does the given Inputfield currently have a hidden state? * - Inputfields.changed(f): Has given Inputfield changed? (or use 2nd argument to set) * - Inputfields.columnWidth(f): Get the column width percent of Inputfield (between 1-100) * - Inputfields.columnWidth(f, w): Set the column width percent of Inputfield, where w is percent width between 1-100. * - Inputfields.name(f): Get the name of the given Inputfield * - Inputfields.label(f): Get the text label of the given Inputfield * - Inputfields.input(f): Get the input element(s) within the given Inputfield * - Inputfields.insertBefore(f, ff): Insert Inputfield 'f' before Inputfield 'ff'. * - Inputfields.insertAfter(f, ff): Insert Inputfield 'f' after Inputfield 'ff'. * - Inputfields.startSpinner(f): Start spinner for Inputfield. * - Inputfields.stopSpinner(f): Stop spinner for Inputfield. * - Inputfields.init(target): Manually initialize all .Inputfield elements within target. * Calling init() is only necessary for Inputfields not present during page load. * - This file also contains lots of other functions, but they are not part of the public API. * * CLASSES * ======= * Form classes: * - InputfieldForm: Class assigned to all Inputfield forms. * - InputfieldFormConfirm: Form that will warn the user if they attempt to navigate away before submit. * - InputfieldFormSubmitted: Class assigned to form when the submit button has been pressed. * - InputfieldFormFocusFirst: Class assigned to form that should focus the first field. * - InputfieldFormNoDependencies: Form with dependencies disabled. * - InputfieldFormNoWidths: Form with column widths disabled (or handled elsewhere). * - InputfieldFormNoHeights: Form where matching of column heights is disabled (or handled elsewhere). * - InputfieldFormNoFocus: Form where automatic focus of first field is specificallyl disabled. * - nosubmit: Internal class assigned when submit of form is temporarily disabled due to other events. * * Form field (Inputfield) classes: * - Inputfield: Assigned to all Inputfield elements. * - Inputfield[Type]: Class where [Type] is replaced by Inputfield type, i.e. "Radios", "Select", etc. * - InputfieldWrapper: Assigned to Inputfields that can contain other Inputfield elements. * - InputfieldStateHidden: Item that is current in a hidden state (not visible to user). * - InputfieldStateRequired: Item that requires a value in at least one of its inputs. * - InputfieldStateChanged: Item that has changed. * - InputfieldStateShowIf: Item that contains a show-if dependency via a 'data-show-if' attribute. * - InputfieldStateRequiredIf: Item that contains a required-if dependency via a 'data-required-if' attribute. * - InputfieldStateCollapsed: Item that is collapsed and must be clicked to be opened. * - InputfieldStateWasCollapsed: Item that was previously collapsed. * - InputfieldStateToggling: Item that is currently between an open and collapsed state. * - InputfieldColumnWidth: Item that has some column width smaller than 100%. * - InputfieldColumnWidthFirst: Item that has column width < 100% and is the first in a row of columns. * - InputfieldColumnWidthFirstTmp: Temporary/runtime class for column width used internally. * - InputfieldNoFocus: Item that should not have its input element automatically focused. * - InputfieldAjaxLoading: Item that is currently loading from an ajax request. * - InputfieldIgnoreChanges: Item that should not be tracked for changes to value. * - InputfieldHasUpload: Item that has a file upload input within it. * - InputfieldIsOffset: Item that is offset from others (not supported by all admin themes). * - InputfieldRepeaterItem: Item that represents a Repeater item. * - collapsed9: Item that is not collapsible (always open). * - collapsed10: Item that is collapsed and dynamically loaded by AJAX when opened. * - collapsed11: Item that is collapsed only when blank, and dynamically loaded by AJAX when opened. * * Children of Inputfield elements have these classes: * - InputfieldHeader: Assigned to the header of an Inputfield, typically the