forked from cloudfour/hideShowPassword
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
257 lines (217 loc) · 6.1 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
<!doctype html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1">
<title>hideShowPassword Demo</title>
<style>
/*
* Add this if you want to disable IE10's implementation
* of the winking eye in favor of your own.
* Alternatively, you could set the 'innerToggle' option to
* false for that browser only.
*/
::-ms-reveal {
display:none !important;
}
/*
* This toggle style shows a winking "eye-con" (nyuk, nyuk).
* Open eye means "show," closed eye means "hide."
*/
.hideShowPassword-toggle {
background-image: url(img/wink.svg);
background-position: 0 center;
background-repeat: no-repeat;
cursor: pointer;
height: 100%;
overflow: hidden;
text-indent: -9999em;
width: 44px;
}
.hideShowPassword-toggle-hide {
background-position: -44px center;
}
/* Simple text toggle style */
.my-toggle-class {
color: #888;
cursor: pointer;
font-size: 0.75em;
font-weight: bold;
padding: 0.5em 1em;
text-transform: uppercase;
}
/*
* Because our input elements have a z-index so that
* their borders will overlap on focus, we'll give ours
* a higher one to make sure they're always visible.
*/
.hideShowPassword-toggle,
.my-toggle-class {
z-index: 3;
}
/* Some boilerplate styles */
html {
background-color: #f6f6f6;
}
body {
color: #444;
font-family: sans-serif;
line-height: 1.4em;
margin: 1em auto 2em;
padding: 0 1em;
max-width: 30em;
}
h1, p, figcaption {
text-align: center;
}
h1 {
font-size: 1.25em;
line-height: 1em;
margin: 1.5em 0 1em;
padding: 0;
}
figure {
margin: 0 0 1em;
}
figcaption {
color: #999;
font-size: 0.875em;
margin-top: 0.5em;
}
.btn {
background-color: #0088cc;
border-radius: 0.25em;
color: #fff;
display: inline-block;
padding: 0.5em 1em;
text-decoration: none;
}
/*
* Styles for the login forms.
* None of this is plugin-dependent.
*/
.login, .login-field {
border-radius: 0.25em;
}
.login {
background-color: #e6e6e6;
}
.login-field {
background-color: #fff;
border: 2px solid #ccc;
border-radius: 0.25em;
color: inherit;
display: block;
font-family: inherit;
font-size: inherit;
line-height: inherit;
margin: 0;
padding: 0.5em;
position: relative;
vertical-align: middle;
width: 100%;
-webkit-appearance: none;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.login-field:focus {
border-color: #0088cc;
outline: transparent;
z-index: 2;
}
.login-field-username {
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
margin-bottom: -2px;
}
.login-field-password {
border-top-left-radius: 0;
border-top-right-radius: 0;
margin-top: -2px;
}
.login-option {
padding: 0.25em 0.5em 0.5em;
}
.login-option input {
vertical-align: baseline;
}
</style>
<!-- Including Modernizr to test for touch support. -->
<script src="vendor/modernizr.custom.js"></script>
</head>
<body>
<h1>hideShowPassword Demo</h1>
<figure>
<div class="login">
<input class="login-field login-field-username" type="text" placeholder="Username" autocapitalize="off" autocomplete="off" autocorrect="off">
<input class="login-field login-field-password" id="password-1" type="password" placeholder="Password">
</div>
<figcaption>Inner toggle styled as icon.</figcaption>
</figure>
<figure>
<div class="login">
<input class="login-field login-field-username" type="text" placeholder="Username" autocapitalize="off" autocomplete="off" autocorrect="off">
<input class="login-field login-field-password" id="password-2" type="password" placeholder="Password">
</div>
<figcaption>Password visible by default, toggle styled as text and shows on focus.</figcaption>
</figure>
<figure>
<div class="login">
<input class="login-field login-field-username" type="text" placeholder="Username" autocapitalize="off" autocomplete="off" autocorrect="off">
<input class="login-field login-field-password" id="password-3" type="password" placeholder="Password" value="example password">
<div class="login-option"><input type="checkbox" id="show-password"> <label for="show-password">Show password</label></div>
</div>
<figcaption>Checkbox toggles password visibility.</figcaption>
</figure>
<p><a href="https://github.com/cloudfour/hideShowPassword" class="btn">More info and source</a></p>
<!--
Include Zepto by default or jQuery as a fallback.
See: http://zeptojs.com/#download
The Zepto build here is custom because we need the
data module to be included.
See the README for more info on when to use
Zepto versus jQuery.
-->
<script>
document.write('<script src=vendor/' +
('__proto__' in {} ? 'zepto.custom' : 'jquery') +
'.js><\/script>')
</script>
<!-- Include the plugin. Yay! -->
<script src="hideShowPassword.min.js"></script>
<script>
// Example 1
$('#password-1').hideShowPassword({
// Creates a wrapper and toggle element with minimal styles.
innerToggle: true,
// Makes the toggle functional in touch browsers without
// the element losing focus.
touchSupport: Modernizr.touch
});
// Example 2
$('#password-2').hideShowPassword({
// Make the password visible right away.
show: true,
// Create the toggle goodness.
innerToggle: true,
// Give the toggle a custom class so we can style it
// separately from the previous example.
toggleClass: 'my-toggle-class',
// Don't show the toggle until the input triggers
// the 'focus' event.
hideToggleUntil: 'focus',
// Enable touch support for toggle.
touchSupport: Modernizr.touch
});
// Example 3
$('#show-password').on('change', function () {
// When the '#show-password' checkbox changes its value,
// set the visibility of the password field to whatever
// its 'checked' attribute is.
$('#password-3').hideShowPassword($(this).prop('checked'));
});
</script>
</body>
</html>