diff --git a/media/system/js/subform-repeatable-uncompressed.js b/media/system/js/subform-repeatable-uncompressed.js index 6f095903cbb05..f8f8c5b864350 100644 --- a/media/system/js/subform-repeatable-uncompressed.js +++ b/media/system/js/subform-repeatable-uncompressed.js @@ -66,7 +66,8 @@ $.subformRepeatable.prototype.prepareTemplate = function(){ // create from template if(this.options.rowTemplateSelector){ - this.template = $.trim(this.$container.find(this.options.rowTemplateSelector).text()); + var tmplElement = this.$container.find(this.options.rowTemplateSelector)[0] || {}; + this.template = $.trim(tmplElement.text || tmplElement.textContent); //(text || textContent) is IE8 fix } // create from existing rows else { diff --git a/media/system/js/subform-repeatable.js b/media/system/js/subform-repeatable.js index bc785f671e23c..2f429d1b7fd81 100644 --- a/media/system/js/subform-repeatable.js +++ b/media/system/js/subform-repeatable.js @@ -1 +1 @@ -(function(e){"use strict";e.subformRepeatable=function(t,n){this.$container=e(t);if(this.$container.data("subformRepeatable"))return r;this.$container.data("subformRepeatable",r),this.options=e.extend({},e.subformRepeatable.defaults,n),this.template="",this.prepareTemplate(),this.$containerRows=this.options.rowsContainer?this.$container.find(this.options.rowsContainer):this.$container;var r=this;this.$container.on("click",this.options.btAdd,function(t){t.preventDefault();var n=e(this).parents(r.options.repeatableElement);n.length||(n=null),r.addRow(n)}),this.$container.on("click",this.options.btRemove,function(t){t.preventDefault();var n=e(this).parents(r.options.repeatableElement);r.removeRow(n)}),this.options.btMove&&this.$containerRows.sortable({items:this.options.repeatableElement,handle:this.options.btMove,tolerance:"pointer",update:this.resortNames.bind(this)}),this.$container.trigger("subform-ready")},e.subformRepeatable.prototype.prepareTemplate=function(){if(this.options.rowTemplateSelector)this.template=e.trim(this.$container.find(this.options.rowTemplateSelector).text());else{var t=this.$container.find(this.options.repeatableElement).get(0),n=e(t).clone();try{this.clearScripts(n)}catch(r){window.console&&console.log(r)}this.template=n.prop("outerHTML")}},e.subformRepeatable.prototype.resortNames=function(){var t=this.$container.find(this.options.repeatableElement),n=[];for(var r=0,i=t.length;r=this.options.maximum)return null;var r=e.parseHTML(this.template);t?e(t).after(r):this.$containerRows.append(r);var i=e(r);i.attr("data-new","true"),this.fixUniqueAttributes(i,n),this.resortNames();try{this.fixScripts(i)}catch(s){window.console&&console.log(s)}return this.$container.trigger("subform-row-add",i),i},e.subformRepeatable.prototype.removeRow=function(e){var t=this.$containerRows.find(this.options.repeatableElement).length;if(t<=this.options.minimum)return;this.$container.trigger("subform-row-remove",e),e.remove(),this.resortNames()},e.subformRepeatable.prototype.fixUniqueAttributes=function(t,n){var r=t.attr("data-group"),i=t.attr("data-base-name"),n=n?n-1:0,s=i+(n+1);t.attr("data-group",s);var o=t.find("*[name]"),u={};for(var a=0,f=o.length;a=this.options.maximum)return null;var r=e.parseHTML(this.template);t?e(t).after(r):this.$containerRows.append(r);var i=e(r);i.attr("data-new","true"),this.fixUniqueAttributes(i,n),this.resortNames();try{this.fixScripts(i)}catch(s){window.console&&console.log(s)}return this.$container.trigger("subform-row-add",i),i},e.subformRepeatable.prototype.removeRow=function(e){var t=this.$containerRows.find(this.options.repeatableElement).length;if(t<=this.options.minimum)return;this.$container.trigger("subform-row-remove",e),e.remove(),this.resortNames()},e.subformRepeatable.prototype.fixUniqueAttributes=function(t,n){var r=t.attr("data-group"),i=t.attr("data-base-name"),n=n?n-1:0,s=i+(n+1);t.attr("data-group",s);var o=t.find("*[name]"),u={};for(var a=0,f=o.length;a