Mercurial > public > sg101
comparison static/js/tiny_mce/utils/validate.js @ 442:6c182ceb7147
Fixing #217; upgrade TinyMCE to 3.4.2 and enable the paste plugin.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Thu, 26 May 2011 00:43:49 +0000 |
parents | 88b2b9cb8c1f |
children |
comparison
equal
deleted
inserted
replaced
441:33d0c55e57a9 | 442:6c182ceb7147 |
---|---|
30 isAbsUrl : function(s) { | 30 isAbsUrl : function(s) { |
31 return this.test(s, '^(news|telnet|nttp|file|http|ftp|https)://[-A-Za-z0-9\\.]+\\/?.*$'); | 31 return this.test(s, '^(news|telnet|nttp|file|http|ftp|https)://[-A-Za-z0-9\\.]+\\/?.*$'); |
32 }, | 32 }, |
33 | 33 |
34 isSize : function(s) { | 34 isSize : function(s) { |
35 return this.test(s, '^[0-9]+(%|in|cm|mm|em|ex|pt|pc|px)?$'); | 35 return this.test(s, '^[0-9.]+(%|in|cm|mm|em|ex|pt|pc|px)?$'); |
36 }, | 36 }, |
37 | 37 |
38 isId : function(s) { | 38 isId : function(s) { |
39 return this.test(s, '^[A-Za-z_]([A-Za-z0-9_])*$'); | 39 return this.test(s, '^[A-Za-z_]([A-Za-z0-9_])*$'); |
40 }, | 40 }, |
94 | 94 |
95 validate : function(f) { | 95 validate : function(f) { |
96 var i, nl, s = this.settings, c = 0; | 96 var i, nl, s = this.settings, c = 0; |
97 | 97 |
98 nl = this.tags(f, 'label'); | 98 nl = this.tags(f, 'label'); |
99 for (i=0; i<nl.length; i++) | 99 for (i=0; i<nl.length; i++) { |
100 this.removeClass(nl[i], s.invalid_cls); | 100 this.removeClass(nl[i], s.invalid_cls); |
101 nl[i].setAttribute('aria-invalid', false); | |
102 } | |
101 | 103 |
102 c += this.validateElms(f, 'input'); | 104 c += this.validateElms(f, 'input'); |
103 c += this.validateElms(f, 'select'); | 105 c += this.validateElms(f, 'select'); |
104 c += this.validateElms(f, 'textarea'); | 106 c += this.validateElms(f, 'textarea'); |
105 | 107 |
107 }, | 109 }, |
108 | 110 |
109 invalidate : function(n) { | 111 invalidate : function(n) { |
110 this.mark(n.form, n); | 112 this.mark(n.form, n); |
111 }, | 113 }, |
114 | |
115 getErrorMessages : function(f) { | |
116 var nl, i, s = this.settings, field, msg, values, messages = [], ed = tinyMCEPopup.editor; | |
117 nl = this.tags(f, "label"); | |
118 for (i=0; i<nl.length; i++) { | |
119 if (this.hasClass(nl[i], s.invalid_cls)) { | |
120 field = document.getElementById(nl[i].getAttribute("for")); | |
121 values = { field: nl[i].textContent }; | |
122 if (this.hasClass(field, s.min_cls, true)) { | |
123 message = ed.getLang('invalid_data_min'); | |
124 values.min = this.getNum(field, s.min_cls); | |
125 } else if (this.hasClass(field, s.number_cls)) { | |
126 message = ed.getLang('invalid_data_number'); | |
127 } else if (this.hasClass(field, s.size_cls)) { | |
128 message = ed.getLang('invalid_data_size'); | |
129 } else { | |
130 message = ed.getLang('invalid_data'); | |
131 } | |
132 | |
133 message = message.replace(/{\#([^}]+)\}/g, function(a, b) { | |
134 return values[b] || '{#' + b + '}'; | |
135 }); | |
136 messages.push(message); | |
137 } | |
138 } | |
139 return messages; | |
140 }, | |
112 | 141 |
113 reset : function(e) { | 142 reset : function(e) { |
114 var t = ['label', 'input', 'select', 'textarea']; | 143 var t = ['label', 'input', 'select', 'textarea']; |
115 var i, j, nl, s = this.settings; | 144 var i, j, nl, s = this.settings; |
116 | 145 |
117 if (e == null) | 146 if (e == null) |
118 return; | 147 return; |
119 | 148 |
120 for (i=0; i<t.length; i++) { | 149 for (i=0; i<t.length; i++) { |
121 nl = this.tags(e.form ? e.form : e, t[i]); | 150 nl = this.tags(e.form ? e.form : e, t[i]); |
122 for (j=0; j<nl.length; j++) | 151 for (j=0; j<nl.length; j++) { |
123 this.removeClass(nl[j], s.invalid_cls); | 152 this.removeClass(nl[j], s.invalid_cls); |
153 nl[j].setAttribute('aria-invalid', false); | |
154 } | |
124 } | 155 } |
125 }, | 156 }, |
126 | 157 |
127 validateElms : function(f, e) { | 158 validateElms : function(f, e) { |
128 var nl, i, n, s = this.settings, st = true, va = Validator, v; | 159 var nl, i, n, s = this.settings, st = true, va = Validator, v; |
199 | 230 |
200 mark : function(f, n) { | 231 mark : function(f, n) { |
201 var s = this.settings; | 232 var s = this.settings; |
202 | 233 |
203 this.addClass(n, s.invalid_cls); | 234 this.addClass(n, s.invalid_cls); |
235 n.setAttribute('aria-invalid', 'true'); | |
204 this.markLabels(f, n, s.invalid_cls); | 236 this.markLabels(f, n, s.invalid_cls); |
205 | 237 |
206 return false; | 238 return false; |
207 }, | 239 }, |
208 | 240 |