CoreFiles by mySites.guru
subform-repeatable.min.js1 lines, 4,436 bytes, from Joomla_4.0.0-alpha2-Alpha-Full_Package.zip
Raw History Compare with 3.10.0-alpha9
md5
50bfdc6b8aa4b83497c655bcaf72a9c8
sha1
cf595136e320e29075404994cb8efe9c08b0dff4
sha256
db9aff0fbaa436231741715acb19f7562099774b781751a80e2843500832498d
!function(e){"use strict";e.subformRepeatable=function(t,o){if(this.$container=e(t),this.$container.data("subformRepeatable"))return a;this.$container.data("subformRepeatable",a),this.options=e.extend({},e.subformRepeatable.defaults,o),this.template="",this.prepareTemplate(),this.$containerRows=this.options.rowsContainer?this.$container.find(this.options.rowsContainer):this.$container,this.lastRowNum=this.$containerRows.find(this.options.repeatableElement).length;var a=this;this.$container.on("click",this.options.btAdd,function(t){t.preventDefault();var o=e(this).parents(a.options.repeatableElement);o.length||(o=null),a.addRow(o)}),this.$container.on("click",this.options.btRemove,function(t){t.preventDefault();var o=e(this).parents(a.options.repeatableElement);a.removeRow(o)}),this.options.btMove&&e.fn.sortable&&this.$containerRows.sortable({items:this.options.repeatableElement,handle:this.options.btMove,tolerance:"pointer"}),this.$container.trigger("subform-ready")},e.subformRepeatable.prototype.prepareTemplate=function(){if(this.options.rowTemplateSelector){var t=this.$container.find(this.options.rowTemplateSelector)[0]||{};this.template=e.trim(t.text||t.textContent)}else{var o=this.$container.find(this.options.repeatableElement).get(0),a=e(o).clone();try{this.clearScripts(a)}catch(e){window.console&&console.log(e)}this.template=a.prop("outerHTML")}},e.subformRepeatable.prototype.addRow=function(t){var o=this.$containerRows.find(this.options.repeatableElement).length;if(o>=this.options.maximum)return null;var a=e.parseHTML(this.template);t?e(t).after(a):this.$containerRows.append(a);var i=e(a);i.attr("data-new","true"),this.fixUniqueAttributes(i,o);try{this.fixScripts(i)}catch(e){window.console&&console.log(e)}return this.$container.trigger("subform-row-add",i),Joomla.Event.dispatch(i.get(0),"joomla:updated"),i},e.subformRepeatable.prototype.removeRow=function(e){this.$containerRows.find(this.options.repeatableElement).length<=this.options.minimum||(this.$container.trigger("subform-row-remove",e),Joomla.Event.dispatch(e.get(0),"joomla:removed"),e.remove())},e.subformRepeatable.prototype.fixUniqueAttributes=function(t,o){this.lastRowNum++;var a=t.attr("data-group"),i=t.attr("data-base-name"),o=o||0,r=Math.max(this.lastRowNum,o+1),n=i+r;this.lastRowNum=r,t.attr("data-group",n);for(var s=t.find("[name]"),l={},p=0,f=s.length;p<f;p++){var c=e(s[p]),d=c.attr("name"),h=d.replace(/(\[\]$)/g,"").replace(/(\]\[)/g,"__").replace(/\[/g,"_").replace(/\]/g,""),m=d.replace("["+a+"][","["+n+"]["),u=h.replace(a,n),b=0,w=h;"checkbox"===c.prop("type")&&d.match(/\[\]$/)?((b=l[h]?l[h].length:0)||(c.closest("fieldset.checkboxes").attr("id",u),t.find('label[for="'+h+'"]').attr("for",u).attr("id",u+"-lbl")),w+=b,u+=b):"radio"===c.prop("type")&&((b=l[h]?l[h].length:0)||(c.closest("fieldset.radio").attr("id",u),t.find('label[for="'+h+'"]').attr("for",u).attr("id",u+"-lbl")),w+=b,u+=b),l[h]?l[h].push(!0):l[h]=[!0],c.attr("name",m),c.attr("id",u),t.find('label[for="'+w+'"]').attr("for",u).attr("id",u+"-lbl")}},e.subformRepeatable.prototype.clearScripts=function(t){e.fn.chosen&&t.find("select.chzn-done").each(function(){var t=e(this);t.next(".chzn-container").remove(),t.show().addClass("fix-chosen")})},e.subformRepeatable.prototype.fixScripts=function(t){t.find('a[onclick*="jInsertFieldValue"]').each(function(){var t=e(this),o=t.siblings('input[type="text"]').attr("id"),a=t.prev(),i=a.attr("href");t.attr("onclick","jInsertFieldValue('', '"+o+"');return false;"),a.attr("href",i.replace(/&fieldid=(.+)&/,"&fieldid="+o+"&"))}),e.fn.fieldMedia&&t.find(".field-media-wrapper").fieldMedia(),e.fn.tooltip&&t.find(".hasTooltip").tooltip({html:!0,container:"body"}),e.fn.fieldUser&&t.find(".field-user-wrapper").fieldUser(),window.SqueezeBox&&window.SqueezeBox.assign&&SqueezeBox.assign(t.find("a.modal").get(),{parse:"rel"})},e.subformRepeatable.defaults={btAdd:".group-add",btRemove:".group-remove",btMove:".group-move",minimum:0,maximum:10,repeatableElement:".subform-repeatable-group",rowTemplateSelector:"script.subform-repeatable-template-section",rowsContainer:null},e.fn.subformRepeatable=function(t){return this.each(function(){var t=t||{},o=e(this).data();if(!o.subformRepeatable){for(var a in o)o.hasOwnProperty(a)&&(t[a]=o[a]);var i=new e.subformRepeatable(this,t);e(this).data("subformRepeatable",i)}})},e(window).on("load",function(){e("div.subform-repeatable").subformRepeatable()})}(jQuery);

No other release has this exact content. See every version of this file.