12345678910111213141516171819202122232425262728293031323334353637383940 |
- function Password(parent, open) {
- let value = ''
- let pass = document.createElement('input')
- let check = document.createElement('input')
- check.type = 'checkbox'
- parent.append(pass, check)
- check.onchange = () => {
- this.setOpen(check.checked)
- }
- //добавить pass oninput, который из pass забирает value, запускает setValue
- this.getValue = function () {
- return value
- }
- this.setValue = function (value) {
- // передает value в onchange если он есть
- }
- this.getOpen = function () {
- return open
- }
- this.setOpen = function (newOpen) {
- open = newOpen
- pass.type = open ? 'text' : 'password'
- check.checked = open
- if (typeof this.onOpenChange === 'function') {
- this.onOpenChange(open)
- }
- }
- this.setOpen(open)
- check.oninput = () => {
- if (this.getOpen() === true) {
- this.setOpen(true);
- } else {
- this.setOpen(false);
- }
- if (typeof this.onOpenChange === "function") {
- this.onOpenChange(this.getOpen());
- }
- };
- }
|