1var _____WB$wombat$assign$function_____=function(name){return (self._wb_wombat && self._wb_wombat.local_init && self._wb_wombat.local_init(name))||self[name];};if(!self.__WB_pmw){self.__WB_pmw=function(obj){this.__WB_source=obj;return this;}}{ 2let window = _____WB$wombat$assign$function_____("window"); 3let self = _____WB$wombat$assign$function_____("self"); 4let document = _____WB$wombat$assign$function_____("document"); 5let location = _____WB$wombat$assign$function_____("location"); 6let top = _____WB$wombat$assign$function_____("top"); 7let parent = _____WB$wombat$assign$function_____("parent"); 8let frames = _____WB$wombat$assign$function_____("frames"); 9let opens = _____WB$wombat$assign$function_____("opens"); 10jQuery( document ).ready(function() { 11 var heightToAdd = jQuery(".pbuilder_row_stick_top").height(); 12 heightToAdd = heightToAdd-28; 13 jQuery('.stick-top-div').css('height', heightToAdd+'px'); 14}); 15(function ($) { 16 /* 17 Validation Singleton 18 */ 19 var Validation = function () { 20 21 var rules = { 22 email: { 23 check: function (value, default_value) { 24 if (value !== default_value) 25 return testPattern(value, "[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])"); 26 return true; 27 }, 28 msg: "Enter a valid e-mail address." 29 }, 30 url: { 31 check: function (value, default_value) { 32 33 if (value !== default_value) 34 return testPattern(value, "^https?://(.+\.)+.{2,4}(/.*)?$"); 35 return true; 36 }, 37 msg: "Enter a valid URL." 38 }, 39 checkbox: { 40 check: function (value, default_value, checked) { 41 if (checked == 'checked') 42 return true; 43 }, 44 msg: "You need to check the box." 45 }, 46 required: { 47 check: function (value, default_value) { 48 if (value !== default_value) 49 return true; 50 else 51 return false; 52 }, 53 msg: "This field is required." 54 } 55 } 56 var testPattern = function (value, pattern) { 57 58 var regExp = new RegExp(pattern, ""); 59 return regExp.test(value); 60 } 61 return { 62 addRule: function (name, rule) { 63 64 rules[name] = rule; 65 }, 66 getRule: function (name) { 67 68 return rules[name]; 69 } 70 } 71 } 72 73 /* 74 Form factory 75 */ 76 var Form = function (form) { 77 78 var fields = []; 79 80 form.find("[validation]").each(function () { 81 var field = $(this); 82 83 if (field.attr('validation') !== undefined) { 84 fields.push(new Field(field)); 85 } 86 }); 87 this.fields = fields; 88 } 89 Form.prototype = { 90 validate: function () { 91 92 for (field in this.fields) { 93 if(field != "remove"){ 94 this.fields[field].validate(); 95 } 96 } 97 }, 98 isValid: function () { 99 100 for (field in this.fields) { 101 102 if(field != "remove"){ 103 if (!this.fields[field].valid) { 104 this.fields[field].field.focus(); 105 return false; 106 } 107 } 108 } 109 return true; 110 } 111 } 112 113 /* 114 Field factory 115 */ 116 var Field = function (field) { 117 118 this.field = field; 119 this.valid = false; 120 this.attach("change"); 121 } 122 Field.prototype = { 123 attach: function (event) { 124 125 var obj = this; 126 if (event == "change") { 127 obj.field.bind("change", function () { 128 return obj.validate(); 129 }); 130 } 131 if (event == "keyup") { 132 obj.field.bind("keyup", function (e) { 133 return obj.validate(); 134 }); 135 } 136 }, 137 validate: function () { 138 139 var obj = this, 140 field = obj.field, 141 errorClass = "errorlist", 142 errorlist = $(document.createElement("ul")).addClass(errorClass), 143 types = field.attr("validation").split(" "), 144 container = field.parent(), 145 errors = []; 146 147 field.next(".errorlist").remove(); 148 149 for (var type in types) { 150 if (type != "remove") { 151 console.log('Validate '+field.attr('name')); 152 var rule = $.Validation.getRule(types[type]); 153 if (!rule.check(field.val(), field.attr('default-value'), field.attr('checked'))) { 154 container.addClass("error"); 155 156 errors.push(field.attr('error-message')); 157 container.css("margin", ''); 158 field.css("border-color", 'red !important;'); 159 160 } 161 } 162 } 163 if (errors.length) {
164 obj.field.unbind("keyup") 165 obj.attach("keyup"); 166 field.after(errorlist.empty()); 167 168 for (error in errors) { 169 if(error != "remove"){ 170 errorlist.append("<li>" + errors[error].toString() + "</li>"); 171 } 172 } 173 obj.valid = false; 174 } 175 else { 176 errorlist.remove(); 177 container.removeClass("error"); 178 obj.valid = true; 179 } 180 } 181 } 182 183 /* 184 Validation extends jQuery prototype 185 */ 186 $.extend($.fn, { 187 validation: function () { 188 189 var validator = new Form($(this)); 190 $.data($(this)[0], 'validator', validator); 191 192 $(this).bind("submit", function (e) { 193 validator.validate(); 194 if (!validator.isValid()) { 195 e.preventDefault(); 196 } 197 }); 198 }, 199 validate: function (form) { 200 201 var validator = new Form(form); 202 $.data(form, 'validator', validator); 203 validator.validate(); 204 return validator.isValid(); 205 206 } 207 }); 208 $.Validation = new Validation(); 209})(jQuery); 210 211}
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.