-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathshow-hide-password.min.js
7 lines (6 loc) · 1.26 KB
/
show-hide-password.min.js
1
2
3
4
5
6
7
// Name : Show Hide Password
// Version : 1.0.3
// Developer : Ekrem KAYA
// Website : https://openix.io
// GitHub : https://github.com/openix/show-hide-password
!function(s){"use strict";s.fn.showHidePassword=function(t){s.extend(this,t);var a=s(this),i=a.parent().hasClass("input-group"),e=a.parent().hasClass("form-floating");i?a.css({borderTopRightRadius:"4px",borderBottomRightRadius:"4px"}):e||a.wrap('<div class="password-container"></div>'),a.after('<span class="show-hide-password"><i class="fa-solid fa-eye"></i></span>'),s(".password-container").css({position:"relative"});var r=a.parent().find(".show-hide-password");s(r).css({position:"absolute",display:"none",top:"0",right:"0",height:a.outerHeight(!0)-2,marginTop:"1px",padding:e?"18px 12px":"6px 11px",cursor:"pointer",zIndex:"999",color:"dark"==s("html").attr("data-bs-theme")?"white":"black"}),a.keyup((function(t){var e=s(this);e.val().length>0?(e.css({paddingRight:"34px"}),i&&s(r).css({padding:"8px 11px"}),e.parent().find(r).show()):""==a.val()&&e.parent().find(r).hide()})),a.trigger("keyup"),s(r).on("click",(function(){s(this).find("i").toggleClass("fa-eye fa-eye-slash");var t=s(this).parent().find("input");"password"==t.attr("type")?t.attr("type","text"):t.attr("type","password")}))}}(window.jQuery);