forked from gregorio-project/GregoBase
-
Notifications
You must be signed in to change notification settings - Fork 0
/
relCopy.min.js
2 lines (2 loc) · 950 Bytes
/
relCopy.min.js
1
2
(function(a){a.fn.relCopy=function(e){var b=jQuery.extend({excludeSelector:".exclude",emptySelector:".empty",copyClass:"copy",append:"",clearInputs:!0,limit:0},e);b.limit=parseInt(b.limit);this.each(function(){a(this).click(function(){var f=a(this).attr("rel"),d=a(f).length;if(0!=b.limit&&d>=b.limit)return!1;var c=a(f+":first"),e=a(c).parent(),c=a(c).clone(!0).addClass(b.copyClass+d).append(b.append);b.excludeSelector&&a(c).find(b.excludeSelector).remove();b.emptySelector&&a(c).find(b.emptySelector).empty();
if(a(c).attr("id")){var g=a(c).attr("id")+(d+1);a(c).attr("id",g)}a(c).find("[id]").each(function(){var b=a(this).attr("id")+(d+1);a(this).attr("id",b)});b.clearInputs&&a(c).find(":input").each(function(){switch(a(this).attr("type")){case "button":break;case "reset":break;case "submit":break;case "checkbox":a(this).attr("checked","");break;default:a(this).val("")}});a(e).find(f+":last").after(c);return!1})});return this}})(jQuery);