Revision 5341,
1.5 KB
checked in by wmerlotto, 13 years ago
(diff) |
Ticket #2434 - Commit inicial do novo módulo de agenda do Expresso - expressoCalendar
|
Line | |
---|
1 | (function($){
|
---|
2 |
|
---|
3 | $.fn.alphanumeric = function(p) {
|
---|
4 |
|
---|
5 | p = $.extend({
|
---|
6 | ichars: "!@#$%^&*()+=[]\\\';,/{}|\":<>?~`.- ",
|
---|
7 | nchars: "",
|
---|
8 | allow: ""
|
---|
9 | }, p);
|
---|
10 |
|
---|
11 | return this.each
|
---|
12 | (
|
---|
13 | function()
|
---|
14 | {
|
---|
15 |
|
---|
16 | if (p.nocaps) p.nchars += "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
---|
17 | if (p.allcaps) p.nchars += "abcdefghijklmnopqrstuvwxyz";
|
---|
18 |
|
---|
19 | s = p.allow.split('');
|
---|
20 | for ( i=0;i<s.length;i++) if (p.ichars.indexOf(s[i]) != -1) s[i] = "\\" + s[i];
|
---|
21 | p.allow = s.join('|');
|
---|
22 |
|
---|
23 | var reg = new RegExp(p.allow,'gi');
|
---|
24 | var ch = p.ichars + p.nchars;
|
---|
25 | ch = ch.replace(reg,'');
|
---|
26 |
|
---|
27 | $(this).keypress
|
---|
28 | (
|
---|
29 | function (e)
|
---|
30 | {
|
---|
31 |
|
---|
32 | if (!e.charCode) k = String.fromCharCode(e.which);
|
---|
33 | else k = String.fromCharCode(e.charCode);
|
---|
34 |
|
---|
35 | if (ch.indexOf(k) != -1) e.preventDefault();
|
---|
36 | if (e.ctrlKey&&k=='v') e.preventDefault();
|
---|
37 |
|
---|
38 | }
|
---|
39 |
|
---|
40 | );
|
---|
41 |
|
---|
42 | $(this).bind('contextmenu',function () {return false});
|
---|
43 |
|
---|
44 | }
|
---|
45 | );
|
---|
46 |
|
---|
47 | };
|
---|
48 |
|
---|
49 | $.fn.numeric = function(p) {
|
---|
50 |
|
---|
51 | var az = "abcdefghijklmnopqrstuvwxyz";
|
---|
52 | az += az.toUpperCase();
|
---|
53 |
|
---|
54 | p = $.extend({
|
---|
55 | nchars: az
|
---|
56 | }, p);
|
---|
57 |
|
---|
58 | return this.each (function()
|
---|
59 | {
|
---|
60 | $(this).alphanumeric(p);
|
---|
61 | }
|
---|
62 | );
|
---|
63 |
|
---|
64 | };
|
---|
65 |
|
---|
66 | $.fn.alpha = function(p) {
|
---|
67 |
|
---|
68 | var nm = "1234567890";
|
---|
69 |
|
---|
70 | p = $.extend({
|
---|
71 | nchars: nm
|
---|
72 | }, p);
|
---|
73 |
|
---|
74 | return this.each (function()
|
---|
75 | {
|
---|
76 | $(this).alphanumeric(p);
|
---|
77 | }
|
---|
78 | );
|
---|
79 |
|
---|
80 | };
|
---|
81 |
|
---|
82 | })(jQuery);
|
---|
Note: See
TracBrowser
for help on using the repository browser.