PageSourceSearch

https://moto-office.com/themes/discounter/js/global.js

js moto-office.com collected 2026-09-25 04:31:27 UTC 14,962 bytes, 463 lines download raw bytes

1/*
2* 2007-2015 PrestaShop
3*
4* NOTICE OF LICENSE
5*
6* This source file is subject to the Academic Free License (AFL 3.0)
7* that is bundled with this package in the file LICENSE.txt.
8* It is also available through the world-wide-web at this URL:
9* http://opensource.org/licenses/afl-3.0.php
10* If you did not receive a copy of the license and are unable to
11* obtain it through the world-wide-web, please send an email
12* to [email protected] so we can send you a copy immediately.
13*
14* DISCLAIMER
15*
16* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
17* versions in the future. If you wish to customize PrestaShop for your
18* needs please refer to http://www.prestashop.com for more information.
19*
20*  @author PrestaShop SA <[email protected]>
21*  @copyright  2007-2015 PrestaShop SA
22*  @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
23*  International Registered Trademark & Property of PrestaShop SA
24*/
25//global variables
26var responsiveflag = false;
27
28$(document).ready(function(){
29	highdpiInit();
30	responsiveResize();
31	$(window).resize(responsiveResize);
32	if (navigator.userAgent.match(/Android/i))
33	{
34		var viewport = document.querySelector('meta[name="viewport"]');
35		viewport.setAttribute('content', 'initial-scale=1.0,maximum-scale=1.0,user-scalable=0,width=device-width,height=device-height');
36		window.scrollTo(0, 1);
37	}
38	if (typeof quickView !== 'undefined' && quickView)
39		quick_view();
40	dropDown();
41
42	if (typeof page_name != 'undefined' && !in_array(page_name, ['index', 'product']))
43	{
44		bindGrid();
45
46		$(document).on('change', '.selectProductSort', function(e){
47			if (typeof request != 'undefined' && request)
48				var requestSortProducts = request;
49			var splitData = $(this).val().split(':');
50			var url = '';
51			if (typeof requestSortProducts != 'undefined' && requestSortProducts)
52			{
53				url += requestSortProducts ;
54				if (typeof splitData[0] !== 'undefined' && splitData[0])
55				{
56					url += ( requestSortProducts.indexOf('?') < 0 ? '?' : '&') + 'orderby=' + splitData[0] + (splitData[1] ? '&orderway=' + splitData[1] : '');
57					if (typeof splitData[1] !== 'undefined' && splitData[1])
58						url += '&orderway=' + splitData[1];
59				}
60				document.location.href = url;
61			}
62		});
63
64		$(document).on('change', 'select[name="n"]', function(){
65			$(this.form).submit();
66		});
67
68		$(document).on('change', 'select[name="currency_payment"]', function(){
69			setCurrency($(this).val());
70		});
71	}
72
73	$(document).on('change', 'select[name="manufacturer_list"], select[name="supplier_list"]', function(){
74		if (this.value != '')
75			location.href = this.value;
76	});
77
78	$(document).on('click', '.back', function(e){
79		e.preventDefault();
80		history.back();
81	});
82
83	jQuery.curCSS = jQuery.css;
84	if (!!$.prototype.cluetip)
85		$('a.cluetip').cluetip({
86			local:true,
87			cursor: 'pointer',
88			dropShadow: false,
89			dropShadowSteps: 0,
90			showTitle: false,
91			tracking: true,
92			sticky: false,
93			mouseOutClose: true,
94			fx: {
95				open:       'fadeIn',
96				openSpeed:  'fast'
97			}
98		}).css('opacity', 0.8);
99
100	if (!!$.prototype.fancybox)
101		$.extend($.fancybox.defaults.tpl, {
102			closeBtn : '<a title="' + FancyboxI18nClose + '" class="fancybox-item fancybox-close" href="javascript:;"></a>',
103			next     : '<a title="' + FancyboxI18nNext + '" class="fancybox-nav fancybox-next" href="javascript:;"><span></span></a>',
104			prev     : '<a title="' + FancyboxI18nPrev + '" class="fancybox-nav fancybox-prev" href="javascript:;"><span></span></a>'
105		});
106
107	// Close Alert messages
108	$(".alert.alert-danger").on('click', this, function(e){
109		if (e.offsetX >= 16 && e.offsetX <= 39 && e.offsetY >= 16 && e.offsetY <= 34)
110			$(this).fadeOut();
111	});
112});
113
114function highdpiInit()
115{
116	if($('.replace-2x').css('font-size') == "1px")
117	{
118		var els = $("img.replace-2x").get();
119		for(var i = 0; i < els.length; i++)
120		{
121			src = els[i].src;
122			extension = src.substr( (src.lastIndexOf('.') +1) );
123			src = src.replace("." + extension, "2x." + extension);
124
125			var img = new Image();
126			img.src = src;
127			img.height != 0 ? els[i].src = src : els[i].src = els[i].src;
128		}
129	}
130}
131
132
133// Used to compensante Chrome/Safari bug (they don't care about scroll bar for width)
134function scrollCompensate()
135{
136	var inner = document.createElement('p');
137	inner.style.width = "100%";
138	inner.style.height = "200px";
139
140	var outer = document.createElement('div');
141	outer.style.position = "absolute";
142	outer.style.top = "0px";
143	outer.style.left = "0px";
144	outer.style.visibility = "hidden";
145	outer.style.width = "200px";
146	outer.style.height = "150px";
147	outer.style.overflow = "hidden";
148	outer.appendChild(inner);
149
150	document.body.appendChild(outer);
151	var w1 = inner.offsetWidth;
152	outer.style.overflow = 'scroll';
153	var w2 = inner.offsetWidth;
154	if (w1 == w2) w2 = outer.clientWidth;
155
156	document.body.removeChild(outer);
157
158	return (w1 - w2);
159}
160
161function responsiveResize()
162{
163	compensante = scrollCompensate();
164	if (($(window).width()+scrollCompensate()) <= 767 && responsiveflag == false)
165	{
166		accordion('enable');
167		accordionFooter('enable');
168		responsiveflag = true;
169	}
170	else if (($(window).width()+scrollCompensate()) >= 768)
171	{
172		accordion('disable');
173		accordionFooter('disable');
174		responsiveflag = false;
175		if (typeof bindUniform !=='undefined')
176			bindUniform();
177	}
178	blockHover();
179}
180
181function blockHover(status)
182{
183	var screenLg = $('body').find('.container').width() >= 1;
184
185	if ($('.product_list').is('.grid'))
186		if (screenLg)
187			$('.product_list .button-container').hide();
188		else
189			$('.product_list .button-container').show();
190
191	$(document).off('mouseenter').on('mouseenter', '.product_list.grid li.ajax_block_product .product-container', function(e){
192		if (screenLg)
193		{
194			var pcHeight = $(this).parent().outerHeight();
195			var pcPHeight = $(this).parent().find('.comments_note').outerHeight() + $(this).parent().find('.functional-buttons').outerHeight();
196			$(this).parent().addClass('hovered').css({'height':pcHeight + pcPHeight, 'margin-bottom':pcPHeight * (-1)});
197			$(this).find('.button-container').show();
198		}
199	});
200
201	$(document).off('mouseleave').on('mouseleave', '.product_list.grid li.ajax_block_product .product-container', function(e){
202		if (screenLg)
203		{
204			$(this).parent().removeClass('hovered').css({'height':'auto', 'margin-bottom':'0'});
205			$(this).find('.button-container').hide();
206		}
207	});
208}
209
210function quick_view()
211{
212	$(document).on('click', '.quick-view:visible, .quick-view-mobile:visible', function(e){
213		e.preventDefault();
214		var url = this.rel;
215		var anchor = '';
216
217		if (url.indexOf('#') != -1)
218		{
219			anchor = url.substring(url.indexOf('#'), url.length);
220			url = url.substring(0, url.indexOf('#'));
221		}
222
223		if (url.indexOf('?') != -1)
224			url += '&';
225		else
226			url += '?';
227
228		if (!!$.prototype.fancybox)
229			$.fancybox({
230				'padding':  0,
231				'width':    1087,
232				'height':   610,
233				'type':     'iframe',
234				'href':     url + 'content_only=1' + anchor
235			});
236	});
237}
238
239function bindGrid()
240{
241	var view = $.totalStorage('display');
242
243	if (!view && (typeof displayList != 'undefined') && displayList)
244		view = 'list';
245
246	if (view && view != 'grid')
247		display(view);
248	else
249		$('.display').find('li#grid').addClass('selected');
250
251	$(document).on('click', '#grid', function(e){
252		e.preventDefault();
253		display('grid');
254	});
255
256	$(document).on('click', '#list', function(e){
257		e.preventDefault();
258		display('list');
259	});
260}
261
262function display(view)
263{
264	if (view == 'list')
265	{
266		$('ul.product_list').removeClass('grid').addClass('list row');
267		$('.product_list > li').removeClass('col-xs-12 col-sm-6 col-md-4').addClass('col-xs-12');
268		$('.product_list > li').each(function(index, element) {
269			html = '';
270			html = '<div class="product-container"><div class="row">';
271				html += '<div class="left-block col-xs-4 col-sm-5 col-md-4">' + $(element).find('.left-block').html() + '</div>';
272				html += '<div class="center-block col-xs-4 col-sm-7 col-md-4">';
273					html += '<div class="product-flags">'+ $(element).find('.product-flags').html() + '</div>';
274					html += '<h5 itemprop="name">'+ $(element).find('h5').html() + '</h5>';
275					var rating = $(element).find('.comments_note').html(); // check : rating
276					if (rating != null) {
277						html += '<div itemprop="aggregateRating" itemscope itemtype="https://schema.org/AggregateRating" class="comments_note">'+ rating + '</div>';
278					}
279					html += '<p class="product-desc">'+ $(element).find('.product-desc').html() + '</p>';
280					var colorList = $(element).find('.color-list-container').html();
281					if (colorList != null) {
282						html += '<div class="color-list-container">'+ colorList +'</div>';
283					}
284					var availability = $(element).find('.availability').html();	// check : catalog mode is enabled
285					if (availability != null) {
286						html += '<span class="availability">'+ availability +'</span>';
287					}
288				html += '</div>';
289				html += '<div class="right-block col-xs-4 col-sm-12 col-md-4"><div class="right-block-content row">';
290					var price = $(element).find('.content_price').html();       // check : catalog mode is enabled
291					if (price != null) {
292						html += '<div class="content_price col-xs-5 col-md-12">'+ price + '</div>';
293					}
294					html += '<div class="button-container col-xs-7 col-md-12">'+ $(element).find('.button-container').html() +'</div>';
295					
296				html += '</div>';
297			html += '</div></div>';
298		$(element).html(html);
299		});
300		$('.display').find('li#list').addClass('selected');
301		$('.display').find('li#grid').removeAttr('class');
302		$.totalStorage('display', 'list');
303	}
304	else
305	{
306		$('ul.product_list').removeClass('list').addClass('grid row');
307		$('.product_list > li').removeClass('col-xs-12').addClass('col-xs-12 col-sm-6 col-md-4');
308		$('.product_list > li').each(function(index, element) {
309		html = '';
310		html += '<div class="product-container">';
311			html += '<div class="left-block">' + $(element).find('.left-block').html() + '</div>';
312			html += '<div class="right-block">';
313				html += '<div class="product-flags">'+ $(element).find('.product-flags').html() + '</div>';
314				html += '<h5 itemprop="name">'+ $(element).find('h5').html() + '</h5>';
315				var rating = $(element).find('.comments_note').html(); // check : rating
316					if (rating != null) {
317						html += '<div itemprop="aggregateRating" itemscope itemtype="https://schema.org/AggregateRating" class="comments_note">'+ rating + '</div>';
318					}
319				html += '<p itemprop="description" class="product-desc">'+ $(element).find('.product-desc').html() + '</p>';
320				var price = $(element).find('.content_price').html(); // check : catalog mode is enabled
321					if (price != null) {
322						html += '<div class="content_price">'+ price + '</div>';
323					}
324				html += '<div itemprop="offers" itemscope itemtype="https://schema.org/Offer" class="button-container">'+ $(element).find('.button-container').html() +'</div>';
325				var colorList = $(element).find('.color-list-container').html();
326				if (colorList != null) {
327					html += '<div class="color-list-container">'+ colorList +'</div>';
328				}
329				var availability = $(element).find('.availability').html(); // check : catalog mode is enabled
330				if (availability != null) {
331					html += '<span class="availability">'+ availability +'</span>';
332				}
333			html += '</div>';
334			
335		html += '</div>';
336		$(element).html(html);
337		});
338		$('.display').find('li#grid').addClass('selected');
339		$('.display').find('li#list').removeAttr('class');
340		$.totalStorage('display', 'grid');
341	}
342}
343
344function dropDown()
345{
346	elementClick = '#header .current';
347	elementSlide =  'ul.toogle_content';
348	activeClass = 'active';
349
350	$(elementClick).on('click', function(e){
351		e.stopPropagation();
352		var subUl = $(this).next(elementSlide);
353		if(subUl.is(':hidden'))
354		{
355			subUl.slideDown();
356			$(this).addClass(activeClass);
357		}
358		else
359		{
360			subUl.slideUp();
361			$(this).removeClass(activeClass);
362		}
363		$(elementClick).not(this).next(elementSlide).slideUp();
364		$(elementClick).not(this).removeClass(activeClass);
365		e.preventDefault();
366	});
367
368	$(elementSlide).on('click', function(e){
369		e.stopPropagation();
370	});
371
372	$(document).on('click', function(e){
373		e.stopPropagation();
374		var elementHide = $(elementClick).next(elementSlide);
375		$(elementHide).slideUp();
376		$(elementClick).removeClass('active');
377	});
378}
379
380function accordionFooter(status)
381{
382	if(status == 'enable')
383	{
384		$('#footer .footer-block h4').on('click', function(){
385			$(this).toggleClass('active').parent().find('.toggle-footer').stop().slideToggle('medium');
386		})
387		$('#footer').addClass('accordion').find('.toggle-footer').slideUp('fast');
388	}
389	else
390	{
391		$('.footer-block h4').removeClass('active').off().parent().find('.toggle-footer').removeAttr('style').slideDown('fast');
392		$('#footer').removeClass('accordion');
393	}
394}
395
396function accordion(status)
397{
398	if(status == 'enable')
399	{
400		var accordion_selector = '#right_column .block .title_block, #left_column .block .title_block, #left_column #newsletter_block_left h4,' +
401								'#left_column .shopping_cart > a:first-child, #right_column .shopping_cart > a:first-child';
402
403		$(accordion_selector).on('click', function(e){
404			$(this).toggleClass('active').parent().find('.block_content').stop().slideToggle('medium');
405		});
406		$('#right_column, #left_column').addClass('accordion').find('.block .block_content').slideUp('fast');
407		if (typeof(ajaxCart) !== 'undefined')
408			ajaxCart.collapse();
409	}
410	else
411	{
412		$('#right_column .block .title_block, #left_column .block .title_block, #left_column #newsletter_block_left h4').removeClass('active').off().parent().find('.block_content').removeAttr('style').slideDown('fast');
413		$('#left_column, #right_column').removeClass('accordion');
414	}
415}
416
417function bindUniform()
418{
419	if (!!$.prototype.uniform)
420		$("select.form-control,input[type='radio'],input[type='checkbox']").not(".not_unifrom").uniform();
421}
422
423$(document).ready(function() {
424    if (!!$.prototype.bxSlider)
425        $('#slider-blocknewproducts').bxSlider({
426            minSlides: 1,
427            maxSlides: 8,
428            slideWidth: 250,
429            slideMargin: 22,
430            pager: true,
431            controls: false,
432            nextText: 'Next',
433            prevText: 'Prev',
434            moveSlides:1,
435            infiniteLoop:false,
436            hideControlOnEnd: false
437        });
438});
439
440$(document).ready(function() {
441    if (!!$.prototype.bxSlider)
442        $('#slider-blockbestsellers').bxSlider({
443            minSlides: 1,
444            maxSlides: 8,
445            slideWidth: 250,
446            slideMargin: 22,
447            pager: true,
448            controls: false,
449            nextText: 'Next',
450            prevText: 'Prev',
451            moveSlides:1,
452            infiniteLoop:false,
453            hideControlOnEnd: false
454        });
455});
456
457$(document).ready(function() {
458    $('.homeslider-description h2').addClass('wow fadeInUp');
459    $('.homeslider-description p').addClass('wow fadeInUp');
460    $('.homeslider-description h2').css('-webkit-animation-delay', '0.2s');
461    $('.homeslider-description p').css('-webkit-animation-delay', '0.4s');    
462});
463

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.