[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/media/system/js/fields/ -> joomla-field-subform-es5.min.js (source)

   1  !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:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function r(e,t){return(r=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(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 a(e,t,o){return(a=n()?Reflect.construct:function(e,t,n){var a=[null];a.push.apply(a,t);var o=new(Function.bind.apply(e,a));return n&&r(o,n.prototype),o}).apply(null,arguments)}function o(e){var n="function"==typeof Map?new Map:void 0;return(o=function(e){if(null===e||(o=e,-1===Function.toString.call(o).indexOf("[native code]")))return e;var o;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 a(e,arguments,t(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),r(i,e)})(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,a=27,u=13;var s=function(t){var o,s;function l(){var e,r=i(e=t.call(this)||this);if(e.containerWithRows=i(e),e.rowsContainer){var a=e.querySelectorAll(e.rowsContainer);Array.from(a).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 a=t.closest(r.repeatableElement);a=a&&a.closest("joomla-field-subform")===r?a:null,r.addRow(a),e.preventDefault()}else if(n&&n.closest("joomla-field-subform")===r){var o=n.closest(r.repeatableElement);r.removeRow(o),e.preventDefault()}})),e.addEventListener("keydown",(function(e){if(e.keyCode===n){var t=r.buttonAdd&&e.target.matches(r.buttonAdd),a=r.buttonRemove&&e.target.matches(r.buttonRemove);if((t||a)&&e.target.closest("joomla-field-subform")===r){var o=e.target.closest(r.repeatableElement);o=o&&o.closest("joomla-field-subform")===r?o:null,a&&o?r.removeRow(o):t&&r.addRow(o),e.preventDefault()}}}))),e.buttonMove&&e.setUpDragSort(),e}s=t,(o=l).prototype=Object.create(s.prototype),o.prototype.constructor=o,r(o,s);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,a=e.getAttribute("data-group"),o=e.getAttribute("data-base-name"),i=Math.max(this.lastRowIndex,n),u=o+i;this.lastRowIndex=i+1,e.setAttribute("data-group",u);var s=e.querySelectorAll("[name]"),l={};(s=[].slice.call(s).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"),o=r.getAttribute("aria-describedby"),i=n.replace(/(\[\]$)/g,"").replace(/(\]\[)/g,"__").replace(/\[/g,"_").replace(/\]/g,""),s=n.replace("["+a+"][","["+u+"]["),b=i.replace(a,u).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=s,r.id&&(r.id=b),o&&r.setAttribute("aria-describedby",s+"-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 o(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 a=o(n.target),u=a?a.closest(e.repeatableElement):null;u&&u.closest("joomla-field-subform")===e&&(t?(u!==t&&i(t,u),t.setAttribute("draggable","false"),t.setAttribute("aria-grabbed","false"),t=null):(u.setAttribute("draggable","true"),u.setAttribute("aria-grabbed","true"),t=u),n.preventDefault())})),this.addEventListener("mousedown",(function(n){var a=n.target;if(!r){var i=o(a),u=i?i.closest(e.repeatableElement):null;u&&u.closest("joomla-field-subform")===e&&(u.setAttribute("draggable","true"),u.setAttribute("aria-grabbed","true"),t=u)}})),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!==a&&r.keyCode!==n&&r.keyCode!==u||r.target.form)&&r.target.matches(e.repeatableElement)){var o=r.target;if(o&&o.closest("joomla-field-subform")===e&&(r.keyCode===n&&function(e){return e.ctrlKey||e.metaKey||e.shiftKey}(r)&&("true"===o.getAttribute("aria-grabbed")?(o.setAttribute("draggable","false"),o.setAttribute("aria-grabbed","false"),t=null):(t&&(t.setAttribute("draggable","false"),t.setAttribute("aria-grabbed","false"),t=null),o.setAttribute("draggable","true"),o.setAttribute("aria-grabbed","true"),t=o),r.preventDefault()),r.keyCode===a&&t&&(t.setAttribute("draggable","false"),t.setAttribute("aria-grabbed","false"),t=null),r.keyCode===u&&t)){if(t.setAttribute("draggable","false"),t.setAttribute("aria-grabbed","false"),o===t)return void(t=null);i(t,o),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 a=n.closest(e.repeatableElement);a&&a.closest("joomla-field-subform")===e&&i(t,a)}})),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}(o(HTMLElement));t.define("joomla-field-subform",s)}(customElements)}();


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer