Sid Gifari File Manager
🏠 Root
/
home2
/
meumer25
/
www
/
wp-content
/
plugins
/
wpforms-lite
/
assets
/
js
/
admin
/
builder
/
modules
/
undo-redo
/
Editing: choices-list.min.js
export default function(e,o,t){class n extends WPForms.Admin.Builder.UndoRedoInputCommandBase.get(){static id="ChoicesListDefaultChangeCommand";canMerge(){return!1}applyValue(e){var o=this.getElement(),n=o.closest(".choices-list");if(n?.length&&e&&"function"==typeof e[Symbol.iterator]){r.preventRecordingCommand=!0;for(var[t,i]of e){t=n.find(`li[data-key="${t}"] input.default`);t.length&&t.prop("checked",!!i)}o.trigger("change");e=o.closest(".choices-list"),o=e.data("field-type"),e=e.data("field-id");WPFormsBuilder.fieldChoiceUpdate(o,e),r.preventRecordingCommand=!1}}getInputLabel(){return r.getInputLabel(this.$input)}}class i extends WPForms.Admin.Builder.UndoRedoInputCommandBase.get(){static id="ChoicesListIconChoiceChangeCommand";applyValue(e){var o=this.getElement(),n=o.closest("li"),o=o.closest(".wpforms-field-option-row-choices"),t=o.find("ul").data("field-type"),o=o.data("field-id");WPFormsBuilder.iconChoices.updateIcon(n,e?.icon,e?.style),WPFormsBuilder.fieldChoiceUpdate(t,o)}getInputLabel(){return wp.i18n.__("Choice Icon","wpforms")}}class d extends WPForms.Admin.Builder.UndoRedoActionCommandBase.get(){static id="ChoicesListReorderCommand";constructor(e){super(e),this.actionName=this.getActionName()}execute(){r.UndoRedo.executeTriggerEvents&&this.reorderChoices(this.args,"new")}undo(){r.UndoRedo.executeTriggerEvents&&this.reorderChoices(this.args,"old")}reorderChoices(e,o){var n;e[o="new"===o?"new":"old"].$container?.length&&(r.UndoRedo.preventRecord(!0),n=r.UndoRedoHelpers.getElement(e[o].$container),(o=e[o].$container).find("li").attr("style",null),o.find("li.ui-sortable-placeholder").remove(),this.replaceDOMElementContent(n,o),r.el.$builder.trigger(e.event??"wpformsFieldChoiceMove",[e.ui]),WPFormsBuilder.fieldChoiceUpdate(e.fieldType,e.fieldId),r.UndoRedo.preventRecord(!1))}getActionName(){var e,o;return this.actionName||(e=r.UndoRedoHelpersFields.getFieldName(this.args.fieldType),o=`(#${this.args.fieldId})`,[wp.i18n.__("Reorder choices","wpforms"),r.actionNameSeparator,e,o].filter(Boolean).join(" "))}}let r={el:{},sel:{choicesList:".choices-list",choicesListDefault:".choices-list input.default",iconChoiceIconSelect:".choices-list .wpforms-icon-select",iconChoiceIcon:"input.source-icon",iconChoiceIconStyle:"input.source-icon-style"},undoManager:null,init(){r.setup(),r.el.$builder.on("wpformsBuilderReady",_.debounce(r.ready,250))},setup(){r.el.$document=t(e),r.el.$builder=t("#wpforms-builder")},ready(){try{r.UndoRedo=WPForms.Admin.Builder.UndoRedo,r.UndoRedoHelpers=WPForms.Admin.Builder.UndoRedoHelpers,r.undoManager=r.UndoRedo.undoManager,r.UndoRedoHelpersFields=WPForms.Admin.Builder.UndoRedoHelpersFields,r.actionNameSeparator=r.UndoRedo.config.actionNameSeparator,r.el={...r.el,...r.UndoRedo.el}}catch(e){return void wpf.debug("UndoRedoChoicesList: Dependency modules are not available.")}r.UndoRedo.registerCommand(n),r.UndoRedo.registerCommand(i),r.UndoRedo.registerCommand(d),r.events()},events(){r.el.$document.on("mousedown",r.sel.choicesListDefault,r.onChoicesListDefaultInteraction).on("focus",r.sel.choicesListDefault,r.onChoicesListDefaultInteraction).on("change",r.sel.choicesListDefault,r.onChoicesListDefaultChange),r.el.$builder.on("mousedown",r.sel.iconChoiceIconSelect,r.onIconChoiceIconSelectClick).on("wpformsBuilderIconChoicesIconSelected",r.onIconChoicesIconSelected),r.el.$builder.on("wpformsBeforeFieldChoiceDragStart",r.onBeforeFieldChoiceDragStart).on("wpformsBeforeLikertScaleFieldChoiceDragStart",r.onBeforeFieldChoiceDragStart).on("wpformsFieldChoiceMove",r.onFieldChoiceMove).on("wpformsLikertScaleFieldChoiceMove",r.onFieldChoiceMove)},getChoicesListDefaultValues(e){e=e?.closest(".choices-list");if(!e?.length)return null;let n=new Map;return e.find("li").each(function(){var e=t(this),o=e.find("input.default"),e=e.data("key");n.set(e,o.is(":checked"))}),n},onChoicesListDefaultInteraction(e){var e=t(e.target),o=e.closest(".choices-list"),o=r.UndoRedoHelpers.getElementKey(o);r.UndoRedo.trackedInputs.set(o,r.getChoicesListDefaultValues(e))},onChoicesListDefaultChange(e){var o,n;r.UndoRedo.isSuppressed()||r.UndoRedo.isRecordPrevented()||r.preventRecordingCommand||(o=(e=t(e.target)).closest(".choices-list"),o=r.UndoRedoHelpers.getElementKey(o),(o=r.UndoRedo.trackedInputs.get(o))&&(n=r.getChoicesListDefaultValues(e),e=r.UndoRedo.getCommand("ChoicesListDefaultChangeCommand",e,o,n),r.UndoRedo.record(e)))},onIconChoiceIconSelectClick(){var e=t(this).find(r.sel.iconChoiceIcon),o=t(this).find(r.sel.iconChoiceIconStyle),n=r.UndoRedoHelpers.getElementKey(e),e={icon:e.val(),style:o.val()};r.UndoRedo.trackedInputs.set(n,e)},onIconChoicesIconSelected(e,o,n,t){var i;r.UndoRedo.isSuppressed()||r.UndoRedo.isRecordPrevented()||r.preventRecordingCommand||(o=o.find(r.sel.iconChoiceIcon),i=r.UndoRedoHelpers.getElementKey(o),i=r.UndoRedo.trackedInputs.get(i),n={icon:n,style:t},r.UndoRedoHelpers.areValuesEqual(i,n))||(t=r.UndoRedo.getCommand("ChoicesListIconChoiceChangeCommand",o,i,n),r.UndoRedo.record(t))},onBeforeFieldChoiceDragStart(e,o){r.UndoRedo.isRecordPrevented()||(r.$trackContainer=r.UndoRedoHelpers.getElement(o.item.closest(".choices-list")),r.UndoRedoHelpers.getCurrentContainer(r.$trackContainer))},onFieldChoiceMove(e,o){r.UndoRedo.isRecordPrevented()||r.$trackContainer?.length&&(e=r.UndoRedo.getCommand("ChoicesListReorderCommand",{fieldType:r.$trackContainer.data("field-type"),fieldId:r.$trackContainer.data("field-id"),event:e.type??"",ui:o,old:{$container:r.UndoRedoHelpers.getTrackedContainer(r.$trackContainer)},new:{$container:r.UndoRedoHelpers.getCurrentContainer(r.$trackContainer)}}),r.UndoRedo.record(e))},getInputLabel(e){return e?.closest(r.sel.choicesList).length?(e=e.attr("name")??"").includes("[default]")?wp.i18n.__("Default choices","wpforms"):e.includes("[label]")?wp.i18n.__("Choice label","wpforms"):e.includes("[value]")?wp.i18n.__("Choice value","wpforms"):"":""}};return r}
Save
Cancel