PageSourceSearch

https://atar-almadinah.com/js/forms.js

js atar-almadinah.com collected 2026-10-04 00:19:19 UTC 5,592 bytes, 187 lines download raw bytes

1//forms
2;(function($){
3	$.fn.forms=function(o){
4		return this.each(function(){
5			var th=$(this)
6				,_=th.data('forms')||{
7					errorCl:'error',
8					emptyCl:'empty',
9					invalidCl:'invalid',
10					notRequiredCl:'notRequired',
11					successCl:'success',
12					successShow:'4000',
13					mailHandlerURL:'bat/MailHandler.php',
14					ownerEmail:'[email protected]',
15					stripHTML:true,
16					smtpMailServer:'localhost',
17					targets:'input,textarea',
18					controls:'a[data-type=reset],a[data-type=submit]',
19					validate:true,
20					rx:{
21						".name":{rx:/^[a-zA-Z'][a-zA-Z-' ]+[a-zA-Z']?$/,target:'input'},
22						".state":{rx:/^[a-zA-Z'][a-zA-Z-' ]+[a-zA-Z']?$/,target:'input'},
23						".email":{rx:/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i,target:'input'},
24						".phone":{rx:/^\+?(\d[\d\-\+\(\) ]{5,}\d$)/,target:'input'},
25						".fax":{rx:/^\+?(\d[\d\-\+\(\) ]{5,}\d$)/,target:'input'},
26						".message":{rx:/.{20}/,target:'textarea'}
27					},
28					preFu:function(){
29						_.labels.each(function(){
30							var label=$(this),
31								inp=$(_.targets,this),
32								defVal=inp.val(),
33								trueVal=(function(){
34											var tmp=inp.is('input')?(tmp=label.html().match(/value=['"](.+?)['"].+/),!!tmp&&!!tmp[1]&&tmp[1]):inp.html()
35											return defVal==''?defVal:tmp
36										})()
37							trueVal!=defVal
38								&&inp.val(defVal=trueVal||defVal)
39							label.data({defVal:defVal})								
40							inp
41								.bind('focus',function(){
42									inp.val()==defVal
43										&&(inp.val(''),_.hideEmptyFu(label),label.removeClass(_.invalidCl))
44								})
45								.bind('blur',function(){
46									_.validateFu(label)
47									if(_.isEmpty(label))
48										inp.val(defVal)
49										,_.hideErrorFu(label.removeClass(_.invalidCl))											
50								})
51								.bind('keyup',function(){
52									label.hasClass(_.invalidCl)
53										&&_.validateFu(label)
54								})
55							label.find('.'+_.errorCl+',.'+_.emptyCl).css({display:'block'}).hide()
56						})
57						_.success=$('.'+_.successCl,_.form).hide()
58					},
59					isRequired:function(el){							
60						return !el.hasClass(_.notRequiredCl)
61					},
62					isValid:function(el){							
63						var ret=true
64						$.each(_.rx,function(k,d){
65							if(el.is(k))
66								ret=d.rx.test(el.find(d.target).val())										
67						})
68						return ret							
69					},
70					isEmpty:function(el){
71						var tmp
72						return (tmp=el.find(_.targets).val())==''||tmp==el.data('defVal')
73					},
74					validateFu:function(el){							
75						el.each(function(){
76							var th=$(this)
77								,req=_.isRequired(th)
78								,empty=_.isEmpty(th)
79								,valid=_.isValid(th)								
80							
81							if(empty&&req)
82								_.showEmptyFu(th.addClass(_.invalidCl))
83							else
84								_.hideEmptyFu(th.removeClass(_.invalidCl))
85							
86							if(!empty)
87								if(valid)
88									_.hideErrorFu(th.removeClass(_.invalidCl))
89								else
90									_.showErrorFu(th.addClass(_.invalidCl))								
91						})
92					},
93					getValFromLabel:function(label){
94						var val=$('input,textarea',label).val()
95							,defVal=label.data('defVal')								
96						return label.length?val==defVal?'nope':val:'nope'
97					}
98					,submitFu:function(){
99						_.validateFu(_.labels)							
100						if(!_.form.has('.'+_.invalidCl).length)
101							$.ajax({
102								type: "POST",
103								url:_.mailHandlerURL,
104								data:{
105									name:_.getValFromLabel($('.name',_.form)),
106									email:_.getValFromLabel($('.email',_.form)),
107									phone:_.getValFromLabel($('.phone',_.form)),
108									fax:_.getValFromLabel($('.fax',_.form)),
109									state:_.getValFromLabel($('.state',_.form)),
110									message:_.getValFromLabel($('.message',_.form)),
111									owner_email:_.ownerEmail,
112									stripHTML:_.stripHTML
113								},
114								success: function(){
115									_.showFu()
116								}
117							})			
118					},
119					showFu:function(){
120						_.success.slideDown(function(){
121							setTimeout(function(){
122								_.success.slideUp()
123								_.form.trigger('reset')
124							},_.successShow)
125						})
126					},
127					controlsFu:function(){
128						$(_.controls,_.form).each(function(){
129							var th=$(this)
130							th
131								.bind('click',function(){
132									_.form.trigger(th.data('type'))
133									return false
134								})
135						})
136					},
137					showErrorFu:function(label){
138						label.find('.'+_.errorCl).slideDown()
139					},
140					hideErrorFu:function(label){
141						label.find('.'+_.errorCl).slideUp()
142					},
143					showEmptyFu:function(label){
144						label.find('.'+_.emptyCl).slideDown()
145						_.hideErrorFu(label)
146					},
147					hideEmptyFu:function(label){
148						label.find('.'+_.emptyCl).slideUp()
149					},
150					init:function(){
151						_.form=_.me						
152						_.labels=$('label',_.form)
153
154						_.preFu()
155						
156						_.controlsFu()
157														
158						_.form
159							.bind('submit',function(){
160								if(_.validate)
161									_.submitFu()
162								else
163									_.form[0].submit()
164								return false
165							})
166							.bind('reset',function(){
167								_.labels.removeClass(_.invalidCl)									
168								_.labels.each(function(){
169									var th=$(this)
170									_.hideErrorFu(th)
171									_.hideEmptyFu(th)
172								})
173							})
174						_.form.trigger('reset')
175					}
176				}
177			_.me||_.init(_.me=th.data({forms:_}))
178			typeof o=='object'
179				&&$.extend(_,o)
180		})
181	}
182})(jQuery)
183$(window).load(function(){ 	
184			 $('#contact-form').forms({
185 	     ownerEmail:'#'
186 	     })
187   })

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.