my_assets 0.0.5 → 0.0.6
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 +4 -4
- data/lib/my_assets/version.rb +1 -1
- data/vendor/assets/javascripts/index.js +28 -0
- data/vendor/assets/javascripts/jquery.mask.js +522 -0
- data/vendor/assets/javascripts/jquery.mask.min.js +12 -0
- data/vendor/assets/javascripts/my_assets.js +19 -0
- data/vendor/assets/stylesheets/my_assets.scss +4 -0
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5fce445e07bfe0bee5b1907b6094b4cc9e3a372c4cbda67f1baa14ef4f90de73
|
4
|
+
data.tar.gz: bdeea8314d27f7c24eadbff757ceae56a915a7866ca71106a33f092bccb76d84
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1bba81c5d14272682551f81852b4e27e75c727d21489ce9dc9b29bd88857d4f31ca15972a7290cec0a3e158860e7e5b2438e0c7f0cd187e52eb1e5358bea15e1
|
7
|
+
data.tar.gz: e52b584eed15141f35245df65baa2f922ac4a26276254af338e8d0d1f05659fb12bd2ea715e75a5ca9d02267e0f017b8c4bd87ff1d7941f5f33fc9aba1f97891
|
data/lib/my_assets/version.rb
CHANGED
@@ -0,0 +1,28 @@
|
|
1
|
+
$(document).ready( function () {
|
2
|
+
$('#index').DataTable({
|
3
|
+
"language": {
|
4
|
+
"responsive": true,
|
5
|
+
"sEmptyTable": "Nenhum registro encontrado",
|
6
|
+
"sInfo": "Mostrando de _START_ até _END_ de _TOTAL_ registros",
|
7
|
+
"sInfoEmpty": "Mostrando 0 até 0 de 0 registros",
|
8
|
+
"sInfoFiltered": "(Filtrados de _MAX_ registros)",
|
9
|
+
"sInfoPostFix": "",
|
10
|
+
"sInfoThousands": ".",
|
11
|
+
"sLengthMenu": "_MENU_ resultados por página",
|
12
|
+
"sLoadingRecords": "Carregando...",
|
13
|
+
"sProcessing": "Processando...",
|
14
|
+
"sZeroRecords": "Nenhum registro encontrado",
|
15
|
+
"sSearch": "Pesquisar",
|
16
|
+
"oPaginate": {
|
17
|
+
"sNext": "Próximo",
|
18
|
+
"sPrevious": "Anterior",
|
19
|
+
"sFirst": "Primeiro",
|
20
|
+
"sLast": "Último"
|
21
|
+
},
|
22
|
+
"oAria": {
|
23
|
+
"sSortAscending": ": Ordenar colunas de forma ascendente",
|
24
|
+
"sSortDescending": ": Ordenar colunas de forma descendente"
|
25
|
+
}
|
26
|
+
}
|
27
|
+
});
|
28
|
+
} );
|
@@ -0,0 +1,522 @@
|
|
1
|
+
/**
|
2
|
+
* jquery.mask.js
|
3
|
+
* @version: v1.14.0
|
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
|
+
|
55
|
+
var p = {
|
56
|
+
invalid: [],
|
57
|
+
getCaret: function () {
|
58
|
+
try {
|
59
|
+
var sel,
|
60
|
+
pos = 0,
|
61
|
+
ctrl = el.get(0),
|
62
|
+
dSel = document.selection,
|
63
|
+
cSelStart = ctrl.selectionStart;
|
64
|
+
|
65
|
+
// IE Support
|
66
|
+
if (dSel && navigator.appVersion.indexOf('MSIE 10') === -1) {
|
67
|
+
sel = dSel.createRange();
|
68
|
+
sel.moveStart('character', -p.val().length);
|
69
|
+
pos = sel.text.length;
|
70
|
+
}
|
71
|
+
// Firefox support
|
72
|
+
else if (cSelStart || cSelStart === '0') {
|
73
|
+
pos = cSelStart;
|
74
|
+
}
|
75
|
+
|
76
|
+
return pos;
|
77
|
+
} catch (e) {}
|
78
|
+
},
|
79
|
+
setCaret: function(pos) {
|
80
|
+
try {
|
81
|
+
if (el.is(':focus')) {
|
82
|
+
var range, ctrl = el.get(0);
|
83
|
+
|
84
|
+
// Firefox, WebKit, etc..
|
85
|
+
if (ctrl.setSelectionRange) {
|
86
|
+
ctrl.focus();
|
87
|
+
ctrl.setSelectionRange(pos, pos);
|
88
|
+
} else { // IE
|
89
|
+
range = ctrl.createTextRange();
|
90
|
+
range.collapse(true);
|
91
|
+
range.moveEnd('character', pos);
|
92
|
+
range.moveStart('character', pos);
|
93
|
+
range.select();
|
94
|
+
}
|
95
|
+
}
|
96
|
+
} catch (e) {}
|
97
|
+
},
|
98
|
+
events: function() {
|
99
|
+
el
|
100
|
+
.on('keydown.mask', function(e) {
|
101
|
+
el.data('mask-keycode', e.keyCode || e.which);
|
102
|
+
})
|
103
|
+
.on($.jMaskGlobals.useInput ? '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 !== p.val() && !el.data('changed')) {
|
114
|
+
el.trigger('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 = p.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
|
+
|
207
|
+
var keyCode = el.data('mask-keycode');
|
208
|
+
|
209
|
+
if ($.inArray(keyCode, jMask.byPassKeys) === -1) {
|
210
|
+
var caretPos = p.getCaret(),
|
211
|
+
currVal = p.val(),
|
212
|
+
currValL = currVal.length,
|
213
|
+
newVal = p.getMasked(),
|
214
|
+
newValL = newVal.length,
|
215
|
+
maskDif = p.getMCharsBeforeCount(newValL - 1) - p.getMCharsBeforeCount(currValL - 1),
|
216
|
+
changeCaret = caretPos < currValL;
|
217
|
+
|
218
|
+
p.val(newVal);
|
219
|
+
|
220
|
+
if (changeCaret) {
|
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, val) {
|
232
|
+
var buf = [],
|
233
|
+
value = val === undefined ? p.val() : 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
|
+
el = $(el);
|
326
|
+
var jMask = this, oldValue = p.val(), regexMask;
|
327
|
+
|
328
|
+
mask = typeof mask === 'function' ? mask(p.val(), undefined, el, options) : mask;
|
329
|
+
|
330
|
+
|
331
|
+
// public methods
|
332
|
+
jMask.mask = mask;
|
333
|
+
jMask.options = options;
|
334
|
+
jMask.remove = function() {
|
335
|
+
var caret = p.getCaret();
|
336
|
+
p.destroyEvents();
|
337
|
+
p.val(jMask.getCleanVal());
|
338
|
+
p.setCaret(caret - p.getMCharsBeforeCount(caret));
|
339
|
+
return el;
|
340
|
+
};
|
341
|
+
|
342
|
+
// get value without mask
|
343
|
+
jMask.getCleanVal = function() {
|
344
|
+
return p.getMasked(true);
|
345
|
+
};
|
346
|
+
|
347
|
+
// get masked value without the value being in the input or element
|
348
|
+
jMask.getMaskedVal = function(val) {
|
349
|
+
return p.getMasked(false, val);
|
350
|
+
};
|
351
|
+
|
352
|
+
jMask.init = function(onlyMask) {
|
353
|
+
onlyMask = onlyMask || false;
|
354
|
+
options = options || {};
|
355
|
+
|
356
|
+
jMask.clearIfNotMatch = $.jMaskGlobals.clearIfNotMatch;
|
357
|
+
jMask.byPassKeys = $.jMaskGlobals.byPassKeys;
|
358
|
+
jMask.translation = $.extend({}, $.jMaskGlobals.translation, options.translation);
|
359
|
+
|
360
|
+
jMask = $.extend(true, {}, jMask, options);
|
361
|
+
|
362
|
+
regexMask = p.getRegexMask();
|
363
|
+
|
364
|
+
if (onlyMask === false) {
|
365
|
+
|
366
|
+
if (options.placeholder) {
|
367
|
+
el.attr('placeholder' , options.placeholder);
|
368
|
+
}
|
369
|
+
|
370
|
+
// this is necessary, otherwise if the user submit the form
|
371
|
+
// and then press the "back" button, the autocomplete will erase
|
372
|
+
// the data. Works fine on IE9+, FF, Opera, Safari.
|
373
|
+
if (el.data('mask')) {
|
374
|
+
el.attr('autocomplete', 'off');
|
375
|
+
}
|
376
|
+
|
377
|
+
p.destroyEvents();
|
378
|
+
p.events();
|
379
|
+
|
380
|
+
var caret = p.getCaret();
|
381
|
+
p.val(p.getMasked());
|
382
|
+
p.setCaret(caret + p.getMCharsBeforeCount(caret, true));
|
383
|
+
|
384
|
+
} else {
|
385
|
+
p.events();
|
386
|
+
p.val(p.getMasked());
|
387
|
+
}
|
388
|
+
};
|
389
|
+
|
390
|
+
jMask.init(!el.is('input'));
|
391
|
+
};
|
392
|
+
|
393
|
+
$.maskWatchers = {};
|
394
|
+
var HTMLAttributes = function () {
|
395
|
+
var input = $(this),
|
396
|
+
options = {},
|
397
|
+
prefix = 'data-mask-',
|
398
|
+
mask = input.attr('data-mask');
|
399
|
+
|
400
|
+
if (input.attr(prefix + 'reverse')) {
|
401
|
+
options.reverse = true;
|
402
|
+
}
|
403
|
+
|
404
|
+
if (input.attr(prefix + 'clearifnotmatch')) {
|
405
|
+
options.clearIfNotMatch = true;
|
406
|
+
}
|
407
|
+
|
408
|
+
if (input.attr(prefix + 'selectonfocus') === 'true') {
|
409
|
+
options.selectOnFocus = true;
|
410
|
+
}
|
411
|
+
|
412
|
+
if (notSameMaskObject(input, mask, options)) {
|
413
|
+
return input.data('mask', new Mask(this, mask, options));
|
414
|
+
}
|
415
|
+
},
|
416
|
+
notSameMaskObject = function(field, mask, options) {
|
417
|
+
options = options || {};
|
418
|
+
var maskObject = $(field).data('mask'),
|
419
|
+
stringify = JSON.stringify,
|
420
|
+
value = $(field).val() || $(field).text();
|
421
|
+
try {
|
422
|
+
if (typeof mask === 'function') {
|
423
|
+
mask = mask(value);
|
424
|
+
}
|
425
|
+
return typeof maskObject !== 'object' || stringify(maskObject.options) !== stringify(options) || maskObject.mask !== mask;
|
426
|
+
} catch (e) {}
|
427
|
+
},
|
428
|
+
eventSupported = function(eventName) {
|
429
|
+
var el = document.createElement('div'), isSupported;
|
430
|
+
|
431
|
+
eventName = 'on' + eventName;
|
432
|
+
isSupported = (eventName in el);
|
433
|
+
|
434
|
+
if ( !isSupported ) {
|
435
|
+
el.setAttribute(eventName, 'return;');
|
436
|
+
isSupported = typeof el[eventName] === 'function';
|
437
|
+
}
|
438
|
+
el = null;
|
439
|
+
|
440
|
+
return isSupported;
|
441
|
+
};
|
442
|
+
|
443
|
+
$.fn.mask = function(mask, options) {
|
444
|
+
options = options || {};
|
445
|
+
var selector = this.selector,
|
446
|
+
globals = $.jMaskGlobals,
|
447
|
+
interval = globals.watchInterval,
|
448
|
+
watchInputs = options.watchInputs || globals.watchInputs,
|
449
|
+
maskFunction = function() {
|
450
|
+
if (notSameMaskObject(this, mask, options)) {
|
451
|
+
return $(this).data('mask', new Mask(this, mask, options));
|
452
|
+
}
|
453
|
+
};
|
454
|
+
|
455
|
+
$(this).each(maskFunction);
|
456
|
+
|
457
|
+
if (selector && selector !== '' && watchInputs) {
|
458
|
+
clearInterval($.maskWatchers[selector]);
|
459
|
+
$.maskWatchers[selector] = setInterval(function(){
|
460
|
+
$(document).find(selector).each(maskFunction);
|
461
|
+
}, interval);
|
462
|
+
}
|
463
|
+
return this;
|
464
|
+
};
|
465
|
+
|
466
|
+
$.fn.masked = function(val) {
|
467
|
+
return this.data('mask').getMaskedVal(val);
|
468
|
+
};
|
469
|
+
|
470
|
+
$.fn.unmask = function() {
|
471
|
+
clearInterval($.maskWatchers[this.selector]);
|
472
|
+
delete $.maskWatchers[this.selector];
|
473
|
+
return this.each(function() {
|
474
|
+
var dataMask = $(this).data('mask');
|
475
|
+
if (dataMask) {
|
476
|
+
dataMask.remove().removeData('mask');
|
477
|
+
}
|
478
|
+
});
|
479
|
+
};
|
480
|
+
|
481
|
+
$.fn.cleanVal = function() {
|
482
|
+
return this.data('mask').getCleanVal();
|
483
|
+
};
|
484
|
+
|
485
|
+
$.applyDataMask = function(selector) {
|
486
|
+
selector = selector || $.jMaskGlobals.maskElements;
|
487
|
+
var $selector = (selector instanceof $) ? selector : $(selector);
|
488
|
+
$selector.filter($.jMaskGlobals.dataMaskAttr).each(HTMLAttributes);
|
489
|
+
};
|
490
|
+
|
491
|
+
var globals = {
|
492
|
+
maskElements: 'input,td,span,div',
|
493
|
+
dataMaskAttr: '*[data-mask]',
|
494
|
+
dataMask: true,
|
495
|
+
watchInterval: 300,
|
496
|
+
watchInputs: true,
|
497
|
+
useInput: eventSupported('input'),
|
498
|
+
watchDataMask: false,
|
499
|
+
byPassKeys: [9, 16, 17, 18, 36, 37, 38, 39, 40, 91],
|
500
|
+
translation: {
|
501
|
+
'0': {pattern: /\d/},
|
502
|
+
'9': {pattern: /\d/, optional: true},
|
503
|
+
'#': {pattern: /\d/, recursive: true},
|
504
|
+
'A': {pattern: /[a-zA-Z0-9]/},
|
505
|
+
'S': {pattern: /[a-zA-Z]/}
|
506
|
+
}
|
507
|
+
};
|
508
|
+
|
509
|
+
$.jMaskGlobals = $.jMaskGlobals || {};
|
510
|
+
globals = $.jMaskGlobals = $.extend(true, {}, globals, $.jMaskGlobals);
|
511
|
+
|
512
|
+
// looking for inputs with data-mask attribute
|
513
|
+
if (globals.dataMask) {
|
514
|
+
$.applyDataMask();
|
515
|
+
}
|
516
|
+
|
517
|
+
setInterval(function() {
|
518
|
+
if ($.jMaskGlobals.watchDataMask) {
|
519
|
+
$.applyDataMask();
|
520
|
+
}
|
521
|
+
}, globals.watchInterval);
|
522
|
+
}));
|
@@ -0,0 +1,12 @@
|
|
1
|
+
// jQuery Mask Plugin v1.7.7
|
2
|
+
// github.com/igorescobar/jQuery-Mask-Plugin
|
3
|
+
(function(f){"function"===typeof define&&define.amd?define(["jquery"],f):f(window.jQuery||window.Zepto)})(function(f){var A=function(a,d,b){var h=this,m,p;a=f(a);d="function"===typeof d?d(a.val(),void 0,a,b):d;var c={getCaret:function(){try{var e,l=0,c=a.get(0),g=document.selection,d=c.selectionStart;if(g&&!~navigator.appVersion.indexOf("MSIE 10"))e=g.createRange(),e.moveStart("character",a.is("input")?-a.val().length:-a.text().length),l=e.text.length;else if(d||"0"===d)l=d;return l}catch(b){}},setCaret:function(e){try{if(a.is(":focus")){var l,
|
4
|
+
c=a.get(0);c.setSelectionRange?c.setSelectionRange(e,e):c.createTextRange&&(l=c.createTextRange(),l.collapse(!0),l.moveEnd("character",e),l.moveStart("character",e),l.select())}}catch(g){}},events:function(){a.on("keydown.mask",function(){m=c.val()}).on("keyup.mask",c.behaviour).on("paste.mask drop.mask",function(){setTimeout(function(){a.keydown().keyup()},100)}).on("change.mask",function(){a.data("changed",!0)}).on("blur.mask",function(){m===a.val()||a.data("changed")||a.trigger("change");a.data("changed",
|
5
|
+
!1)}).on("focusout.mask",function(){b.clearIfNotMatch&&!p.test(c.val())&&c.val("")})},getRegexMask:function(){for(var e=[],a,c,g,b,k=0;k<d.length;k++)(a=h.translation[d[k]])?(c=a.pattern.toString().replace(/.{1}$|^.{1}/g,""),g=a.optional,(a=a.recursive)?(e.push(d[k]),b={digit:d[k],pattern:c}):e.push(g||a?c+"?":c)):e.push(d[k].replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"));e=e.join("");b&&(e=e.replace(new RegExp("("+b.digit+"(.*"+b.digit+")?)"),"($1)?").replace(new RegExp(b.digit,"g"),b.pattern));return new RegExp(e)},
|
6
|
+
destroyEvents:function(){a.off("keydown keyup paste drop change blur focusout DOMNodeInserted ".split(" ").join(".mask ")).removeData("changeCalled")},val:function(e){var c=a.is("input");return 0<arguments.length?c?a.val(e):a.text(e):c?a.val():a.text()},getMCharsBeforeCount:function(e,a){for(var c=0,b=0,f=d.length;b<f&&b<e;b++)h.translation[d.charAt(b)]||(e=a?e+1:e,c++);return c},caretPos:function(e,a,b,g){return h.translation[d.charAt(Math.min(e-1,d.length-1))]?Math.min(e+b-a-g,b):c.caretPos(e+1,
|
7
|
+
a,b,g)},behaviour:function(a){a=a||window.event;var b=a.keyCode||a.which;if(-1===f.inArray(b,h.byPassKeys)){var d=c.getCaret(),g=c.val(),t=g.length,k=d<t,m=c.getMasked(),n=m.length,p=c.getMCharsBeforeCount(n-1)-c.getMCharsBeforeCount(t-1);m!==g&&c.val(m);!k||65===b&&a.ctrlKey||(8!==b&&46!==b&&(d=c.caretPos(d,t,n,p)),c.setCaret(d));return c.callbacks(a)}},getMasked:function(a){var l=[],f=c.val(),g=0,m=d.length,k=0,p=f.length,n=1,u="push",r=-1,q,v;b.reverse?(u="unshift",n=-1,q=0,g=m-1,k=p-1,v=function(){return-1<
|
8
|
+
g&&-1<k}):(q=m-1,v=function(){return g<m&&k<p});for(;v();){var w=d.charAt(g),x=f.charAt(k),s=h.translation[w];if(s)x.match(s.pattern)?(l[u](x),s.recursive&&(-1===r?r=g:g===q&&(g=r-n),q===r&&(g-=n)),g+=n):s.optional&&(g+=n,k-=n),k+=n;else{if(!a)l[u](w);x===w&&(k+=n);g+=n}}a=d.charAt(q);m!==p+1||h.translation[a]||l.push(a);return l.join("")},callbacks:function(e){var f=c.val(),h=f!==m;if(!0===h&&"function"===typeof b.onChange)b.onChange(f,e,a,b);if(!0===h&&"function"===typeof b.onKeyPress)b.onKeyPress(f,
|
9
|
+
e,a,b);if("function"===typeof b.onComplete&&f.length===d.length)b.onComplete(f,e,a,b)}};h.mask=d;h.options=b;h.remove=function(){var b;c.destroyEvents();c.val(h.getCleanVal()).removeAttr("maxlength");b=c.getCaret();c.setCaret(b-c.getMCharsBeforeCount(b));return a};h.getCleanVal=function(){return c.getMasked(!0)};h.init=function(){b=b||{};h.byPassKeys=[9,16,17,18,36,37,38,39,40,91];h.translation={0:{pattern:/\d/},9:{pattern:/\d/,optional:!0},"#":{pattern:/\d/,recursive:!0},A:{pattern:/[a-zA-Z0-9]/},
|
10
|
+
S:{pattern:/[a-zA-Z]/}};h.translation=f.extend({},h.translation,b.translation);h=f.extend(!0,{},h,b);p=c.getRegexMask();!1!==b.maxlength&&a.attr("maxlength",d.length);b.placeholder&&a.attr("placeholder",b.placeholder);a.attr("autocomplete","off");c.destroyEvents();c.events();var e=c.getCaret();c.val(c.getMasked());c.setCaret(e+c.getMCharsBeforeCount(e,!0))}()},y={},z=function(){var a=f(this),d={};a.attr("data-mask-reverse")&&(d.reverse=!0);"false"===a.attr("data-mask-maxlength")&&(d.maxlength=!1);
|
11
|
+
a.attr("data-mask-clearifnotmatch")&&(d.clearIfNotMatch=!0);a.mask(a.attr("data-mask"),d)};f.fn.mask=function(a,d){var b=this.selector,h=function(){var b=f(this).data("mask"),h=JSON.stringify;if("object"!==typeof b||h(b.options)!==h(d)||b.mask!==a)return f(this).data("mask",new A(this,a,d))};this.each(h);b&&!y[b]&&(y[b]=!0,setTimeout(function(){f(document).on("DOMNodeInserted.mask",b,h)},500))};f.fn.unmask=function(){try{return this.each(function(){f(this).data("mask").remove().removeData("mask")})}catch(a){}};
|
12
|
+
f.fn.cleanVal=function(){return this.data("mask").getCleanVal()};f("*[data-mask]").each(z);f(document).on("DOMNodeInserted.mask","*[data-mask]",z)});
|
@@ -0,0 +1,19 @@
|
|
1
|
+
//= require jquery
|
2
|
+
//= require popper
|
3
|
+
//= require notify
|
4
|
+
//= require select2
|
5
|
+
//= require bootstrap
|
6
|
+
//= require data-confirm-modal
|
7
|
+
//= require spinner
|
8
|
+
//= require jquery.mask
|
9
|
+
|
10
|
+
|
11
|
+
/* Sobrescreve data-confirm do Rails */
|
12
|
+
|
13
|
+
dataConfirmModal.setDefaults({
|
14
|
+
title: 'Confirme sua Ação',
|
15
|
+
commit: 'Confirmar',
|
16
|
+
cancel: 'Cancelar'
|
17
|
+
});
|
18
|
+
|
19
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: my_assets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Your Name
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-06-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -72,7 +72,11 @@ files:
|
|
72
72
|
- vendor/assets/javascripts/bootstrap/util.js
|
73
73
|
- vendor/assets/javascripts/data-confirm-modal.js
|
74
74
|
- vendor/assets/javascripts/datatables.js
|
75
|
+
- vendor/assets/javascripts/index.js
|
75
76
|
- vendor/assets/javascripts/jquery.js
|
77
|
+
- vendor/assets/javascripts/jquery.mask.js
|
78
|
+
- vendor/assets/javascripts/jquery.mask.min.js
|
79
|
+
- vendor/assets/javascripts/my_assets.js
|
76
80
|
- vendor/assets/javascripts/notify.js
|
77
81
|
- vendor/assets/javascripts/popper.js
|
78
82
|
- vendor/assets/javascripts/select2.js
|
@@ -160,6 +164,7 @@ files:
|
|
160
164
|
- vendor/assets/stylesheets/bootstrap/utilities/_visibility.scss
|
161
165
|
- vendor/assets/stylesheets/datatables.scss
|
162
166
|
- vendor/assets/stylesheets/font-awesome.css.erb
|
167
|
+
- vendor/assets/stylesheets/my_assets.scss
|
163
168
|
- vendor/assets/stylesheets/select2.css
|
164
169
|
- vendor/assets/stylesheets/spinner.scss
|
165
170
|
homepage: https://github.com/regiscarlos13/my_assets
|