Skip to content

Commit

Permalink
Release v1.3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
slackero committed Nov 6, 2021
2 parents edd2314 + 46684e0 commit dc67ccb
Show file tree
Hide file tree
Showing 8 changed files with 134 additions and 29 deletions.
6 changes: 2 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ node_modules/*
._*
.cache
.DS_Store
.idea
Thumbs.db

# Files
package-lock.json
npm-debug.log

# JetBrains
.idea
npm-debug.log
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
## Changes

### [1.3.2] - 2021-10-31
- Added script working with jQuery or Cash.

### [1.3.1] - 2021-10-31
- Fixes the problem that autofill hides the toggle icon.
- Added the `aria-pressed` attribute.
- Updated the demos ([Bootstrap 4](https://slackero.github.io/bootstrap-show-password-toggle/tests/bootstrap4-sign-in/), [Bootstrap 5](https://slackero.github.io/bootstrap-show-password-toggle/tests/bootstrap5-sign-in/))

### [1.3.0] - 2021-10-30
- Works with multiple `input[type=password]`.
- The `aria-label` of the toggle button can be customized adding `data-show` and `data-hide` attributes to the password input.
- The toggle button is added by JavaScript, remove existing `<button>` tags.
- The toggle button works more stable.
- The toggle button is always visible.
21 changes: 4 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[![LICENSE](https://img.shields.io/badge/license-MIT-lightgrey.svg)](https://raw.githubusercontent.com/slackero/bootstrap-show-password-toggle/master/LICENSE)
[![NPM Version](https://img.shields.io/npm/v/@slackero/bootstrap-show-password-toggle)](https://www.npmjs.com/package/@slackero/bootstrap-show-password-toggle)

# Show Password Toggle
# Bootstrap Show Password Toggle

A show password as text toggle for Bootstrap forms

Expand Down Expand Up @@ -37,7 +37,7 @@ A show password as text toggle for Bootstrap forms
</div>
```

3. Load the `show-password-toggle.js` after the form
3. Load the `show-password-toggle.min.js` after the form

I highly recommend adding the attributes: `spellcheck="false"` and `autocapitalize="off"` to the password input so that when the password is displayed in plain text the input is not auto-corrected, capitalized or spellchecked (to avoid red squiggly line underneath).

Expand All @@ -46,6 +46,7 @@ You should also add `id="current-password"` and `autocomplete="current-password"
## Demo

- [Bootstrap 4 Demo](https://slackero.github.io/bootstrap-show-password-toggle/tests/bootstrap4-sign-in/)
- [Bootstrap 4 Demo with jQuery](https://slackero.github.io/bootstrap-show-password-toggle/tests/bootstrap4-jquery-sign-in/)
- [Bootstrap 5 Demo](https://slackero.github.io/bootstrap-show-password-toggle/tests/bootstrap5-sign-in/)

## Browser Support
Expand All @@ -58,23 +59,9 @@ Q. **Can I change the show password icon?**

A. You could change the icon displayed by replacing the `.input-password[type="password"]` [Base64 encoded](https://yoksel.github.io/url-encoder/) background image. SVG is recommended.

## Changes

### [1.3.1] - 2021-10-31
- Fixes the problem that autofill hides the toggle icon.
- Added the `aria-pressed` attribute.
- Updated the demos ([Bootstrap 4](https://slackero.github.io/bootstrap-show-password-toggle/tests/bootstrap4-sign-in/), [Bootstrap 5](https://slackero.github.io/bootstrap-show-password-toggle/tests/bootstrap5-sign-in/))

### [1.3.0] - 2021-10-30
- Works with multiple `input[type=password]`.
- The `aria-label` of the toggle button can be customized adding `data-show` and `data-hide` attributes to the password input.
- The toggle button is added by JavaScript, remove existing `<button>` tags.
- The toggle button works more stable.
- The toggle button is always visible.

## Known Issues

- Browsers without [Element.after()](https://developer.mozilla.org/en-US/docs/Web/API/Element/after#browser_compatibility) are not supported.
- For browsers without [Element.after()](https://developer.mozilla.org/en-US/docs/Web/API/Element/after#browser_compatibility) load `show-password-toggle-jquery.min.js` instead. jQuery or Cash needs to be loaded before.

## Credits and Thanks

Expand Down
28 changes: 28 additions & 0 deletions js/show-password-toggle-jquery.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
$(function () {
let ShowPasswordToggles = $('input:password');
if (ShowPasswordToggles.length) {
ShowPasswordToggles.each(function () {
let $this = $(this);
$this.addClass('input-password');
let $toggleButtonLabels = {
show: $this.data('show') || 'Show password as plain text. Warning: this will display your password on the screen.',
hide: $this.data('hide') || 'Hide password.'
};
let $toggleButton = $('<button class="toggle-password" aria-label="" aria-pressed="false"></button>');
$toggleButton.on('click', function () {
if ($this.attr('type') === 'password') {
$this.attr('type', 'text');
$toggleButton.addClass('password-visible');
$toggleButton.attr('aria-label', $toggleButtonLabels.hide);
$toggleButton.attr('aria-pressed', 'true');
} else {
$this.attr('type', 'password');
$toggleButton.removeClass('password-visible');
$toggleButton.attr('aria-label', $toggleButtonLabels.show);
$toggleButton.attr('aria-pressed', 'false');
}
});
$this.after($toggleButton);
});
}
});
1 change: 1 addition & 0 deletions js/show-password-toggle-jquery.min.js

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

14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@slackero/bootstrap-show-password-toggle",
"version": "1.3.1",
"version": "1.3.2",
"description": "A show password as text toggle for Bootstrap",
"keywords": [
"bootstrap",
Expand Down Expand Up @@ -34,17 +34,17 @@
"css-compile": "sass --style expanded --embed-sources scss:css",
"css-lint": "stylelint \"scss/*.scss\"",
"css-minify": "cleancss -O1 --format breakWith=lf --output css/show-password-toggle.min.css css/show-password-toggle.css",
"js-lint": "eslint js/show-password-toggle.js",
"js-minify": "terser --ecma 5 --keep-classnames --keep-fnames --output js/show-password-toggle.min.js -- js/show-password-toggle.js",
"js-lint": "eslint js/show-password-toggle.js js/show-password-toggle-jquery.js",
"js-minify": "terser --ecma 5 --keep-classnames --keep-fnames --output js/show-password-toggle.min.js -- js/show-password-toggle.js && terser --ecma 5 --keep-classnames --keep-fnames --output js/show-password-toggle-jquery.min.js -- js/show-password-toggle-jquery.js",
"test": "npm-run-all css-lint js-lint"
},
"devDependencies": {
"clean-css-cli": "^5.4.1",
"clean-css-cli": "^5.4.2",
"eslint": "^8.1.0",
"npm-run-all": "^4.1.5",
"sass": "^1.42.1",
"stylelint": "^13.13.1",
"stylelint-config-twbs-bootstrap": "^2.2.4",
"sass": "^1.43.4",
"stylelint": "13.13.1",
"stylelint-config-twbs-bootstrap": "2.2.4",
"terser": "^5.9.0"
}
}
75 changes: 75 additions & 0 deletions tests/bootstrap4-jquery-sign-in/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<!doctype html>
<html lang="en">

<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Show Password Toggle for Bootstrap 4</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4/dist/css/bootstrap.min.css">
<meta name="description" content="Show Password Toggle for Bootstrap 4">
<meta name="author" content="Christian Oliff">
<meta name="twitter:creator" content="@christianoliff">
<meta name="monetization" content="$ilp.uphold.com/Epqzn3YGr2MB">
<link rel="stylesheet" href="../../css/show-password-toggle.css">
</head>

<body class="bg-light p-3">
<form class="mx-auto card p-4 col-12 col-sm-8 col-md-5 col-lg-4 mt-sm-4 mt-md-5" autocomplete="off">
<h1 class="h2 mb-4 text-center text-primary">Please sign in</h1>

<div class="form-group">
<label for="email">Email address</label>
<input type="email" name="email" id="email" class="form-control" required autofocus>
</div>

<div class="form-group">
<label for="current-password">Password</label>
<div class="input-group">
<input type="password"
name="password"
id="current-password"
autocomplete="current-password"
class="form-control rounded"
spellcheck="false"
autocapitalize="off"
required
data-show="Show password as plain text. Warning: this will display your password on the screen."
data-hide="Hide password."
>
</div>
</div>

<div class="form-group">
<label for="repeat-password">Password repeat</label>
<div class="input-group">
<input type="password"
name="password_repeat"
id="repeat-password"
autocomplete="current-password"
class="form-control rounded"
spellcheck="false"
autocapitalize="off"
required
data-show="Show password as plain text. Warning: this will display your password on the screen."
data-hide="Hide password."
>
</div>
</div>

<button class="btn btn-lg btn-primary btn-block mt-3" type="submit">
Sign in
</button>

</form>

<p class="my-3 text-center">
<a href="https://github.com/slackero/bootstrap-show-password-toggle" class="text-muted">
&copy; 2021
</a>
</p>

<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
<script src="../../js/show-password-toggle-jquery.min.js" async></script>
</body>

</html>
2 changes: 1 addition & 1 deletion tests/bootstrap5-sign-in/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ <h1 class="h2 mb-4 text-center text-primary">Please sign in</h1>
</form>

<p class="my-3 text-center">
<a href="https://github.com/slackero/bootstrap-show-password-toggle" class="small text-muted text-decoration-none">
<a href="https://github.com/slackero/bootstrap-show-password-toggle" class="small text-muted text-decoration-none">
&copy; 2021
</a>
</p>
Expand Down

0 comments on commit dc67ccb

Please sign in to comment.