~canonical-sysadmins/wordpress/3.9.x

« back to all changes in this revision

Viewing changes to wp-includes/js/tinymce/utils/validate.js

  • Committer: Paul Collins
  • Date: 2011-07-13 02:31:10 UTC
  • Revision ID: paul.collins@canonical.com-20110713023110-rvp7cjj31rsaomkr
import Wordpress 3.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
        },
33
33
 
34
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
38
        isId : function(s) {
96
96
                var i, nl, s = this.settings, c = 0;
97
97
 
98
98
                nl = this.tags(f, 'label');
99
 
                for (i=0; i<nl.length; i++)
 
99
                for (i=0; i<nl.length; i++) {
100
100
                        this.removeClass(nl[i], s.invalid_cls);
 
101
                        nl[i].setAttribute('aria-invalid', false);
 
102
                }
101
103
 
102
104
                c += this.validateElms(f, 'input');
103
105
                c += this.validateElms(f, 'select');
109
111
        invalidate : function(n) {
110
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
142
        reset : function(e) {
114
143
                var t = ['label', 'input', 'select', 'textarea'];
119
148
 
120
149
                for (i=0; i<t.length; i++) {
121
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
152
                                this.removeClass(nl[j], s.invalid_cls);
 
153
                                nl[j].setAttribute('aria-invalid', false);
 
154
                        }
124
155
                }
125
156
        },
126
157
 
201
232
                var s = this.settings;
202
233
 
203
234
                this.addClass(n, s.invalid_cls);
 
235
                n.setAttribute('aria-invalid', 'true');
204
236
                this.markLabels(f, n, s.invalid_cls);
205
237
 
206
238
                return false;