-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
228 lines (227 loc) · 15.9 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
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<title>Maskfy 2 - Simple, No Dependences, Mobile Compatibility, Only 1kb (gzip)</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico?2">
<style>
html, body{min-height: 100vh;}
*{box-sizing: border-box;margin: 0;padding: 0;}
@keyframes logo{
0% {opacity: 0;transform: perspective(1000px) rotateX(-90deg);}
100% {opacity: 1;transform: perspective(1000px) rotateX(0deg);}
}
@keyframes bg{
0%{background-color: #111;}
100%{background-color: #ee7517;}
}
@keyframes version{
0%{transform: translate(244px, 0px);opacity: 0;}
100%{transform: translate(244px, 120px);opacity: 1;}
}
.fullwrap{width: 100%;position: absolute;top: 0;left: 0;}
.wrap-social{max-width: 1000px;width: 100%;padding: 10px;margin: 0 auto;font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;text-align: right;}
.wrap-social .btn{padding: 10px 25px;display: inline-block;font-size: 13px;color: #666;background-color: #ddd;border-radius: 3px;text-decoration: none;font-weight: bold;border-bottom: 2px solid #aaa;}
.wrap-social .btn:hover{background-color: #fff;}
.logo-svg{width: 300px;display: block;margin: 0 auto;}
.logo-mask{transform-origin: 50% 100%;animation: logo 1s;animation-fill-mode: forwards;}
.logo-mask-left{d: path('M124.3,21.9L124.3,21.9L97.5,0v63v1.5v21.2l45,22.3V18C136,18,129.9,19.4,124.3,21.9z');}
.logo-mask-right{d: path('M187.5,64.5V63V0l-26.9,21.8l0,0c-5.6-2.5-11.7-3.8-18.2-3.8v90l45-22.3L187.5,64.5L187.5,64.5z');}
.logo-mask-m{d: path('M172.6,75.3V34.7l-29.5,32.1h-1.5l-29.5-32.1v40.6h-1.9V32h1.5l30.6,33.3L172.9,32h1.5v43.3 H172.6z');}
.logo-version{font: 16px Arial, Helvetica, sans-serif;fill:#fff;animation: version 1s 0.2s;animation-fill-mode: forwards;}
.key{animation-fill-mode: forwards;}
.key0{animation: logo 0.2s;d: path('M43.2,174.9v-43.2l-20.4,34.1h-1L1.3,131.7v43.2H0v-46.1h1l21.2,35.4l21.3-35.3h1V175h-1.3 V174.9z');}
.key1{animation: logo 0.4s;d: path('M72.2,128.9h1.2L93.5,175h-1.4l-7.3-16.5H60.7l-7.2,16.4h-1.4L72.2,128.9z M84.2,157.2 l-11.4-26.4l-11.6,26.4H84.2z');}
.key2{animation: logo 0.6s;d: path('M127,135c-1.8-2-3.7-3.4-5.7-4.1c-2-0.7-4.3-1.1-7-1.1c-2.6,0-4.9,0.3-6.8,0.8 s-3.4,1.3-4.6,2.2c-1.2,1-2.1,2.1-2.7,3.5c-0.6,1.3-0.8,2.9-0.8,4.5s0.3,3,0.8,4.1c0.6,1.1,1.4,2,2.6,2.8s2.7,1.4,4.5,1.9 s4,1.1,6.6,1.6s4.9,1.1,6.9,1.7c2.1,0.6,3.8,1.4,5.3,2.3c1.4,0.9,2.6,2,3.3,3.4c0.8,1.3,1.2,3,1.2,5.1c0,3.8-1.4,6.6-4.3,8.6 c-2.9,2-6.8,3-11.9,3c-3.7,0-7-0.6-9.9-1.7c-2.9-1.1-5.5-3-8-5.4l1-0.8c2.3,2.4,4.9,4.2,7.6,5.3s5.9,1.6,9.4,1.6 c4.6,0,8.2-0.9,10.9-2.6c2.7-1.7,4-4.3,4-7.8c0-1.7-0.3-3.2-0.9-4.4c-0.6-1.2-1.5-2.2-2.8-3.1c-1.3-0.9-2.9-1.6-4.8-2.2 c-1.9-0.6-4.2-1.2-6.9-1.7c-2.6-0.5-4.8-1-6.8-1.5s-3.6-1.2-5-2.1s-2.4-1.9-3.1-3.2s-1-2.9-1-4.8c0-2,0.4-3.8,1.1-5.3 c0.8-1.5,1.8-2.8,3.2-3.9c1.4-1.1,3.1-1.9,5.1-2.4s4.2-0.8,6.7-0.8c2.9,0,5.5,0.4,7.7,1.3s4.2,2.3,6,4.3L127,135z');}
.key3{animation: logo 0.8s;d: path('M139.5,174.9v-46.1h1.3v29.9l29.3-29.9h1.9l-19.7,20.1l20.6,26h-1.7l-19.9-25.1l-10.6,10.7 v14.3h-1.2V174.9z');}
.key4{animation: logo 1s;d: path('M176.6,152.6c0-2.2,0.2-4.4,0.7-6.5s1.1-4.2,1.8-6.2c0.8-2.1,1.7-4.1,2.8-6.1s2.2-4,3.3-6 l1,0.8c-1,1.5-2.1,3.3-3.1,5.2c-1,2-1.9,4-2.7,6.2s-1.4,4.3-1.9,6.5s-0.7,4.3-0.7,6.2c0,1.6,0.2,3.4,0.6,5.3 c0.4,1.9,0.9,3.9,1.6,5.8c0.7,2,1.6,4,2.7,6c1.1,2,2.3,4,3.6,5.9l-1,0.8c-2.8-4.1-5-8.2-6.4-12.2 C177.3,160.5,176.6,156.5,176.6,152.6z');}
.key5{animation: logo 1.2s;d: path('M194.9,174.9v-46.1h29.7v1.3h-28.4v20.5h24.3v1.3h-24.2v23H194.9z');}
.key6{animation: logo 1.4s;d: path('M230.6,128.9l17.8,26.7l17.8-26.7h1.5L249,157.1v17.8h-1.3v-18l-18.6-28.1h1.5V128.9z');}
.key7{animation: logo 1.6s;d: path('M281.1,152.6c0,3.9-0.7,7.9-2.2,11.9s-3.6,8.1-6.4,12.2l-1-0.8c1.3-1.9,2.5-3.9,3.6-5.9 s1.9-4,2.7-6c0.7-2,1.3-3.9,1.6-5.8c0.4-1.9,0.6-3.7,0.6-5.3c0-1.9-0.2-4-0.7-6.2s-1.1-4.4-1.9-6.5s-1.7-4.2-2.7-6.2 s-2-3.7-3.1-5.2l1-0.8c1.2,2,2.3,4,3.3,6c1.1,2,2,4,2.8,6.1s1.4,4.1,1.8,6.2C280.9,148.2,281.1,150.3,281.1,152.6z');}
.st0{fill:#000;}
.st1{fill:#fff;}
.st2{fill:#1a1a1a;}
.st4{fill:#111;}
.st5{fill:#ee7517;}
.full{animation: bg 1.6s;animation-fill-mode: forwards;height: 70vh;background-color: orange;display: flex;justify-content: center;align-content: center;flex-flow: wrap;}
.full--subtitle{width: 100%;text-align: center;font-family: Arial, Helvetica, sans-serif;color: #fff;font-weight: lighter;font-size: 30px;margin-top: 50px;-webkit-text-stroke: 1px #ee7517;}
.full--subtitle-strong{font-weight: bold;}
.page{padding: 40px 100px;background-color: #fff;font-family: Arial, Helvetica, sans-serif;color: #222;}
.page a{color: #ee7517;text-decoration: none;}
.page a:hover{color: #000;}
.page--input{width: 100%;padding: 10px;font-size: 20px;border-radius: 4px;border: 1px solid #ccc;}
.page--bigtitle{font-size: 40px;margin-bottom: 5px;}
.page--contain{margin: 10px 0;background-color: #f6f6f6;padding: 10px;border-radius: 4px;}
.page--subtitle{margin-top: 20px;font-size: 20px;}
.page--subtitle-small{font-size: 15px;}
.page--form{display: flex;flex-flow: wrap;align-items: center;}
.page--label{width: 20%;margin-bottom: 10px;padding-right: 10px;font-size: 18px;text-align: right;}
.page--field{width: 80%;margin-bottom: 10px;}
.page code{background-color: #222;display: block;padding: 5px;color: #fff;border-radius: 3px;white-space: pre;}
.page--tag{color: #f92672;}
.page--attr{color: #a6e22e;}
.page--value{color: #e6db74;}
.page--important{color: #66d9ef;font-weight: bold;font-style: italic;}
@media (max-width: 768px){
.full{padding: 20px 10px;}
.full--subtitle{-webkit-text-stroke: 0 transparent;font-size: 20px;}
.page{padding: 20px;}
.page code{overflow: auto;padding: 20px 10px;}
.page--label{text-align: left;width: 100%;}
.page--field{width: 100%;}
}
</style>
</head>
<body>
<div class="full">
<div class="fullwrap">
<div class="wrap-social">
<a href="https://github.com/figuarnieri/maskfy/archive/master.zip" class="btn download" target="_blank" aria-label="Download button">Download</a>
<a href="https://www.npmjs.com/package/maskfy" class="btn github" target="_blank" aria-label="Button to repository on npm js">npm</a>
<a href="https://www.npmjs.com/package/react-maskfy" class="btn github" target="_blank" aria-label="Button to repository on React Maskfy">React</a>
<a href="https://github.com/figuarnieri/maskfy" class="btn github" target="_blank" aria-label="Button to repository on GitHub.com">GitHub</a>
</div>
</div>
<svg class="logo-svg" version="1.1" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" viewBox="0 0 281.1 176.7">
<text class="logo-version">2.0.0</text>
<path class="key key0 st0"/>
<path class="key key1 st0"/>
<path class="key key2 st0"/>
<path class="key key3 st0"/>
<path class="key key4 st1"/>
<path class="key key5 st1"/>
<path class="key key6 st1"/>
<path class="key key7 st1"/>
<g class="logo-mask">
<path class="st2 logo-mask-left"/>
<path class="st4 logo-mask logo-mask-right"/>
<path class="st5 logo-mask logo-mask-m"/>
</g>
</svg>
<div class="full--subtitle">Simple, No Dependences, Mobile Compatibility, IE Compatibility <span class="full--subtitle-strong">Only 1kb (gzip)</span> = ♥</div>
</div>
<div class="page">
<h1 class="page--bigtitle">Maskfy 2 - Input Mask Simple</h1>
<p>A Javascript library without a dependency of jQuery, Zepto, and etc ... Very simple to install and use. With only 1kb (gzip) code, IE Compatibility, it's also well accepted on mobile devices</p>
<div class="page--contain">
<h2 class="page--title">Install / Usage</h2>
<p>Add Maskfy file</p>
<code><span data-clipboard><<span class="page--tag">script</span> <span class="page--attr">src</span>=<span class="page--value">"https://cdn.rawgit.com/figuarnieri/maskfy/master/maskfy.js"</span>></<span class="page--tag">script</span>></span>
or
<span data-clipboard><<span class="page--tag">script</span> <span class="page--attr">src</span>=<span class="page--value">"path/js/maskfy.es5.js"</span>></<span class="page--tag">script</span>></code>
<h3 class="page--subtitle">HTML <small class="page--subtitle-small">(by class or attribute)</small></h3>
<p>Insert a selector in class tag</p>
<code><span data-clipboard><<span class="page--tag">input</span> <span class="page--attr">class</span>=<span class="page--value">"page--input"</span> <span class="page--important">data-maskfy="999.999.999-99"</span> <span class="page--attr">type</span>=<span class="page--value">"text"</span> <span class="page--attr">placeholder</span>=<span class="page--value">"CPF (Ex.: 999.999.999-99)"</span>></span>
or
<span data-clipboard><<span class="page--tag">input</span> <span class="page--attr">class</span>=<span class="page--value">"page--input <span class="page--important">mask-by-class</span>"</span> <span class="page--attr">type</span>=<span class="page--value">"text"</span> <span class="page--attr">placeholder</span>=<span class="page--value">"CPF (Ex.: 999.999.999-99)"</span>></span></code>
<h3 class="page--subtitle">Javascript Options</h3>
<code data-clipboard><<span class="page--tag">script</span>>
<span class="page--tag">new</span> <span class="page--value">Maskfy({</span>
<span data-clipboard><span class="page--attr">tag</span>: <span class="page--value">'[data-maskfy]'</span>, //{String: undefined} (required) selector input</span>
<span data-clipboard><span class="page--attr">mask</span>: <span class="page--value">'999.999.999,99'</span>, //{String: undefined} (required) input mask pattern</span>
<span data-clipboard><span class="page--attr">reverse</span>: <span class="page--value">false</span>, //{Boolean: false} reverse typing</span>
<span data-clipboard><span class="page--attr">minSize</span>: <span class="page--value">3</span> //{Boolean: false} minimum digits</span>
<span data-clipboard><span class="page--attr">defaultValue</span>: <span class="page--value">'123'</span> //{String: undefined} initial value</span>
<span data-clipboard><span class="page--attr">letters</span>: <span class="page--value">true</span> //{Boolean: false} allowed letters</span>
<span data-clipboard><span class="page--attr">after</span>: <span class="page--value">(input) => console.log(input)</span> //{Function: undefined} after input event</span>
<span class="page--value">})</span>;
</<span class="page--tag">script</span>></code>
</div>
<div class="page--contain">
<h2 class="page--title">Examples</h2>
<div class="page--form">
<div class="page--label">
<label for="Money">Money</label>
</div>
<div class="page--field">
<input id="Money" class="page--input mask-by-class" data-maskfy="999.999.999.999,99" data-maskfy-reverse="true" data-maskfy-minsize="3" type="text" value="000">
</div>
<div class="page--label">
<label for="CPF">CPF</label>
</div>
<div class="page--field">
<input id="CPF" class="page--input" data-maskfy="999.999.999-99" type="text" placeholder="CPF (Ex.: 999.999.999-99)">
</div>
<div class="page--label">
<label for="MoneySet">Money Set</label>
</div>
<div class="page--field">
<input id="MoneySet" class="page--input" data-maskfy="999.999.999.999,99" data-maskfy-reverse="true" data-maskfy-minsize="4" type="text" value="2.015,42">
</div>
<div class="page--label">
<label for="Phone">Phone BR</label>
</div>
<div class="page--field">
<input id="Phone" class="page--input" data-maskfy="(99) 99999-9999" type="text">
</div>
<div class="page--label">
<label for="Phone I11l">Phone US</label>
</div>
<div class="page--field">
<input id="Phone I11l" class="page--input" data-maskfy="+ 1 - 541 - 754 - 3010" type="text" value="">
</div>
<div class="page--label">
<label for="Date">Date</label>
</div>
<div class="page--field">
<input id="Date" class="page--input" data-maskfy="99/99/9999" type="text">
</div>
<div class="page--label">
<label for="Plate">Vehicle Plate</label>
</div>
<div class="page--field">
<input id="Plate" class="page--input" data-maskfy="999-9999" data-maskfy-letters="true" type="text">
</div>
</div>
</div>
<div class="page--contain">
<h2 class="page--title">HTML attributes <small class="page--subtitle-small">[data-*]</small></h2>
<p>If necessary, you could add attributes in the tag, to configure your mask options</p>
<h3 class="page--subtitle">data-maskfy</h3>
<code data-clipboard="data"><<span class="page--tag">input</span> <span class="page--important">data-maskfy="999.999.999,99"</span>></code>
<h3 class="page--subtitle">data-maskfy-reverse</h3>
<code data-clipboard="data"><<span class="page--tag">input</span> <span class="page--attr">data-maskfy</span>=<span class="page--value">"999.999.999,99"</span> <span class="page--important">data-maskfy-reverse="true"</span>></code>
<h3 class="page--subtitle">data-maskfy-minsize</h3>
<code data-clipboard="data"><<span class="page--tag">input</span> <span class="page--attr">data-maskfy</span>=<span class="page--value">"999.999.999,99"</span> <span class="page--attr">data-maskfy-reverse</span>=<span class="page--value">"true"</span> <span class="page--important">data-maskfy-minsize="3"</span>></code>
<h3 class="page--subtitle">data-letters</h3>
<code data-clipboard="data"><<span class="page--tag">input</span> <span class="page--attr">data-maskfy</span>=<span class="page--value">"999-9999"</span> <span class="page--important">data-maskfy-letters="true"</span>></code>
<h3 class="page--subtitle">default value</h3>
<code data-clipboard="data"><<span class="page--tag">input</span> <span class="page--attr">data-maskfy</span>=<span class="page--value">"999.999.999,99"</span> <span class="page--important">value="123.456.789,01"</span>></code>
</div>
<div class="page--contain">
<h2 class="page--title">Source</h2>
<p>
<a href="https://github.com/figuarnieri/maskfy" target="_blank">Github</a> | <a href="https://twitter.com/figuarnieri" target="_blank">@figuarnieri</a>
</p>
</div>
<div class="page--contain">
<h2 class="page--title">License</h2>
<p>
The MIT License<br>
Copyright 2018 <sup>©</sup> <a href="https://figuarnieri.github.io/" target="_blank">Filipe Guarnieri</a>
</p>
</div>
</div>
<script src="maskfy.js"></script>
<!-- IE -->
<!-- <script src="maskfy.es5.js"></script> -->
<script src="https://cdn.rawgit.com/zenorocha/clipboard.js/v1.7.1/dist/clipboard.min.js"></script>
<script>const clipcode=new Clipboard('[data-clipboard]',{target:(e)=>{e.setAttribute('data-clipboard-copy','');return document.querySelector(e.dataset.clipboard==='data'?'[data-clipboard-copy] .page--important':'[data-clipboard-copy]')}});clipcode.on('success',(e)=>{e.trigger.removeAttribute('data-clipboard-copy');});</script>
<script>
new Maskfy({tag:'[data-maskfy]'});
new Maskfy({
tag:'#Plate',
after:(input, type)=>input.addEventListener('input',e=>{
const _value=input.value.split('');
if(_value.length<=3){
if(!/[A-Z]/gi.test(_value[_value.length-1]))_value.pop()
}else{
if(!/\d/.test(_value[_value.length-1]))_value.pop()
}
input.value =_value.join('');
})
});
</script>
</body>
</html>