payment_info_rails 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +31 -0
- data/Rakefile +2 -0
- data/app/assets/javascripts/jquery.mask.js +489 -0
- data/app/assets/javascripts/modernizr.js +4 -0
- data/app/assets/javascripts/payment_info.js +514 -0
- data/app/assets/javascripts/payment_info_initializer.js +3 -0
- data/app/assets/javascripts/payment_info_main.js +1 -0
- data/app/assets/stylesheets/normalize.css +502 -0
- data/app/assets/stylesheets/payment_info.css +394 -0
- data/app/assets/stylesheets/payment_info_main.css +8 -0
- data/lib/payment_info_rails/engine.rb +4 -0
- data/lib/payment_info_rails/version.rb +3 -0
- data/lib/payment_info_rails.rb +6 -0
- data/payment_info_rails.gemspec +23 -0
- metadata +90 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d4c48dac42a4aa35fc8db442d198a30124e5e349
|
4
|
+
data.tar.gz: caadfbaa9afbf8402f3faf302c65b2511d358cd5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 52e399adb6a745190a9d248b1510427f6d5a58364f3152e488a3c8fabd592dc81871cc130fb1bb8f5b8d8abfd56ee745d9d3d589609d8ec965b0ccc4126f5e1f
|
7
|
+
data.tar.gz: 3109dc61709968e041c2634eb7992af1bd660669b428ae295dc046dc629a7b15d518c843f7cf55c8e012462366b01002f339ef308f8ef116ae1fd25852d621f6
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Nora Alvarado
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# PaymentInfoRails
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'payment_info_rails'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install payment_info_rails
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
TODO: Write usage instructions here
|
24
|
+
|
25
|
+
## Contributing
|
26
|
+
|
27
|
+
1. Fork it ( https://github.com/[my-github-username]/payment_info_rails/fork )
|
28
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
29
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
30
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
31
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,489 @@
|
|
1
|
+
/**
|
2
|
+
* jquery.mask.js
|
3
|
+
* @version: v1.13.4
|
4
|
+
* @author: Igor Escobar
|
5
|
+
*
|
6
|
+
* Created by Igor Escobar on 2012-03-10. Please report any bug at http://blog.igorescobar.com
|
7
|
+
*
|
8
|
+
* Copyright (c) 2012 Igor Escobar http://blog.igorescobar.com
|
9
|
+
*
|
10
|
+
* The MIT License (http://www.opensource.org/licenses/mit-license.php)
|
11
|
+
*
|
12
|
+
* Permission is hereby granted, free of charge, to any person
|
13
|
+
* obtaining a copy of this software and associated documentation
|
14
|
+
* files (the "Software"), to deal in the Software without
|
15
|
+
* restriction, including without limitation the rights to use,
|
16
|
+
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
17
|
+
* copies of the Software, and to permit persons to whom the
|
18
|
+
* Software is furnished to do so, subject to the following
|
19
|
+
* conditions:
|
20
|
+
*
|
21
|
+
* The above copyright notice and this permission notice shall be
|
22
|
+
* included in all copies or substantial portions of the Software.
|
23
|
+
*
|
24
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
25
|
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
26
|
+
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
27
|
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
28
|
+
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
29
|
+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
30
|
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
31
|
+
* OTHER DEALINGS IN THE SOFTWARE.
|
32
|
+
*/
|
33
|
+
|
34
|
+
/* jshint laxbreak: true */
|
35
|
+
/* global define, jQuery, Zepto */
|
36
|
+
|
37
|
+
'use strict';
|
38
|
+
|
39
|
+
// UMD (Universal Module Definition) patterns for JavaScript modules that work everywhere.
|
40
|
+
// https://github.com/umdjs/umd/blob/master/jqueryPluginCommonjs.js
|
41
|
+
(function (factory) {
|
42
|
+
|
43
|
+
if (typeof define === 'function' && define.amd) {
|
44
|
+
define(['jquery'], factory);
|
45
|
+
} else if (typeof exports === 'object') {
|
46
|
+
module.exports = factory(require('jquery'));
|
47
|
+
} else {
|
48
|
+
factory(jQuery || Zepto);
|
49
|
+
}
|
50
|
+
|
51
|
+
}(function ($) {
|
52
|
+
|
53
|
+
var Mask = function (el, mask, options) {
|
54
|
+
el = $(el);
|
55
|
+
|
56
|
+
var jMask = this, oldValue = el.val(), regexMask;
|
57
|
+
|
58
|
+
mask = typeof mask === 'function' ? mask(el.val(), undefined, el, options) : mask;
|
59
|
+
|
60
|
+
var p = {
|
61
|
+
invalid: [],
|
62
|
+
getCaret: function () {
|
63
|
+
try {
|
64
|
+
var sel,
|
65
|
+
pos = 0,
|
66
|
+
ctrl = el.get(0),
|
67
|
+
dSel = document.selection,
|
68
|
+
cSelStart = ctrl.selectionStart;
|
69
|
+
|
70
|
+
// IE Support
|
71
|
+
if (dSel && navigator.appVersion.indexOf('MSIE 10') === -1) {
|
72
|
+
sel = dSel.createRange();
|
73
|
+
sel.moveStart('character', el.is('input') ? -el.val().length : -el.text().length);
|
74
|
+
pos = sel.text.length;
|
75
|
+
}
|
76
|
+
// Firefox support
|
77
|
+
else if (cSelStart || cSelStart === '0') {
|
78
|
+
pos = cSelStart;
|
79
|
+
}
|
80
|
+
|
81
|
+
return pos;
|
82
|
+
} catch (e) {}
|
83
|
+
},
|
84
|
+
setCaret: function(pos) {
|
85
|
+
try {
|
86
|
+
if (el.is(':focus')) {
|
87
|
+
var range, ctrl = el.get(0);
|
88
|
+
|
89
|
+
if (ctrl.setSelectionRange) {
|
90
|
+
ctrl.setSelectionRange(pos,pos);
|
91
|
+
} else if (ctrl.createTextRange) {
|
92
|
+
range = ctrl.createTextRange();
|
93
|
+
range.collapse(true);
|
94
|
+
range.moveEnd('character', pos);
|
95
|
+
range.moveStart('character', pos);
|
96
|
+
range.select();
|
97
|
+
}
|
98
|
+
}
|
99
|
+
} catch (e) {}
|
100
|
+
},
|
101
|
+
events: function() {
|
102
|
+
el
|
103
|
+
.on('input.mask keyup.mask', p.behaviour)
|
104
|
+
.on('paste.mask drop.mask', function() {
|
105
|
+
setTimeout(function() {
|
106
|
+
el.keydown().keyup();
|
107
|
+
}, 100);
|
108
|
+
})
|
109
|
+
.on('change.mask', function(){
|
110
|
+
el.data('changed', true);
|
111
|
+
})
|
112
|
+
.on('blur.mask', function(){
|
113
|
+
if (oldValue !== el.val() && !el.data('changed')) {
|
114
|
+
el.triggerHandler('change');
|
115
|
+
}
|
116
|
+
el.data('changed', false);
|
117
|
+
})
|
118
|
+
// it's very important that this callback remains in this position
|
119
|
+
// otherwhise oldValue it's going to work buggy
|
120
|
+
.on('blur.mask', function() {
|
121
|
+
oldValue = el.val();
|
122
|
+
})
|
123
|
+
// select all text on focus
|
124
|
+
.on('focus.mask', function (e) {
|
125
|
+
if (options.selectOnFocus === true) {
|
126
|
+
$(e.target).select();
|
127
|
+
}
|
128
|
+
})
|
129
|
+
// clear the value if it not complete the mask
|
130
|
+
.on('focusout.mask', function() {
|
131
|
+
if (options.clearIfNotMatch && !regexMask.test(p.val())) {
|
132
|
+
p.val('');
|
133
|
+
}
|
134
|
+
});
|
135
|
+
},
|
136
|
+
getRegexMask: function() {
|
137
|
+
var maskChunks = [], translation, pattern, optional, recursive, oRecursive, r;
|
138
|
+
|
139
|
+
for (var i = 0; i < mask.length; i++) {
|
140
|
+
translation = jMask.translation[mask.charAt(i)];
|
141
|
+
|
142
|
+
if (translation) {
|
143
|
+
|
144
|
+
pattern = translation.pattern.toString().replace(/.{1}$|^.{1}/g, '');
|
145
|
+
optional = translation.optional;
|
146
|
+
recursive = translation.recursive;
|
147
|
+
|
148
|
+
if (recursive) {
|
149
|
+
maskChunks.push(mask.charAt(i));
|
150
|
+
oRecursive = {digit: mask.charAt(i), pattern: pattern};
|
151
|
+
} else {
|
152
|
+
maskChunks.push(!optional && !recursive ? pattern : (pattern + '?'));
|
153
|
+
}
|
154
|
+
|
155
|
+
} else {
|
156
|
+
maskChunks.push(mask.charAt(i).replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'));
|
157
|
+
}
|
158
|
+
}
|
159
|
+
|
160
|
+
r = maskChunks.join('');
|
161
|
+
|
162
|
+
if (oRecursive) {
|
163
|
+
r = r.replace(new RegExp('(' + oRecursive.digit + '(.*' + oRecursive.digit + ')?)'), '($1)?')
|
164
|
+
.replace(new RegExp(oRecursive.digit, 'g'), oRecursive.pattern);
|
165
|
+
}
|
166
|
+
|
167
|
+
return new RegExp(r);
|
168
|
+
},
|
169
|
+
destroyEvents: function() {
|
170
|
+
el.off(['input', 'keydown', 'keyup', 'paste', 'drop', 'blur', 'focusout', ''].join('.mask '));
|
171
|
+
},
|
172
|
+
val: function(v) {
|
173
|
+
var isInput = el.is('input'),
|
174
|
+
method = isInput ? 'val' : 'text',
|
175
|
+
r;
|
176
|
+
|
177
|
+
if (arguments.length > 0) {
|
178
|
+
if (el[method]() !== v) {
|
179
|
+
el[method](v);
|
180
|
+
}
|
181
|
+
r = el;
|
182
|
+
} else {
|
183
|
+
r = el[method]();
|
184
|
+
}
|
185
|
+
|
186
|
+
return r;
|
187
|
+
},
|
188
|
+
getMCharsBeforeCount: function(index, onCleanVal) {
|
189
|
+
for (var count = 0, i = 0, maskL = mask.length; i < maskL && i < index; i++) {
|
190
|
+
if (!jMask.translation[mask.charAt(i)]) {
|
191
|
+
index = onCleanVal ? index + 1 : index;
|
192
|
+
count++;
|
193
|
+
}
|
194
|
+
}
|
195
|
+
return count;
|
196
|
+
},
|
197
|
+
caretPos: function (originalCaretPos, oldLength, newLength, maskDif) {
|
198
|
+
var translation = jMask.translation[mask.charAt(Math.min(originalCaretPos - 1, mask.length - 1))];
|
199
|
+
|
200
|
+
return !translation ? p.caretPos(originalCaretPos + 1, oldLength, newLength, maskDif)
|
201
|
+
: Math.min(originalCaretPos + newLength - oldLength - maskDif, newLength);
|
202
|
+
},
|
203
|
+
behaviour: function(e) {
|
204
|
+
e = e || window.event;
|
205
|
+
p.invalid = [];
|
206
|
+
var keyCode = e.keyCode || e.which;
|
207
|
+
if ($.inArray(keyCode, jMask.byPassKeys) === -1) {
|
208
|
+
|
209
|
+
var caretPos = p.getCaret(),
|
210
|
+
currVal = p.val(),
|
211
|
+
currValL = currVal.length,
|
212
|
+
changeCaret = caretPos < currValL,
|
213
|
+
newVal = p.getMasked(),
|
214
|
+
newValL = newVal.length,
|
215
|
+
maskDif = p.getMCharsBeforeCount(newValL - 1) - p.getMCharsBeforeCount(currValL - 1);
|
216
|
+
|
217
|
+
p.val(newVal);
|
218
|
+
|
219
|
+
// change caret but avoid CTRL+A
|
220
|
+
if (changeCaret && !(keyCode === 65 && e.ctrlKey)) {
|
221
|
+
// Avoid adjusting caret on backspace or delete
|
222
|
+
if (!(keyCode === 8 || keyCode === 46)) {
|
223
|
+
caretPos = p.caretPos(caretPos, currValL, newValL, maskDif);
|
224
|
+
}
|
225
|
+
p.setCaret(caretPos);
|
226
|
+
}
|
227
|
+
|
228
|
+
return p.callbacks(e);
|
229
|
+
}
|
230
|
+
},
|
231
|
+
getMasked: function(skipMaskChars) {
|
232
|
+
var buf = [],
|
233
|
+
value = p.val(),
|
234
|
+
m = 0, maskLen = mask.length,
|
235
|
+
v = 0, valLen = value.length,
|
236
|
+
offset = 1, addMethod = 'push',
|
237
|
+
resetPos = -1,
|
238
|
+
lastMaskChar,
|
239
|
+
check;
|
240
|
+
|
241
|
+
if (options.reverse) {
|
242
|
+
addMethod = 'unshift';
|
243
|
+
offset = -1;
|
244
|
+
lastMaskChar = 0;
|
245
|
+
m = maskLen - 1;
|
246
|
+
v = valLen - 1;
|
247
|
+
check = function () {
|
248
|
+
return m > -1 && v > -1;
|
249
|
+
};
|
250
|
+
} else {
|
251
|
+
lastMaskChar = maskLen - 1;
|
252
|
+
check = function () {
|
253
|
+
return m < maskLen && v < valLen;
|
254
|
+
};
|
255
|
+
}
|
256
|
+
|
257
|
+
while (check()) {
|
258
|
+
var maskDigit = mask.charAt(m),
|
259
|
+
valDigit = value.charAt(v),
|
260
|
+
translation = jMask.translation[maskDigit];
|
261
|
+
|
262
|
+
if (translation) {
|
263
|
+
if (valDigit.match(translation.pattern)) {
|
264
|
+
buf[addMethod](valDigit);
|
265
|
+
if (translation.recursive) {
|
266
|
+
if (resetPos === -1) {
|
267
|
+
resetPos = m;
|
268
|
+
} else if (m === lastMaskChar) {
|
269
|
+
m = resetPos - offset;
|
270
|
+
}
|
271
|
+
|
272
|
+
if (lastMaskChar === resetPos) {
|
273
|
+
m -= offset;
|
274
|
+
}
|
275
|
+
}
|
276
|
+
m += offset;
|
277
|
+
} else if (translation.optional) {
|
278
|
+
m += offset;
|
279
|
+
v -= offset;
|
280
|
+
} else if (translation.fallback) {
|
281
|
+
buf[addMethod](translation.fallback);
|
282
|
+
m += offset;
|
283
|
+
v -= offset;
|
284
|
+
} else {
|
285
|
+
p.invalid.push({p: v, v: valDigit, e: translation.pattern});
|
286
|
+
}
|
287
|
+
v += offset;
|
288
|
+
} else {
|
289
|
+
if (!skipMaskChars) {
|
290
|
+
buf[addMethod](maskDigit);
|
291
|
+
}
|
292
|
+
|
293
|
+
if (valDigit === maskDigit) {
|
294
|
+
v += offset;
|
295
|
+
}
|
296
|
+
|
297
|
+
m += offset;
|
298
|
+
}
|
299
|
+
}
|
300
|
+
|
301
|
+
var lastMaskCharDigit = mask.charAt(lastMaskChar);
|
302
|
+
if (maskLen === valLen + 1 && !jMask.translation[lastMaskCharDigit]) {
|
303
|
+
buf.push(lastMaskCharDigit);
|
304
|
+
}
|
305
|
+
|
306
|
+
return buf.join('');
|
307
|
+
},
|
308
|
+
callbacks: function (e) {
|
309
|
+
var val = p.val(),
|
310
|
+
changed = val !== oldValue,
|
311
|
+
defaultArgs = [val, e, el, options],
|
312
|
+
callback = function(name, criteria, args) {
|
313
|
+
if (typeof options[name] === 'function' && criteria) {
|
314
|
+
options[name].apply(this, args);
|
315
|
+
}
|
316
|
+
};
|
317
|
+
|
318
|
+
callback('onChange', changed === true, defaultArgs);
|
319
|
+
callback('onKeyPress', changed === true, defaultArgs);
|
320
|
+
callback('onComplete', val.length === mask.length, defaultArgs);
|
321
|
+
callback('onInvalid', p.invalid.length > 0, [val, e, el, p.invalid, options]);
|
322
|
+
}
|
323
|
+
};
|
324
|
+
|
325
|
+
|
326
|
+
// public methods
|
327
|
+
jMask.mask = mask;
|
328
|
+
jMask.options = options;
|
329
|
+
jMask.remove = function() {
|
330
|
+
var caret = p.getCaret();
|
331
|
+
p.destroyEvents();
|
332
|
+
p.val(jMask.getCleanVal());
|
333
|
+
p.setCaret(caret - p.getMCharsBeforeCount(caret));
|
334
|
+
return el;
|
335
|
+
};
|
336
|
+
|
337
|
+
// get value without mask
|
338
|
+
jMask.getCleanVal = function() {
|
339
|
+
return p.getMasked(true);
|
340
|
+
};
|
341
|
+
|
342
|
+
jMask.init = function(onlyMask) {
|
343
|
+
onlyMask = onlyMask || false;
|
344
|
+
options = options || {};
|
345
|
+
|
346
|
+
jMask.byPassKeys = $.jMaskGlobals.byPassKeys;
|
347
|
+
jMask.translation = $.jMaskGlobals.translation;
|
348
|
+
|
349
|
+
jMask.translation = $.extend({}, jMask.translation, options.translation);
|
350
|
+
jMask = $.extend(true, {}, jMask, options);
|
351
|
+
|
352
|
+
regexMask = p.getRegexMask();
|
353
|
+
|
354
|
+
if (onlyMask === false) {
|
355
|
+
|
356
|
+
if (options.placeholder) {
|
357
|
+
el.attr('placeholder' , options.placeholder);
|
358
|
+
}
|
359
|
+
|
360
|
+
// this is necessary, otherwise if the user submit the form
|
361
|
+
// and then press the "back" button, the autocomplete will erase
|
362
|
+
// the data. Works fine on IE9+, FF, Opera, Safari.
|
363
|
+
if ($('input').length && 'oninput' in $('input')[0] === false && el.attr('autocomplete') === 'on') {
|
364
|
+
el.attr('autocomplete', 'off');
|
365
|
+
}
|
366
|
+
|
367
|
+
p.destroyEvents();
|
368
|
+
p.events();
|
369
|
+
|
370
|
+
var caret = p.getCaret();
|
371
|
+
p.val(p.getMasked());
|
372
|
+
p.setCaret(caret + p.getMCharsBeforeCount(caret, true));
|
373
|
+
|
374
|
+
} else {
|
375
|
+
p.events();
|
376
|
+
p.val(p.getMasked());
|
377
|
+
}
|
378
|
+
};
|
379
|
+
|
380
|
+
jMask.init(!el.is('input'));
|
381
|
+
};
|
382
|
+
|
383
|
+
$.maskWatchers = {};
|
384
|
+
var HTMLAttributes = function () {
|
385
|
+
var input = $(this),
|
386
|
+
options = {},
|
387
|
+
prefix = 'data-mask-',
|
388
|
+
mask = input.attr('data-mask');
|
389
|
+
|
390
|
+
if (input.attr(prefix + 'reverse')) {
|
391
|
+
options.reverse = true;
|
392
|
+
}
|
393
|
+
|
394
|
+
if (input.attr(prefix + 'clearifnotmatch')) {
|
395
|
+
options.clearIfNotMatch = true;
|
396
|
+
}
|
397
|
+
|
398
|
+
if (input.attr(prefix + 'selectonfocus') === 'true') {
|
399
|
+
options.selectOnFocus = true;
|
400
|
+
}
|
401
|
+
|
402
|
+
if (notSameMaskObject(input, mask, options)) {
|
403
|
+
return input.data('mask', new Mask(this, mask, options));
|
404
|
+
}
|
405
|
+
},
|
406
|
+
notSameMaskObject = function(field, mask, options) {
|
407
|
+
options = options || {};
|
408
|
+
var maskObject = $(field).data('mask'),
|
409
|
+
stringify = JSON.stringify,
|
410
|
+
value = $(field).val() || $(field).text();
|
411
|
+
try {
|
412
|
+
if (typeof mask === 'function') {
|
413
|
+
mask = mask(value);
|
414
|
+
}
|
415
|
+
return typeof maskObject !== 'object' || stringify(maskObject.options) !== stringify(options) || maskObject.mask !== mask;
|
416
|
+
} catch (e) {}
|
417
|
+
};
|
418
|
+
|
419
|
+
|
420
|
+
$.fn.mask = function(mask, options) {
|
421
|
+
options = options || {};
|
422
|
+
var selector = this.selector,
|
423
|
+
globals = $.jMaskGlobals,
|
424
|
+
interval = $.jMaskGlobals.watchInterval,
|
425
|
+
maskFunction = function() {
|
426
|
+
if (notSameMaskObject(this, mask, options)) {
|
427
|
+
return $(this).data('mask', new Mask(this, mask, options));
|
428
|
+
}
|
429
|
+
};
|
430
|
+
|
431
|
+
$(this).each(maskFunction);
|
432
|
+
|
433
|
+
if (selector && selector !== '' && globals.watchInputs) {
|
434
|
+
clearInterval($.maskWatchers[selector]);
|
435
|
+
$.maskWatchers[selector] = setInterval(function(){
|
436
|
+
$(document).find(selector).each(maskFunction);
|
437
|
+
}, interval);
|
438
|
+
}
|
439
|
+
return this;
|
440
|
+
};
|
441
|
+
|
442
|
+
$.fn.unmask = function() {
|
443
|
+
clearInterval($.maskWatchers[this.selector]);
|
444
|
+
delete $.maskWatchers[this.selector];
|
445
|
+
return this.each(function() {
|
446
|
+
var dataMask = $(this).data('mask');
|
447
|
+
if (dataMask) {
|
448
|
+
dataMask.remove().removeData('mask');
|
449
|
+
}
|
450
|
+
});
|
451
|
+
};
|
452
|
+
|
453
|
+
$.fn.cleanVal = function() {
|
454
|
+
return this.data('mask').getCleanVal();
|
455
|
+
};
|
456
|
+
|
457
|
+
$.applyDataMask = function(selector) {
|
458
|
+
selector = selector || $.jMaskGlobals.maskElements;
|
459
|
+
var $selector = (selector instanceof $) ? selector : $(selector);
|
460
|
+
$selector.filter($.jMaskGlobals.dataMaskAttr).each(HTMLAttributes);
|
461
|
+
};
|
462
|
+
|
463
|
+
var globals = {
|
464
|
+
maskElements: 'input,td,span,div',
|
465
|
+
dataMaskAttr: '*[data-mask]',
|
466
|
+
dataMask: true,
|
467
|
+
watchInterval: 300,
|
468
|
+
watchInputs: true,
|
469
|
+
watchDataMask: false,
|
470
|
+
byPassKeys: [9, 16, 17, 18, 36, 37, 38, 39, 40, 91],
|
471
|
+
translation: {
|
472
|
+
'0': {pattern: /\d/},
|
473
|
+
'9': {pattern: /\d/, optional: true},
|
474
|
+
'#': {pattern: /\d/, recursive: true},
|
475
|
+
'A': {pattern: /[a-zA-Z0-9]/},
|
476
|
+
'S': {pattern: /[a-zA-Z]/}
|
477
|
+
}
|
478
|
+
};
|
479
|
+
|
480
|
+
$.jMaskGlobals = $.jMaskGlobals || {};
|
481
|
+
globals = $.jMaskGlobals = $.extend(true, {}, globals, $.jMaskGlobals);
|
482
|
+
|
483
|
+
// looking for inputs with data-mask attribute
|
484
|
+
if (globals.dataMask) { $.applyDataMask(); }
|
485
|
+
|
486
|
+
setInterval(function(){
|
487
|
+
if ($.jMaskGlobals.watchDataMask) { $.applyDataMask(); }
|
488
|
+
}, globals.watchInterval);
|
489
|
+
}));
|
@@ -0,0 +1,4 @@
|
|
1
|
+
/* Modernizr 2.7.1 (Custom Build) | MIT & BSD
|
2
|
+
* Build: http://modernizr.com/download/#-svg-touch-shiv-cssclasses-teststyles-prefixes
|
3
|
+
*/
|
4
|
+
;window.Modernizr=function(a,b,c){function x(a){j.cssText=a}function y(a,b){return x(m.join(a+";")+(b||""))}function z(a,b){return typeof a===b}function A(a,b){return!!~(""+a).indexOf(b)}function B(a,b,d){for(var e in a){var f=b[a[e]];if(f!==c)return d===!1?a[e]:z(f,"function")?f.bind(d||b):f}return!1}var d="2.7.1",e={},f=!0,g=b.documentElement,h="modernizr",i=b.createElement(h),j=i.style,k,l={}.toString,m=" -webkit- -moz- -o- -ms- ".split(" "),n={svg:"http://www.w3.org/2000/svg"},o={},p={},q={},r=[],s=r.slice,t,u=function(a,c,d,e){var f,i,j,k,l=b.createElement("div"),m=b.body,n=m||b.createElement("body");if(parseInt(d,10))while(d--)j=b.createElement("div"),j.id=e?e[d]:h+(d+1),l.appendChild(j);return f=["­",'<style id="s',h,'">',a,"</style>"].join(""),l.id=h,(m?l:n).innerHTML+=f,n.appendChild(l),m||(n.style.background="",n.style.overflow="hidden",k=g.style.overflow,g.style.overflow="hidden",g.appendChild(n)),i=c(l,a),m?l.parentNode.removeChild(l):(n.parentNode.removeChild(n),g.style.overflow=k),!!i},v={}.hasOwnProperty,w;!z(v,"undefined")&&!z(v.call,"undefined")?w=function(a,b){return v.call(a,b)}:w=function(a,b){return b in a&&z(a.constructor.prototype[b],"undefined")},Function.prototype.bind||(Function.prototype.bind=function(b){var c=this;if(typeof c!="function")throw new TypeError;var d=s.call(arguments,1),e=function(){if(this instanceof e){var a=function(){};a.prototype=c.prototype;var f=new a,g=c.apply(f,d.concat(s.call(arguments)));return Object(g)===g?g:f}return c.apply(b,d.concat(s.call(arguments)))};return e}),o.touch=function(){var c;return"ontouchstart"in a||a.DocumentTouch&&b instanceof DocumentTouch?c=!0:u(["@media (",m.join("touch-enabled),("),h,")","{#modernizr{top:9px;position:absolute}}"].join(""),function(a){c=a.offsetTop===9}),c},o.svg=function(){return!!b.createElementNS&&!!b.createElementNS(n.svg,"svg").createSVGRect};for(var C in o)w(o,C)&&(t=C.toLowerCase(),e[t]=o[C](),r.push((e[t]?"":"no-")+t));return e.addTest=function(a,b){if(typeof a=="object")for(var d in a)w(a,d)&&e.addTest(d,a[d]);else{a=a.toLowerCase();if(e[a]!==c)return e;b=typeof b=="function"?b():b,typeof f!="undefined"&&f&&(g.className+=" "+(b?"":"no-")+a),e[a]=b}return e},x(""),i=k=null,function(a,b){function l(a,b){var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;return c.innerHTML="x<style>"+b+"</style>",d.insertBefore(c.lastChild,d.firstChild)}function m(){var a=s.elements;return typeof a=="string"?a.split(" "):a}function n(a){var b=j[a[h]];return b||(b={},i++,a[h]=i,j[i]=b),b}function o(a,c,d){c||(c=b);if(k)return c.createElement(a);d||(d=n(c));var g;return d.cache[a]?g=d.cache[a].cloneNode():f.test(a)?g=(d.cache[a]=d.createElem(a)).cloneNode():g=d.createElem(a),g.canHaveChildren&&!e.test(a)&&!g.tagUrn?d.frag.appendChild(g):g}function p(a,c){a||(a=b);if(k)return a.createDocumentFragment();c=c||n(a);var d=c.frag.cloneNode(),e=0,f=m(),g=f.length;for(;e<g;e++)d.createElement(f[e]);return d}function q(a,b){b.cache||(b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag()),a.createElement=function(c){return s.shivMethods?o(c,a,b):b.createElem(c)},a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+m().join().replace(/[\w\-]+/g,function(a){return b.createElem(a),b.frag.createElement(a),'c("'+a+'")'})+");return n}")(s,b.frag)}function r(a){a||(a=b);var c=n(a);return s.shivCSS&&!g&&!c.hasCSS&&(c.hasCSS=!!l(a,"article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}mark{background:#FF0;color:#000}template{display:none}")),k||q(a,c),a}var c="3.7.0",d=a.html5||{},e=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,f=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,g,h="_html5shiv",i=0,j={},k;(function(){try{var a=b.createElement("a");a.innerHTML="<xyz></xyz>",g="hidden"in a,k=a.childNodes.length==1||function(){b.createElement("a");var a=b.createDocumentFragment();return typeof a.cloneNode=="undefined"||typeof a.createDocumentFragment=="undefined"||typeof a.createElement=="undefined"}()}catch(c){g=!0,k=!0}})();var s={elements:d.elements||"abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output progress section summary template time video",version:c,shivCSS:d.shivCSS!==!1,supportsUnknownElements:k,shivMethods:d.shivMethods!==!1,type:"default",shivDocument:r,createElement:o,createDocumentFragment:p};a.html5=s,r(b)}(this,b),e._version=d,e._prefixes=m,e.testStyles=u,g.className=g.className.replace(/(^|\s)no-js(\s|$)/,"$1$2")+(f?" js "+r.join(" "):""),e}(this,this.document);
|