PageSourceSearch

https://deserttech.com/static/version1790073598/frontend/Mgs/desert/en_US/MGS_Fbuilder/js/custom.js

js deserttech.com collected 2026-09-24 20:33:37 UTC 14,873 bytes, 500 lines download raw bytes

1if (typeof(WEB_URL) == 'undefined') {
2	if (typeof(BASE_URL) !== 'undefined') {
3		var WEB_URL_AJAX = BASE_URL;
4	}else{
5		pubUrlAjax = require.s.contexts._.config.baseUrl;
6		arrUrlAjax = pubUrlAjax.split('pub/');
7		var WEB_URL_AJAX = arrUrlAjax[0];
8	}
9}
10
11require([
12	'jquery',
13	'waypoints',
14	'mgslightbox'
15], function(jQuery){
16	(function($) {
17		$.fn.appear = function(fn, options) {
18
19			var settings = $.extend({
20
21				//arbitrary data to pass to fn
22				data: undefined,
23
24				//call fn only on the first appear?
25				one: true,
26
27				// X & Y accuracy
28				accX: 0,
29				accY: 0
30
31			}, options);
32
33			return this.each(function() {
34
35				var t = $(this);
36
37				//whether the element is currently visible
38				t.appeared = false;
39
40				if (!fn) {
41
42					//trigger the custom event
43					t.trigger('appear', settings.data);
44					return;
45				}
46
47				var w = $(window);
48
49				//fires the appear event when appropriate
50				var check = function() {
51
52					//is the element hidden?
53					if (!t.is(':visible')) {
54
55						//it became hidden
56						t.appeared = false;
57						return;
58					}
59
60					//is the element inside the visible window?
61					var a = w.scrollLeft();
62					var b = w.scrollTop();
63					var o = t.offset();
64					var x = o.left;
65					var y = o.top;
66
67					var ax = settings.accX;
68					var ay = settings.accY;
69					var th = t.height();
70					var wh = w.height();
71					var tw = t.width();
72					var ww = w.width();
73
74					if (y + th + ay >= b &&
75						y <= b + wh + ay &&
76						x + tw + ax >= a &&
77						x <= a + ww + ax) {
78
79						//trigger the custom event
80						if (!t.appeared) t.trigger('appear', settings.data);
81
82					} else {
83
84						//it scrolled out of view
85						t.appeared = false;
86					}
87				};
88
89				//create a modified fn with some additional logic
90				var modifiedFn = function() {
91
92					//mark the element as visible
93					t.appeared = true;
94
95					//is this supposed to happen only once?
96					if (settings.one) {
97
98						//remove the check
99						w.unbind('scroll', check);
100						var i = $.inArray(check, $.fn.appear.checks);
101						if (i >= 0) $.fn.appear.checks.splice(i, 1);
102					}
103
104					//trigger the original fn
105					fn.apply(this, arguments);
106				};
107
108				//bind the modified fn to the element
109				if (settings.one) t.one('appear', settings.data, modifiedFn);
110				else t.bind('appear', settings.data, modifiedFn);
111
112				//check whenever the window scrolls
113				w.scroll(check);
114
115				//check whenever the dom changes
116				$.fn.appear.checks.push(check);
117
118				//check now
119				(check)();
120			});
121		};
122
123		//keep a queue of appearance checks
124		$.extend($.fn.appear, {
125
126			checks: [],
127			timeout: null,
128
129			//process the queue
130			checkAll: function() {
131				var length = $.fn.appear.checks.length;
132				if (length > 0) while (length--) ($.fn.appear.checks[length])();
133			},
134
135			//check the queue asynchronously
136			run: function() {
137				if ($.fn.appear.timeout) clearTimeout($.fn.appear.timeout);
138				$.fn.appear.timeout = setTimeout($.fn.appear.checkAll, 20);
139			}
140		});
141
142		//run checks when these methods are called
143		$.each(['append', 'prepend', 'after', 'before', 'attr',
144			'removeAttr', 'addClass', 'removeClass', 'toggleClass',
145			'remove', 'css', 'show', 'hide'], function(i, n) {
146			var old = $.fn[n];
147			if (old) {
148				$.fn[n] = function() {
149					var r = old.apply(this, arguments);
150					$.fn.appear.run();
151					return r;
152				}
153			}
154		});
155		
156		$(document).ready(function(){
157			$("[data-appear-animation]").each(function() {
158				$(this).addClass("appear-animation");
159				if($(window).width() > 767) {
160					$(this).appear(function() {
161
162						var delay = ($(this).attr("data-appear-animation-delay") ? $(this).attr("data-appear-animation-delay") : 1);
163
164						if(delay > 1) $(this).css("animation-delay", delay + "ms");
165						$(this).addClass($(this).attr("data-appear-animation"));
166						$(this).addClass("animated");
167
168						setTimeout(function() {
169							$(this).addClass("appear-animation-visible");
170						}, delay);
171
172					}
172, {accX: 0, accY: -150});
173				} else {
174					$(this).addClass("appear-animation-visible");
175				}
176			});
177			
178			/* Progress Bar */
179			$('.mgs-progressbar .progress').css("width",
180				function() {
181					return $(this).attr("aria-valuenow") + "%";
182				}
183			)
184			
185			/* Progress Circle */
186			$('.mgs-progress-circle').each(function(){
187				var progressPercent = $(this).attr('progress-to');
188				$(this).attr('data-progress', progressPercent);
189			});
190			
191			$('.tab-title-ajax').each(function(){
192				$(this).find('a').click();
193			});
194			
195		});
196		
197		
198	})(jQuery);
199});
200
201function setLocation(url) {
202    require([
203        'jquery'
204    ], function (jQuery) {
205        (function () {
206            window.location.href = url;
207        })(jQuery);
208    });
209}
210
211require([
212	'jquery',
213	'Magento_Ui/js/modal/modal'
214], function( $, modal ) {
215	$(document).ready(function(){
216		$('button.mgs-modal-popup-button').click(
217			function(){
218				id = $(this).attr('data-button-id');
219				var popupContent = $('#mgs_modal_container_'+id).html();
220				if ($('#modal_popup_'+id).length) {
221					var options = {
222						type: 'popup',
223						responsive: true,
224						innerScroll: true,
225						title: '',
226						modalClass: 'mgs-modal modal-'+id,
227						buttons: []
228					};
229					var newsletterPopup = modal(options, $('#modal_popup_'+id));
230					$('#modal_popup_'+id).trigger('openModal');
231					
232					$('.modal-'+id+' .pop-sletter-title').insertBefore('.modal-'+id+' .modal-header button');
233					$('.modal-'+id+' .action-close').click(function(){
234						$('.modal-'+id+' .modal-header .pop-sletter-title').remove();
235						setTimeout(function(){ $('.modals-wrapper .modal-'+id).remove(); $('#mgs_modal_container_'+id).html(popupContent) }, 500);
236					});
237				}
238			}
239		);
240	});
241});
242
243function getAjaxProductCollection(catId, attribute, blockType, productNum, blockId, useSlider, perrowDefault, perrowTablet, perrowMobile, numberRow, slideBy, hideName, hideReview, hidePrice, hideAddcart, hideAddwishlist, hideAddcompare, autoPlay, stopAuto, nav, dot, isLoop, hideNav, navTop, navPos, pagPos, isRtl, slideMargin, activeCatLink, CatLink){
244	require([
245		"jquery",
246		"mlazyload"
247	], function($){
248		if(catId!=''){
249			var $contentContainer = $('#'+catId.toString() + blockId.toString());
250		}else{
251			var $contentContainer = $('#'+attribute.toString() + blockId.toString());
252		}
253		var tabContent = $contentContainer.html();
254		if(tabContent.trim() == ''){
255			$contentContainer.addClass('div-loading');
256			var requestUrl = WEB_URL_AJAX+'fbuilder/index/ajax';
257			$.ajax({
258				url: requestUrl,
259				data:{
260					category_id: catId,
261					attribute_type: attribute,
262					block_type: blockType,
263					limit: productNum,
264					block_id: blockId,
265					use_slider: useSlider,
266					perrow: perrowDefault,
267					perrow_tablet: perrowTablet,
268					perrow_mobile: perrowMobile,
269					number_row: numberRow,
270					slide_by: slideBy,
271					hide_name:hideName,
272					hide_review:hideReview,
273					hide_price:hidePrice,
274					hide_addcart:hideAddcart,
275					hide_addwishlist:hideAddwishlist,
276					hide_addcompare:hideAddcompare,
277					autoplay: autoPlay,
278					stop_auto: stopAuto,
279					navigation: nav,
280					pagination: dot,
281					loop: isLoop,
282					hide_nav: hideNav,
283					nav_top: navTop,
284					navigation_position: navPos,
285					pagination_position: pagPos,
286					rtl: isRtl,
287					slide_margin: slideMargin,
288					use_catlink: activeCatLink,
289					cat_link: CatLink
290				},
291				success: function(data) {
292						if(data!=''){
293							$contentContainer.append(data);
294							$contentContainer.removeClass('div-loading');
295							
296							$("img.lazy").unveil(25, function(){
297								var self = $(this);
298								setTimeout(function(){
299									self.removeClass('lazy');
300									self.parents('.parent_lazy').addClass('lazy_loaded');
301								}, 0);
302							});
303							
304							includeQuickviewAction($);
305							
306							$('button.tocart').click(function(event){
307								event.preventDefault();
308								var formEl = $(this).parents('form:first');
309								
310								var data = formEl.serializeArray();
311								var formData = new FormData();
312								for(var i = 0; i < data.length; i++){
313									formData.append(data[i].name, data[i].value);
314								}
315								formData.append('action_url', formEl.attr('action'));
316								initAjaxAddToCart(formEl, 'catalog-add-to-cart-' + $.now(), formEl.attr('action'), formData);
317							});
318						}
319					}
320			   });
321			}
322		}
323	);
324}
325
326function initAjaxAddToCart(tag, actionId, url, formData){
327	require([
328		'jquery', 
329		'MGS_AjaxCart/js/config',
330		'Magento_Ui/js/modal/modal'
331	],function($, mgsConfig, modal){
332		var self = this;
333		/* Loading Effect */
334		if(tag.closest('.product-top').length){
335			// tag.closest('.product-top').addClass('loading-ajax');
336			tag.find('.tocart > span').text('Adding...');
337		}else {
338			if(tag.find('.tocart').length){
339				tag.find('.tocart > span').text('Adding...');
340			}else{
341				tag.find('.tocart > span').text('Adding...');
342			}
343		} 
344		/*========================*/
345		
346		formData.append(mgsConfig.requestParamName, 1);
347		formData.append('ajax', 1);
348		
349		jQuery.ajax({
350			url: url,
351			data: formData,
352			type: 'post',
353			dataType: 'json',
354			contentType: false,
355			cache: false,
356			processData:false, 
357			beforeSend: function(xhr, options) {
358				if(tag.find('.tocart').length){
359					tag.find('.tocart').addClass('disabled');
360				}else{
361					tag.addClass('disabled');
362				} 
363			},
364			success: function(response, status) {
365				/* Remove Loading Effect */
366				if(tag.closest('.product-top').length){
367					tag.find('.tocart > span').text('Add to cart');
368				}
369				if(tag.find('.tocart').length){
370					tag.find('.tocart > span').text('Add to cart');
371					tag.find('.tocart').removeClass('disabled');
372				}else{
373					tag.find('.tocart > span').text('Add to cart');
374					tag.removeClass('disabled');
375				}
376				/*========================*/
377				
378				if (status == 'success') {
379					if(response.backUrl){
380						formData.append('action_url', response.backUrl);
381						initAjaxAddToCart(tag, actionId, response.backUrl, formData);
382					}else{
383						if (response.ui) {
384							if(response.productView){
385								$('#ajaxcart_loading_overlay').addClass('loading');
386								/* Add to cart false - Show popup options */
387								if($('body.catalog-product-view').size() > 0){
388									 $('body').addClass('origin-catalog-product-view');
389								}else {
390									 $('body').addClass('catalog-product-view');
391								}
392								$.ajax({
393									url: response.ui,
394									dataType: 'json',
395									success: function (result) {
396										$('#ajaxcart_loading_overlay').removeClass('loading');
397										if (result.product_detail) {
398											$('body').append('<div id="ajaxcart_form_popup'+result.id_product+'" class="product_quickview_content"></div>');
399											var options =
400											{
401												type: 'popup',
402												modalClass: "ajaxCartForm viewBox",
403												responsive: true,
404												innerScroll: true,
405												title: false,
406												buttons: false
407											};
408											
409											var popup = modal(options, $('#ajaxcart_form_popup'+result.id_product));
410											$('#ajaxcart_form_popup'+result.id_product).html(result.product_detail);
411											$('#ajaxcart_form_popup'+result.id_product).trigger('contentUpdated');
412											$('#ajaxcart_form_popup'+result.id_product).modal('openModal').on('modalclosed', function() { 
413												$('#ajaxcart_form_popup'+result.id_product).parents('.ajaxCartForm').remove();
414												$('body:not(.origin-catalog-product-view)').removeClass('catalog-product-view');
415											});
416										}
417									}
418								});
419							}else{
420								/* After Add to cart success */
421								if(response.animationType == 'popup') {
422									/* Success Cart Popup */
423									$('body').append('<div id="popup_ajaxcart_success" class="popup__main popup--result"></div>');
424									
425									var options =
426									{
427										type: 'popup',
428										modalClass: "success-ajax--popup viewBox",
429										responsive: true,
430										innerScroll: true,
431										title: false,
432										buttons: false
433									};
434									
435									var popup = modal(options, $('#popup_ajaxcart_success'));
436									$('#popup_ajaxcart_success').html(response.ui + response.related);
437									$('#popup_ajaxcart_success').trigger('contentUpdated');
438									$('#popup_ajaxcart_success').modal('openModal').on('modalclosed', function() { 
439										$('#popup_ajaxcart_success').parents('.success-ajax--popup').remove();
440									});
441								}else if(response.animationType == 'flycart'){
442									/* Success Cart Fly */
443									var $source = '';
444									if(tag.find('.tocart').length){
445										if(tag.closest('.product-item-info').length){
446											$source = tag.closest('.product-item-info');
447										}else{
448											$source = tag.find('.tocart');
449										}
450									}else{
451										tag.removeClass('disabled');
452										$source = tag.closest('.product-item-info');
453									}
454									
455									var $animatedObject = jQuery('<div class="flycart-animated-add" style="position: absolute;z-index: 99999;">'+response.image+'</div>');
456									
457									var $_left = $source.offset().left - 1;
458									var $_top = $source.offset().top - 1;
459									
460									$animatedObject.css({top: $_top, left: $_left});
461									jQuery('html').append($animatedObject);
462									
463									if(jQuery(window).width() > 767){
464										var gotoX = jQuery("#fixed-cart-footer").offset().left + 20;
465										var gotoY = jQuery("#fixed-cart-footer").offset().top;      
466										
467										jQuery('#footer-cart-trigger').addClass('active');
468										jQuery('#footer-mini-cart').slideDown(300);
469									}else {
470										var gotoX = jQuery("#cart-top-action").offset().left;
471										var gotoY = jQuery("#cart-top-action").offset().top;      
472									}
473									
474									$animatedObject.animate({
475										opacity: 0.6,
476										left: gotoX,
477										top: gotoY
478									}, 2000,
479									function () {
480										$animatedObject.remove();
481									});
482								}else {
483									$("header.page-header").addClass("show-sticky-menu");
484									$('[data-block="minicart"]').find('[data-role="dropdownDialog"]').dropdownDialog("open");
485									setTimeout(function(){
486										$("header.page-header").removeClass("show-sticky-menu");
487										$('[data-block="minicart"]').find('[data-role="dropdownDialog"]').dropdownDialog("close");
488									},5000);
489								}
490							}
491						}
492					}
493				}
494			},
495			error: function() {
496				window.location.href = mgsConfig.redirectCartUrl;
497			}
498		});
499	});
500}

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.