Skip to content

Commit

Permalink
add the 'clear' method.
Browse files Browse the repository at this point in the history
  • Loading branch information
HichemTab-tech committed Aug 28, 2023
1 parent 01a0b19 commit 3afc095
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 8 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ You can install OTP-designer-jquery via npm:
You can also include OTP-designer-jquery directly from a CDN by adding the following script tag to your HTML file:

```HTML
<script src="https://cdn.jsdelivr.net/gh/HichemTab-tech/OTP-designer-jquery@2.0.2/dist/otpdesigner.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/HichemTab-tech/OTP-designer-jquery@2.1.0/dist/otpdesigner.min.js"></script>
```

### Local Download
Expand Down Expand Up @@ -253,6 +253,7 @@ The OTP Designer jQuery Plugin provides the following method:
| **`code`** | String | The entered OTP code. |

- **`set`**: Set a value to the current OTP code.
- **`clear`**: Clear the value of the current OTP code.
- **`focus`**: Request a focus on the OTP code input.
- **`hiddenInput`**: Return the hidden input element which stores the OTP code value.

Expand Down
8 changes: 7 additions & 1 deletion dist/otpdesigner.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* OTP-designer-jquery v2.0.2
* OTP-designer-jquery v2.1.0
* (c) HichemTech
* Released under the MIT License.
* Github: github.com/HichemTab-tech/OTP-designer-jquery
Expand Down Expand Up @@ -576,6 +576,12 @@ const otpdesigner = function (options = {}, ...args) {
}
return results;
},
clear: function (results, data) {
for (let i = data.settings.length - 1; i >= 0; i--) {
$('#'+optInputId + (i) + "_" + data.idSuffix).trigger('otp-written', ["Backspace"]);
}
return results;
},
focus: function (results, data) {
$('#'+optInputId + (data.settings.length - 1) + "_" + data.idSuffix).otpdesigner__toggleFocus__(true);
return results;
Expand Down
4 changes: 2 additions & 2 deletions dist/otpdesigner.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "otp-designer-jquery",
"version": "2.0.2",
"version": "2.1.0",
"description": "OTP-designer-jquery: Create custom OTP code inputs effortlessly! This jQuery plugin enables designers and developers to design visually appealing, secure OTP code input fields. Enjoy seamless integration and built-in validation events, ensuring a delightful user experience. Simplify OTP input implementation with ease.",
"keywords": [
"jquery",
Expand Down
6 changes: 6 additions & 0 deletions src/otpdesigner.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ export const otpdesigner = function (options = {}, ...args) {
}
return results;
},
clear: function (results, data) {
for (let i = data.settings.length - 1; i >= 0; i--) {
$('#'+optInputId + (i) + "_" + data.idSuffix).trigger('otp-written', ["Backspace"]);
}
return results;
},
focus: function (results, data) {
$('#'+optInputId + (data.settings.length - 1) + "_" + data.idSuffix).otpdesigner__toggleFocus__(true);
return results;
Expand Down
2 changes: 1 addition & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const webpack = require("webpack");
// noinspection JSUnresolvedReference
let bannerPlugin = new webpack.BannerPlugin({
banner: `/*!
* OTP-designer-jquery v2.0.2
* OTP-designer-jquery v2.1.0
* (c) HichemTech
* Released under the MIT License.
* Github: github.com/HichemTab-tech/OTP-designer-jquery
Expand Down

0 comments on commit 3afc095

Please sign in to comment.