From ddbfa9039da23b3414222abe61eb802de7232db4 Mon Sep 17 00:00:00 2001 From: bemol Date: Thu, 30 Jun 2016 17:29:29 +0200 Subject: [PATCH 1/2] Added option stopOnBackspace There is the case when you have a couples of inputs and if you press and hold backspace then you'll delete whole form. To prevent this situation I write another setting called stopOnBackspace. --- js/jquery.autotab.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/js/jquery.autotab.js b/js/jquery.autotab.js index c863476..d08dd84 100644 --- a/js/jquery.autotab.js +++ b/js/jquery.autotab.js @@ -46,7 +46,8 @@ changed: false, editable: (e.type === 'text' || e.type === 'password' || e.type === 'textarea' || e.type === 'tel' || e.type === 'number' || e.type === 'email' || e.type === 'search' || e.type === 'url'), filterable: (e.type === 'text' || e.type === 'password' || e.type === 'textarea'), - tabOnSelect: false + tabOnSelect: false, + stopOnBackspace: false }; // If $.autotab.selectFilterByClas is true and the format not specified, automatically select an element's format based on a matching class name. @@ -547,7 +548,7 @@ setSettings(this, { changed: (this.value !== defaults.originalValue) }); - if (this.value.length === 0) { + if (this.value.length === 0 && !stopOnBackspace) { $(this).trigger('autotab-previous', defaults); return; } @@ -764,4 +765,4 @@ return $(this).autotab('filter', defaults); }; -})(jQuery); \ No newline at end of file +})(jQuery); From 52a5d5f9852e9181f647b6202d007cb274f0b537 Mon Sep 17 00:00:00 2001 From: bemol Date: Thu, 7 Jul 2016 10:32:16 +0200 Subject: [PATCH 2/2] Fixed bug with wrong reference --- js/jquery.autotab.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/jquery.autotab.js b/js/jquery.autotab.js index d08dd84..f709eb6 100644 --- a/js/jquery.autotab.js +++ b/js/jquery.autotab.js @@ -548,7 +548,7 @@ setSettings(this, { changed: (this.value !== defaults.originalValue) }); - if (this.value.length === 0 && !stopOnBackspace) { + if (this.value.length === 0 && !defaults.stopOnBackspace) { $(this).trigger('autotab-previous', defaults); return; }