From 7d6408e4da49e747022e49321cc7eb74a0c202e6 Mon Sep 17 00:00:00 2001 From: Kurtis LoVerde Date: Mon, 29 Aug 2016 21:14:17 -0400 Subject: [PATCH 1/2] changed .prop to .attr --- CHANGELOG.md | 1 + jquery.addremovetextbox.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b2d61bf..8f8c4f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ## Release 1.1.2 (August 29, 2016) +* Changed an occurrence of prop() to attr() - no functional impact, but made for the sake of correctness * Refinements to demo.html diff --git a/jquery.addremovetextbox.js b/jquery.addremovetextbox.js index 4f9f33f..cb2a704 100644 --- a/jquery.addremovetextbox.js +++ b/jquery.addremovetextbox.js @@ -141,7 +141,7 @@ } if( title != null ) { - btn.prop( "title", title ); + btn.attr( "title", title ); } return btn; From 01daca0eef3c441a30db25398fa015542e398213 Mon Sep 17 00:00:00 2001 From: Kurtis LoVerde Date: Mon, 29 Aug 2016 21:17:36 -0400 Subject: [PATCH 2/2] sync with non-minified script --- jquery.addremovetextbox.min.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery.addremovetextbox.min.js b/jquery.addremovetextbox.min.js index 5b98869..5b8c619 100644 --- a/jquery.addremovetextbox.min.js +++ b/jquery.addremovetextbox.min.js @@ -30,4 +30,4 @@ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -!function(a){"use strict";a.fn.addRemoveTextbox=function(b){function h(a){throw"AddRemoveTextbox error: "+a}function i(b){var e=a("input[id^='"+d+"']");null!=c.maxFields&&e.length>c.maxFields&&h("There are more fields in the '"+d+"' set ("+e.length+") than are allowed by maxFields ("+c.maxFields+")"),e.each(function(){var b=a(this),c=b.parent();l().insertAfter(b),c.is(":last-child")&&k().appendTo(c)}),q()}function j(b,c){var d=a("");return null!=b&&d.addClass(b),null!=c&&d.prop("title",c),d}function k(){var b=j(c.addButtonClass,c.addButtonTooltip);return b.on("click",function(){var b=n(a(this));a(r("#"+b)).focus()}),b}function l(){var b=j(c.removeButtonClass,c.removeButtonTooltip);return b.on("click",function(){p(a(this))}),b}function m(){var b=null,c=null,e=a("input[id^='"+d+"']");return e.each(function(){var d=a(this);null==b&&(b=d),c=d,b.attr("id")>d.attr("id")||(b=d)}),{highestBox:b,lastBox:c,numBoxes:e.length}}function n(a){var b=a.parent(),d=b.clone(!0),e=d.children("input"),f=o();return e.val(""),e.attr("id",f.nextId),e.attr("name",e.attr("id")),a.remove(),null!=c.maxFields&&f.numBoxes+1>=c.maxFields&&d.find("span[class='"+c.addButtonClass+"']").remove(),d.insertAfter(b),f.nextId}function o(){var a=m();null!=c.maxFields&&a.numBoxes>=c.maxFields&&h("Field count limit reached for "+d);var b=a.highestBox,e=parseInt(b.attr("id").replace(/.*(\d+).*$/,"$1")),g=e+1,i=f?d+"["+g+"]":d+g;return{nextId:i,numBoxes:a.numBoxes}}function p(b){var e=b.parent(),f=e.prev(),g=e.children("input").attr("id"),h=!1;a("input[id^='"+d+"']").each(function(){if(a(this).attr("id")!==g)return void(h=!0)}),h?(e.is(":last-child")?k().appendTo(f):e.parent().last().find("span[class='"+c.addButtonClass+"']").length||k().appendTo(e.siblings(":last")),e.remove(),q()):a(r("#"+g)).val("")}function q(){if(c.contiguous===!0){var b=c.startingNumber;a("input[id^="+d+"]").each(function(){var c=a(this),e=f?d+"["+b+"]":d+b;c.attr("id",e),c.attr("name",e),b++})}}function r(a){return a.replace(/(\[|\])/g,"\\$1")}var c=a.extend({addButtonClass:"addButton",addButtonTooltip:null,removeButtonClass:"removeButton",removeButtonTooltip:null,maxFields:null,contiguous:!1,startingNumber:0},b),d=this.attr("id").replace(/\[?[0-9]*\]?$/,""),e=null!=this.attr("id").match(/[0-9]+$/),f=null!=this.attr("id").match(/\[[0-9]\]$/);if(e||f?e&&f&&h("Invalid state: ID '"+this.attr("id")+"' notation not detected correctly"):h("Invalid ID attribute '"+this.attr("id")+"': IDs must be nunmbered like id1, id2, or use array notation, like id[0], id[1]"),null!=c.maxFields){var g="maxFields ("+c.maxFields+") must be an integer greater than 1";isNaN(c.maxFields)?h(g):(c.maxField=parseInt(c.maxField),(c.maxFields<2||c.maxFields%1!==0)&&h(g))}if(c.contiguous===!0&&null!=c.startingNumber){var g="startingNumber ("+c.startingNumber+") must be an integer greater than or equal to 0";isNaN(c.startingNumber)?h(g):(c.startingNumber=parseInt(c.startingNumber),(c.startingNumber<0||c.startingNumber%1!==0)&&h(g))}i(this)}}(jQuery); \ No newline at end of file +!function(a){"use strict";a.fn.addRemoveTextbox=function(b){function h(a){throw"AddRemoveTextbox error: "+a}function i(b){var e=a("input[id^='"+d+"']");null!=c.maxFields&&e.length>c.maxFields&&h("There are more fields in the '"+d+"' set ("+e.length+") than are allowed by maxFields ("+c.maxFields+")"),e.each(function(){var b=a(this),c=b.parent();l().insertAfter(b),c.is(":last-child")&&k().appendTo(c)}),q()}function j(b,c){var d=a("");return null!=b&&d.addClass(b),null!=c&&d.attr("title",c),d}function k(){var b=j(c.addButtonClass,c.addButtonTooltip);return b.on("click",function(){var b=n(a(this));a(r("#"+b)).focus()}),b}function l(){var b=j(c.removeButtonClass,c.removeButtonTooltip);return b.on("click",function(){p(a(this))}),b}function m(){var b=null,c=null,e=a("input[id^='"+d+"']");return e.each(function(){var d=a(this);null==b&&(b=d),c=d,b.attr("id")>d.attr("id")||(b=d)}),{highestBox:b,lastBox:c,numBoxes:e.length}}function n(a){var b=a.parent(),d=b.clone(!0),e=d.children("input"),f=o();return e.val(""),e.attr("id",f.nextId),e.attr("name",e.attr("id")),a.remove(),null!=c.maxFields&&f.numBoxes+1>=c.maxFields&&d.find("span[class='"+c.addButtonClass+"']").remove(),d.insertAfter(b),f.nextId}function o(){var a=m();null!=c.maxFields&&a.numBoxes>=c.maxFields&&h("Field count limit reached for "+d);var b=a.highestBox,e=parseInt(b.attr("id").replace(/.*(\d+).*$/,"$1")),g=e+1,i=f?d+"["+g+"]":d+g;return{nextId:i,numBoxes:a.numBoxes}}function p(b){var e=b.parent(),f=e.prev(),g=e.children("input").attr("id"),h=!1;a("input[id^='"+d+"']").each(function(){if(a(this).attr("id")!==g)return void(h=!0)}),h?(e.is(":last-child")?k().appendTo(f):e.parent().last().find("span[class='"+c.addButtonClass+"']").length||k().appendTo(e.siblings(":last")),e.remove(),q()):a(r("#"+g)).val("")}function q(){if(c.contiguous===!0){var b=c.startingNumber;a("input[id^="+d+"]").each(function(){var c=a(this),e=f?d+"["+b+"]":d+b;c.attr("id",e),c.attr("name",e),b++})}}function r(a){return a.replace(/(\[|\])/g,"\\$1")}var c=a.extend({addButtonClass:"addButton",addButtonTooltip:null,removeButtonClass:"removeButton",removeButtonTooltip:null,maxFields:null,contiguous:!1,startingNumber:0},b),d=this.attr("id").replace(/\[?[0-9]*\]?$/,""),e=null!=this.attr("id").match(/[0-9]+$/),f=null!=this.attr("id").match(/\[[0-9]\]$/);if(e||f?e&&f&&h("Invalid state: ID '"+this.attr("id")+"' notation not detected correctly"):h("Invalid ID attribute '"+this.attr("id")+"': IDs must be nunmbered like id1, id2, or use array notation, like id[0], id[1]"),null!=c.maxFields){var g="maxFields ("+c.maxFields+") must be an integer greater than 1";isNaN(c.maxFields)?h(g):(c.maxField=parseInt(c.maxField),(c.maxFields<2||c.maxFields%1!==0)&&h(g))}if(c.contiguous===!0&&null!=c.startingNumber){var g="startingNumber ("+c.startingNumber+") must be an integer greater than or equal to 0";isNaN(c.startingNumber)?h(g):(c.startingNumber=parseInt(c.startingNumber),(c.startingNumber<0||c.startingNumber%1!==0)&&h(g))}i(this)}}(jQuery); \ No newline at end of file