Your IP : 216.73.216.43


Current Path : /var/www/surf/TYPO3/vendor/typo3/cms-backend/Resources/Public/JavaScript/
Upload File :
Current File : /var/www/surf/TYPO3/vendor/typo3/cms-backend/Resources/Public/JavaScript/form-engine-review.js

/*
 * This file is part of the TYPO3 CMS project.
 *
 * It is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License, either version 2
 * of the License, or any later version.
 *
 * For the full copyright and license information, please read the
 * LICENSE.txt file that was distributed with this source code.
 *
 * The TYPO3 project - inspiring people to share!
 */
import"bootstrap";import DocumentService from"@typo3/core/document-service.js";import $ from"jquery";import FormEngine from"@typo3/backend/form-engine.js";import{selector}from"@typo3/core/literals.js";import"@typo3/backend/element/icon-element.js";import Popover from"@typo3/backend/popover.js";class FormEngineReview{constructor(){this.toggleButtonClass="t3js-toggle-review-panel",this.labelSelector=".t3js-formengine-label",this.legendSelector=".t3js-formengine-legend",this.checkForReviewableField=()=>{const e=FormEngineReview.findInvalidField(),t=document.querySelector("."+this.toggleButtonClass);if(null!==t)if(e.length>0){const o=$("<div />",{class:"list-group"});e.each(((e,t)=>{const i=$(t),n=i.find("[data-formengine-validation-rules]"),r=document.createElement("a");r.classList.add("list-group-item"),r.href="#",r.textContent=i.find(this.labelSelector).text()||i.find(this.legendSelector).text(),r.addEventListener("click",(e=>this.switchToField(e,n))),o.append(r)})),t.classList.remove("hidden"),Popover.setOptions(t,{html:!0,content:o[0]})}else t.classList.add("hidden"),Popover.hide(t)},this.switchToField=(e,t)=>{e.preventDefault(),t.parents('[id][role="tabpanel"]').each((function(){$(selector`[aria-controls="${$(this).attr("id")}]`).tab("show")})),t.focus()},this.initialize()}static findInvalidField(){return $(document).find(".tab-content ."+FormEngine.Validation.errorClass)}static attachButtonToModuleHeader(e){const t=document.querySelector(".t3js-module-docheader-bar-buttons").lastElementChild.querySelector('[role="toolbar"]'),o=document.createElement("typo3-backend-icon");o.setAttribute("identifier","actions-info"),o.setAttribute("size","small");const i=document.createElement("button");i.type="button",i.classList.add("btn","btn-danger","btn-sm","hidden",e.toggleButtonClass),i.title=TYPO3.lang["buttons.reviewFailedValidationFields"],i.appendChild(o),Popover.popover(i),t.prepend(i)}initialize(){const e=$(document);DocumentService.ready().then((()=>{FormEngineReview.attachButtonToModuleHeader(this)})),e.on("t3-formengine-postfieldvalidation",this.checkForReviewableField)}}export default new FormEngineReview;