PageSourceSearch

https://www.aflath.org.sa/_core/_website/resources/@setup.js?v=1.63.1

js aflath.org.sa collected 2026-09-24 11:59:06 UTC 18,430 bytes, 618 lines download raw bytes

1//Form Validation Configuration
2var errors = [];
3
4var validationLanguage = {
5	errorTitle: "خطأ في البيانات المدخلة",
6	requiredFields: "لم تقم بإدخال كافة البيانات المطلوبة",
7	badEmail: "لم تقم بإدخال البريد الإلكتروني بشكل صحيح"
8};
9
10var validationConfiguration = {
11	validateOnBlur: false,
12	errorMessagePosition: "top",
13	scrollToTopOnError: false,
14	validateHiddenInputs: true,
15	language: validationLanguage,
16	onElementValidate: function(valid, $el, $form, errorMess){
17		if (!valid){ errors.push({el: $el, error: errorMess}); }
18	}
19};
20
21//Validate Mime
22$.formUtils.addValidator({
23	name: "validateMime",
24	validatorFunction: function(value, $el, config, language, $form){
25		if ($el[0].files.length){
26			var allowedMimes = $el.attr("allowed-mimes").split(",");
27			return allowedMimes.includes($el[0].files[0].type);
28		} else {
29			return ($el.attr("data-mandatory") ? false : true);
30		}
31	},
32	errorMessage: "لم تقم بإدخال كافة البيانات المطلوبة"
33});
34
35//Validate Attachments
36$.formUtils.addValidator({
37	name: "validateAttachments",
38	validatorFunction: function(value, $el, config, language, $form){
39		var target = $("[data-attachments=" + $el.attr("name") + "]").find("ul li");
40		return (target.length ? true : false);
41	},
42	errorMessage: "لم تقم بإدخال كافة البيانات المطلوبة"
43});
44
45//Required If Visible
46$.formUtils.addValidator({
47	name: "requiredVisible",
48	validatorFunction: function(value, $el, config, language, $form){
49		if ($el.is(":visible") && !value){
50			return false;
51		} else {
52			return true;
53		}
54	},
55	errorMessage: "لم تقم بإدخال كافة البيانات المطلوبة"
56});
57
58//Required If Parent Table Row is Visible [Used for Select2 Search]
59$.formUtils.addValidator({
60	name: "requiredParentVisible",
61	validatorFunction: function(value, $el, config, language, $form){
62		if ($el.parents("tr").is(":visible") && (!value || value==0)){
63			return false;
64		} else {
65			return true;
66		}
67	},
68	errorMessage: "لم تقم بإدخال كافة البيانات المطلوبة"
69});
70
71$.formUtils.addValidator({
72	name: "validateYouTube",
73	validatorFunction: function(value, $el, config, language, $form){
74		if (value && getYoutubeID(value)){
75			return true;
76		} else {
77			return false;
78		}
79	},
80	errorMessage: "يجب ان يكون رابط الفيديو علي يوتيوب"
81});	
82
83//Submit Button
84$("form .submit").not("#submit_button").not("[type=submit]").on("click", function(){
85	errors = [];
86	if (typeof onBeforeValidation === "function"){ onBeforeValidation() }
87	if (!$(this).parents("form:first").isValid(validationLanguage, validationConfiguration, true)){
88		scrollToView($(".form-error"), $("#nav-sticky").outerHeight()+10, "start");	
89	} else {
90		formSubmit($(this).parents("form:first"));
91	}
92});
93
94//Initialize JSConfirm
95var jconfirmInstance = null;
96jconfirm.defaults = {
97	rtl: true,
98	theme: "light-noborder",
99	animateFromElement: false,
100	containerFluid: true,
101	container: parent.document.getElementsByTagName("body"),
102	buttons: {},
103	onOpenBefore: function(){
104		jconfirmInstance = this;
105	},
106	onClose: function(){
107		jconfirmInstance = null;
108	},
109	defaultButtons: {
110		ok: {
111			text: "موافق",
112			action: function (){}
113		},
114		cancel: {
115			text: "إلغاء",
116			action: function (){}
117		},
118	},
119};
120
121//Initialize Data Tables (If Exists)
122if (typeof $.fn.dataTable !== "undefined"){
123	$.extend(true,$.fn.dataTable.defaults,{
124		language: {
125			"decimal":        "",
126			"emptyTable":     "لا يوجد سجلات",
127			"info":           "معروض _START_ الي _END_ من _TOTAL_ سجل",
128			"infoEmpty":      "لا يوجد سجلات",
129			"infoFiltered":   "",
130			"infoPostFix":    "",
131			"thousands":      ",",
132			"lengthMenu":     "_MENU_",
133			"loadingRecords": "جاري التحميل..",
134			"processing":     "جاري التحميل..",
135			"search":         "",
136			"zeroRecords":    "لا يوجد سجلات مطابقة",
137			"paginate": {
138				"first":      "الاولي",
139				"last":       "الاخيرة",
140				"next":       "التالي",
141				"previous":   "السابق"
142			},
143			"aria": {
144				"sortAscending":  "",
145				"sortDescending": ""
146			}
147		}
148	});
149}
150
151//Initialize Bootbox (If Exists)
152if (typeof bootbox !== "undefined"){
153	bootbox.addLocale("ar", {
154		OK : "موافق",
155		CANCEL : "إلغاء",
156		CONFIRM : "تأكيد"
157	});
158	bootbox.setLocale("ar");
159}
160	
161//Prevent POST on Refresh
162if (typeof replaceState === "undefined" || replaceState == false){
163	if (window.history.replaceState){
164		window.history.replaceState(null, null, window.location.href);
165	}
166}
167
168//Initialize Fancybox
169$.fancybox.defaults.buttons = ["close"];
170$.fancybox.defaults.autoSize = false;
171$.fancybox.defaults.protect = true;
172$.fancybox.defaults.parentEl = parent.document.getElementsByTagName("body");
173$.fancybox.defaults.iframe.preload = true;
174$(parent).on("beforeLoad.fb", function(e,instance,slide){
175	//For Mobile Only
176	if (on_mobile && !navigator.onLine){
177		sendParentMessage("Call-Function","connectionError");
178		instance.close();
179		return false;
180	}
181	var element = slide.opts.$orig;
182	if (element){
183		slide.opts.iframe.css = (element.data("frame-width") ? {width: element.data("frame-width")} : {});
184	}
185});
186$(parent).on("afterShow.fb", function(e,instance,slide){
187	slide.opts.iframe.preload = false;
188	if (typeof slide.$iframe !== "undefined"){
189		slide.$iframe.unbind();
190	}
191});
192$(parent).on("afterClose.fb", function(e,instance,slide){
193	if (instance.current.opts.$orig[0].hasAttribute('data-refresh')){
194		parent.location.reload(true);
195	}
196});
197
198//Disable Form Submit on Enter
199$("form input").on("keyup keypress", function(e){
200	var keyCode = e.keyCode || e.which;
201	if (keyCode === 13){
202		e.preventDefault();
203		if ($(this).attr("disable-enter")){
204			return false;
205		} else {
206			$(this).parent("form").find(".submit").click();
207		}
208	}
209});
210
211//Initialize Bootstrap Scripts
212$("[data-toggle=tooltip]").tooltip();
213$("[data-toggle=popover]").popover();
214
215//Initialize Waves
216if (typeof Waves !== "undefined"){
217    Waves.init();
218}
219
220//Form Submit If (formSubmit) Not Defined
221if (typeof window.formSubmit === "undefined"){
222    window.formSubmit = function(form){
223		if (typeof attachmentsBuild === "function"){ attachmentsBuild() }
224		if (typeof imagesUploaderBuild === "function"){ imagesUploaderBuild() }
225		if (typeof multipleDataBuild === "function"){ multipleDataBuild() }
226		if (typeof fixedDataBuild === "function"){ fixedDataBuild() }
227		if (typeof doMenuBuild === "function"){ doMenuBuild() }
228		if (typeof onBeforeSubmit === "function"){ onBeforeSubmit() }
229		$(form).submit();
230    }
231}
232
233//Show Loading on Form Submit
234$("form:not([loading=false])").on("submit",function(){
235	showLoadingCover();
236});
237
238//========== Rafed Website Only ==========
239
240//Update Sticky Header
241$(window).on("load",function(){
242	$("#nav-sticky").sticky("update");
243});
244$(window).resize(function() {
245	$("#nav-sticky").sticky("update");
246});
247
248if (typeof SmoothScroll !== "undefined"){
249	//Initialize Smooth Scroll
250	SmoothScroll({
251		//Scrolling Core
252		animationTime    : 600, //ms
253		stepSize         : 80, //px
254
255		//Acceleration
256		accelerationDelta : 20,
257		accelerationMax   : 2,
258
259		//Keyboard Settings
260		keyboardSupport   : true,
261		arrowScroll       : 50, //px
262
263		//Pulse (less tweakable) - Ratio of "tail" to "acceleration"
264		pulseAlgorithm   : true,
265		pulseScale       : 4,
266		pulseNormalize   : 1,
267
268		//Other
269		touchpadSupport   : false, //Ignore touchpad by default
270		fixedBackground   : true, 
271		excluded          : ""
272	});
273}
274
275//Hide loading cover on load
276$(document).ready(function(){
277	hideLoadingCover();
278});
279
280$(document).ready(function(){
281	//Initialize Sticky Header
282	$("#nav-sticky").sticky({
283		className: "nav-stuck",
284		topSpacing: 0,
285		bottomSpacing: 0,
286		zIndex: 1000
287	});
288	
289	//Initialize Animations
290	AOS.init({easing:"ease-in-out-sine"});
291
292	//Attach Fancybox to WYSIWYG Content
293	$(".html-content img").each(function(){
294		if (!$(this).parent().is("a")){
295			$(this).wrap("<a data-fancybox=images href='" + $(this).attr("src") + "'></a>");
296		}
297	});
298	
299	//Bind donation spinner button
300	$(".input_spinner button").bind("click", function(event) {
301        var button = $(this);
302        var input = button.parent().find("input");
303		var value = parseInt(input.val());
304		var new_value = 0;
305		var minimum = parseInt(input.attr("min"));
306		var maximum = parseInt(input.attr("max"));
307        button.parent().find("button").prop("disabled", false);
308    	if (button.attr("data-dir")=="up"){
309			if (value < minimum){
310				new_value = minimum;
311			} else if (value > maximum){
312				new_value = maximum;
313			} else if (value < maximum){
314				new_value = value + 1;
315			}
316			input.val(new_value).trigger("input");
317			if (new_value >= maximum){ button.prop("disabled", true); }
318    	} else if (button.attr("data-dir")=="down"){
319			if (value > maximum){
320				new_value = maximum;
321			} else if (value < minimum){
322				new_value = minimum;
323			} else if (value > minimum){
324				new_value = value - 1;
325			}
326			input.val(new_value).trigger("input");
327			if (new_value <= minimum ){ button.prop("disabled", true); }
328    	}
329    });	
330});
331
332//Console Warnings
333var cssRule = "color: red; font-size: 30px; font-weight: bold; text-shadow: 1px 1px 5px rgb(249, 162, 34); filter: dropshadow(color=rgb(249, 162, 34), offx=1, offy=1);";
334setTimeout(console.log.bind(console, "%c" + "تحذير", cssRule), 0);
335
336var cssRule = "color: #404040; font-size: 14px; font-weight: bold;";
337setTimeout(console.log.bind(console, "%c" + "هذه الصفحة خاصة بمديرين الموقع فقط و غير مصرح للاعضاء او الزوار بدخولها - تم تسجيل رقم الاي بي الخاص بجهازك و مراقبة التعديلات التي يتم اجراءها", cssRule), 0);
338
339//===== Cart =====
340
341//Update amount on shares input
342$("[marketing-block] input[name=shares]").on("input", function(){
343	var container = $(this).closest("[marketing-block]");
344	var share_price = $(this).closest("[share-price]").attr("share-price");
345	container.find("[name=amount]").val($(this).val() * share_price);
346});
347
348//Update amount on donation label change
349$("[marketing-block] label").on("click", function(){
350	var container = $(this).closest("[marketing-block]");
351	container.find("[name=amount]").val($(this).data("amount"));
352});
353
354//Update amount on donation label change
355$("[marketing-block] [cart-insert]").on("click", function(){
356	var checkout = ($(this).attr("cart-insert")=="checkout" ? true : false);
357	var gift = ($(this).attr("cart-insert")=="gift" ? true : false);
358	var container = $(this).closest("[marketing-block]");
359	var marketing_id = container.attr("marketing-block");
360	var marketing_data = JSON.parse(atob(container.attr("marketing-d
360ata")));
361	var amount_object = container.find("[name=amount]");
362	var amount = (isNaN(parseInt(amount_object.val())) ? 0 : parseFloat(amount_object.val()));
363	var minimum = (isNaN(parseInt(amount_object.attr("min"))) ? 0 : parseInt(amount_object.attr("min")));
364	var maximum = (isNaN(parseInt(amount_object.attr("max"))) ? 0 : parseInt(amount_object.attr("max")));
365	
366	if (amount <= 0) {
367		quickNotify("برجاء ادخال قيمة التبرع", "تعثر الإضافة للسلة", "danger", "fal fa-times-circle fa-3x");
368	} else if (amount < minimum){
369		quickNotify("الحد الأدني للتبرع لصالح <b>" + marketing_data.title + "</b> هو <b>" + minimum + "</b> ريال سعودي", "تعثر الإضافة للسلة", "danger", "fal fa-times-circle fa-3x");
370	} else if (amount > maximum){
371		quickNotify("الحد الأقصي للتبرع لصالح <b>" + marketing_data.title + "</b> هو <b>" + maximum + "</b> ريال سعودي", "تعثر الإضافة للسلة", "danger", "fal fa-times-circle fa-3x");
372	} else {
373		if (gift) {
374			$('#giftModal').modal('show');
375			$('#giftModal').find("[proceed]").on("click", function(){
376				if (!$("#gift_form").isValid(validationLanguage, validationConfiguration, true)){
377					quickNotify("برجاء إدخال بيانات الإهداء بشكل صحيح", null, "danger", "fal fa-times fa-3x");
378					return false;
379				} else {
380					let data = buildObjectFromInputs($("#gift_form"));
381					setCookie('DONATION_GIFT', encodeURIComponent(JSON.stringify(data)), 1);
382					cartInsert(marketing_id, amount, marketing_data, true);
383				}
384			});
385		} else {
386			cartInsert(marketing_id, amount, marketing_data, checkout);
387		}
388	}
389});
390
391//Cart remove button
392$(document).on("click", "[cart-remove]", function(){
393	var marketing_id = $(this).closest("[cart-item=row]").attr("marketing-id");
394	cartRemove(marketing_id);	
395});
396
397//Insert cart item
398function cartInsert(marketing_id, amount, marketing_data, checkout=false){
399	$.confirm({
400		content: function (){
401			var self = this;
402			self.showLoading();
403			return $.ajax({
404				type: "POST",
405				url: "requests-legacy/",
406				dataType: "json",
407				data: {
408					token: user_token,
409					action: "cart_insert",
410					marketing_id: marketing_id,
411					amount: amount
412				}
413			}).done(function(response){
414				// Trigger add to cart pixel event for the inserted item
415				emitPixelEvent('add_to_cart', {
416					total: response.amount,
417					items: [{
418						id: 'website_marketing:' + marketing_id,
419						title: response.title,
420						canonical: response.canonical,
421						price: response.amount,
422					}]
423				});
424
425				if (checkout){
426					cartReload();
427					self.close();
428					setWindowLocation("checkout/");
429				} else {
430					quickNotify("تم إضافة التبرع بمبلغ <b>" + amount + "</b> ريال سعودي لصالح <b>" + marketing_data.title + "</b> للسلة بنجاح!", "تم الإضافة للسلة", "success", "fal fa-check-circle fa-3x");
431					cartReload();
432				}
433			}).fail(function(response){
434				quickNotify(response.responseText, "تعثر الإضافة للسلة", "danger", "fal fa-times-circle fa-3x");
435			}).always(function(){
436				self.close();
437			});
438		}
439	});
440}
441
442//Remove cart item
443function cartRemove(marketing_id, callback=null){
444	$.ajax({
445		type: "POST",
446		url: "requests-legacy/",
447		dataType: "json",
448		data: {
449			token: user_token,
450			action: "cart_remove",
451			marketing_id: marketing_id
452		},
453		success: function(result) {
454			if (result) {
455				// Trigger remove from cart pixel event for the deleted item
456				emitPixelEvent('remove_from_cart', {
457					total: result.amount,
458					items: [{
459						id: 'website_marketing:' + marketing_id,
460						title: result.title,
461						canonical: result.canonical,
462						price: result.amount,
463					}]
464				});
465			}
466
467			cartReload();
468			if (typeof callback === "function"){
469				callback();
470			}
471		}
472	});
473}
474
475//Reload cart content
476function cartReload(){
477	$.ajax({
478		type: "POST",
479		url: "requests-legacy/",
480		data: {
481			token: user_token,
482			action: "cart_reload"
483		}
484	}).done(function(response){
485		//Cart is empty
486		if (!response){
487			//Cart Count
488			$(".cart_count").removeClass("active");
489			$(".cart_count").text(0);
490			
491			//Cart Update
492			$("[cart-template]").each(function(){
493				var target = $("." + $(this).attr("cart-template"));
494				target.find("[cart-item]").remove();
495				
496				//Empty Cart DOM
497				var clone = $(this).find("[cart-item=empty]").clone();
498				clone.appendTo(target);
499				
500				//Show/Hide in cart for blocks
501				$(document).ready(function(){
502					$("[show-in-cart]").hide();
503					$("[hide-in-cart]").show();
504				});
505			});
506
507		//Cart is not empty
508		} else {
509			var response = JSON.parse(response);
510			
511			//Cart Count
512			$(".cart_count").addClass("active");
513			$(".cart_count").text(response.cart_count);
514						
515			//Cart Update
516			$("[cart-template]").each(function(){
517				var template = $(this);
518				var target = $("." + $(this).attr("cart-template"));
519				target.find("[cart-item]").remove();
520
521				//Cart Rows DOM
522				response.marketing_data.forEach(function(item, index){
523					var clone = template.find("[cart-item=row]").clone();
524					clone.attr("marketing-id", response.marketing_data[index].id);
525					var replace = replaceTokens(clone.prop("outerHTML"), response.marketing_data[index]);
526					target.append(replace);
527				});
528				
529				//Cart Append DOM
530				var clone = $(this).find("[cart-item=append]").clone();
531				var replace = replaceTokens(clone.prop("outerHTML"), response);
532				target.append(replace);
533			});
534
535			//Show/Hide in cart for blocks
536			$("[marketing-block]").each(function(){
537				var marketing_id = $(this).attr("marketing-block");
538				if (response.marketing_ids.includes(parseInt(marketing_id))){
539					$("[marketing-block=" + marketing_id + "] [show-in-cart]").show();
540					$("[marketing-block=" + marketing_id + "] [hide-in-cart]").hide();							
541				} else {
542					$("[marketing-block=" + marketing_id + "] [show-in-cart]").hide();
543					$("[marketing-block=" + marketing_id + "] [hide-in-cart]").show();					
544				}
545			});
546		}
547		
548		//Call on cart reload function if exists
549		if (typeof onCartReload==="function"){
550			onCartReload(response);
551		}
552	});
553}
554
555//Reload cart
556$(document).ready(function(){
557	cartReload();
558});
559			
560//Program enroll
561function programEnroll(program_id,program_title="برنامج تدريبي"){
562	$.confirm({
563		icon: "fa fa-laptop",
564		title: "الإنضمام لبرنامج",
565		content: "هل أنت متأكد من رغبتك في الإنضمام لبرنامج " + program_title + "؟",
566		theme: "modern",
567		closeIcon: true,
568		buttons: {
569			Ok: {
570				text: "نعم",
571				btnClass: "btn-primary",
572				action: function(){
573					legacy_postForm({
574						program_id: program_id,
575					}, "programs-register/");
576				}
577			},
578			Cancel: {
579				text: "إلغاء",
580				btnClass: "btn-default",
581			}
582		}
583	});
584}
585
586//Chance enroll
587function chanceEnroll(chance_id,chance_title="فرصة تطوعية"){
588	$.confirm({
589		icon: "fa fa-heart",
590		title: "تطوع لفرصة",
591		content: "هل انت متأكد من رغبتك في التطوع لهذه الفرصة " + chance_title + "؟ بالتقدم لها قد تحرم غيرك منها..",
592		theme: "modern",
593		closeIcon: true,
594		buttons: {
595			Ok: {
596				text: "نعم",
597				btnClass: "btn-primary",
598				action: function(){
599					legacy_postForm({
600						chance_id: chance_id,
601					}, "chances/");
602				}
603			},
604			Cancel: {
605				text: "إلغاء",
606				btnClass: "btn-default",
607			}
608		}
609	});
610}
611
612$("iframe").each(function(){
613	var src = $(this).attr("src");
614	var ext = src.substring(src.lastIndexOf('/')+1).split('.').pop().toLowerCase();
615	if (ext == "pdf"){
616		$(this).attr("src", "pdf-render/?file=" + $("base").attr("href") + src).addClass("pdf_render");
617	}
618});

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.