PageSourceSearch

https://www.dalitsotrust.org/zenvalidator/javascript/zenvalidator.js?m=1411636179

js dalitsotrust.org collected 2026-10-04 02:10:56 UTC 4,101 bytes, 185 lines download raw bytes

1(function($) {
2	$.entwine('ss.zenvalidator', function($) {
3		$('form.parsley').parsley();
4		$.listen('parsley:field:validate', function(field) {
5			var $el = field.$element;
6			if ( $el.hasClass('ignore-validation') || !$el.is( ':visible' ) ) {
7				return true;
8			}
9			return false;
10		});
11
12		$('.field').entwine({
13
14			getFormField: function() {
15				return this.find('[name='+this.getFieldName()+']');
16			},
17
18			getFieldName: function() {
19				return this.attr('id');
20			},
21
22			getFieldValue: function() {
23				return this.getFormField().val();
24			},
25
26			evaluateEqualTo: function(val) {
27				return this.getFieldValue() === val;
28			},
29
30			evaluateNotEqualTo: function(val) {
31				return this.getFieldValue() !== val;
32			},
33
34			evaluateLessThan: function(val) {
35				num = parseFloat(val);
36				return this.getFieldValue() < num;
37			},
38
39			evaluateGreaterThan: function(val) {
40				num = parseFloat(val);
41				return parseFloat(this.getFieldValue()) > num;
42			},
43
44			evaluateContains: function(val) {
45				return this.getFieldValue().match(val) !== null;
46			},
47
48			evaluateEmpty: function() {
49				return $.trim(this.getFieldValue()).length === 0;
50			},
51
52			evaluateNotEmpty: function() {
53				return !this.evaluateEmpty();
54			},
55
56			evaluateChecked: function() {
57				return this.getFormField().is(":checked");
58			}
59
60
61		});
62
63
64		$('.field.validation-logic').entwine({
65			onmatch: function () {
66				masters = this.getMasters();			
67				for(m in masters) {
68					this.closest('form').find('#'+masters[m]).addClass("validation-logic-master");				
69				}
70			},
71
72			getLogic: function() {
73				return $.trim(this.getFormField().data('validation-logic-eval'));
74			},
75
76			parseLogic: function() {
77				js = this.getLogic();
78				result = eval(js);			
79				return result;
80			},
81
82			getMasters: function() {
83				return this.getFormField().data('validation-logic-masters').split(",");
84			}
85
86		});
87
88
89		$('.field.optionset').entwine({
90
91			getFormField: function() {
92				f = this._super().filter(":checked");			
93				return f;
94			}
95
96		});
97
98
99		$('.field.optionset.checkboxset').entwine({
100
101			evaluateHasCheckedOption: function(val) {
102				this.find(':checkbox').filter(':checked').each(function() {
103					return $(this).val() === val || $(this).getLabel() === val;
104				})
105			},
106
107			evaluateHasCheckedAtLeast: function(num) {
108				return this.find(':checked').length >= num;
109			},
110
111			evaluateHasCheckedLessThan: function(num) {
112				return this.find(':checked').length <= num;	
113			}
114		});
115
116		$('.field input[type=checkbox]').entwine({
117			getLabel: function() {
118				return this.closest('form').find('label[for='+this.attr('id')+']');
119			}
120		});
121
122		$('.field.validation-logic.validation-logic-validate').entwine({
123			testLogic: function() {
124				this.getFormField().toggleClass('ignore-validation', this.parseLogic());
125			}
126		});
127
128
129		$('.field.validation-logic.validation-logic-exclude').entwine({
130			testLogic: function() {
131				this.getFormField().toggleClass('ignore-validation', !this.parseLogic());
132			}
133		});
134
135		$('.field.validation-logic-master :text, .field.validation-logic-master select').entwine({
136			onmatch: function() {
137				this.closest(".field").notify();
138			},
139
140			onchange: function() {
141				this.closest(".field").notify();
142			}
143		});
144
145		$('.field.validation-logic-master :checkbox, .field.validation-logic-master :radio').entwine({
146			onmatch: function() {			
147				this.closest(".field").notify();
148			},
149
150			onclick: function() {			
151				this.closest(".field").notify();
152			}
153		});
154
155		$('.field.validation-logic-master').entwine({
156			Listeners: null,
157
158			notify: function() {
159				$.each(this.getListeners(), function() {				
160					$(this).testLogic();
161				});
162			},
163
164			getListeners: function() {
165				if(l = this._super()) {
166					return l;
167				}
168				var self = this;
169				var listeners = [];
170				this.closest("form").find('.validation-logic').each(function() {
171					masters = $(this).getMasters();
172					for(m in masters) {
173						if(masters[m] == self.attr('id')) {
174							listeners.push($(this));
175							break;
176						}
177					}
178				});
179				this.setListeners(listeners);
180				return this.getListeners();
181			}
182		});
183	});	
184
185})(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.