PageSourceSearch

https://libreria.unicach.mx/themes/default-bootstrap/js/global.js

js unicach.mx collected 2026-09-24 09:47:38 UTC 14,095 bytes, 432 lines download raw bytes

1/*
2* 2007-2017 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-2017 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];
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 (typeof(FancyboxI18nClose) !== 'undefined' && typeof(FancyboxI18nNext) !== 'undefined' && typeof(FancyboxI18nPrev) !== 'undefined' && !!$.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 (typeof highDPI === 'undefined')
117		return;
118	if(highDPI && $('.replace-2x').css('font-size') == "1px")
119	{
120		var els = $("img.replace-2x").get();
121		for(var i = 0; i < els.length; i++)
122		{
123			src = els[i].src;
124			extension = src.substr( (src.lastIndexOf('.') +1) );
125			src = src.replace("." + extension, "2x." + extension);
126
127			var img = new Image();
128			img.src = src;
129			img.height != 0 ? els[i].src = src : els[i].src = els[i].src;
130		}
131	}
132}
133
134
135// Used to compensante Chrome/Safari bug (they don't care about scroll bar for width)
136function scrollCompensate()
137{
138	var inner = document.createElement('p');
139	inner.style.width = "100%";
140	inner.style.height = "200px";
141
142	var outer = document.createElement('div');
143	outer.style.position = "absolute";
144	outer.style.top = "0px";
145	outer.style.left = "0px";
146	outer.style.visibility = "hidden";
147	outer.style.width = "200px";
148	outer.style.height = "150px";
149	outer.style.overflow = "hidden";
150	outer.appendChild(inner);
151
152	document.body.appendChild(outer);
153	var w1 = inner.offsetWidth;
154	outer.style.overflow = 'scroll';
155	var w2 = inner.offsetWidth;
156	if (w1 == w2) w2 = outer.clientWidth;
157
158	document.body.removeChild(outer);
159
160	return (w1 - w2);
161}
162
163function responsiveResize()
164{
165	compensante = scrollCompensate();
166	if (($(window).width()+scrollCompensate()) <= 767 && responsiveflag == false)
167	{
168		accordion('enable');
169		accordionFooter('enable');
170		responsiveflag = true;
171	}
172	else if (($(window).width()+scrollCompensate()) >= 768)
173	{
174		accordion('disable');
175		accordionFooter('disable');
176		responsiveflag = false;
177		if (typeof bindUniform !=='undefined')
178			bindUniform();
179	}
180	blockHover();
181}
182
183function blockHover(status)
184{
185	var screenLg = $('body').find('.container').width() == 1170;
186
187	if ($('.product_list').is('.grid'))
188		if (screenLg)
189			$('.product_list .button-container').hide();
190		else
191			$('.product_list .button-container').show();
192
193	$(document).off('mouseenter').on('mouseenter', '.product_list.grid li.ajax_block_product .product-container', function(e){
194		if (screenLg)
195		{
196			var pcHeight = $(this).parent().outerHeight();
197			var pcPHeight = $(this).parent().find('.button-container').outerHeight() + $(this).parent().find('.comments_note').outerHeight() + $(this).parent().find('.functional-buttons').outerHeight();
198			$(this).parent().addClass('hovered').css({'height':pcHeight + pcPHeight, 'margin-bottom':pcPHeight * (-1)});
199			$(this).find('.button-container').show();
200		}
201	});
202
203	$(document).off('mouseleave').on('mouseleave', '.product_list.grid li.ajax_block_product .product-container', function(e){
204		if (screenLg)
205		{
206			$(this).parent().removeClass('hovered').css({'height':'auto', 'margin-bottom':'0'});
207			$(this).find('.button-container').hide();
208		}
209	});
210}
211
212function quick_view()
213{
214	$(document).on('click', '.quick-view:visible, .quick-view-mobile:visible', function(e){
215		e.preventDefault();
216		var url = this.rel;
217		var anchor = '';
218
219		if (url.indexOf('#') != -1)
220		{
221			anchor = url.substring(url.indexOf('#'), url.length);
222			url = url.substring(0, url.indexOf('#'));
223		}
224
225		if (url.indexOf('?') != -1)
226			url += '&';
227		else
228			url += '?';
229
230		if (!!$.prototype.fancybox)
231			$.fancybox({
232				'padding':  0,
233				'width':    1087,
234				'height':   610,
235				'type':     'iframe',
236				'href':     url + 'content_only=1' + anchor
237			});
238	});
239}
240
241function bindGrid()
242{
243	var storage = false;
244	if (typeof(getStorageAvailable) !== 'undefined') {
245		storage = getStorageAvailable();
246	}
247	if (!storage) {
248		return;
249	}
250
251	var view = $.totalStorage('display');
252
253	if (!view && (typeof displayList != 'undefined') && displayList)
254		view = 'list';
255
256	if (view && view != 'grid')
257		display(view);
258	else
259		$('.display').find('li#grid').addClass('selected');
260
261	$(document).on('click', '#grid', function(e){
262		e.preventDefault();
263		display('grid');
264	});
265
266	$(document).on('click', '#list', function(e){
267		e.preventDefault();
268		display('list');
269	});
270}
271
272function display(view)
273{
274	if (view == 'list')
275	{
276		$('ul.product_list').removeClass('grid').addClass('list row');
277		$('.product_list > li').removeClass('col-xs-12 col-sm-6 col-md-4').addClass('col-xs-12');
278		$('.product_list > li').each(function(index, element) {
279			var html = '';
280			html = '<div class="product-container"><div class="row">';
281			html += '<div class="left-block col-xs-4 col-sm-5 col-md-4">' + $(element).find('.left-block').html() + '</div>';
282			html += '<div class="center-block col-xs-4 col-sm-7 col-md-4">';
283			html += '<div class="product-flags">'+ $(element).find('.product-flags').html() + '</div>';
284			html += '<h5 itemprop="name">'+ $(element).find('h5').html() + '</h5>';
285			var hookReviews = $(element).find('.hook-reviews');
286			if (hookReviews.length) {
287				html += hookReviews.clone().wrap('<div>').parent().html();
288			}
289			html += '<p class="product-desc">'+ $(element).find('.product-desc').html() + '</p>';
290			var colorList = $(element).find('.color-list-container').html();
291			if (colorList != null) {
292				html += '<div class="color-list-container">'+ colorList +'</div>';
293			}
294			var availability = $(element).find('.availability').html();	// check : catalog mode is enabled
295			if (availability != null) {
296				html += '<span class="availability">'+ availability +'</span>';
297			}
298			html += '</div>';
299			html += '<div class="right-block col-xs-4 col-sm-12 col-md-4"><div class="right-block-content row">';
300			var price = $(element).find('.content_price').html();       // check : catalog mode is enabled
301			if (price != null) {
302				html += '<div class="content_price col-xs-5 col-md-12">'+ price + '</div>';
303			}
304			html += '<div class="button-container col-xs-7 col-md-12">'+ $(element).find('.button-container').html() +'</div>';
305			html += '<div class="functional-buttons clearfix col-sm-12">' + $(element).find('.functional-buttons').html() + '</div>';
306			html += '</div>';
307			html += '</div></div>';
308			$(element).html(html);
309		});
310		$('.display').find('li#list').addClass('selected');
311		$('.display').find('li#grid').removeAttr('class');
312		$.totalStorage('display', 'list');
313	}
314	else
315	{
316		$('ul.product_list').removeClass('list').addClass('grid row');
317		$('.product_list > li').removeClass('col-xs-12').addClass('col-xs-12 col-sm-6 col-md-4');
318		$('.product_list > li').each(function(index, element) {
319			var html = '';
320			html += '<div class="product-container">';
321			html += '<div class="left-block">' + $(element).find('.left-block').html() + '</div>';
322			html += '<div class="right-block">';
323			html += '<div class="product-flags">'+ $(element).find('.product-flags').html() + '</div>';
324			html += '<h5 itemprop="name">'+ $(element).find('h5').html() + '</h5>';
325			var hookReviews = $(element).find('.hook-reviews');
326			if (hookReviews.length) {
327				html += hookReviews.clone().wrap('<div>').parent().html();
328			}
329			html += '<p itemprop="description" class="product-desc">'+ $(element).find('.product-desc').html() + '</p>';
330			var price = $(element).find('.content_price').html(); // check : catalog mode is enabled
331			if (price != null) {
332				html += '<div class="content_price">'+ price + '</div>';
333			}
334			html += '<div itemprop="offers" itemscope itemtype="https://schema.org/Offer" class="button-container">'+ $(element).find('.button-container').html() +'</div>';
335			var colorList = $(element).find('.color-list-container').html();
336			if (colorList != null) {
337				html += '<div class="color-list-container">'+ colorList +'</div>';
338			}
339			var availability = $(element).find('.availability').html(); // check : catalog mode is enabled
340			if (availability != null) {
341				html += '<span class="availability">'+ availability +'</span>';
342			}
343			html += '</div>';
344			html += '<div class="functional-buttons clearfix">' + $(element).find('.functional-buttons').html() + '</div>';
345			html += '</div>';
346			$(element).html(html);
347		});
348		$('.display').find('li#grid').addClass('selected');
349		$('.display').find('li#list').removeAttr('class');
350		$.totalStorage('display', 'grid');
351	}
352}
353
354function dropDown()
355{
356	elementClick = '#header .current';
357	elementSlide =  'ul.toogle_content';
358	activeClass = 'active';
359
360	$(elementClick).on('click', function(e){
361		e.stopPropagation();
362		var subUl = $(this).next(elementSlide);
363		if(subUl.is(':hidden'))
364		{
365			subUl.slideDown();
366			$(this).addClass(activeClass);
367		}
368		else
369		{
370			subUl.slideUp();
371			$(this).removeClass(activeClass);
372		}
373		$(elementClick).not(this).next(elementSlide).slideUp();
374		$(elementClick).not(this).removeClass(activeClass);
375		e.preventDefault();
376	});
377
378	$(elementSlide).on('click', function(e){
379		e.stopPropagation();
380	});
381
382	$(document).on('click', function(e){
383		e.stopPropagation();
384		var elementHide = $(elementClick).next(elementSlide);
385		$(elementHide).slideUp();
386		$(elementClick).removeClass('active');
387	});
388}
389
390function accordionFooter(status)
391{
392	if(status == 'enable')
393	{
394		$('#footer .footer-block h4').on('click', function(e){
395			$(this).toggleClass('active').parent().find('.toggle-footer').stop().slideToggle('medium');
396			e.preventDefault();
397		})
398		$('#footer').addClass('accordion').find('.toggle-footer').slideUp('fast');
399	}
400	else
401	{
402		$('.footer-block h4').removeClass('active').off().parent().find('.toggle-footer').removeAttr('style').slideDown('fast');
403		$('#footer').removeClass('accordion');
404	}
405}
406
407function accordion(status)
408{
409	if(status == 'enable')
410	{
411		var accordion_selector = '#right_column .block .title_block, #left_column .block .title_block, #left_column #newsletter_block_left h4,' +
412								'#left_column .shopping_cart > a:first-child, #right_column .shopping_cart > a:first-child';
413
414		$(accordion_selector).on('click', function(e){
415			$(this).toggleClass('active').parent().find('.block_content').stop().slideToggle('medium');
416		});
417		$('#right_column, #left_column').addClass('accordion').find('.block .block_content').slideUp('fast');
418		if (typeof(ajaxCart) !== 'undefined')
419			ajaxCart.collapse();
420	}
421	else
422	{
423		$('#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');
424		$('#left_column, #right_column').removeClass('accordion');
425	}
426}
427
428function bindUniform()
429{
430	if (!!$.prototype.uniform)
431		$("select.form-control,input[type='radio'],input[type='checkbox']").not(".not_uniform").uniform();
432}

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.