diff --git a/Build/Sources/TypeScript/backend/form-engine.ts b/Build/Sources/TypeScript/backend/form-engine.ts index 129d5a50b78572d218b6145d4f86a2a9dfbcfcb4..39ef71d2a025d52596f445d4240c8d0cf9ba49ca 100644 --- a/Build/Sources/TypeScript/backend/form-engine.ts +++ b/Build/Sources/TypeScript/backend/form-engine.ts @@ -66,8 +66,8 @@ export default (function() { } }); // @see \TYPO3\CMS\Backend\Form\Behavior\ReloadOnFieldChange - onFieldChangeHandlers.set('typo3-backend-form-reload', (data: {confirm: boolean}, evt: Event) => { - if (!data.confirm) { + onFieldChangeHandlers.set('typo3-backend-form-reload', (data: {confirmation: boolean}, evt: Event) => { + if (!data.confirmation) { FormEngine.saveDocument(); return; } diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/form-engine.js b/typo3/sysext/backend/Resources/Public/JavaScript/form-engine.js index 82d35052139032cd1f6580c6ab5899920568e6a9..6cca8c42a9b2d3d62ca2c74270cfeb8fc154bec8 100644 --- a/typo3/sysext/backend/Resources/Public/JavaScript/form-engine.js +++ b/typo3/sysext/backend/Resources/Public/JavaScript/form-engine.js @@ -10,4 +10,4 @@ * * The TYPO3 project - inspiring people to share! */ -import $ from"jquery";import FormEngineValidation from"@typo3/backend/form-engine-validation.js";import Icons from"@typo3/backend/icons.js";import Modal from"@typo3/backend/modal.js";import*as MessageUtility from"@typo3/backend/utility/message-utility.js";import Severity from"@typo3/backend/severity.js";import*as BackendExceptionModule from"@typo3/backend/backend-exception.js";import InteractionRequestMap from"@typo3/backend/event/interaction-request-map.js";export default(function(){function e(e,n){n?t.interactionRequestMap.resolveFor(e):t.interactionRequestMap.rejectFor(e)}const n=new Map;n.set("typo3-backend-form-update-value",(e,n)=>{const t=document.querySelector('[name="'+CSS.escape(e.elementName)+'"]'),a=document.querySelector('[data-formengine-input-name="'+CSS.escape(e.elementName)+'"]');FormEngineValidation.updateInputField(e.elementName),null!==t&&(FormEngineValidation.markFieldAsChanged(t),FormEngineValidation.validateField(t)),null!==a&&a!==t&&FormEngineValidation.validateField(a)}),n.set("typo3-backend-form-reload",(e,n)=>{e.confirm?Modal.confirm(TYPO3.lang["FormEngine.refreshRequiredTitle"],TYPO3.lang["FormEngine.refreshRequiredContent"]).on("button.clicked",e=>{"ok"==e.target.name&&t.saveDocument(),Modal.dismiss()}):t.saveDocument()}),n.set("typo3-backend-form-update-bitmask",(e,n)=>{const t=n.target,a=document.editform[e.elementName],o=t.checked!==e.invert,i=Math.pow(2,e.position),r=Math.pow(2,e.total)-i-1;a.value=o?a.value|i:a.value&r,a.dispatchEvent(new Event("change",{bubbles:!0,cancelable:!0}))});const t={consumeTypes:["typo3.setUrl","typo3.beforeSetUrl","typo3.refresh"],Validation:FormEngineValidation,interactionRequestMap:InteractionRequestMap,formName:TYPO3.settings.FormEngine.formName,openedPopupWindow:null,legacyFieldChangedCb:function(){!$.isFunction(TYPO3.settings.FormEngine.legacyFieldChangedCb)||TYPO3.settings.FormEngine.legacyFieldChangedCb()},browserUrl:"",openPopupWindow:function(e,n,a){return Modal.advanced({type:Modal.types.iframe,content:t.browserUrl+"&mode="+e+"&bparams="+n+(a?"&"+("db"===e?"expandPage":"expandFolder")+"="+a:""),size:Modal.sizes.large})},setSelectOptionFromExternalSource:function(e,n,a,o,i,r){i=String(i);let l,c,s=!1,d=!1;if(l=t.getFieldElement(e),c=l.get(0),null===c||"--div--"===n||c instanceof HTMLOptGroupElement)return;const u=t.getFieldElement(e,"_list",!0);if(u.length>0&&(l=u,s=l.prop("multiple")&&"1"!=l.prop("size"),d=!0),s||d){const d=t.getFieldElement(e,"_avail");if(s||(l.find("option").each((e,n)=>{const a=d.find('option[value="'+$.escapeSelector($(n).attr("value"))+'"]');a.length&&(a.removeClass("hidden").prop("disabled",!1),t.enableOptGroup(a.get(0)))}),l.empty()),i){let e=!1,a=new RegExp("(^|,)"+n+"($|,)");i.match(a)?(l.empty(),e=!0):1==l.find("option").length&&(a=new RegExp("(^|,)"+l.find("option").prop("value")+"($|,)"),i.match(a)&&(l.empty(),e=!0)),e&&void 0!==r&&r.closest("select").querySelectorAll("[disabled]").forEach((function(e){e.classList.remove("hidden"),e.disabled=!1,t.enableOptGroup(e)}))}let u=!0;const m=t.getFieldElement(e,"_mul",!0);if((0==m.length||0==m.val())&&(l.find("option").each((function(e,t){if($(t).prop("value")==n)return u=!1,!1})),u&&void 0!==r)){r.classList.add("hidden"),r.disabled=!0;const e=r.parentElement;e instanceof HTMLOptGroupElement&&0===e.querySelectorAll("option:not([disabled]):not([hidden]):not(.hidden)").length&&(e.disabled=!0,e.classList.add("hidden"))}if(u){const e=$("<option></option>");e.attr({value:n,title:o}).text(a),e.appendTo(l),t.updateHiddenFieldValueFromSelect(l,c),t.legacyFieldChangedCb(),FormEngineValidation.markFieldAsChanged(c),t.Validation.validateField(l),t.Validation.validateField(d)}}else{const e=/_(\d+)$/,a=n.toString().match(e);null!=a&&(n=a[1]),l.val(n),t.Validation.validateField(l)}},updateHiddenFieldValueFromSelect:function(e,n){const t=[];$(e).find("option").each((e,n)=>{t.push($(n).prop("value"))}),n.value=t.join(","),n.dispatchEvent(new Event("change",{bubbles:!0,cancelable:!0}))},getFormElement:function(e){const n=$('form[name="'+t.formName+'"]:first');if(!e)return n;{const a=t.getFieldElement(e),o=t.getFieldElement(e,"_list");if(a.length>0&&("select-one"===a.prop("type")||o.length>0&&o.prop("type").match(/select-(one|multiple)/)))return n;console.error("Form fields missing: form: "+t.formName+", field name: "+e),alert("Form field is invalid")}},getFieldElement:function(e,n,a){const o=$('form[name="'+t.formName+'"]:first');if(n){let t;switch(n){case"_list":t=$(':input[data-formengine-input-name="'+e+'"]:not([type=hidden])',o);break;case"_avail":t=$(':input[data-relatedfieldname="'+e+'"]',o);break;case"_mul":case"_hr":t=$(':input[type=hidden][data-formengine-input-name="'+e+'"]',o);break;default:t=null}if(t&&t.length>0||!0===a)return t}return $(':input[name="'+e+'"]',o)},initializeEvents:function(){top.TYPO3&&void 0!==top.TYPO3.Backend&&(top.TYPO3.Backend.consumerScope.attach(t),$(window).on("unload",(function(){top.TYPO3.Backend.consumerScope.detach(t)}))),$(document).on("click",".t3js-editform-close",e=>{e.preventDefault(),t.preventExitIfNotSaved(t.preventExitIfNotSavedCallback)}).on("click",".t3js-editform-view",e=>{e.preventDefault(),t.previewAction(e,t.previewActionCallback)}).on("click",".t3js-editform-new",e=>{e.preventDefault(),t.newAction(e,t.newActionCallback)}).on("click",".t3js-editform-duplicate",e=>{e.preventDefault(),t.duplicateAction(e,t.duplicateActionCallback)}).on("click",".t3js-editform-delete-record",e=>{e.preventDefault(),t.deleteAction(e,t.deleteActionCallback)}).on("click",".t3js-editform-submitButton",e=>{const n=$(e.currentTarget),t=n.data("name")||e.currentTarget.name,a=$("<input />").attr("type","hidden").attr("name",t).attr("value","1");n.parents("form").append(a)}).on("change",'.t3-form-field-eval-null-checkbox input[type="checkbox"]',e=>{$(e.currentTarget).closest(".t3js-formengine-field-item").toggleClass("disabled")}).on("change",'.t3js-form-field-eval-null-placeholder-checkbox input[type="checkbox"]',e=>{t.toggleCheckboxField($(e.currentTarget)),FormEngineValidation.markFieldAsChanged($(e.currentTarget))}).on("change",(function(e){$(".module-docheader-bar .btn").removeClass("disabled").prop("disabled",!1)})).on("click",".t3js-element-browser",(function(e){e.preventDefault(),e.stopPropagation();const n=$(e.currentTarget),a=n.data("mode"),o=n.data("params"),i=n.data("entryPoint");t.openPopupWindow(a,o,i)})).on("click",'[data-formengine-field-change-event="click"]',e=>{const n=JSON.parse(e.currentTarget.dataset.formengineFieldChangeItems);t.processOnFieldChange(n,e)}).on("change",'[data-formengine-field-change-event="change"]',e=>{const n=JSON.parse(e.currentTarget.dataset.formengineFieldChangeItems);t.processOnFieldChange(n,e)}),document.editform.addEventListener("submit",(function(){if(document.editform.closeDoc.value)return;const e=["button[form]",'button[name^="_save"]','a[data-name^="_save"]','button[name="CMD"][value^="save"]','a[data-name="CMD"][data-value^="save"]'].join(","),n=document.querySelector(e);null!==n&&(n.disabled=!0,Icons.getIcon("spinner-circle-dark",Icons.sizes.small).then((function(e){n.querySelector(".t3js-icon").outerHTML=e})))})),window.addEventListener("message",t.handlePostMessage)},consume:function(n){if(!n)throw new BackendExceptionModule.BackendException("No interaction request given",1496589980);const a=$.Deferred();if(n.concernsTypes(t.consumeTypes)){const o=n.outerMostRequest;t.interactionRequestMap.attachFor(o,a),o.isProcessed()?e(o,o.getProcessedData().response):t.hasChange()?t.preventExitIfNotSaved((function(n){o.setProcessedData({response:n}),e(o,n)})):t.interactionRequestMap.resolveFor(o)}return a},handlePostMessage:function(e){if(!MessageUtility.MessageUtility.verifyOrigin(e.origin))throw"Denied message sent by "+e.origin;if("typo3:elementBrowser:elementAdded"===e.data.actionName){if(void 0===e.data.fieldName)throw"fieldName not defined in message";if(void 0===e.data.value)throw"value not defined in message";const n=e.data.label||e.data.value,a=e.data.title||n,o=e.data.exclusiveValues||"";t.setSelectOptionFromExternalSource(e.data.fieldName,e.data.value,n,a,o)}},initializeRemainingCharacterViews:function(){const e=$("[maxlength]").not(".t3js-datetimepicker").not(".t3js-color-picker").not(".t3js-charcounter-initialized");e.on("focus",e=>{const n=$(e.currentTarget),a=n.parents(".t3js-formengine-field-item:first"),o=t.getCharacterCounterProperties(n);a.append($("<div />",{class:"t3js-charcounter"}).append($("<span />",{class:o.labelClass}).text(TYPO3.lang["FormEngine.remainingCharacters"].replace("{0}",o.remainingCharacters))))}).on("blur",e=>{$(e.currentTarget).parents(".t3js-formengine-field-item:first").find(".t3js-charcounter").remove()}).on("keyup",e=>{const n=$(e.currentTarget),a=n.parents(".t3js-formengine-field-item:first"),o=t.getCharacterCounterProperties(n);a.find(".t3js-charcounter span").removeClass().addClass(o.labelClass).text(TYPO3.lang["FormEngine.remainingCharacters"].replace("{0}",o.remainingCharacters))}),e.addClass("t3js-charcounter-initialized")},getCharacterCounterProperties:function(e){const n=e.val(),t=e.attr("maxlength")-n.length-(n.match(/\n/g)||[]).length;let a="";return a=t<15?"badge-danger":t<30?"badge-warning":"badge-info",{remainingCharacters:t,labelClass:"badge "+a}},initializeNullNoPlaceholderCheckboxes:function(){$(".t3-form-field-eval-null-checkbox").each((function(e,n){const t=$(n),a=t.find('input[type="checkbox"]'),o=t.closest(".t3js-formengine-field-item");a.attr("checked")||o.addClass("disabled")}))},initializeNullWithPlaceholderCheckboxes:function(){$(".t3js-form-field-eval-null-placeholder-checkbox").each((e,n)=>{t.toggleCheckboxField($(n).find('input[type="checkbox"]'),!1)})},toggleCheckboxField:function(e,n=!0){const t=e.closest(".t3js-formengine-field-item");e.prop("checked")?(t.find(".t3js-formengine-placeholder-placeholder").hide(),t.find(".t3js-formengine-placeholder-formfield").show(),n&&t.find(".t3js-formengine-placeholder-formfield").find(":input").trigger("focus")):(t.find(".t3js-formengine-placeholder-placeholder").show(),t.find(".t3js-formengine-placeholder-formfield").hide())},reinitialize:function(){const e=Array.from(document.querySelectorAll(".t3js-clearable"));e.length>0&&import("@typo3/backend/input/clearable.js").then((function(){e.forEach(e=>e.clearable())})),t.initializeNullNoPlaceholderCheckboxes(),t.initializeNullWithPlaceholderCheckboxes(),t.initializeLocalizationStateSelector(),t.initializeRemainingCharacterViews()},initializeLocalizationStateSelector:function(){$(".t3js-l10n-state-container").each((e,n)=>{const t=$(n),a=t.closest(".t3js-formengine-field-item").find("[data-formengine-input-name]"),o=t.find('input[type="radio"]:checked').val();"parent"!==o&&"source"!==o||a.attr("disabled","disabled")})},hasChange:function(){const e=$('form[name="'+t.formName+'"] .has-change').length>0,n=$('[name^="data["].has-change').length>0;return e||n},preventExitIfNotSavedCallback:function(e){t.closeDocument()},preventFollowLinkIfNotSaved:function(e){return t.preventExitIfNotSaved((function(){window.location.href=e})),!1},preventExitIfNotSaved:function(e){if(e=e||t.preventExitIfNotSavedCallback,t.hasChange()){const n=TYPO3.lang["label.confirm.close_without_save.title"]||"Do you want to close without saving?",a=TYPO3.lang["label.confirm.close_without_save.content"]||"You currently have unsaved changes. Are you sure you want to discard these changes?",o=$("<input />").attr("type","hidden").attr("name","_saveandclosedok").attr("value","1"),i=[{text:TYPO3.lang["buttons.confirm.close_without_save.no"]||"No, I will continue editing",btnClass:"btn-default",name:"no"},{text:TYPO3.lang["buttons.confirm.close_without_save.yes"]||"Yes, discard my changes",btnClass:"btn-default",name:"yes"}];0===$(".has-error").length&&i.push({text:TYPO3.lang["buttons.confirm.save_and_close"]||"Save and close",btnClass:"btn-warning",name:"save",active:!0});Modal.confirm(n,a,Severity.warning,i).on("button.clicked",(function(n){"no"===n.target.name?Modal.dismiss():"yes"===n.target.name?(Modal.dismiss(),e.call(null,!0)):"save"===n.target.name&&($("form[name="+t.formName+"]").append(o),Modal.dismiss(),t.saveDocument())}))}else e.call(null,!0)},preventSaveIfHasErrors:function(){if($(".has-error").length>0){const e=TYPO3.lang["label.alert.save_with_error.title"]||"You have errors in your form!",n=TYPO3.lang["label.alert.save_with_error.content"]||"Please check the form, there is at least one error in your form.";return Modal.confirm(e,n,Severity.error,[{text:TYPO3.lang["buttons.alert.save_with_error.ok"]||"OK",btnClass:"btn-danger",name:"ok"}]).on("button.clicked",(function(e){"ok"===e.target.name&&Modal.dismiss()})),!1}return!0},requestFormEngineUpdate:function(e){if(e){Modal.confirm(TYPO3.lang["FormEngine.refreshRequiredTitle"],TYPO3.lang["FormEngine.refreshRequiredContent"]).on("button.clicked",(function(e){"ok"===e.target.name?(t.closeModalsRecursive(),t.saveDocument()):Modal.dismiss()}))}else t.saveDocument()},processOnFieldChange:function(e,t){e.forEach(e=>{const a=n.get(e.name);a instanceof Function&&a.call(null,e.data||null,t)})},registerOnFieldChangeHandler:function(e,t){n.has(e)&&console.warn("Handler for onFieldChange name `"+e+"` has been overridden."),n.set(e,t)},closeModalsRecursive:function(){void 0!==Modal.currentModal&&null!==Modal.currentModal&&(Modal.currentModal.on("hidden.bs.modal",(function(){t.closeModalsRecursive(Modal.currentModal)})),Modal.currentModal.trigger("modal-dismiss"))},previewAction:function(e,n){n=n||t.previewActionCallback;const a=e.target.href,o=e.target.dataset.hasOwnProperty("isNew"),i=$("<input />").attr("type","hidden").attr("name","_savedokview").attr("value","1");t.hasChange()?t.showPreviewModal(a,o,i,n):($("form[name="+t.formName+"]").append(i),window.open("","newTYPO3frontendWindow"),document.editform.submit())},previewActionCallback:function(e,n,a){switch(Modal.dismiss(),e){case"discard":const e=window.open(n,"newTYPO3frontendWindow");e.focus(),e.location.href===n&&e.location.reload();break;case"save":$("form[name="+t.formName+"]").append(a),window.open("","newTYPO3frontendWindow"),t.saveDocument()}},showPreviewModal:function(e,n,t,a){const o=TYPO3.lang["label.confirm.view_record_changed.title"]||"Do you want to save before viewing?",i={text:TYPO3.lang["buttons.confirm.view_record_changed.cancel"]||"Cancel",btnClass:"btn-default",name:"cancel"},r={text:TYPO3.lang["buttons.confirm.view_record_changed.no-save"]||"View without changes",btnClass:"btn-info",name:"discard"},l={text:TYPO3.lang["buttons.confirm.view_record_changed.save"]||"Save changes and view",btnClass:"btn-info",name:"save",active:!0};let c=[],s="";n?(c=[i,l],s=TYPO3.lang["label.confirm.view_record_changed.content.is-new-page"]||"You need to save your changes before viewing the page. Do you want to save and view them now?"):(c=[i,r,l],s=TYPO3.lang["label.confirm.view_record_changed.content"]||"You currently have unsaved changes. You can either discard these changes or save and view them.");const d=Modal.confirm(o,s,Severity.info,c);d.on("button.clicked",(function(n){a(n.target.name,e,t,d)}))},newAction:function(e,n){n=n||t.newActionCallback;const a=$("<input />").attr("type","hidden").attr("name","_savedoknew").attr("value","1"),o=e.target.dataset.hasOwnProperty("isNew");t.hasChange()?t.showNewModal(o,a,n):($("form[name="+t.formName+"]").append(a),document.editform.submit())},newActionCallback:function(e,n){const a=$("form[name="+t.formName+"]");switch(Modal.dismiss(),e){case"no":a.append(n),document.editform.submit();break;case"yes":a.append(n),t.saveDocument()}},showNewModal:function(e,n,t){const a=TYPO3.lang["label.confirm.new_record_changed.title"]||"Do you want to save before adding?",o=TYPO3.lang["label.confirm.new_record_changed.content"]||"You need to save your changes before creating a new record. Do you want to save and create now?";let i=[];const r={text:TYPO3.lang["buttons.confirm.new_record_changed.cancel"]||"Cancel",btnClass:"btn-default",name:"cancel"},l={text:TYPO3.lang["buttons.confirm.new_record_changed.no"]||"No, just add",btnClass:"btn-default",name:"no"},c={text:TYPO3.lang["buttons.confirm.new_record_changed.yes"]||"Yes, save and create now",btnClass:"btn-info",name:"yes",active:!0};i=e?[r,c]:[r,l,c];Modal.confirm(a,o,Severity.info,i).on("button.clicked",(function(e){t(e.target.name,n)}))},duplicateAction:function(e,n){n=n||t.duplicateActionCallback;const a=$("<input />").attr("type","hidden").attr("name","_duplicatedoc").attr("value","1"),o=e.target.dataset.hasOwnProperty("isNew");t.hasChange()?t.showDuplicateModal(o,a,n):($("form[name="+t.formName+"]").append(a),document.editform.submit())},duplicateActionCallback:function(e,n){const a=$("form[name="+t.formName+"]");switch(Modal.dismiss(),e){case"no":a.append(n),document.editform.submit();break;case"yes":a.append(n),t.saveDocument()}},showDuplicateModal:function(e,n,t){const a=TYPO3.lang["label.confirm.duplicate_record_changed.title"]||"Do you want to save before duplicating this record?",o=TYPO3.lang["label.confirm.duplicate_record_changed.content"]||"You currently have unsaved changes. Do you want to save your changes before duplicating this record?";let i=[];const r={text:TYPO3.lang["buttons.confirm.duplicate_record_changed.cancel"]||"Cancel",btnClass:"btn-default",name:"cancel"},l={text:TYPO3.lang["buttons.confirm.duplicate_record_changed.no"]||"No, just duplicate the original",btnClass:"btn-default",name:"no"},c={text:TYPO3.lang["buttons.confirm.duplicate_record_changed.yes"]||"Yes, save and duplicate this record",btnClass:"btn-info",name:"yes",active:!0};i=e?[r,c]:[r,l,c];Modal.confirm(a,o,Severity.info,i).on("button.clicked",(function(e){t(e.target.name,n)}))},deleteAction:function(e,n){n=n||t.deleteActionCallback;const a=$(e.target);t.showDeleteModal(a,n)},deleteActionCallback:function(e,n){Modal.dismiss(),"yes"===e&&t.invokeRecordDeletion(n)},showDeleteModal:function(e,n){const t=TYPO3.lang["label.confirm.delete_record.title"]||"Delete this record?";let a=TYPO3.lang["label.confirm.delete_record.content"]||"Are you sure you want to delete this record?";e.data("reference-count-message")&&(a+=" "+e.data("reference-count-message")),e.data("translation-count-message")&&(a+=" "+e.data("translation-count-message"));Modal.confirm(t,a,Severity.warning,[{text:TYPO3.lang["buttons.confirm.delete_record.no"]||"Cancel",btnClass:"btn-default",name:"no"},{text:TYPO3.lang["buttons.confirm.delete_record.yes"]||"Yes, delete this record",btnClass:"btn-warning",name:"yes",active:!0}]).on("button.clicked",(function(t){n(t.target.name,e)}))},enableOptGroup:function(e){const n=e.parentElement;n instanceof HTMLOptGroupElement&&n.querySelectorAll("option:not([hidden]):not([disabled]):not(.hidden)").length&&(n.hidden=!1,n.disabled=!1,n.classList.remove("hidden"))},closeDocument:function(){document.editform.closeDoc.value=1,t.dispatchSubmitEvent(),document.editform.submit()},saveDocument:function(){document.editform.doSave.value=1,t.dispatchSubmitEvent(),document.editform.submit()},dispatchSubmitEvent:function(){const e=document.createEvent("Event");e.initEvent("submit",!1,!0),document.editform.dispatchEvent(e)},initialize:function(e){t.browserUrl=e,$((function(){t.initializeEvents(),t.Validation.initialize(),t.reinitialize(),$("#t3js-ui-block").remove()}))},invokeRecordDeletion:function(e){window.location.href=e.attr("href")}};return void 0!==TYPO3.settings.RequireJS&&void 0!==TYPO3.settings.RequireJS.PostInitializationModules["TYPO3/CMS/Backend/FormEngine"]&&$.each(TYPO3.settings.RequireJS.PostInitializationModules["TYPO3/CMS/Backend/FormEngine"],(function(e,n){window.require([n])})),TYPO3.FormEngine=t,t}()); \ No newline at end of file +import $ from"jquery";import FormEngineValidation from"@typo3/backend/form-engine-validation.js";import Icons from"@typo3/backend/icons.js";import Modal from"@typo3/backend/modal.js";import*as MessageUtility from"@typo3/backend/utility/message-utility.js";import Severity from"@typo3/backend/severity.js";import*as BackendExceptionModule from"@typo3/backend/backend-exception.js";import InteractionRequestMap from"@typo3/backend/event/interaction-request-map.js";export default(function(){function e(e,n){n?t.interactionRequestMap.resolveFor(e):t.interactionRequestMap.rejectFor(e)}const n=new Map;n.set("typo3-backend-form-update-value",(e,n)=>{const t=document.querySelector('[name="'+CSS.escape(e.elementName)+'"]'),a=document.querySelector('[data-formengine-input-name="'+CSS.escape(e.elementName)+'"]');FormEngineValidation.updateInputField(e.elementName),null!==t&&(FormEngineValidation.markFieldAsChanged(t),FormEngineValidation.validateField(t)),null!==a&&a!==t&&FormEngineValidation.validateField(a)}),n.set("typo3-backend-form-reload",(e,n)=>{e.confirmation?Modal.confirm(TYPO3.lang["FormEngine.refreshRequiredTitle"],TYPO3.lang["FormEngine.refreshRequiredContent"]).on("button.clicked",e=>{"ok"==e.target.name&&t.saveDocument(),Modal.dismiss()}):t.saveDocument()}),n.set("typo3-backend-form-update-bitmask",(e,n)=>{const t=n.target,a=document.editform[e.elementName],o=t.checked!==e.invert,i=Math.pow(2,e.position),r=Math.pow(2,e.total)-i-1;a.value=o?a.value|i:a.value&r,a.dispatchEvent(new Event("change",{bubbles:!0,cancelable:!0}))});const t={consumeTypes:["typo3.setUrl","typo3.beforeSetUrl","typo3.refresh"],Validation:FormEngineValidation,interactionRequestMap:InteractionRequestMap,formName:TYPO3.settings.FormEngine.formName,openedPopupWindow:null,legacyFieldChangedCb:function(){!$.isFunction(TYPO3.settings.FormEngine.legacyFieldChangedCb)||TYPO3.settings.FormEngine.legacyFieldChangedCb()},browserUrl:"",openPopupWindow:function(e,n,a){return Modal.advanced({type:Modal.types.iframe,content:t.browserUrl+"&mode="+e+"&bparams="+n+(a?"&"+("db"===e?"expandPage":"expandFolder")+"="+a:""),size:Modal.sizes.large})},setSelectOptionFromExternalSource:function(e,n,a,o,i,r){i=String(i);let l,c,s=!1,d=!1;if(l=t.getFieldElement(e),c=l.get(0),null===c||"--div--"===n||c instanceof HTMLOptGroupElement)return;const u=t.getFieldElement(e,"_list",!0);if(u.length>0&&(l=u,s=l.prop("multiple")&&"1"!=l.prop("size"),d=!0),s||d){const d=t.getFieldElement(e,"_avail");if(s||(l.find("option").each((e,n)=>{const a=d.find('option[value="'+$.escapeSelector($(n).attr("value"))+'"]');a.length&&(a.removeClass("hidden").prop("disabled",!1),t.enableOptGroup(a.get(0)))}),l.empty()),i){let e=!1,a=new RegExp("(^|,)"+n+"($|,)");i.match(a)?(l.empty(),e=!0):1==l.find("option").length&&(a=new RegExp("(^|,)"+l.find("option").prop("value")+"($|,)"),i.match(a)&&(l.empty(),e=!0)),e&&void 0!==r&&r.closest("select").querySelectorAll("[disabled]").forEach((function(e){e.classList.remove("hidden"),e.disabled=!1,t.enableOptGroup(e)}))}let u=!0;const m=t.getFieldElement(e,"_mul",!0);if((0==m.length||0==m.val())&&(l.find("option").each((function(e,t){if($(t).prop("value")==n)return u=!1,!1})),u&&void 0!==r)){r.classList.add("hidden"),r.disabled=!0;const e=r.parentElement;e instanceof HTMLOptGroupElement&&0===e.querySelectorAll("option:not([disabled]):not([hidden]):not(.hidden)").length&&(e.disabled=!0,e.classList.add("hidden"))}if(u){const e=$("<option></option>");e.attr({value:n,title:o}).text(a),e.appendTo(l),t.updateHiddenFieldValueFromSelect(l,c),t.legacyFieldChangedCb(),FormEngineValidation.markFieldAsChanged(c),t.Validation.validateField(l),t.Validation.validateField(d)}}else{const e=/_(\d+)$/,a=n.toString().match(e);null!=a&&(n=a[1]),l.val(n),t.Validation.validateField(l)}},updateHiddenFieldValueFromSelect:function(e,n){const t=[];$(e).find("option").each((e,n)=>{t.push($(n).prop("value"))}),n.value=t.join(","),n.dispatchEvent(new Event("change",{bubbles:!0,cancelable:!0}))},getFormElement:function(e){const n=$('form[name="'+t.formName+'"]:first');if(!e)return n;{const a=t.getFieldElement(e),o=t.getFieldElement(e,"_list");if(a.length>0&&("select-one"===a.prop("type")||o.length>0&&o.prop("type").match(/select-(one|multiple)/)))return n;console.error("Form fields missing: form: "+t.formName+", field name: "+e),alert("Form field is invalid")}},getFieldElement:function(e,n,a){const o=$('form[name="'+t.formName+'"]:first');if(n){let t;switch(n){case"_list":t=$(':input[data-formengine-input-name="'+e+'"]:not([type=hidden])',o);break;case"_avail":t=$(':input[data-relatedfieldname="'+e+'"]',o);break;case"_mul":case"_hr":t=$(':input[type=hidden][data-formengine-input-name="'+e+'"]',o);break;default:t=null}if(t&&t.length>0||!0===a)return t}return $(':input[name="'+e+'"]',o)},initializeEvents:function(){top.TYPO3&&void 0!==top.TYPO3.Backend&&(top.TYPO3.Backend.consumerScope.attach(t),$(window).on("unload",(function(){top.TYPO3.Backend.consumerScope.detach(t)}))),$(document).on("click",".t3js-editform-close",e=>{e.preventDefault(),t.preventExitIfNotSaved(t.preventExitIfNotSavedCallback)}).on("click",".t3js-editform-view",e=>{e.preventDefault(),t.previewAction(e,t.previewActionCallback)}).on("click",".t3js-editform-new",e=>{e.preventDefault(),t.newAction(e,t.newActionCallback)}).on("click",".t3js-editform-duplicate",e=>{e.preventDefault(),t.duplicateAction(e,t.duplicateActionCallback)}).on("click",".t3js-editform-delete-record",e=>{e.preventDefault(),t.deleteAction(e,t.deleteActionCallback)}).on("click",".t3js-editform-submitButton",e=>{const n=$(e.currentTarget),t=n.data("name")||e.currentTarget.name,a=$("<input />").attr("type","hidden").attr("name",t).attr("value","1");n.parents("form").append(a)}).on("change",'.t3-form-field-eval-null-checkbox input[type="checkbox"]',e=>{$(e.currentTarget).closest(".t3js-formengine-field-item").toggleClass("disabled")}).on("change",'.t3js-form-field-eval-null-placeholder-checkbox input[type="checkbox"]',e=>{t.toggleCheckboxField($(e.currentTarget)),FormEngineValidation.markFieldAsChanged($(e.currentTarget))}).on("change",(function(e){$(".module-docheader-bar .btn").removeClass("disabled").prop("disabled",!1)})).on("click",".t3js-element-browser",(function(e){e.preventDefault(),e.stopPropagation();const n=$(e.currentTarget),a=n.data("mode"),o=n.data("params"),i=n.data("entryPoint");t.openPopupWindow(a,o,i)})).on("click",'[data-formengine-field-change-event="click"]',e=>{const n=JSON.parse(e.currentTarget.dataset.formengineFieldChangeItems);t.processOnFieldChange(n,e)}).on("change",'[data-formengine-field-change-event="change"]',e=>{const n=JSON.parse(e.currentTarget.dataset.formengineFieldChangeItems);t.processOnFieldChange(n,e)}),document.editform.addEventListener("submit",(function(){if(document.editform.closeDoc.value)return;const e=["button[form]",'button[name^="_save"]','a[data-name^="_save"]','button[name="CMD"][value^="save"]','a[data-name="CMD"][data-value^="save"]'].join(","),n=document.querySelector(e);null!==n&&(n.disabled=!0,Icons.getIcon("spinner-circle-dark",Icons.sizes.small).then((function(e){n.querySelector(".t3js-icon").outerHTML=e})))})),window.addEventListener("message",t.handlePostMessage)},consume:function(n){if(!n)throw new BackendExceptionModule.BackendException("No interaction request given",1496589980);const a=$.Deferred();if(n.concernsTypes(t.consumeTypes)){const o=n.outerMostRequest;t.interactionRequestMap.attachFor(o,a),o.isProcessed()?e(o,o.getProcessedData().response):t.hasChange()?t.preventExitIfNotSaved((function(n){o.setProcessedData({response:n}),e(o,n)})):t.interactionRequestMap.resolveFor(o)}return a},handlePostMessage:function(e){if(!MessageUtility.MessageUtility.verifyOrigin(e.origin))throw"Denied message sent by "+e.origin;if("typo3:elementBrowser:elementAdded"===e.data.actionName){if(void 0===e.data.fieldName)throw"fieldName not defined in message";if(void 0===e.data.value)throw"value not defined in message";const n=e.data.label||e.data.value,a=e.data.title||n,o=e.data.exclusiveValues||"";t.setSelectOptionFromExternalSource(e.data.fieldName,e.data.value,n,a,o)}},initializeRemainingCharacterViews:function(){const e=$("[maxlength]").not(".t3js-datetimepicker").not(".t3js-color-picker").not(".t3js-charcounter-initialized");e.on("focus",e=>{const n=$(e.currentTarget),a=n.parents(".t3js-formengine-field-item:first"),o=t.getCharacterCounterProperties(n);a.append($("<div />",{class:"t3js-charcounter"}).append($("<span />",{class:o.labelClass}).text(TYPO3.lang["FormEngine.remainingCharacters"].replace("{0}",o.remainingCharacters))))}).on("blur",e=>{$(e.currentTarget).parents(".t3js-formengine-field-item:first").find(".t3js-charcounter").remove()}).on("keyup",e=>{const n=$(e.currentTarget),a=n.parents(".t3js-formengine-field-item:first"),o=t.getCharacterCounterProperties(n);a.find(".t3js-charcounter span").removeClass().addClass(o.labelClass).text(TYPO3.lang["FormEngine.remainingCharacters"].replace("{0}",o.remainingCharacters))}),e.addClass("t3js-charcounter-initialized")},getCharacterCounterProperties:function(e){const n=e.val(),t=e.attr("maxlength")-n.length-(n.match(/\n/g)||[]).length;let a="";return a=t<15?"badge-danger":t<30?"badge-warning":"badge-info",{remainingCharacters:t,labelClass:"badge "+a}},initializeNullNoPlaceholderCheckboxes:function(){$(".t3-form-field-eval-null-checkbox").each((function(e,n){const t=$(n),a=t.find('input[type="checkbox"]'),o=t.closest(".t3js-formengine-field-item");a.attr("checked")||o.addClass("disabled")}))},initializeNullWithPlaceholderCheckboxes:function(){$(".t3js-form-field-eval-null-placeholder-checkbox").each((e,n)=>{t.toggleCheckboxField($(n).find('input[type="checkbox"]'),!1)})},toggleCheckboxField:function(e,n=!0){const t=e.closest(".t3js-formengine-field-item");e.prop("checked")?(t.find(".t3js-formengine-placeholder-placeholder").hide(),t.find(".t3js-formengine-placeholder-formfield").show(),n&&t.find(".t3js-formengine-placeholder-formfield").find(":input").trigger("focus")):(t.find(".t3js-formengine-placeholder-placeholder").show(),t.find(".t3js-formengine-placeholder-formfield").hide())},reinitialize:function(){const e=Array.from(document.querySelectorAll(".t3js-clearable"));e.length>0&&import("@typo3/backend/input/clearable.js").then((function(){e.forEach(e=>e.clearable())})),t.initializeNullNoPlaceholderCheckboxes(),t.initializeNullWithPlaceholderCheckboxes(),t.initializeLocalizationStateSelector(),t.initializeRemainingCharacterViews()},initializeLocalizationStateSelector:function(){$(".t3js-l10n-state-container").each((e,n)=>{const t=$(n),a=t.closest(".t3js-formengine-field-item").find("[data-formengine-input-name]"),o=t.find('input[type="radio"]:checked').val();"parent"!==o&&"source"!==o||a.attr("disabled","disabled")})},hasChange:function(){const e=$('form[name="'+t.formName+'"] .has-change').length>0,n=$('[name^="data["].has-change').length>0;return e||n},preventExitIfNotSavedCallback:function(e){t.closeDocument()},preventFollowLinkIfNotSaved:function(e){return t.preventExitIfNotSaved((function(){window.location.href=e})),!1},preventExitIfNotSaved:function(e){if(e=e||t.preventExitIfNotSavedCallback,t.hasChange()){const n=TYPO3.lang["label.confirm.close_without_save.title"]||"Do you want to close without saving?",a=TYPO3.lang["label.confirm.close_without_save.content"]||"You currently have unsaved changes. Are you sure you want to discard these changes?",o=$("<input />").attr("type","hidden").attr("name","_saveandclosedok").attr("value","1"),i=[{text:TYPO3.lang["buttons.confirm.close_without_save.no"]||"No, I will continue editing",btnClass:"btn-default",name:"no"},{text:TYPO3.lang["buttons.confirm.close_without_save.yes"]||"Yes, discard my changes",btnClass:"btn-default",name:"yes"}];0===$(".has-error").length&&i.push({text:TYPO3.lang["buttons.confirm.save_and_close"]||"Save and close",btnClass:"btn-warning",name:"save",active:!0});Modal.confirm(n,a,Severity.warning,i).on("button.clicked",(function(n){"no"===n.target.name?Modal.dismiss():"yes"===n.target.name?(Modal.dismiss(),e.call(null,!0)):"save"===n.target.name&&($("form[name="+t.formName+"]").append(o),Modal.dismiss(),t.saveDocument())}))}else e.call(null,!0)},preventSaveIfHasErrors:function(){if($(".has-error").length>0){const e=TYPO3.lang["label.alert.save_with_error.title"]||"You have errors in your form!",n=TYPO3.lang["label.alert.save_with_error.content"]||"Please check the form, there is at least one error in your form.";return Modal.confirm(e,n,Severity.error,[{text:TYPO3.lang["buttons.alert.save_with_error.ok"]||"OK",btnClass:"btn-danger",name:"ok"}]).on("button.clicked",(function(e){"ok"===e.target.name&&Modal.dismiss()})),!1}return!0},requestFormEngineUpdate:function(e){if(e){Modal.confirm(TYPO3.lang["FormEngine.refreshRequiredTitle"],TYPO3.lang["FormEngine.refreshRequiredContent"]).on("button.clicked",(function(e){"ok"===e.target.name?(t.closeModalsRecursive(),t.saveDocument()):Modal.dismiss()}))}else t.saveDocument()},processOnFieldChange:function(e,t){e.forEach(e=>{const a=n.get(e.name);a instanceof Function&&a.call(null,e.data||null,t)})},registerOnFieldChangeHandler:function(e,t){n.has(e)&&console.warn("Handler for onFieldChange name `"+e+"` has been overridden."),n.set(e,t)},closeModalsRecursive:function(){void 0!==Modal.currentModal&&null!==Modal.currentModal&&(Modal.currentModal.on("hidden.bs.modal",(function(){t.closeModalsRecursive(Modal.currentModal)})),Modal.currentModal.trigger("modal-dismiss"))},previewAction:function(e,n){n=n||t.previewActionCallback;const a=e.target.href,o=e.target.dataset.hasOwnProperty("isNew"),i=$("<input />").attr("type","hidden").attr("name","_savedokview").attr("value","1");t.hasChange()?t.showPreviewModal(a,o,i,n):($("form[name="+t.formName+"]").append(i),window.open("","newTYPO3frontendWindow"),document.editform.submit())},previewActionCallback:function(e,n,a){switch(Modal.dismiss(),e){case"discard":const e=window.open(n,"newTYPO3frontendWindow");e.focus(),e.location.href===n&&e.location.reload();break;case"save":$("form[name="+t.formName+"]").append(a),window.open("","newTYPO3frontendWindow"),t.saveDocument()}},showPreviewModal:function(e,n,t,a){const o=TYPO3.lang["label.confirm.view_record_changed.title"]||"Do you want to save before viewing?",i={text:TYPO3.lang["buttons.confirm.view_record_changed.cancel"]||"Cancel",btnClass:"btn-default",name:"cancel"},r={text:TYPO3.lang["buttons.confirm.view_record_changed.no-save"]||"View without changes",btnClass:"btn-info",name:"discard"},l={text:TYPO3.lang["buttons.confirm.view_record_changed.save"]||"Save changes and view",btnClass:"btn-info",name:"save",active:!0};let c=[],s="";n?(c=[i,l],s=TYPO3.lang["label.confirm.view_record_changed.content.is-new-page"]||"You need to save your changes before viewing the page. Do you want to save and view them now?"):(c=[i,r,l],s=TYPO3.lang["label.confirm.view_record_changed.content"]||"You currently have unsaved changes. You can either discard these changes or save and view them.");const d=Modal.confirm(o,s,Severity.info,c);d.on("button.clicked",(function(n){a(n.target.name,e,t,d)}))},newAction:function(e,n){n=n||t.newActionCallback;const a=$("<input />").attr("type","hidden").attr("name","_savedoknew").attr("value","1"),o=e.target.dataset.hasOwnProperty("isNew");t.hasChange()?t.showNewModal(o,a,n):($("form[name="+t.formName+"]").append(a),document.editform.submit())},newActionCallback:function(e,n){const a=$("form[name="+t.formName+"]");switch(Modal.dismiss(),e){case"no":a.append(n),document.editform.submit();break;case"yes":a.append(n),t.saveDocument()}},showNewModal:function(e,n,t){const a=TYPO3.lang["label.confirm.new_record_changed.title"]||"Do you want to save before adding?",o=TYPO3.lang["label.confirm.new_record_changed.content"]||"You need to save your changes before creating a new record. Do you want to save and create now?";let i=[];const r={text:TYPO3.lang["buttons.confirm.new_record_changed.cancel"]||"Cancel",btnClass:"btn-default",name:"cancel"},l={text:TYPO3.lang["buttons.confirm.new_record_changed.no"]||"No, just add",btnClass:"btn-default",name:"no"},c={text:TYPO3.lang["buttons.confirm.new_record_changed.yes"]||"Yes, save and create now",btnClass:"btn-info",name:"yes",active:!0};i=e?[r,c]:[r,l,c];Modal.confirm(a,o,Severity.info,i).on("button.clicked",(function(e){t(e.target.name,n)}))},duplicateAction:function(e,n){n=n||t.duplicateActionCallback;const a=$("<input />").attr("type","hidden").attr("name","_duplicatedoc").attr("value","1"),o=e.target.dataset.hasOwnProperty("isNew");t.hasChange()?t.showDuplicateModal(o,a,n):($("form[name="+t.formName+"]").append(a),document.editform.submit())},duplicateActionCallback:function(e,n){const a=$("form[name="+t.formName+"]");switch(Modal.dismiss(),e){case"no":a.append(n),document.editform.submit();break;case"yes":a.append(n),t.saveDocument()}},showDuplicateModal:function(e,n,t){const a=TYPO3.lang["label.confirm.duplicate_record_changed.title"]||"Do you want to save before duplicating this record?",o=TYPO3.lang["label.confirm.duplicate_record_changed.content"]||"You currently have unsaved changes. Do you want to save your changes before duplicating this record?";let i=[];const r={text:TYPO3.lang["buttons.confirm.duplicate_record_changed.cancel"]||"Cancel",btnClass:"btn-default",name:"cancel"},l={text:TYPO3.lang["buttons.confirm.duplicate_record_changed.no"]||"No, just duplicate the original",btnClass:"btn-default",name:"no"},c={text:TYPO3.lang["buttons.confirm.duplicate_record_changed.yes"]||"Yes, save and duplicate this record",btnClass:"btn-info",name:"yes",active:!0};i=e?[r,c]:[r,l,c];Modal.confirm(a,o,Severity.info,i).on("button.clicked",(function(e){t(e.target.name,n)}))},deleteAction:function(e,n){n=n||t.deleteActionCallback;const a=$(e.target);t.showDeleteModal(a,n)},deleteActionCallback:function(e,n){Modal.dismiss(),"yes"===e&&t.invokeRecordDeletion(n)},showDeleteModal:function(e,n){const t=TYPO3.lang["label.confirm.delete_record.title"]||"Delete this record?";let a=TYPO3.lang["label.confirm.delete_record.content"]||"Are you sure you want to delete this record?";e.data("reference-count-message")&&(a+=" "+e.data("reference-count-message")),e.data("translation-count-message")&&(a+=" "+e.data("translation-count-message"));Modal.confirm(t,a,Severity.warning,[{text:TYPO3.lang["buttons.confirm.delete_record.no"]||"Cancel",btnClass:"btn-default",name:"no"},{text:TYPO3.lang["buttons.confirm.delete_record.yes"]||"Yes, delete this record",btnClass:"btn-warning",name:"yes",active:!0}]).on("button.clicked",(function(t){n(t.target.name,e)}))},enableOptGroup:function(e){const n=e.parentElement;n instanceof HTMLOptGroupElement&&n.querySelectorAll("option:not([hidden]):not([disabled]):not(.hidden)").length&&(n.hidden=!1,n.disabled=!1,n.classList.remove("hidden"))},closeDocument:function(){document.editform.closeDoc.value=1,t.dispatchSubmitEvent(),document.editform.submit()},saveDocument:function(){document.editform.doSave.value=1,t.dispatchSubmitEvent(),document.editform.submit()},dispatchSubmitEvent:function(){const e=document.createEvent("Event");e.initEvent("submit",!1,!0),document.editform.dispatchEvent(e)},initialize:function(e){t.browserUrl=e,$((function(){t.initializeEvents(),t.Validation.initialize(),t.reinitialize(),$("#t3js-ui-block").remove()}))},invokeRecordDeletion:function(e){window.location.href=e.attr("href")}};return void 0!==TYPO3.settings.RequireJS&&void 0!==TYPO3.settings.RequireJS.PostInitializationModules["TYPO3/CMS/Backend/FormEngine"]&&$.each(TYPO3.settings.RequireJS.PostInitializationModules["TYPO3/CMS/Backend/FormEngine"],(function(e,n){window.require([n])})),TYPO3.FormEngine=t,t}()); \ No newline at end of file