From ea1b39c5be1ab6bcb11f30494e2806dce736f99d Mon Sep 17 00:00:00 2001 From: Matthew Miller Date: Fri, 20 Feb 2015 19:25:12 -0600 Subject: [PATCH] Fixed pasting issue with input type=button elements Moved the various buttons around in the demo --- CHANGELOG.md | 8 ++++++++ bower.json | 2 +- index.html | 26 +++++++++++++++----------- js/jquery.autotab.js | 6 +++--- js/jquery.autotab.min.js | 21 +++++++++++++++++++-- 5 files changed, 46 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d866b69..79ed95f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +## 1.9.2 (2015-02-20) + +Bug fixes: + +* fixed an issue with input elements that are a button type having their text being overwritten when pasting and modified the demo to test against the bug (#79) +* included a pull request that restores an element's original maxlength value + + ## 1.9.1 (2015-02-04) Bug fixes: diff --git a/bower.json b/bower.json index b4a3e81..d7465e1 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "jquery.autotab", - "version": "1.9.1", + "version": "1.9.2", "description": "A jQuery plugin that provides auto-tabbing and filtering on text fields in a form.", "main": [ "./js/jquery.autotab.min.js" ], "homepage": "https://github.com/Mathachew/jquery-autotab", diff --git a/index.html b/index.html index d149f82..4965e1c 100644 --- a/index.html +++ b/index.html @@ -292,11 +292,15 @@

jQuery Autotab Demo

- - - -
- + + + + + + + + +


- +
- Email: + Email:
- Number: + Number:
- Tel: + Tel:
- Range: + Range:
- URL: + URL:
 // Note: This call is not necessary as 'all' is the default format
diff --git a/js/jquery.autotab.js b/js/jquery.autotab.js
index f5d7cff..c863476 100644
--- a/js/jquery.autotab.js
+++ b/js/jquery.autotab.js
@@ -1,5 +1,5 @@
 /**
- * Autotab - jQuery plugin 1.9.1
+ * Autotab - jQuery plugin 1.9.2
  * https://github.com/Mathachew/jquery-autotab
  * 
  * Copyright (c) 2008, 2015 Matthew Miller
@@ -540,7 +540,7 @@
                 defaults.arrowKey = false;
 
                 // Prevent the browser from of navigating to the previous page
-                if (this.type === 'select-one' || this.type === 'select-multiple' || this.type === 'checkbox' || this.type === 'radio' || this.type === 'button' || this.type === 'submit' || this.type === 'range') {
+                if (!defaults.editable) {
                     $(this).trigger('autotab-previous', defaults);
                     return false;
                 }
@@ -691,7 +691,7 @@
 
                         var defaults = getSettings(e);
 
-                        if ($(e).prop('disabled') || $(e).prop('readonly')) {
+                        if ($(e).prop('disabled') || $(e).prop('readonly') || !defaults.editable) {
                             $(e).trigger('autotab-next');
 
                             if (!settings.iOS) {
diff --git a/js/jquery.autotab.min.js b/js/jquery.autotab.min.js
index f97bba1..ab995a2 100644
--- a/js/jquery.autotab.min.js
+++ b/js/jquery.autotab.min.js
@@ -1,5 +1,5 @@
 /**
- * Autotab - jQuery plugin 1.9.1
+ * Autotab - jQuery plugin 1.9.2
  * https://github.com/Mathachew/jquery-autotab
  * 
  * Copyright (c) 2008, 2015 Matthew Miller
@@ -8,4 +8,21 @@
  *   http://www.opensource.org/licenses/mit-license.php
  */
 
-(function(d){var u=navigator.platform,g=null,r="iPad"===u||"iPhone"===u||"iPod"===u,w="undefined"!==typeof InstallTrigger,x=!window.ActiveXObject&&"ActiveXObject"in window,h=function(a,f){if(null!==f&&"undefined"!==typeof f)for(var b in f)d(a).data("autotab-"+b,f[b])},l=function(a){var f={arrowKey:!1,format:"all",loaded:!1,disabled:!1,pattern:null,uppercase:!1,lowercase:!1,nospace:!1,maxlength:2147483647,target:null,previous:null,trigger:null,originalValue:"",changed:!1,editable:"text"===a.type|| "password"===a.type||"textarea"===a.type||"tel"===a.type||"number"===a.type||"email"===a.type||"search"===a.type||"url"===a.type,filterable:"text"===a.type||"password"===a.type||"textarea"===a.type,tabOnSelect:!1};if(!0===d.autotab.selectFilterByClass&&"undefined"===typeof d(a).data("autotab-format")){var b="all text alpha number numeric alphanumeric hex hexadecimal custom".split(" "),e;for(e in b)if(d(a).hasClass(b[e])){f.format=b[e];break}}for(e in f)"undefined"!==typeof d(a).data("autotab-"+e)&& (f[e]=d(a).data("autotab-"+e));f.loaded||(null!==f.trigger&&"string"===typeof f.trigger&&(f.trigger=f.trigger.toString()),h(a,f));return f},p=function(a){return"undefined"!==typeof a&&("string"===typeof a||!(a instanceof jQuery))},y=function(a){var d=0,b=0,e=0;if("text"===a.type||"password"===a.type||"textarea"===a.type)"number"===typeof a.selectionStart&&"number"===typeof a.selectionEnd?(d=a.selectionStart,b=a.selectionEnd,e=1):document.selection&&document.selection.createRange&&(b=document.selection.createRange(), d=a.createTextRange(),a=a.createTextRange(),e=b.getBookmark(),d.moveToBookmark(e),a.setEndPoint("EndToStart",d),d=a.text.length,b=d+b.text.length,e=2);return{start:d,end:b,selectionType:e}};d.autotab=function(a){"object"!==typeof a&&(a={});d(":input").autotab(a)};d.autotab.selectFilterByClass=!1;d.autotab.next=function(){var a=d(document.activeElement);a.length&&a.trigger("autotab-next")};d.autotab.previous=function(){var a=d(document.activeElement);a.length&&a.trigger("autotab-previous")};d.autotab.remove= function(a){p(a)?d(a).autotab("remove"):d(":input").autotab("remove")};d.autotab.restore=function(a){p(a)?d(a).autotab("restore"):d(":input").autotab("restore")};d.autotab.refresh=function(a){p(a)?d(a).autotab("refresh"):d(":input").autotab("refresh")};d.fn.autotab=function(a,f){if(!this.length)return this;var b=d.grep(this,function(a,c){return"hidden"!=a.type});if("filter"==a){if("string"===typeof f||"function"===typeof f)f={format:f};for(var e=0,m=b.length;e(new Date).getTime()-g.getTime())return g=null,!1}else"range"!==this.type&&"select-one"!==this.type&&"select-multiple"!==this.type&&("tel"!==this.type&&"number"!==this.type||("tel"===this.type||"number"===this.type)&&0==this.value.length)&&(37!=e|| c.editable&&0!=b.start?39!=e||c.editable&&c.filterable&&b.end!=this.value.length&&0!=this.value.length||(c.arrowKey=!0,d(this).trigger("autotab-next",c)):(c.arrowKey=!0,d(this).trigger("autotab-previous",c)))}).on("keypress.autotab",function(a){var c=l(this),b=a.which||a.keyCode;if(!c||c.disabled||w&&0===a.charCode||a.ctrlKey||a.altKey||13==b||this.disabled)return!0;a=String.fromCharCode(b);if("text"!=this.type&&"password"!=this.type&&"textarea"!=this.type)return this.value.length+1>=c.maxlength&& (c.arrowKey=!1,d(this).trigger("autotab-next",c)),this.value.length!=c.maxlength;if(null!==c.trigger&&0<=c.trigger.indexOf(a))return null!==g&&800>(new Date).getTime()-g.getTime()?g=null:(c.arrowKey=!1,d(this).trigger("autotab-next",c)),!1;g=null;b=document.selection&&document.selection.createRange?!0:0(new Date).getTime()-g.getTime())return g=null,!1}else"range"!==this.type&&"select-one"!==this.type&&"select-multiple"!==this.type&&("tel"!==this.type&&"number"!==this.type||("tel"===this.type||"number"===this.type)&&0==this.value.length)&&(37!=e||c.editable&&0!=b.start?39!=e||c.editable&&c.filterable&&b.end!=this.value.length&&0!=this.value.length||(c.arrowKey=!0,d(this).trigger("autotab-next",c)):(c.arrowKey=
+!0,d(this).trigger("autotab-previous",c)))}).on("keypress.autotab",function(a){var c=l(this),b=a.which||a.keyCode;if(!c||c.disabled||w&&0===a.charCode||a.ctrlKey||a.altKey||13==b||this.disabled)return!0;a=String.fromCharCode(b);if("text"!=this.type&&"password"!=this.type&&"textarea"!=this.type)return this.value.length+1>=c.maxlength&&(c.arrowKey=!1,d(this).trigger("autotab-next",c)),this.value.length!=c.maxlength;if(null!==c.trigger&&0<=c.trigger.indexOf(a))return null!==g&&800>(new Date).getTime()-
+g.getTime()?g=null:(c.arrowKey=!1,d(this).trigger("autotab-next",c)),!1;g=null;b=document.selection&&document.selection.createRange?!0:0