CoreFiles by mySites.guru
joomla-field-subform-es5.min.js1 lines, 9,265 bytes, from Joomla_4.3.0-alpha1-Alpha-Full_Package.zip
Raw History Compare with 4.2.0-alpha3
md5
7a203e35a9915f666a6bb033aa225faa
sha1
98664cc4ab635e4da93af0306b6be1c6e025bfdc
sha256
19f611af0dcb583547dc985841f433897a1f11d6b7295415b1d5d01ad394e6ae
!function(){"use strict";function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function t(e){return t=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},t(e)}function r(e,t){return r=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},r(e,t)}function n(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function o(e,t,a){return o=n()?Reflect.construct.bind():function(e,t,n){var o=[null];o.push.apply(o,t);var a=new(Function.bind.apply(e,o));return n&&r(a,n.prototype),a},o.apply(null,arguments)}function a(e){var n="function"==typeof Map?new Map:void 0;return a=function(e){if(null===e||(a=e,-1===Function.toString.call(a).indexOf("[native code]")))return e;var a;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==n){if(n.has(e))return n.get(e);n.set(e,i)}function i(){return o(e,arguments,t(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),r(i,e)},a(e)}function i(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}!function(t){var n=32,o=27,s=13;var u=function(t){var a,u;function l(){var e,r=i(e=t.call(this)||this);if(e.containerWithRows=i(e),e.rowsContainer){var o=e.querySelectorAll(e.rowsContainer);Array.from(o).forEach((function(t){t.closest("joomla-field-subform")===i(e)&&(e.containerWithRows=t)}))}return e.lastRowIndex=e.getRows().length-1,e.template="",e.prepareTemplate(),(e.buttonAdd||e.buttonRemove)&&(e.addEventListener("click",(function(e){var t=null,n=null;if(r.buttonAdd&&(t=e.target.matches(r.buttonAdd)?e.target:e.target.closest(r.buttonAdd)),r.buttonRemove&&(n=e.target.matches(r.buttonRemove)?e.target:e.target.closest(r.buttonRemove)),t&&t.closest("joomla-field-subform")===r){var o=t.closest(r.repeatableElement);o=o&&o.closest("joomla-field-subform")===r?o:null,r.addRow(o),e.preventDefault()}else if(n&&n.closest("joomla-field-subform")===r){var a=n.closest(r.repeatableElement);r.removeRow(a),e.preventDefault()}})),e.addEventListener("keydown",(function(e){if(e.keyCode===n){var t=r.buttonAdd&&e.target.matches(r.buttonAdd),o=r.buttonRemove&&e.target.matches(r.buttonRemove);if((t||o)&&e.target.closest("joomla-field-subform")===r){var a=e.target.closest(r.repeatableElement);a=a&&a.closest("joomla-field-subform")===r?a:null,o&&a?r.removeRow(a):t&&r.addRow(a),e.preventDefault()}}}))),e.buttonMove&&e.setUpDragSort(),e}u=t,(a=l).prototype=Object.create(u.prototype),a.prototype.constructor=a,r(a,u);var b,f,c,d=l.prototype;return d.getRows=function(){var e=this,t=Array.from(this.containerWithRows.children),r=[];return t.forEach((function(t){t.matches(e.repeatableElement)&&r.push(t)})),r},d.prepareTemplate=function(){var e=[].slice.call(this.children).filter((function(e){return e.classList.contains("subform-repeatable-template-section")}));if(e[0]&&(this.template=e[0].innerHTML),!this.template)throw new Error("The row template is required for the subform element to work")},d.addRow=function(e){var t,r=this.getRows().length;if(r>=this.maximum)return null;(t="TBODY"===this.containerWithRows.nodeName||"TABLE"===this.containerWithRows.nodeName?document.createElement("tbody"):document.createElement("div")).innerHTML=this.template;var n=t.children[0];return e?e.parentNode.insertBefore(n,e.nextSibling):this.containerWithRows.append(n),this.buttonMove&&(n.setAttribute("draggable","false"),n.setAttribute("aria-grabbed","false"),n.setAttribute("tabindex","0")),n.setAttribute("data-new","1"),this.fixUniqueAttributes(n,r),this.dispatchEvent(new CustomEvent("subform-row-add",{detail:{row:n},bubbles:!0})),n.dispatchEvent(new CustomEvent("joomla:updated",{bubbles:!0,cancelable:!0})),n},d.removeRow=function(e){this.getRows().length<=this.minimum||(this.dispatchEvent(new CustomEvent("subform-row-remove",{detail:{row:e},bubbles:!0})),e.dispatchEvent(new CustomEvent("joomla:removed",{bubbles:!0,cancelable:!0})),e.parentNode.removeChild(e))},d.fixUniqueAttributes=function(e,t){var r=this,n=t||0,o=e.getAttribute("data-group"),a=e.getAttribute("data-base-name"),i=Math.max(this.lastRowIndex,n),s=a+i;this.lastRowIndex=i+1,e.setAttribute("data-group",s);var u=e.querySelectorAll("[name]"),l={};(u=[].slice.call(u).filter((function(e){return"JOOMLA-FIELD-SUBFORM"===e.nodeName?e.parentElement.closest("joomla-field-subform")===r:e.closest("joomla-field-subform")===r}))).forEach((function(t){var r=t,n=r.getAttribute("name"),a=r.getAttribute("aria-describedby"),i=n.replace(/(\[\]$)/g,"").replace(/(\]\[)/g,"__").replace(/\[/g,"_").replace(/\]/g,""),u=n.replace("["+o+"][","["+s+"]["),b=i.replace(o,s).replace(/\W/g,"_"),f=0,c=i;if("checkbox"===r.type&&n.match(/\[\]$/)){if(!(f=l[i]?l[i].length:0)){var d=r.closest("fieldset.checkboxes"),m=e.querySelector('label[for="'+i+'"]');d&&d.setAttribute("id",b),m&&(m.setAttribute("for",b),m.setAttribute("id",b+"-lbl"))}c+=f,b+=f}else if("radio"===r.type){if(!(f=l[i]?l[i].length:0)){var p=r.closest("fieldset.radio"),g=e.querySelector('label[for="'+i+'"]');p&&p.setAttribute("id",b),g&&(g.setAttribute("for",b),g.setAttribute("id",b+"-lbl"))}c+=f,b+=f}l[i]?l[i].push(!0):l[i]=[!0],r.name=u,r.id&&(r.id=b),a&&r.setAttribute("aria-describedby",u+"-desc");var h=e.querySelector('label[for="'+c+'"]');h&&(h.setAttribute("for",b),h.setAttribute("id",b+"-lbl"))}))},d.setUpDragSort=function(){var e=this,t=null,r=!1;function a(t){return!t.form&&t.matches(e.buttonMove)?t:t.closest(e.buttonMove)}function i(e,t){var r=!1;if(e.parentNode===t.parentNode)for(var n=e;n;n=n.previousSibling)if(n===t){r=!0;break}r?t.parentNode.insertBefore(e,t):t.parentNode.insertBefore(e,t.nextSibling)}Array.from(this.getRows()).forEach((function(e){e.setAttribute("draggable","false"),e.setAttribute("aria-grabbed","false"),e.setAttribute("tabindex","0")})),this.addEventListener("touchstart",(function(n){r=!0;var o=a(n.target),s=o?o.closest(e.repeatableElement):null;s&&s.closest("joomla-field-subform")===e&&(t?(s!==t&&i(t,s),t.setAttribute("draggable","false"),t.setAttribute("aria-grabbed","false"),t=null):(s.setAttribute("draggable","true"),s.setAttribute("aria-grabbed","true"),t=s),n.preventDefault())})),this.addEventListener("mousedown",(function(n){var o=n.target;if(!r){var i=a(o),s=i?i.closest(e.repeatableElement):null;s&&s.closest("joomla-field-subform")===e&&(s.setAttribute("draggable","true"),s.setAttribute("aria-grabbed","true"),t=s)}})),this.addEventListener("mouseup",(function(){t&&!r&&(t.setAttribute("draggable","false"),t.setAttribute("aria-grabbed","false"),t=null)})),this.addEventListener("keydown",(function(r){if(!(r.keyCode!==o&&r.keyCode!==n&&r.keyCode!==s||r.target.form)&&r.target.matches(e.repeatableElement)){var a=r.target;if(a&&a.closest("joomla-field-subform")===e&&(r.keyCode===n&&function(e){return e.ctrlKey||e.metaKey||e.shiftKey}(r)&&("true"===a.getAttribute("aria-grabbed")?(a.setAttribute("draggable","false"),a.setAttribute("aria-grabbed","false"),t=null):(t&&(t.setAttribute("draggable","false"),t.setAttribute("aria-grabbed","false"),t=null),a.setAttribute("draggable","true"),a.setAttribute("aria-grabbed","true"),t=a),r.preventDefault()),r.keyCode===o&&t&&(t.setAttribute("draggable","false"),t.setAttribute("aria-grabbed","false"),t=null),r.keyCode===s&&t)){if(t.setAttribute("draggable","false"),t.setAttribute("aria-grabbed","false"),a===t)return void(t=null);i(t,a),r.preventDefault(),t=null}}})),this.addEventListener("dragstart",(function(e){var r=e.dataTransfer;t&&(r.effectAllowed="move",r.setData("text",""))})),this.addEventListener("dragover",(function(e){t&&e.preventDefault()})),this.addEventListener("dragenter",(function(r){var n=r.target;if(t&&n.parentElement.closest("joomla-field-subform")===e){var o=n.closest(e.repeatableElement);o&&o.closest("joomla-field-subform")===e&&i(t,o)}})),this.addEventListener("dragend",(function(){t&&(t.setAttribute("draggable","false"),t.setAttribute("aria-grabbed","false"),t=null)}))},b=l,(f=[{key:"buttonAdd",get:function(){return this.getAttribute("button-add")}},{key:"buttonRemove",get:function(){return this.getAttribute("button-remove")}},{key:"buttonMove",get:function(){return this.getAttribute("button-move")}},{key:"rowsContainer",get:function(){return this.getAttribute("rows-container")}},{key:"repeatableElement",get:function(){return this.getAttribute("repeatable-element")}},{key:"minimum",get:function(){return this.getAttribute("minimum")}},{key:"maximum",get:function(){return this.getAttribute("maximum")}},{key:"name",get:function(){return this.getAttribute("name")},set:function(e){this.template=this.template.replace(new RegExp(' name="'+this.name.replace(/[[\]]/g,"\\$&"),"g"),' name="'+e),this.setAttribute("name",e)}}])&&e(b.prototype,f),c&&e(b,c),Object.defineProperty(b,"prototype",{writable:!1}),l}(a(HTMLElement));t.define("joomla-field-subform",u)}(customElements)}();

The same content is in 2 releases, Joomla 4.3.0-alpha1 to 4.3.0-alpha2. See them all, or every version of this file.