phanterpwa 13.13.17__py3-none-any.whl → 13.13.18__py3-none-any.whl

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.
@@ -1,851 +1,1113 @@
1
- from org.transcrypt.stubs.browser import __pragma__
2
- __pragma__('alias', "jQuery", "$")
3
- __pragma__('skip')
4
-
5
- # it is ignored on transcrypt
6
- window = jQuery = console = document = localStorage = String = setTimeout =\
7
- sessionStorage = this = FileReader = JSON = js_undefined = navigator = __new__ = Date = 0
8
-
9
- __pragma__('noskip')
10
-
11
-
12
- class Mask():
13
- def __init__(self, target_selector, mask_function, reverse=False, apply_on_init=False):
14
- self.target_selector = target_selector
15
- self.element_target = jQuery(target_selector)
16
- self.mask_function = mask_function
17
- self.reverse = reverse
18
- self.apply_on_init = apply_on_init
19
- self.start()
20
-
21
- @staticmethod
22
- def stringFilter(
23
- value,
24
- you_want_array=["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]):
25
- value = str(value)
26
- new_value = ""
27
- for x in value:
28
- if x in you_want_array:
29
- new_value += x
30
- return new_value
31
-
32
- def onKeyPress(self, event, el):
33
- event.preventDefault()
34
- code = event.keyCode or event.which
35
- element = jQuery(el)
36
- pos = element[0].selectionStart
37
- end = element[0].selectionEnd
38
- if pos == end:
39
- current_value = element.val()
40
- v = String.fromCharCode(code)
41
- text0 = current_value[0: pos] + v
42
- text1 = current_value[pos:]
43
- numbers = [str(x) for x in range(10)]
44
- if v in numbers:
45
- # print(current_value[pos])
46
- if current_value[pos] in numbers or current_value[pos] == "_":
47
- pos = pos + 1
48
- else:
49
- pos = pos + 2
50
- else:
51
- current_value = element.val()
52
- v = String.fromCharCode(code)
53
- text0 = current_value[0: pos] + v
54
- text1 = current_value[end:]
55
- numbers = [str(x) for x in range(10)]
56
- if v in numbers:
57
- pos = pos + 1
58
- new_value = "{0}{1}".format(text0, text1)
59
- pure_value = self.stringFilter(new_value)
60
- new_value = self.mask_function(pure_value)[0]
61
- if pure_value is not "":
62
- element.val(new_value)
63
- else:
64
- element.val("")
65
-
66
- element[0].selectionStart = self.mask_function(pure_value)[1]
67
- element[0].selectionEnd = self.mask_function(pure_value)[1]
68
-
69
- def onKeyUp(self, event, el):
70
- element = jQuery(el)
71
- new_value = element.val()
72
- pure_value = self.stringFilter(new_value)
73
- new_value = self.mask_function(pure_value)[0]
74
- if pure_value is not "":
75
- element.val(new_value)
76
- else:
77
- element.val("")
78
-
79
- element[0].selectionStart = self.mask_function(pure_value)[1]
80
- element[0].selectionEnd = self.mask_function(pure_value)[1]
81
- element.focus()
82
- element[0].setSelectionRange(self.mask_function(pure_value)[1], self.mask_function(pure_value)[1])
83
-
84
-
85
- def onNonPrintingKeysIn(self, event, el):
86
- noprintkeys = [8, 46]
87
- code = event.keyCode or event.which
88
- element = jQuery(el)
89
- if code in noprintkeys:
90
- if code == 8:
91
- current_value = element.val()
92
- if self.stringFilter(current_value) is not "":
93
- pure_value = self.stringFilter(current_value)
94
- pure_value = pure_value[0:-1]
95
- new_value = self.mask_function(pure_value)[0]
96
- if pure_value is not "":
97
- element.val(new_value)
98
- else:
99
- element.val("")
100
- element[0].selectionStart = self.mask_function(pure_value)[1]
101
- element[0].selectionEnd = self.mask_function(pure_value)[1]
102
- else:
103
- element.val("")
104
- elif code == 46:
105
- current_value = element.val()
106
- if self.stringFilter(current_value) is not "":
107
- pos = element[0].selectionStart
108
- end = element[0].selectionEnd
109
- if pos == end:
110
- text0 = current_value[0:pos]
111
- numbers = [str(x) for x in range(10)]
112
- if current_value[pos] in numbers:
113
- text1 = current_value[pos + 1:]
114
- elif current_value[pos] is not "":
115
- text1 = current_value[pos + 2:]
116
-
117
- new_value = "{0}{1}".format(text0, text1)
118
- element[0].selectionStart = pos
119
- element[0].selectionEnd = pos
120
- else:
121
- text0 = current_value[0: pos]
122
- text1 = current_value[end:]
123
- new_value = "{0}{1}".format(text0, text1)
124
- element[0].selectionStart = pos
125
- element[0].selectionEnd = pos
126
- pure_value = self.stringFilter(new_value)
127
- new_value = self.mask_function(pure_value)[0]
128
- if pure_value is not "":
129
- element.val(new_value)
130
- else:
131
- element.val("")
132
- element[0].selectionStart = pos
133
- element[0].selectionEnd = pos
134
- else:
135
- element.val("")
136
-
137
- event.preventDefault()
138
-
139
- def onNonPrintingKeys(self, event, el):
140
- event.preventDefault()
141
- element = jQuery(el)
142
- code = event.keyCode or event.which
143
- noprintkeys = [8, 46, 9]
144
- if code in noprintkeys:
145
- value = element.val()
146
- element.val(value + "_")
147
- if (self.reverse):
148
- if (self.stringFilter(value) != ""):
149
- value = str(int(self.stringFilter(value)))
150
- new_value = ""
151
-
152
- pure_value = self.stringFilter(value)
153
- if pure_value == "":
154
- element.val("")
155
- else:
156
- new_value = self.mask_function(pure_value)[0]
157
- element.attr("phanterpwa-mask-justnumbers", self.stringFilter(new_value))
158
- selection_pos = self.mask_function(pure_value)[1]
159
- element.val(new_value)
160
- if (self.reverse):
161
- element[0].selectionStart = -len(new_value)
162
- element[0].selectionEnd = -len(new_value)
163
- else:
164
- element[0].selectionStart = selection_pos
165
- element[0].selectionEnd = selection_pos
166
- if(code != 9):
167
- event.preventDefault()
168
- else:
169
- pure_value = self.stringFilter(element.val())
170
- if pure_value == "":
171
- element.val("")
172
-
173
- def onFocusOut(self, event, el):
174
- element = jQuery(el)
175
- new_value = element.val()
176
- pure_value = self.stringFilter(new_value)
177
- new_value = self.mask_function(pure_value)[0]
178
- if pure_value is not "":
179
- element.val(new_value)
180
- else:
181
- element.val("")
182
-
183
-
184
- def start(self):
185
- element = jQuery(self.target_selector)
186
- value = element.val()
187
- pure_value = self.stringFilter(value)
188
- new_value = self.mask_function(pure_value)[0]
189
- selection_pos = self.mask_function(pure_value)[1]
190
-
191
- if(self.apply_on_init):
192
- element.val(new_value)
193
- if(self.reverse):
194
- element[0].selectionStart = -len(new_value)
195
- element[0].selectionEnd = -len(new_value)
196
- else:
197
- element[0].selectionStart = selection_pos
198
- element[0].selectionEnd = selection_pos
199
-
200
- element.off(
201
- "keypress.phanterpwaMask"
202
- ).on(
203
- "keypress.phanterpwaMask",
204
- lambda event: self.onKeyPress(event, this)
205
- )
206
- element.off(
207
- "focusout.phanterpwaMask"
208
- ).on(
209
- "focusout.phanterpwaMask",
210
- lambda event: self.onFocusOut(event, this)
211
- )
212
- element.off(
213
- "keyup.phanterpwaMask2,"
214
- ).on(
215
- "keyup.phanterpwaMask2,",
216
- lambda event: self.onKeyUp(event, this)
217
- )
218
- element.off(
219
- "keydown.phanterpwaMask, focusout.phanterpwaMask"
220
- ).on(
221
- "keydown.phanterpwaMask, focusout.phanterpwaMask",
222
- lambda event: self.onNonPrintingKeysIn(event, this)
223
- )
224
-
225
-
226
- def date_and_datetime_to_maks(value):
227
- date_format = ["d", "M", "o", "t", "y", "H", "m", "s"]
228
- string_mask = ""
229
- if isinstance(value, str):
230
- for x in value:
231
- if x in date_format:
232
- y = "#"
233
- else:
234
- y = x
235
- string_mask += y
236
- return string_mask
237
-
238
-
239
- def isNotEmpty(value):
240
- if ((value is not None) and (value is not "") and (value is not js_undefined)):
241
- return True
242
- else:
243
- return False
244
-
245
-
246
- def stringFilter(
247
- value,
248
- you_want_array=["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]):
249
- value = str(value)
250
- new_value = ""
251
- for x in value:
252
- if x in you_want_array:
253
- new_value += x
254
- return new_value
255
-
256
-
257
- def hasCaracter(value, caracter="."):
258
- value = str(value)
259
- has_caractere = False
260
- if caracter in value:
261
- has_caractere = True
262
- return has_caractere
263
-
264
-
265
- def justSearchedCaracter(value, caractere="."):
266
- has_caractere = False
267
- value = str(value)
268
- new_value = ""
269
- for x in value:
270
- if x == caractere:
271
- if not has_caractere:
272
- new_value += x
273
- has_caractere = True
274
- else:
275
- new_value += x
276
- return new_value
277
-
278
-
279
- def stringForceToFloatstring(value, force_dot=False, localeBR=True):
280
- if isNotEmpty(value):
281
- value = str(value)
282
- if localeBR:
283
- value = value.replace(",", ".")
284
- value = stringFilter(value, ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "."])
285
- value = justSearchedCaracter(value)
286
- if (value != ""):
287
- if (value == "."):
288
- if (force_dot):
289
- value = "0."
290
- else:
291
- value = ""
292
- else:
293
- if not force_dot:
294
- value = str(float(value))
295
- return value
296
- else:
297
- return ""
298
-
299
-
300
- def stringToFloatstringLimitDecimals(value, casas_decimais=2, localeBR=True):
301
- value = str(value)
302
- if isNotEmpty(value):
303
- if(localeBR):
304
- value = value.replace(",", ".")
305
- value = stringFilter(value, ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "."])
306
- value = justSearchedCaracter(value)
307
- if(value != ""):
308
- value = str(float(value))
309
- p_inteiro = value.split(".")[0]
310
- p_decimal = value.split(".")[1]
311
- if not isNotEmpty(p_decimal):
312
- p_decimal = "0"
313
- if len(p_decimal) < casas_decimais:
314
- np_decimal = ""
315
- for x in range(casas_decimais - len(p_decimal)):
316
- np_decimal += "0"
317
- p_decimal = p_decimal + np_decimal
318
- else:
319
- np_decimal = ""
320
- for i in range(casas_decimais):
321
- np_decimal += p_decimal[i]
322
- p_decimal = np_decimal
323
- r = "{0}.{1}".format(p_inteiro, p_decimal)
324
- return r
325
- return value
326
- else:
327
- return ""
328
-
329
-
330
- def floatToCurrency(value, casas_decimais=2, separador_decimal=",", separador_milhar=".", currency=""):
331
- casas_decimais = casas_decimais
332
- separador_decimal = separador_decimal
333
- separador_milhar = separador_milhar
334
- value = str(value)
335
- p_m_inteiro = "0"
336
- p_m_decimal = ""
337
- for i in range(casas_decimais):
338
- p_m_decimal += "0"
339
-
340
- if hasCaracter(value, "."):
341
- p_inteiro = value.split(".")[0]
342
- p_decimal = value.split(".")[1]
343
- if(isNotEmpty(p_inteiro)):
344
- p_inteiro = p_inteiro.split("").reverse().join("")
345
- str_inteiro = ""
346
- tamanho_inteiro = len(p_inteiro)
347
- adicionar_separador = False
348
- if (tamanho_inteiro > 3):
349
- for i in range(tamanho_inteiro):
350
- if (((i + 1) % 3) == 0):
351
- str_inteiro += p_inteiro[i]
352
- adicionar_separador = True
353
- else:
354
- if(adicionar_separador):
355
- adicionar_separador = False
356
- str_inteiro += separador_milhar + p_inteiro[i]
357
- else:
358
- str_inteiro += p_inteiro[i]
359
- else:
360
- for i in range(tamanho_inteiro):
361
- str_inteiro += p_inteiro[i]
362
- p_m_inteiro = str_inteiro.split("").reverse().join("")
363
-
364
- if(isNotEmpty(p_decimal)):
365
- str_cd = ""
366
- if (p_decimal.length > casas_decimais):
367
- for i in range(casas_decimais):
368
- str_cd += p_decimal[i]
369
- else:
370
- for i in range(len(p_decimal)):
371
- str_cd += p_decimal[i]
372
- diferenca = casas_decimais - len(p_decimal)
373
- tracos = ""
374
- for i in range(diferenca):
375
- tracos += "0"
376
- str_cd += tracos
377
- p_m_decimal = str_cd
378
-
379
- else:
380
- if value != "":
381
- t_m_inteiro = int(value)
382
- if (isNotEmpty(t_m_inteiro)):
383
- p_m_inteiro = str(t_m_inteiro)
384
- if(isNotEmpty(currency)):
385
- r = "{0} {1}{2}{3}".format(currency, p_m_inteiro, separador_decimal, p_m_decimal)
386
- else:
387
- r = "{1}{2}{3}".format(p_m_inteiro, separador_decimal, p_m_decimal)
388
- return r
389
-
390
-
391
- def baseCustom(value, custom_mask, cursorPosition=0):
392
- value = str(value)
393
- size = len(value)
394
- char_plus = 0
395
- pos_num = 0
396
- new_value = ""
397
- for i in range(len(custom_mask)):
398
- if (custom_mask[i] == "#"):
399
- if (pos_num < size):
400
- new_value += value[pos_num]
401
- pos_num += 1
402
- else:
403
- new_value += "_"
404
- pos_num += 1
405
- else:
406
- if (i < (size + char_plus)):
407
- char_plus += 1
408
-
409
- new_value += custom_mask[i]
410
- if new_value.indexOf("_") > 0:
411
- cursorPosition = new_value.indexOf("_")
412
- else:
413
- cursorPosition = int(size) + char_plus
414
- return [new_value, cursorPosition]
415
-
416
-
417
- def maskFone(valor):
418
- valor = str(valor)
419
- size = len(valor)
420
- if (size == 10):
421
- custom_mask = "(##) ####-####"
422
- elif (size == 11):
423
- custom_mask = "(##) # ####-####"
424
- elif (size > 11):
425
- custom_mask = "(##) #####-#########"
426
- else:
427
- custom_mask = "(##) # ####-####"
428
- return baseCustom(valor, custom_mask)
429
-
430
-
431
- def maskCNPJ(valor):
432
- custom_mask = "##.###.###/####-##"
433
- return baseCustom(valor, custom_mask)
434
-
435
-
436
- def maskCPF(valor):
437
- custom_mask = "###.###.###-##"
438
- return baseCustom(valor, custom_mask)
439
-
440
-
441
- def maskDate(valor):
442
- custom_mask = "##/##/####"
443
- return baseCustom(valor, custom_mask)
444
-
445
-
446
- def maskDatetime(valor):
447
- custom_mask = "##/##/#### ##:##:##"
448
- return baseCustom(valor, custom_mask)
449
-
450
-
451
- def maskCEP(valor):
452
- custom_mask = "##.###-###"
453
- return baseCustom(valor, custom_mask)
454
-
455
-
456
- def applyMask(jq_select, maskfunction, reverse=False, apply_on_init=False):
457
-
458
- def onKeyPress(event, el):
459
- element = jQuery(el)
460
- code = event.keyCode or event.which
461
- noprintkeys = [8, 46, 9]
462
- if code not in noprintkeys:
463
- value = element.val()
464
- if (reverse):
465
- if (stringFilter(value) != ""):
466
- value = str(int(stringFilter(value)))
467
- new_value = ""
468
-
469
- value = value + String.fromCharCode(code)
470
- pure_value = stringFilter(value)
471
- if pure_value == "":
472
- element.val("")
473
- else:
474
- new_value = maskfunction(pure_value)[0]
475
- element.attr("phanterpwa-mask-justnumbers", stringFilter(new_value))
476
- selection_pos = maskfunction(pure_value)[1]
477
- element.val(new_value)
478
- if (reverse):
479
- element[0].selectionStart = -len(new_value)
480
- element[0].selectionEnd = -len(new_value)
481
- else:
482
- element[0].selectionStart = selection_pos
483
- element[0].selectionEnd = selection_pos
484
- if(code != 9):
485
- event.preventDefault()
486
-
487
- def onNonPrintingKeys(event, el):
488
- element = jQuery(el)
489
- code = event.keyCode or event.which
490
- noprintkeys = [8, 46, 9]
491
- if code in noprintkeys:
492
- value = element.val()
493
- if (reverse):
494
- if (stringFilter(value) != ""):
495
- value = str(int(stringFilter(value)))
496
- new_value = ""
497
-
498
- pure_value = stringFilter(value)
499
- if pure_value == "":
500
- element.val("")
501
- else:
502
- new_value = maskfunction(pure_value)[0]
503
- element.attr("phanterpwa-mask-justnumbers", stringFilter(new_value))
504
- selection_pos = maskfunction(pure_value)[1]
505
- element.val(new_value)
506
- if (reverse):
507
- element[0].selectionStart = -len(new_value)
508
- element[0].selectionEnd = -len(new_value)
509
- else:
510
- element[0].selectionStart = selection_pos
511
- element[0].selectionEnd = selection_pos
512
- if(code != 9):
513
- event.preventDefault()
514
-
515
- def onEachElement(el):
516
- element = jQuery(el)
517
- value = element.val()
518
- pure_value = stringFilter(value)
519
- new_value = maskfunction(pure_value)[0]
520
- selection_pos = maskfunction(pure_value)[1]
521
-
522
- if(apply_on_init):
523
- element.val(new_value)
524
- if(reverse):
525
- element[0].selectionStart = -len(new_value)
526
- element[0].selectionEnd = -len(new_value)
527
- else:
528
- element[0].selectionStart = selection_pos
529
- element[0].selectionEnd = selection_pos
530
-
531
- element.off(
532
- "keypress.phanterpwaMask, focusout.phanterpwaMask"
533
- ).on(
534
- "keypress.phanterpwaMask, focusout.phanterpwaMask",
535
- lambda event: onKeyPress(event, this)
536
- )
537
-
538
- element.off(
539
- "keyup.phanterpwaMask, focusout.phanterpwaMask"
540
- ).on(
541
- "keyup.phanterpwaMask, focusout.phanterpwaMask",
542
- lambda event: onNonPrintingKeys(event, this)
543
- )
544
-
545
- jQuery(jq_select).each(lambda: onEachElement(this))
546
- return jQuery(jq_select)
547
-
548
-
549
- def phanterCurrency(
550
- jq_select,
551
- v_currency="R$",
552
- casas_decimais=2,
553
- separador_decimal=",",
554
- separador_milhar="."):
555
- return phanterDecimals(
556
- jq_select=jq_select,
557
- v_currency=v_currency,
558
- casas_decimais=casas_decimais,
559
- separador_decimal=separador_decimal,
560
- separador_milhar=separador_milhar)
561
-
562
-
563
- def phanterDecimals(
564
- jq_select,
565
- v_currency="",
566
- casas_decimais=2,
567
- separador_decimal=",",
568
- separador_milhar="."):
569
- l_currency = v_currency
570
-
571
- def onKeyPress(event, el):
572
- element = jQuery(el)
573
- code = event.keyCode or event.which
574
- value = element.attr("phantermaskTemp")
575
- key_value = String.fromCharCode(code)
576
- if (code == 8):
577
- if(hasCaracter(value, ".")):
578
- value = stringToFloatstringLimitDecimals(value, casas_decimais)
579
- value = stringFilter(value)
580
- value = value[0:-1]
581
- elif((code == 46) and event.key == "Delete"):
582
- value = stringFilter(value)
583
- value = value[1:]
584
- else:
585
- contat_value = "{0}{1}".format(value, key_value)
586
- if (((key_value == separador_decimal) or (event.key == separador_decimal)) and not hasCaracter(value, ".")):
587
- value = stringForceToFloatstring(contat_value, True)
588
- else:
589
- if (hasCaracter(value, ".")):
590
- value = stringForceToFloatstring(contat_value, True)
591
- else:
592
- value = stringForceToFloatstring(contat_value)
593
- element.attr("phantermaskTemp", value)
594
- if not hasCaracter(value, "."):
595
- if (len(value) >= casas_decimais):
596
- p_inteiro = value[0: (-1) * casas_decimais]
597
- if not isNotEmpty(p_inteiro):
598
- p_inteiro = "0"
599
- p_decimal = value[(-1) * casas_decimais:]
600
- value = "{0}.{1}".format(p_inteiro, p_decimal)
601
- else:
602
- diferenca = casas_decimais - len(value)
603
- add_decs = ""
604
- for i in range(diferenca):
605
- add_decs += "0"
606
- p_inteiro = "0"
607
- value = "{0}.{1}{2}".format(p_inteiro, add_decs, value)
608
- value = stringToFloatstringLimitDecimals(value, casas_decimais)
609
- new_value = ""
610
- if (value == ""):
611
- qu_decs = ""
612
- for i in range(casas_decimais):
613
- qu_decs += "0"
614
- new_value = "0{0}{1}".format(separador_decimal, qu_decs)
615
- if(element.prop('TagName') == "INPUT"):
616
- element.val(
617
- floatToCurrency(
618
- stringToFloatstringLimitDecimals(
619
- new_value,
620
- casas_decimais
621
- ),
622
- casas_decimais,
623
- separador_decimal,
624
- separador_milhar,
625
- l_currency)
626
- )
627
- else:
628
- element.text(
629
- floatToCurrency(
630
- stringToFloatstringLimitDecimals(
631
- new_value,
632
- casas_decimais
633
- ),
634
- casas_decimais,
635
- separador_decimal,
636
- separador_milhar,
637
- l_currency)
638
- )
639
- element.attr("phantermaskValue", stringToFloatstringLimitDecimals(new_value, casas_decimais))
640
- else:
641
- new_value = value.replace(".", separador_decimal)
642
- if(element.prop('TagName') == "INPUT"):
643
- element.val(
644
- floatToCurrency(
645
- stringToFloatstringLimitDecimals(
646
- new_value,
647
- casas_decimais
648
- ),
649
- casas_decimais,
650
- separador_decimal,
651
- separador_milhar,
652
- l_currency)
653
- )
654
- else:
655
- element.text(
656
- floatToCurrency(
657
- stringToFloatstringLimitDecimals(
658
- new_value,
659
- casas_decimais
660
- ),
661
- casas_decimais,
662
- separador_decimal,
663
- separador_milhar,
664
- l_currency)
665
- )
666
- element.attr("phantermaskValue", stringToFloatstringLimitDecimals(new_value, casas_decimais))
667
- element[0].selectionStart = -len(new_value)
668
- element[0].selectionEnd = -len(new_value)
669
- if (code != 9):
670
- event.preventDefault()
671
-
672
- def onPaste(el):
673
- setTimeout(
674
- lambda: jQuery(el).trigger("focusout"),
675
- 100
676
- )
677
-
678
- def onFocusOut(event, el):
679
- element = jQuery(el)
680
- value = element.attr("phantermaskValue")
681
- value = stringToFloatstringLimitDecimals(value, casas_decimais)
682
- new_value = ""
683
- if (value == ""):
684
- qu_decs = ""
685
- for i in range(casas_decimais):
686
- qu_decs += "0"
687
- new_value = "0{0}{1}".format(separador_decimal, qu_decs)
688
- if(element.prop('TagName') == "INPUT"):
689
- element.val(floatToCurrency(stringToFloatstringLimitDecimals(
690
- new_value, casas_decimais), casas_decimais, separador_decimal, separador_milhar, l_currency))
691
- else:
692
- element.text(floatToCurrency(stringToFloatstringLimitDecimals(
693
- new_value, casas_decimais), casas_decimais, separador_decimal, separador_milhar, l_currency))
694
- element.attr("phantermaskValue", stringToFloatstringLimitDecimals(value, casas_decimais))
695
- else:
696
- new_value = value.replace(".", separador_decimal)
697
- if(element.prop('TagName') == "INPUT"):
698
- element.val(floatToCurrency(stringToFloatstringLimitDecimals(
699
- new_value, casas_decimais), casas_decimais, separador_decimal, separador_milhar, l_currency))
700
- else:
701
- element.text(floatToCurrency(stringToFloatstringLimitDecimals(
702
- new_value, casas_decimais), casas_decimais, separador_decimal, separador_milhar, l_currency))
703
- element.attr("phantermaskValue", stringToFloatstringLimitDecimals(value, casas_decimais))
704
- element[0].selectionStart = -len(new_value)
705
- element[0].selectionEnd = -len(new_value)
706
-
707
- def onEachElement(el):
708
- l_currency = ""
709
- if(v_currency != ""):
710
- l_currency = v_currency
711
- element = jQuery(el)
712
- if(element.prop('TagName') == "INPUT"):
713
- defaults = element.val()
714
- else:
715
- defaults = element.text()
716
- value = stringForceToFloatstring(defaults)
717
- element.attr("phantermaskTemp", value)
718
- value = stringToFloatstringLimitDecimals(value, casas_decimais)
719
- new_value = ""
720
- if (value == ""):
721
- qu_decs = ""
722
- for i in range(casas_decimais):
723
- qu_decs += "0"
724
- new_value = "0" + separador_decimal + qu_decs
725
- if(element.prop('TagName') == "INPUT"):
726
- element.val(floatToCurrency(stringToFloatstringLimitDecimals(
727
- new_value, casas_decimais), casas_decimais, separador_decimal, separador_milhar, l_currency))
728
- else:
729
- element.text(floatToCurrency(stringToFloatstringLimitDecimals(
730
- new_value, casas_decimais), casas_decimais, separador_decimal, separador_milhar, l_currency))
731
- element.attr("phantermaskValue", stringToFloatstringLimitDecimals(value, casas_decimais))
732
- else:
733
- new_value = value.replace(".", separador_decimal)
734
- if(element.prop('TagName') == "INPUT"):
735
- element.val(floatToCurrency(stringToFloatstringLimitDecimals(
736
- new_value, casas_decimais), casas_decimais, separador_decimal, separador_milhar, l_currency))
737
- else:
738
- element.text(floatToCurrency(stringToFloatstringLimitDecimals(
739
- new_value, casas_decimais), casas_decimais, separador_decimal, separador_milhar, l_currency))
740
- element.attr("phantermaskValue", stringToFloatstringLimitDecimals(value, casas_decimais))
741
- element[0].selectionStart = -len(new_value)
742
- element[0].selectionEnd = -len(new_value)
743
- element.off(
744
- 'keypress.phanterpwaMask'
745
- ).on(
746
- 'keypress.phanterpwaMask',
747
- lambda event: onKeyPress(event, this)
748
- ).off(
749
- "paste.phanterpwaMask, focusin.phanterpwaMask"
750
- ).on(
751
- "paste.phanterpwaMask, focusin.phanterpwaMask",
752
- lambda: onFocusOut(this)
753
- ).off(
754
- 'focusout.phanterpwaMask'
755
- ).on(
756
- 'focusout.phanterpwaMask',
757
- lambda event: onFocusOut(event, this)
758
- )
759
- jq_select.each(lambda: onEachElement(this))
760
- return jQuery(jq_select)
761
-
762
-
763
- def phanterpwaMask(mask, parameters, el):
764
- custom_mask = ""
765
- casas_decimais = 2
766
- separador_decimal = ","
767
- separador_milhar = "."
768
- currency = "R$"
769
- reverse = False
770
- value = ""
771
- apply_on_init = False
772
- date_format = "%d/%m/%Y"
773
- datetime_format = "%d/%m/%Y %H:%M:%S"
774
- if (isNotEmpty(parameters)):
775
- if ("mask" in parameters):
776
- custom_mask = parameters['mask']
777
- if ("casas_decimais" in parameters):
778
- casas_decimais = int(parameters['casas_decimais'])
779
- if ("separador_decimal" in parameters):
780
- separador_decimal = str(parameters['separador_decimal'])
781
- if ("separador_milhar" in parameters):
782
- separador_milhar = str(parameters['separador_milhar'])
783
- if ("currency" in parameters):
784
- currency = str(parameters['currency'])
785
- if ("value" in parameters):
786
- jQuery(el).val(parameters['value'])
787
- if ("date_format" in parameters):
788
- date_format = parameters['date_format']
789
- if ("datetime_format" in parameters):
790
- datetime_format = parameters['datetime_format']
791
- if ("apply_on_init" in parameters):
792
- apply_on_init = parameters['apply_on_init']
793
- jQuery(el).removeClass("masked_input")
794
- if (mask == "fone"):
795
- jQuery(el).addClass("masked_input")
796
- applyMask(el, maskFone, reverse, apply_on_init)
797
- elif(mask == "cnpj"):
798
- jQuery(el).addClass("masked_input")
799
- applyMask(el, maskCNPJ, reverse, apply_on_init)
800
- elif(mask == "cpf"):
801
- jQuery(el).addClass("masked_input")
802
- applyMask(el, maskCPF, reverse, apply_on_init)
803
- elif(mask == "date"):
804
- jQuery(
805
- el
806
- ).off(
807
- 'click.phanterpwaMaskdata focusin.phanterpwaMaskdata'
808
- ).on(
809
- 'click.phanterpwaMaskdata focusin.phanterpwaMaskdata',
810
- console.info("future")
811
- )
812
- applyMask(el, maskDate, reverse, apply_on_init)
813
- elif(mask == "datetime"):
814
- jQuery(
815
- el
816
- ).off(
817
- 'click.phanterpwaMaskdatahora focusin.phanterpwaMaskdatahora'
818
- ).on(
819
- 'click.phanterpwaMaskdatahora focusin.phanterpwaMaskdatahora',
820
- console.info("future")
821
- )
822
- applyMask(el, maskDatetime, reverse, apply_on_init)
823
- elif(mask == "cep"):
824
- jQuery(el).addClass("masked_input")
825
- applyMask(el, maskCEP, reverse, apply_on_init)
826
- elif(mask == "real"):
827
- jQuery(el).addClass("masked_input")
828
- phanterCurrency(el,
829
- v_currency=currency,
830
- casas_decimais=casas_decimais,
831
- separador_decimal=separador_decimal,
832
- separador_milhar=separador_milhar)
833
- elif(mask == "decimal"):
834
- jQuery(el).addClass("masked_input")
835
- phanterDecimals(el,
836
- v_currency="",
837
- casas_decimais=casas_decimais,
838
- separador_decimal=separador_decimal,
839
- separador_milhar=separador_milhar)
840
- elif(mask == "off"):
841
- jQuery(
842
- el
843
- ).removeClass(
844
- "masked_input"
845
- ).off(
846
- "keypress.phanterpwaMask focusout.phanterpwaMask focusin.phanterpwaMask"
847
- )
848
- elif(mask == "custom"):
849
- jQuery(el).addClass("masked_input")
850
- applyMask(el, lambda v: baseCustom(v, parameters['mask']), reverse, apply_on_init)
851
- return jQuery(el)
1
+ from org.transcrypt.stubs.browser import __pragma__
2
+ __pragma__('alias', "jQuery", "$")
3
+ __pragma__('skip')
4
+
5
+ # it is ignored on transcrypt
6
+ window = jQuery = console = document = localStorage = String = setTimeout =\
7
+ sessionStorage = this = FileReader = JSON = js_undefined = navigator = __new__ = Date = 0
8
+
9
+ __pragma__('noskip')
10
+ __pragma__('kwargs')
11
+
12
+ def zfill(number, size):
13
+ number = int(number)
14
+ number = str(number)
15
+ s = number
16
+ for x in range(size - len(number)):
17
+ s = "0" + s
18
+ return s
19
+
20
+
21
+ class Mask():
22
+ def __init__(self, target_selector, mask_function, reverse=False, apply_on_init=False):
23
+ self.target_selector = target_selector
24
+ self.element_target = jQuery(target_selector)
25
+ self.mask_function = mask_function
26
+ self.reverse = reverse
27
+ self.apply_on_init = apply_on_init
28
+ self.start()
29
+
30
+ @staticmethod
31
+ def stringFilter(
32
+ value,
33
+ you_want_array=["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]):
34
+ value = str(value)
35
+ new_value = ""
36
+ for x in value:
37
+ if x in you_want_array:
38
+ new_value += x
39
+ return new_value
40
+
41
+ def onKeyPress(self, event, el):
42
+ event.preventDefault()
43
+ code = event.keyCode or event.which
44
+ element = jQuery(el)
45
+ pos = element[0].selectionStart
46
+ end = element[0].selectionEnd
47
+ if pos == end:
48
+ current_value = element.val()
49
+ v = String.fromCharCode(code)
50
+ text0 = current_value[0: pos] + v
51
+ text1 = current_value[pos:]
52
+ numbers = [str(x) for x in range(10)]
53
+ if v in numbers:
54
+ # print(current_value[pos])
55
+ if current_value[pos] in numbers or current_value[pos] == "_":
56
+ pos = pos + 1
57
+ else:
58
+ pos = pos + 2
59
+ else:
60
+ current_value = element.val()
61
+ v = String.fromCharCode(code)
62
+ text0 = current_value[0: pos] + v
63
+ text1 = current_value[end:]
64
+ numbers = [str(x) for x in range(10)]
65
+ if v in numbers:
66
+ pos = pos + 1
67
+ new_value = "{0}{1}".format(text0, text1)
68
+ pure_value = self.stringFilter(new_value)
69
+ new_value = self.mask_function(pure_value)[0]
70
+ if pure_value is not "":
71
+ element.val(new_value)
72
+ else:
73
+ element.val("")
74
+
75
+ element[0].selectionStart = self.mask_function(pure_value)[1]
76
+ element[0].selectionEnd = self.mask_function(pure_value)[1]
77
+
78
+ def onKeyUp(self, event, el):
79
+ element = jQuery(el)
80
+ new_value = element.val()
81
+ pure_value = self.stringFilter(new_value)
82
+ new_value = self.mask_function(pure_value)[0]
83
+ if pure_value is not "":
84
+ element.val(new_value)
85
+ else:
86
+ element.val("")
87
+
88
+ element[0].selectionStart = self.mask_function(pure_value)[1]
89
+ element[0].selectionEnd = self.mask_function(pure_value)[1]
90
+ element.focus()
91
+ element[0].setSelectionRange(self.mask_function(pure_value)[1], self.mask_function(pure_value)[1])
92
+
93
+
94
+ def onNonPrintingKeysIn(self, event, el):
95
+ noprintkeys = [8, 46]
96
+ code = event.keyCode or event.which
97
+ element = jQuery(el)
98
+ if code in noprintkeys:
99
+ if code == 8:
100
+ current_value = element.val()
101
+ if self.stringFilter(current_value) is not "":
102
+ pure_value = self.stringFilter(current_value)
103
+ pure_value = pure_value[0:-1]
104
+ new_value = self.mask_function(pure_value)[0]
105
+ if pure_value is not "":
106
+ element.val(new_value)
107
+ else:
108
+ element.val("")
109
+ element[0].selectionStart = self.mask_function(pure_value)[1]
110
+ element[0].selectionEnd = self.mask_function(pure_value)[1]
111
+ else:
112
+ element.val("")
113
+ elif code == 46:
114
+ current_value = element.val()
115
+ if self.stringFilter(current_value) is not "":
116
+ pos = element[0].selectionStart
117
+ end = element[0].selectionEnd
118
+ if pos == end:
119
+ text0 = current_value[0:pos]
120
+ numbers = [str(x) for x in range(10)]
121
+ if current_value[pos] in numbers:
122
+ text1 = current_value[pos + 1:]
123
+ elif current_value[pos] is not "":
124
+ text1 = current_value[pos + 2:]
125
+
126
+ new_value = "{0}{1}".format(text0, text1)
127
+ element[0].selectionStart = pos
128
+ element[0].selectionEnd = pos
129
+ else:
130
+ text0 = current_value[0: pos]
131
+ text1 = current_value[end:]
132
+ new_value = "{0}{1}".format(text0, text1)
133
+ element[0].selectionStart = pos
134
+ element[0].selectionEnd = pos
135
+ pure_value = self.stringFilter(new_value)
136
+ new_value = self.mask_function(pure_value)[0]
137
+ if pure_value is not "":
138
+ element.val(new_value)
139
+ else:
140
+ element.val("")
141
+ element[0].selectionStart = pos
142
+ element[0].selectionEnd = pos
143
+ else:
144
+ element.val("")
145
+
146
+ event.preventDefault()
147
+
148
+ def onNonPrintingKeys(self, event, el):
149
+ event.preventDefault()
150
+ element = jQuery(el)
151
+ code = event.keyCode or event.which
152
+ noprintkeys = [8, 46, 9]
153
+ if code in noprintkeys:
154
+ value = element.val()
155
+ element.val(value + "_")
156
+ if (self.reverse):
157
+ if (self.stringFilter(value) != ""):
158
+ value = str(int(self.stringFilter(value)))
159
+ new_value = ""
160
+
161
+ pure_value = self.stringFilter(value)
162
+ if pure_value == "":
163
+ element.val("")
164
+ else:
165
+ new_value = self.mask_function(pure_value)[0]
166
+ element.attr("phanterpwa-mask-justnumbers", self.stringFilter(new_value))
167
+ selection_pos = self.mask_function(pure_value)[1]
168
+ element.val(new_value)
169
+ if (self.reverse):
170
+ element[0].selectionStart = -len(new_value)
171
+ element[0].selectionEnd = -len(new_value)
172
+ else:
173
+ element[0].selectionStart = selection_pos
174
+ element[0].selectionEnd = selection_pos
175
+ if(code != 9):
176
+ event.preventDefault()
177
+ else:
178
+ pure_value = self.stringFilter(element.val())
179
+ if pure_value == "":
180
+ element.val("")
181
+
182
+ def onFocusOut(self, event, el):
183
+ element = jQuery(el)
184
+ new_value = element.val()
185
+ pure_value = self.stringFilter(new_value)
186
+ new_value = self.mask_function(pure_value)[0]
187
+ if pure_value is not "":
188
+ element.val(new_value)
189
+ else:
190
+ element.val("")
191
+
192
+
193
+ def start(self):
194
+ element = jQuery(self.target_selector)
195
+ value = element.val()
196
+ pure_value = self.stringFilter(value)
197
+ new_value = self.mask_function(pure_value)[0]
198
+ selection_pos = self.mask_function(pure_value)[1]
199
+
200
+ if(self.apply_on_init):
201
+ element.val(new_value)
202
+ if(self.reverse):
203
+ element[0].selectionStart = -len(new_value)
204
+ element[0].selectionEnd = -len(new_value)
205
+ else:
206
+ element[0].selectionStart = selection_pos
207
+ element[0].selectionEnd = selection_pos
208
+
209
+ element.off(
210
+ "keypress.phanterpwaMask"
211
+ ).on(
212
+ "keypress.phanterpwaMask",
213
+ lambda event: self.onKeyPress(event, this)
214
+ )
215
+ element.off(
216
+ "focusout.phanterpwaMask"
217
+ ).on(
218
+ "focusout.phanterpwaMask",
219
+ lambda event: self.onFocusOut(event, this)
220
+ )
221
+ element.off(
222
+ "keyup.phanterpwaMask2,"
223
+ ).on(
224
+ "keyup.phanterpwaMask2,",
225
+ lambda event: self.onKeyUp(event, this)
226
+ )
227
+ element.off(
228
+ "keydown.phanterpwaMask, focusout.phanterpwaMask"
229
+ ).on(
230
+ "keydown.phanterpwaMask, focusout.phanterpwaMask",
231
+ lambda event: self.onNonPrintingKeysIn(event, this)
232
+ )
233
+
234
+
235
+ class Currency():
236
+ def __init__(self, target_selector, reverse=False, apply_on_init=False, casas_decimais=2, separador_decimal=",", separador_milhar=".", icurrency=""):
237
+ self.target_selector = target_selector
238
+ self.element_target = jQuery(target_selector)
239
+ self.reverse = reverse
240
+ self.casas_decimais = casas_decimais
241
+ self.apply_on_init = apply_on_init
242
+ self.separador_milhar = separador_milhar
243
+ self.separador_decimal = separador_decimal
244
+ self.icurrency = icurrency
245
+ self.start()
246
+
247
+ def mask_function(self, value):
248
+ value = self.stringFilter(str(value))
249
+ if len(value) <= self.casas_decimais:
250
+ nvalue = "0{}{}".format(self.separador_decimal, zfill(value, 2))
251
+ else:
252
+ ivalue = int(value[0: -self.casas_decimais])
253
+ p_inteiro = str(ivalue).split("").reverse().join("")
254
+ str_inteiro = ""
255
+ tamanho_inteiro = len(p_inteiro)
256
+ adicionar_separador = False
257
+ if (tamanho_inteiro > 3):
258
+ for i in range(tamanho_inteiro):
259
+ if (((i + 1) % 3) == 0):
260
+ str_inteiro += p_inteiro[i]
261
+ adicionar_separador = True
262
+ else:
263
+ if(adicionar_separador):
264
+ adicionar_separador = False
265
+ str_inteiro += self.separador_milhar + p_inteiro[i]
266
+ else:
267
+ str_inteiro += p_inteiro[i]
268
+ str_inteiro = str_inteiro.split("").reverse().join("")
269
+ else:
270
+ str_inteiro = str(ivalue)
271
+ nvalue = "{}{}{}".format(
272
+ str_inteiro,
273
+ self.separador_decimal,
274
+ value[-int(self.casas_decimais):]
275
+ )
276
+ if self.icurrency != "":
277
+ nvalue = "{} {}".format(self.icurrency, nvalue)
278
+ return [nvalue, len(nvalue)]
279
+
280
+ @staticmethod
281
+ def stringFilter(
282
+ value,
283
+ you_want_array=["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]):
284
+ value = str(value)
285
+ new_value = ""
286
+ for x in value:
287
+ if x in you_want_array:
288
+ new_value += x
289
+ return new_value
290
+
291
+ def onKeyPress(self, event, el):
292
+ event.preventDefault()
293
+ code = event.keyCode or event.which
294
+ element = jQuery(el)
295
+ pos = element[0].selectionStart
296
+ end = element[0].selectionEnd
297
+ if pos == end:
298
+ current_value = element.val()
299
+ v = String.fromCharCode(code)
300
+ text0 = current_value[0: pos] + v
301
+ text1 = current_value[pos:]
302
+ numbers = [str(x) for x in range(10)]
303
+ if v in numbers:
304
+ # print(current_value[pos])
305
+ if current_value[pos] in numbers or current_value[pos] == "_":
306
+ pos = pos + 1
307
+ else:
308
+ pos = pos + 2
309
+ else:
310
+ current_value = element.val()
311
+ v = String.fromCharCode(code)
312
+ text0 = current_value[0: pos] + v
313
+ text1 = current_value[end:]
314
+ numbers = [str(x) for x in range(10)]
315
+ if v in numbers:
316
+ pos = pos + 1
317
+ new_value = "{0}{1}".format(text0, text1)
318
+ pure_value = self.stringFilter(new_value, ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", self.separador_decimal])
319
+ new_value = self.mask_function(pure_value)[0]
320
+ if pure_value is not "":
321
+ element.val(new_value)
322
+ else:
323
+ element.val("")
324
+
325
+ element[0].selectionStart = self.mask_function(pure_value)[1]
326
+ element[0].selectionEnd = self.mask_function(pure_value)[1]
327
+
328
+ def onKeyUp(self, event, el):
329
+ element = jQuery(el)
330
+ new_value = element.val()
331
+ pure_value = self.stringFilter(new_value)
332
+ new_value = self.mask_function(pure_value)[0]
333
+ if pure_value is not "":
334
+ element.val(new_value)
335
+ else:
336
+ element.val("")
337
+
338
+ element[0].selectionStart = self.mask_function(pure_value)[1]
339
+ element[0].selectionEnd = self.mask_function(pure_value)[1]
340
+ element.focus()
341
+ element[0].setSelectionRange(self.mask_function(pure_value)[1], self.mask_function(pure_value)[1])
342
+
343
+
344
+ def onNonPrintingKeysIn(self, event, el):
345
+ noprintkeys = [8, 46]
346
+ code = event.keyCode or event.which
347
+ element = jQuery(el)
348
+ if code in noprintkeys:
349
+ if code == 8:
350
+ current_value = element.val()
351
+ if self.stringFilter(current_value) is not "":
352
+ pure_value = self.stringFilter(current_value)
353
+ pure_value = pure_value[0:-1]
354
+ new_value = self.mask_function(pure_value)[0]
355
+ if pure_value is not "":
356
+ element.val(new_value)
357
+ else:
358
+ element.val("")
359
+ element[0].selectionStart = self.mask_function(pure_value)[1]
360
+ element[0].selectionEnd = self.mask_function(pure_value)[1]
361
+ else:
362
+ element.val("")
363
+ elif code == 46:
364
+ current_value = element.val()
365
+ if self.stringFilter(current_value) is not "":
366
+ pos = element[0].selectionStart
367
+ end = element[0].selectionEnd
368
+ if pos == end:
369
+ text0 = current_value[0:pos]
370
+ numbers = [str(x) for x in range(10)]
371
+ if current_value[pos] in numbers:
372
+ text1 = current_value[pos + 1:]
373
+ elif current_value[pos] is not "":
374
+ text1 = current_value[pos + 2:]
375
+
376
+ new_value = "{0}{1}".format(text0, text1)
377
+ element[0].selectionStart = pos
378
+ element[0].selectionEnd = pos
379
+ else:
380
+ text0 = current_value[0: pos]
381
+ text1 = current_value[end:]
382
+ new_value = "{0}{1}".format(text0, text1)
383
+ element[0].selectionStart = pos
384
+ element[0].selectionEnd = pos
385
+ pure_value = self.stringFilter(new_value)
386
+ new_value = self.mask_function(pure_value)[0]
387
+ if pure_value is not "":
388
+ element.val(new_value)
389
+ else:
390
+ element.val("")
391
+ element[0].selectionStart = pos
392
+ element[0].selectionEnd = pos
393
+ else:
394
+ element.val("")
395
+
396
+ event.preventDefault()
397
+
398
+ def onNonPrintingKeys(self, event, el):
399
+ event.preventDefault()
400
+ element = jQuery(el)
401
+ code = event.keyCode or event.which
402
+ noprintkeys = [8, 46, 9]
403
+ if code in noprintkeys:
404
+ value = element.val()
405
+ element.val(value + "_")
406
+ if (self.reverse):
407
+ if (self.stringFilter(value) != ""):
408
+ value = str(int(self.stringFilter(value)))
409
+ new_value = ""
410
+
411
+ pure_value = self.stringFilter(value)
412
+ if pure_value == "":
413
+ element.val("")
414
+ else:
415
+ new_value = self.mask_function(pure_value)[0]
416
+ element.attr("phanterpwa-mask-justnumbers", self.stringFilter(new_value))
417
+ selection_pos = self.mask_function(pure_value)[1]
418
+ element.val(new_value)
419
+ if (self.reverse):
420
+ element[0].selectionStart = -len(new_value)
421
+ element[0].selectionEnd = -len(new_value)
422
+ else:
423
+ element[0].selectionStart = selection_pos
424
+ element[0].selectionEnd = selection_pos
425
+ if(code != 9):
426
+ event.preventDefault()
427
+ else:
428
+ pure_value = self.stringFilter(element.val())
429
+ if pure_value == "":
430
+ element.val("")
431
+
432
+ def onFocusOut(self, event, el):
433
+ element = jQuery(el)
434
+ new_value = element.val()
435
+ pure_value = self.stringFilter(new_value)
436
+ new_value = self.mask_function(pure_value)[0]
437
+ if pure_value is not "":
438
+ element.val(new_value)
439
+ else:
440
+ element.val("")
441
+
442
+
443
+ def start(self):
444
+ element = jQuery(self.target_selector)
445
+ value = element.val()
446
+ pure_value = self.stringFilter(value)
447
+ new_value = self.mask_function(pure_value)[0]
448
+ selection_pos = self.mask_function(pure_value)[1]
449
+
450
+ if(self.apply_on_init):
451
+ element.val(new_value)
452
+ if(self.reverse):
453
+ element[0].selectionStart = -len(new_value)
454
+ element[0].selectionEnd = -len(new_value)
455
+ else:
456
+ element[0].selectionStart = selection_pos
457
+ element[0].selectionEnd = selection_pos
458
+
459
+ element.off(
460
+ "keypress.phanterpwaMask"
461
+ ).on(
462
+ "keypress.phanterpwaMask",
463
+ lambda event: self.onKeyPress(event, this)
464
+ )
465
+ element.off(
466
+ "focusout.phanterpwaMask"
467
+ ).on(
468
+ "focusout.phanterpwaMask",
469
+ lambda event: self.onFocusOut(event, this)
470
+ )
471
+ element.off(
472
+ "keyup.phanterpwaMask2,"
473
+ ).on(
474
+ "keyup.phanterpwaMask2,",
475
+ lambda event: self.onKeyUp(event, this)
476
+ )
477
+ element.off(
478
+ "keydown.phanterpwaMask, focusout.phanterpwaMask"
479
+ ).on(
480
+ "keydown.phanterpwaMask, focusout.phanterpwaMask",
481
+ lambda event: self.onNonPrintingKeysIn(event, this)
482
+ )
483
+
484
+
485
+
486
+ def date_and_datetime_to_maks(value):
487
+ date_format = ["d", "M", "o", "t", "y", "H", "m", "s"]
488
+ string_mask = ""
489
+ if isinstance(value, str):
490
+ for x in value:
491
+ if x in date_format:
492
+ y = "#"
493
+ else:
494
+ y = x
495
+ string_mask += y
496
+ return string_mask
497
+
498
+
499
+ def isNotEmpty(value):
500
+ if ((value is not None) and (value is not "") and (value is not js_undefined)):
501
+ return True
502
+ else:
503
+ return False
504
+
505
+
506
+ def stringFilter(
507
+ value,
508
+ you_want_array=["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]):
509
+ value = str(value)
510
+ new_value = ""
511
+ for x in value:
512
+ if x in you_want_array:
513
+ new_value += x
514
+ return new_value
515
+
516
+
517
+ def hasCaracter(value, caracter="."):
518
+ value = str(value)
519
+ has_caractere = False
520
+ if caracter in value:
521
+ has_caractere = True
522
+ return has_caractere
523
+
524
+
525
+ def justSearchedCaracter(value, caractere="."):
526
+ has_caractere = False
527
+ value = str(value)
528
+ new_value = ""
529
+ for x in value:
530
+ if x == caractere:
531
+ if not has_caractere:
532
+ new_value += x
533
+ has_caractere = True
534
+ else:
535
+ new_value += x
536
+ return new_value
537
+
538
+
539
+ def stringForceToFloatstring(value, force_dot=False, localeBR=True):
540
+ if isNotEmpty(value):
541
+ value = str(value)
542
+ if localeBR:
543
+ value = value.replace(",", ".")
544
+ value = stringFilter(value, ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "."])
545
+ value = justSearchedCaracter(value)
546
+ if (value != ""):
547
+ if (value == "."):
548
+ if (force_dot):
549
+ value = "0."
550
+ else:
551
+ value = ""
552
+ else:
553
+ if not force_dot:
554
+ value = str(float(value))
555
+ return value
556
+ else:
557
+ return ""
558
+
559
+
560
+ def stringToFloatstringLimitDecimals(value, casas_decimais=2, localeBR=True):
561
+ value = str(value)
562
+ if isNotEmpty(value):
563
+ if(localeBR):
564
+ value = value.replace(",", ".")
565
+ value = stringFilter(value, ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "."])
566
+ value = justSearchedCaracter(value)
567
+ if(value != ""):
568
+ value = str(float(value))
569
+ p_inteiro = value.split(".")[0]
570
+ p_decimal = value.split(".")[1]
571
+ if not isNotEmpty(p_decimal):
572
+ p_decimal = "0"
573
+ if len(p_decimal) < casas_decimais:
574
+ np_decimal = ""
575
+ for x in range(casas_decimais - len(p_decimal)):
576
+ np_decimal += "0"
577
+ p_decimal = p_decimal + np_decimal
578
+ else:
579
+ np_decimal = ""
580
+ for i in range(casas_decimais):
581
+ np_decimal += p_decimal[i]
582
+ p_decimal = np_decimal
583
+ r = "{0}.{1}".format(p_inteiro, p_decimal)
584
+ return r
585
+ return value
586
+ else:
587
+ return ""
588
+
589
+
590
+ def floatToCurrency(value, casas_decimais=2, separador_decimal=",", separador_milhar=".", currency=""):
591
+ casas_decimais = casas_decimais
592
+ separador_decimal = separador_decimal
593
+ separador_milhar = separador_milhar
594
+ value = str(value)
595
+ p_m_inteiro = "0"
596
+ p_m_decimal = ""
597
+ for i in range(casas_decimais):
598
+ p_m_decimal += "0"
599
+
600
+ if hasCaracter(value, "."):
601
+ p_inteiro = value.split(".")[0]
602
+ p_decimal = value.split(".")[1]
603
+ if(isNotEmpty(p_inteiro)):
604
+ p_inteiro = p_inteiro.split("").reverse().join("")
605
+ str_inteiro = ""
606
+ tamanho_inteiro = len(p_inteiro)
607
+ adicionar_separador = False
608
+ if (tamanho_inteiro > 3):
609
+ for i in range(tamanho_inteiro):
610
+ if (((i + 1) % 3) == 0):
611
+ str_inteiro += p_inteiro[i]
612
+ adicionar_separador = True
613
+ else:
614
+ if(adicionar_separador):
615
+ adicionar_separador = False
616
+ str_inteiro += separador_milhar + p_inteiro[i]
617
+ else:
618
+ str_inteiro += p_inteiro[i]
619
+ else:
620
+ for i in range(tamanho_inteiro):
621
+ str_inteiro += p_inteiro[i]
622
+ p_m_inteiro = str_inteiro.split("").reverse().join("")
623
+
624
+ if(isNotEmpty(p_decimal)):
625
+ str_cd = ""
626
+ if (p_decimal.length > casas_decimais):
627
+ for i in range(casas_decimais):
628
+ str_cd += p_decimal[i]
629
+ else:
630
+ for i in range(len(p_decimal)):
631
+ str_cd += p_decimal[i]
632
+ diferenca = casas_decimais - len(p_decimal)
633
+ tracos = ""
634
+ for i in range(diferenca):
635
+ tracos += "0"
636
+ str_cd += tracos
637
+ p_m_decimal = str_cd
638
+
639
+ else:
640
+ if value != "":
641
+ t_m_inteiro = int(value)
642
+ if (isNotEmpty(t_m_inteiro)):
643
+ p_m_inteiro = str(t_m_inteiro)
644
+ if(isNotEmpty(currency)):
645
+ r = "{0} {1}{2}{3}".format(currency, p_m_inteiro, separador_decimal, p_m_decimal)
646
+ else:
647
+ r = "{0}{1}{2}".format(p_m_inteiro, separador_decimal, p_m_decimal)
648
+ return r
649
+
650
+
651
+ def baseCustom(value, custom_mask, cursorPosition=0):
652
+ value = str(value)
653
+ size = len(value)
654
+ char_plus = 0
655
+ pos_num = 0
656
+ new_value = ""
657
+ for i in range(len(custom_mask)):
658
+ if (custom_mask[i] == "#"):
659
+ if (pos_num < size):
660
+ new_value += value[pos_num]
661
+ pos_num += 1
662
+ else:
663
+ new_value += "_"
664
+ pos_num += 1
665
+ else:
666
+ if (i < (size + char_plus)):
667
+ char_plus += 1
668
+
669
+ new_value += custom_mask[i]
670
+ if new_value.indexOf("_") > 0:
671
+ cursorPosition = new_value.indexOf("_")
672
+ else:
673
+ cursorPosition = int(size) + char_plus
674
+ return [new_value, cursorPosition]
675
+
676
+
677
+ def maskFone(valor):
678
+ valor = str(valor)
679
+ size = len(valor)
680
+ if (size == 10):
681
+ custom_mask = "(##) ####-####"
682
+ elif (size == 11):
683
+ custom_mask = "(##) # ####-####"
684
+ elif (size > 11):
685
+ custom_mask = "(##) #####-#########"
686
+ else:
687
+ custom_mask = "(##) # ####-####"
688
+ return baseCustom(valor, custom_mask)
689
+
690
+
691
+ def maskCNPJ(valor):
692
+ custom_mask = "##.###.###/####-##"
693
+ return baseCustom(valor, custom_mask)
694
+
695
+
696
+ def maskCPF(valor):
697
+ custom_mask = "###.###.###-##"
698
+ return baseCustom(valor, custom_mask)
699
+
700
+
701
+ def maskDate(valor):
702
+ custom_mask = "##/##/####"
703
+ return baseCustom(valor, custom_mask)
704
+
705
+
706
+ def maskDatetime(valor):
707
+ custom_mask = "##/##/#### ##:##:##"
708
+ return baseCustom(valor, custom_mask)
709
+
710
+
711
+ def maskCEP(valor):
712
+ custom_mask = "##.###-###"
713
+ return baseCustom(valor, custom_mask)
714
+
715
+
716
+ def applyMask(jq_select, maskfunction, reverse=False, apply_on_init=False):
717
+
718
+ def onKeyPress(event, el):
719
+ element = jQuery(el)
720
+ code = event.keyCode or event.which
721
+ noprintkeys = [8, 46, 9]
722
+ if code not in noprintkeys:
723
+ value = element.val()
724
+ if (reverse):
725
+ if (stringFilter(value) != ""):
726
+ value = str(int(stringFilter(value)))
727
+ new_value = ""
728
+
729
+ value = value + String.fromCharCode(code)
730
+ pure_value = stringFilter(value)
731
+ if pure_value == "":
732
+ element.val("")
733
+ else:
734
+ new_value = maskfunction(pure_value)[0]
735
+ element.attr("phanterpwa-mask-justnumbers", stringFilter(new_value))
736
+ selection_pos = maskfunction(pure_value)[1]
737
+ element.val(new_value)
738
+ if (reverse):
739
+ element[0].selectionStart = -len(new_value)
740
+ element[0].selectionEnd = -len(new_value)
741
+ else:
742
+ element[0].selectionStart = selection_pos
743
+ element[0].selectionEnd = selection_pos
744
+ if(code != 9):
745
+ event.preventDefault()
746
+
747
+ def onNonPrintingKeys(event, el):
748
+ element = jQuery(el)
749
+ code = event.keyCode or event.which
750
+ noprintkeys = [8, 46, 9]
751
+ if code in noprintkeys:
752
+ value = element.val()
753
+ if (reverse):
754
+ if (stringFilter(value) != ""):
755
+ value = str(int(stringFilter(value)))
756
+ new_value = ""
757
+
758
+ pure_value = stringFilter(value)
759
+ if pure_value == "":
760
+ element.val("")
761
+ else:
762
+ new_value = maskfunction(pure_value)[0]
763
+ element.attr("phanterpwa-mask-justnumbers", stringFilter(new_value))
764
+ selection_pos = maskfunction(pure_value)[1]
765
+ element.val(new_value)
766
+ if (reverse):
767
+ element[0].selectionStart = -len(new_value)
768
+ element[0].selectionEnd = -len(new_value)
769
+ else:
770
+ element[0].selectionStart = selection_pos
771
+ element[0].selectionEnd = selection_pos
772
+ if(code != 9):
773
+ event.preventDefault()
774
+
775
+ def onEachElement(el):
776
+ element = jQuery(el)
777
+ value = element.val()
778
+ pure_value = stringFilter(value)
779
+ new_value = maskfunction(pure_value)[0]
780
+ selection_pos = maskfunction(pure_value)[1]
781
+
782
+ if(apply_on_init):
783
+ element.val(new_value)
784
+ if(reverse):
785
+ element[0].selectionStart = -len(new_value)
786
+ element[0].selectionEnd = -len(new_value)
787
+ else:
788
+ element[0].selectionStart = selection_pos
789
+ element[0].selectionEnd = selection_pos
790
+
791
+ element.off(
792
+ "keypress.phanterpwaMask, focusout.phanterpwaMask"
793
+ ).on(
794
+ "keypress.phanterpwaMask, focusout.phanterpwaMask",
795
+ lambda event: onKeyPress(event, this)
796
+ )
797
+
798
+ element.off(
799
+ "keyup.phanterpwaMask, focusout.phanterpwaMask"
800
+ ).on(
801
+ "keyup.phanterpwaMask, focusout.phanterpwaMask",
802
+ lambda event: onNonPrintingKeys(event, this)
803
+ )
804
+
805
+ jQuery(jq_select).each(lambda: onEachElement(this))
806
+ return jQuery(jq_select)
807
+
808
+
809
+ def phanterCurrency(
810
+ jq_select,
811
+ v_currency="R$",
812
+ casas_decimais=2,
813
+ separador_decimal=",",
814
+ separador_milhar="."):
815
+ return phanterDecimals(
816
+ jq_select=jq_select,
817
+ v_currency=v_currency,
818
+ casas_decimais=casas_decimais,
819
+ separador_decimal=separador_decimal,
820
+ separador_milhar=separador_milhar)
821
+
822
+
823
+ def phanterDecimals(
824
+ jq_select,
825
+ v_currency="",
826
+ casas_decimais=2,
827
+ separador_decimal=",",
828
+ separador_milhar="."):
829
+ l_currency = v_currency
830
+
831
+ def onKeyPress(event, el):
832
+ element = jQuery(el)
833
+ code = event.keyCode or event.which
834
+ value = element.attr("phantermaskTemp")
835
+ key_value = String.fromCharCode(code)
836
+ if (code == 8):
837
+ if(hasCaracter(value, ".")):
838
+ value = stringToFloatstringLimitDecimals(value, casas_decimais)
839
+ value = stringFilter(value)
840
+ value = value[0:-1]
841
+ elif((code == 46) and event.key == "Delete"):
842
+ value = stringFilter(value)
843
+ value = value[1:]
844
+ else:
845
+ contat_value = "{0}{1}".format(value, key_value)
846
+ if (((key_value == separador_decimal) or (event.key == separador_decimal)) and not hasCaracter(value, ".")):
847
+ value = stringForceToFloatstring(contat_value, True)
848
+ else:
849
+ if (hasCaracter(value, ".")):
850
+ value = stringForceToFloatstring(contat_value, True)
851
+ else:
852
+ value = stringForceToFloatstring(contat_value)
853
+ element.attr("phantermaskTemp", value)
854
+ if not hasCaracter(value, "."):
855
+ if (len(value) >= casas_decimais):
856
+ p_inteiro = value[0: (-1) * casas_decimais]
857
+ if not isNotEmpty(p_inteiro):
858
+ p_inteiro = "0"
859
+ p_decimal = value[(-1) * casas_decimais:]
860
+ value = "{0}.{1}".format(p_inteiro, p_decimal)
861
+ else:
862
+ diferenca = casas_decimais - len(value)
863
+ add_decs = ""
864
+ for i in range(diferenca):
865
+ add_decs += "0"
866
+ p_inteiro = "0"
867
+ value = "{0}.{1}{2}".format(p_inteiro, add_decs, value)
868
+ value = stringToFloatstringLimitDecimals(value, casas_decimais)
869
+ new_value = ""
870
+ if (value == ""):
871
+ qu_decs = ""
872
+ for i in range(casas_decimais):
873
+ qu_decs += "0"
874
+ new_value = "0{0}{1}".format(separador_decimal, qu_decs)
875
+ if(element.prop('TagName') == "INPUT"):
876
+ element.val(
877
+ floatToCurrency(
878
+ stringToFloatstringLimitDecimals(
879
+ new_value,
880
+ casas_decimais
881
+ ),
882
+ casas_decimais,
883
+ separador_decimal,
884
+ separador_milhar,
885
+ l_currency)
886
+ )
887
+ else:
888
+ element.text(
889
+ floatToCurrency(
890
+ stringToFloatstringLimitDecimals(
891
+ new_value,
892
+ casas_decimais
893
+ ),
894
+ casas_decimais,
895
+ separador_decimal,
896
+ separador_milhar,
897
+ l_currency)
898
+ )
899
+ element.attr("phantermaskValue", stringToFloatstringLimitDecimals(new_value, casas_decimais))
900
+ else:
901
+ new_value = value.replace(".", separador_decimal)
902
+ if(element.prop('TagName') == "INPUT"):
903
+ element.val(
904
+ floatToCurrency(
905
+ stringToFloatstringLimitDecimals(
906
+ new_value,
907
+ casas_decimais
908
+ ),
909
+ casas_decimais,
910
+ separador_decimal,
911
+ separador_milhar,
912
+ l_currency)
913
+ )
914
+ else:
915
+ element.text(
916
+ floatToCurrency(
917
+ stringToFloatstringLimitDecimals(
918
+ new_value,
919
+ casas_decimais
920
+ ),
921
+ casas_decimais,
922
+ separador_decimal,
923
+ separador_milhar,
924
+ l_currency)
925
+ )
926
+ element.attr("phantermaskValue", stringToFloatstringLimitDecimals(new_value, casas_decimais))
927
+ element[0].selectionStart = -len(new_value)
928
+ element[0].selectionEnd = -len(new_value)
929
+ if (code != 9):
930
+ event.preventDefault()
931
+
932
+ def onPaste(el):
933
+ setTimeout(
934
+ lambda: jQuery(el).trigger("focusout"),
935
+ 100
936
+ )
937
+
938
+ def onFocusOut(event, el):
939
+ element = jQuery(el)
940
+ value = element.attr("phantermaskValue")
941
+ value = stringToFloatstringLimitDecimals(value, casas_decimais)
942
+ new_value = ""
943
+ if (value == ""):
944
+ qu_decs = ""
945
+ for i in range(casas_decimais):
946
+ qu_decs += "0"
947
+ new_value = "0{0}{1}".format(separador_decimal, qu_decs)
948
+ if(element.prop('TagName') == "INPUT"):
949
+ element.val(floatToCurrency(stringToFloatstringLimitDecimals(
950
+ new_value, casas_decimais), casas_decimais, separador_decimal, separador_milhar, l_currency))
951
+ else:
952
+ element.text(floatToCurrency(stringToFloatstringLimitDecimals(
953
+ new_value, casas_decimais), casas_decimais, separador_decimal, separador_milhar, l_currency))
954
+ element.attr("phantermaskValue", stringToFloatstringLimitDecimals(value, casas_decimais))
955
+ else:
956
+ new_value = value.replace(".", separador_decimal)
957
+ if(element.prop('TagName') == "INPUT"):
958
+ element.val(floatToCurrency(stringToFloatstringLimitDecimals(
959
+ new_value, casas_decimais), casas_decimais, separador_decimal, separador_milhar, l_currency))
960
+ else:
961
+ element.text(floatToCurrency(stringToFloatstringLimitDecimals(
962
+ new_value, casas_decimais), casas_decimais, separador_decimal, separador_milhar, l_currency))
963
+ element.attr("phantermaskValue", stringToFloatstringLimitDecimals(value, casas_decimais))
964
+ element[0].selectionStart = -len(new_value)
965
+ element[0].selectionEnd = -len(new_value)
966
+
967
+ def onEachElement(el):
968
+ l_currency = ""
969
+ if(v_currency != ""):
970
+ l_currency = v_currency
971
+ element = jQuery(el)
972
+ if(element.prop('TagName') == "INPUT"):
973
+ defaults = element.val()
974
+ else:
975
+ defaults = element.text()
976
+ value = stringForceToFloatstring(defaults)
977
+ element.attr("phantermaskTemp", value)
978
+ value = stringToFloatstringLimitDecimals(value, casas_decimais)
979
+ new_value = ""
980
+ if (value == ""):
981
+ qu_decs = ""
982
+ for i in range(casas_decimais):
983
+ qu_decs += "0"
984
+ new_value = "0" + separador_decimal + qu_decs
985
+ if(element.prop('TagName') == "INPUT"):
986
+ element.val(floatToCurrency(stringToFloatstringLimitDecimals(
987
+ new_value, casas_decimais), casas_decimais, separador_decimal, separador_milhar, l_currency))
988
+ else:
989
+ element.text(floatToCurrency(stringToFloatstringLimitDecimals(
990
+ new_value, casas_decimais), casas_decimais, separador_decimal, separador_milhar, l_currency))
991
+ element.attr("phantermaskValue", stringToFloatstringLimitDecimals(value, casas_decimais))
992
+ else:
993
+ new_value = value.replace(".", separador_decimal)
994
+ if(element.prop('TagName') == "INPUT"):
995
+ element.val(floatToCurrency(stringToFloatstringLimitDecimals(
996
+ new_value, casas_decimais), casas_decimais, separador_decimal, separador_milhar, l_currency))
997
+ else:
998
+ element.text(floatToCurrency(stringToFloatstringLimitDecimals(
999
+ new_value, casas_decimais), casas_decimais, separador_decimal, separador_milhar, l_currency))
1000
+ element.attr("phantermaskValue", stringToFloatstringLimitDecimals(value, casas_decimais))
1001
+ element[0].selectionStart = -len(new_value)
1002
+ element[0].selectionEnd = -len(new_value)
1003
+ element.off(
1004
+ 'keypress.phanterpwaMask'
1005
+ ).on(
1006
+ 'keypress.phanterpwaMask',
1007
+ lambda event: onKeyPress(event, this)
1008
+ ).off(
1009
+ "paste.phanterpwaMask, focusin.phanterpwaMask"
1010
+ ).on(
1011
+ "paste.phanterpwaMask, focusin.phanterpwaMask",
1012
+ lambda: onFocusOut(this)
1013
+ ).off(
1014
+ 'focusout.phanterpwaMask'
1015
+ ).on(
1016
+ 'focusout.phanterpwaMask',
1017
+ lambda event: onFocusOut(event, this)
1018
+ )
1019
+ jq_select.each(lambda: onEachElement(this))
1020
+ return jQuery(jq_select)
1021
+
1022
+
1023
+ def phanterpwaMask(mask, parameters, el):
1024
+ custom_mask = ""
1025
+ casas_decimais = 2
1026
+ separador_decimal = ","
1027
+ separador_milhar = "."
1028
+ currency = "R$"
1029
+ reverse = False
1030
+ value = ""
1031
+ apply_on_init = False
1032
+ date_format = "%d/%m/%Y"
1033
+ datetime_format = "%d/%m/%Y %H:%M:%S"
1034
+ if (isNotEmpty(parameters)):
1035
+ if ("mask" in parameters):
1036
+ custom_mask = parameters['mask']
1037
+ if ("casas_decimais" in parameters):
1038
+ casas_decimais = int(parameters['casas_decimais'])
1039
+ if ("separador_decimal" in parameters):
1040
+ separador_decimal = str(parameters['separador_decimal'])
1041
+ if ("separador_milhar" in parameters):
1042
+ separador_milhar = str(parameters['separador_milhar'])
1043
+ if ("currency" in parameters):
1044
+ currency = str(parameters['currency'])
1045
+ if ("value" in parameters):
1046
+ jQuery(el).val(parameters['value'])
1047
+ if ("date_format" in parameters):
1048
+ date_format = parameters['date_format']
1049
+ if ("datetime_format" in parameters):
1050
+ datetime_format = parameters['datetime_format']
1051
+ if ("apply_on_init" in parameters):
1052
+ apply_on_init = parameters['apply_on_init']
1053
+ jQuery(el).removeClass("masked_input")
1054
+ if (mask == "fone"):
1055
+ jQuery(el).addClass("masked_input")
1056
+ applyMask(el, maskFone, reverse, apply_on_init)
1057
+ elif(mask == "cnpj"):
1058
+ jQuery(el).addClass("masked_input")
1059
+ applyMask(el, maskCNPJ, reverse, apply_on_init)
1060
+ elif(mask == "cpf"):
1061
+ jQuery(el).addClass("masked_input")
1062
+ applyMask(el, maskCPF, reverse, apply_on_init)
1063
+ elif(mask == "date"):
1064
+ jQuery(
1065
+ el
1066
+ ).off(
1067
+ 'click.phanterpwaMaskdata focusin.phanterpwaMaskdata'
1068
+ ).on(
1069
+ 'click.phanterpwaMaskdata focusin.phanterpwaMaskdata',
1070
+ console.info("future")
1071
+ )
1072
+ applyMask(el, maskDate, reverse, apply_on_init)
1073
+ elif(mask == "datetime"):
1074
+ jQuery(
1075
+ el
1076
+ ).off(
1077
+ 'click.phanterpwaMaskdatahora focusin.phanterpwaMaskdatahora'
1078
+ ).on(
1079
+ 'click.phanterpwaMaskdatahora focusin.phanterpwaMaskdatahora',
1080
+ console.info("future")
1081
+ )
1082
+ applyMask(el, maskDatetime, reverse, apply_on_init)
1083
+ elif(mask == "cep"):
1084
+ jQuery(el).addClass("masked_input")
1085
+ applyMask(el, maskCEP, reverse, apply_on_init)
1086
+ elif(mask == "real"):
1087
+ jQuery(el).addClass("masked_input")
1088
+ phanterCurrency(el,
1089
+ v_currency=currency,
1090
+ casas_decimais=casas_decimais,
1091
+ separador_decimal=separador_decimal,
1092
+ separador_milhar=separador_milhar)
1093
+ elif(mask == "decimal"):
1094
+ jQuery(el).addClass("masked_input")
1095
+ phanterDecimals(el,
1096
+ v_currency="",
1097
+ casas_decimais=casas_decimais,
1098
+ separador_decimal=separador_decimal,
1099
+ separador_milhar=separador_milhar)
1100
+ elif(mask == "off"):
1101
+ jQuery(
1102
+ el
1103
+ ).removeClass(
1104
+ "masked_input"
1105
+ ).off(
1106
+ "keypress.phanterpwaMask focusout.phanterpwaMask focusin.phanterpwaMask"
1107
+ )
1108
+ elif(mask == "custom"):
1109
+ jQuery(el).addClass("masked_input")
1110
+ applyMask(el, lambda v: baseCustom(v, parameters['mask']), reverse, apply_on_init)
1111
+ return jQuery(el)
1112
+
1113
+ __pragma__('nokwargs')