PageSourceSearch

https://e-aprendizaje.es/wp-content/themes/mx/js/jquery.theme.js?ver=3.1

js e-aprendizaje.es collected 2026-10-02 06:47:19 UTC 49,548 bytes, 1,664 lines download raw bytes

1// Description: MX Theme
2
3"use strict";
4
5jQuery(document).ready(function($) {
6  
7	/* ----------------------------------------------------
8		Functions
9	---------------------------------------------------- */
10	var totalCountTimerId = '';
11	
12	// ---------------------------------------
13	//	init menu
14	// ---------------------------------------
15	function menuInit(){
16		//add arrow
17		$('ul.mx-nav-menu > li > ul').each(function() {
18			if($('.site-header-style-1 ').length > 0 || $('.site-header-style-4 ').length > 0){
19				$(this).parent().children('a').append('<i class="fa fa-angle-down"></i>');
20			}
21
22			$(this).find('ul').each(function() {
23				$(this).parent().children('a').append('<i class="fa fa-angle-right"></i>');
24			});
25		});
26		
27		//mobile menu
28		$('.header-responsive-menu-btn').click(function() {
29			if($('#wpadminbar').length > 0){
30				$('#mobile-menu').css('top',$('#wpadminbar').height());
31				$('#mobile-menu').css('height',$(window).height()-$('#wpadminbar').height());
32			}else{
33				$('#mobile-menu').css('height',$(window).height());
34			}
35            $('#mobile-menu').animate({'right':0});
36			return false;
37        });
38		
39		$('.mobile-menu-close-btn').click(function() {
40             $('#mobile-menu').animate({'right':'-300px'});
41			$('.wrapper').css('height','auto');
42			return false;
43        });
44		
45	}
46	// ---------------------------------------
47	//	init mega menu
48	// ---------------------------------------
49	function megaMenuInit(){
50		// add arrow
51		$('ul.mx-nav-menu > li .mega-menu > ul').each(function() {
52			if($('.site-header-style-1').length > 0){
53				$(this).parent().parent().children('a').append('<i class="fa fa-angle-down"></i>');
54			}
55			
56			if($(this).parent().hasClass('mega-horizontal') && $(this).parent().hasClass('mega-wide')){
57				var column = $(this).children('li').length;
58				$(this).children('li').addClass('mega-menu-column-'+column);
59			}
60			
61			if($(this).parent().hasClass('mega-vertical')){
62				$(this).children('li').children('ul').each(function() {
63                    $(this).parent().children('a').prepend('<i class="fa fa-angle-right"></i>');
64                });
65			}
66		});
67		
68		// disable mega menu for header style 2, 3
69		if($('.site-header-style-2').length > 0 || $('.site-header-style-3').length > 0 || $('.site-header-style-4').length > 0){
70			$('.mega-menu-main .mega-menu.mega-vertical').each(function() {
71                $(this).parent().append($(this).html());
72				$(this).remove();
73            });
74		}
75		
76		$('.mega-menu-main .mega-menu.mega-wide.mega-vertical > ul > li').mouseover(function() {
77			var current_megamenu_width = 0;
78			var current_megamenu_height = 0;
79			var current_menu_top = $(this).position().top;
80			var current_menu_height = $(this).outerHeight();
81			var items = $(this).children('ul').children('li');
82			//var megamenu_item_max_width = 0;
83			for(var i=0; i<items.length;i++){
84				current_megamenu_width += $(items[i]).outerWidth();
85				if($(items[i]).outerHeight() > current_megamenu_height){
86					current_megamenu_height = $(items[i]).outerHeight();
87				}
88			}
89			
90			$(this).children('ul').css({'width':(current_megamenu_width + 2) + 'px'});
91			
92			if((current_menu_top - 6 +current_menu_height) > current_megamenu_height){
93				$(this).children('ul').css({'margin-top':( - current_megamenu_height + current_menu_height) + 'px'});
94			}else{
95				$(this).children('ul').css({'margin-top':( - current_menu_top + 6) + 'px'});
96			}
97		});
98		
99		var megamenu_main_width =0;
100		
101		$('.mega-menu-main .mega-menu.mega-horizontal').parent().mouseover(function() {
102			
103			if($(this).find('.mega-menu.mega-wide').length > 0){
104				if($('.site-header-style-2').length > 0 || $('.site-header-style-3').length > 0 || $('.site-header-style-4').length > 0){
105					megamenu_main_width = $('#mx-header').children('.container').width();
106					$(this).find('.mega-menu').css('width',megamenu_main_width);
107					$(this).find('.mega-menu').css('left', -($(this).parent().offset().left - $('#mx-header').children('.container').offset().left -15));
108				}
109				
110				clearMegaWidgetOver(this);
111				
112				return;
113			}
114			
115			megamenu_main_width = $(this).parent().width();
116			var current_menu_width = $(this).width();
117            var current_menu_left = $(this).position().left;
118			var current_megamenu_width = 0;
119			var items = $(this).find('.mega-menu > ul > li');
120			var target_position = 0;
121			var megamenu_item_max_width = 0;
122
123			for(var i=0; i<items.length;i++){
124				current_megamenu_width += $(items[i]).outerWidth();
125				if($(items[i]).outerWidth() > megamenu_item_max_width){
126					megamenu_item_max_width = $(items[i]).outerWidth();
127				}
128			}
129			
130			$(items).css('width',megamenu_item_max_width);
131			current_megamenu_width = items.length * megamenu_item_max_width;
132			
133			if($('.site-header-style-2').length > 0 || $('.site-header-style-4').length > 0){
134				
135				if(current_megamenu_width > megamenu_main_width){
136					$(this).find('.mega-menu').css({'left': -(current_megamenu_width - megamenu_main_width),'width':current_megamenu_width + 2});
137				}else{
138					var p_l = $(this).position().left + $('.mx-nav-menu').offset().left - $('#mx-header').children('.container').offset().left - 15;
139					
140					if( ($('#mx-header').children('.container').width() - p_l) > current_megamenu_width){
141						$(this).find('.mega-menu').css({'left': $(this).position().left ,'width':current_megamenu_width + 2});
142					}else{
143						$(this).find('.mega-menu').css({'right': 0 ,'width':current_megamenu_width + 2});
144					}
145				}
146				
147				//$(items).css('width',(current_megamenu_width - 30 * items.length - 2)/items.length);
148				clearMegaWidgetOver(this);
149				return;
150			}else if($('.site-header-style-3').length > 0){
151				if(current_megamenu_width > megamenu_main_width){
152					$(this).find('.mega-menu').css({'left': -((current_megamenu_width - megamenu_main_width)/2),'width':current_megamenu_width + 2});
153				}else{
154					var p_l2 = $(this).position().left + $('.mx-nav-menu').offset().left - $('#mx-header').children('.container').offset().left - 15;
155					
156					if( ($('#mx-header').children('.container').width() - p_l2) > current_megamenu_width){
157						$(this).find('.mega-menu').css({'left': $(this).position().left ,'width':current_megamenu_width + 2});
158					}else{
159						$(this).find('.mega-menu').css({'right': 0 ,'width':current_megamenu_width + 2});
160					}
161				}
162				
163				//$(items).css('width',(current_megamenu_width - 30 * items.length - 2)/items.length);
164				clearMegaWidgetOver(this);
165				return;
166			}
167			
168			
169			
170			if(current_megamenu_width > megamenu_main_width){
171				$(this).find('.mega-menu').css({'left':'0','width':'100%'});
172			}else if(current_megamenu_width > 3*current_menu_width){
173				target_position = current_megamenu_width/2;
174				target_position = target_position - current_menu_width/2;
175				if(current_menu_left-target_position > 0){
176					$(this).find('.mega-menu').css('left', current_menu_left-target_position +'px');
177				}else{
178					$(this).find('.mega-menu').css('left', '0');
179				}
180			}else{
181				if(current_menu_left + current_megamenu_width < megamenu_main_width){
182					$(this).find('.mega-menu').css('left',current_menu_left +'px');
183				}else{
184					$(this).find('.mega-menu').css('left',(megamenu_main_width-current_megamenu_width) +'px');
185				}
186			}
187			clearMegaWidgetOver(this);
188        });
189		
190		function clearMegaWidgetOver(element){
191			$('.mega-custom-widget-content').removeClass('over');
192			$(element).find('.mega-custom-widget-content').addClass('over');
193		}
194	}
195	// ---------------------------------------
196	//	title line menu
197	// ---------------------------------------
198	function titleLineInit(){
199		$('.line').each(function() {
200			if( $(this).children('.left-line').length === 0 ) {
201				$(this).append('<span class="left-line"></span>');
202			}
203			if( $(this).children('.right-line').length === 0 ) {
204				$(this).append('<span class="right-line"></span>');
205			}
206		});
207	}
208	// ---------------------------------------
209	//	quickly search tools
210	// ---------------------------------------
211	function quicklySearchToolsInit(){
212		var mouse_over = false;
213		
214		$('.header-search-btn').click(function() {
215			if($(this).hasClass('open')){
216				$(this).removeClass('open');
217				hideNormalSearch();
218			}else{
219				$(this).addClass('open');
220				$('.mx-form-search').fadeIn();
221				$('.mx-form-search').find('input').focus();
222				$(window).bind("click", hideNormalSearch );
223			}
224			return false; 
225		});
226		
227		$('.mx-form-search').mouseleave(function() { mouse_over = false; });
228		$('.mx-form-search').mouseenter(function() { mouse_over = true; });
229
230		function hideNormalSearch(){
231			if(!mouse_over){
232				$('.header-search-btn').removeClass('open');
233				$('.mx-form-search').fadeOut();
234				$(window).unbind("click", hideNormalSearch );
235			}
236		}
237		
238		// change product search submit button
239		$('.widget_product_search #searchsubmit').each(function() {
240            $(this).parent().append('<button type="submit" class="btn btn-theme"><i class="fa fa-search"></i></button>');
241			$(this).remove();
242        });
243	}
244	// ---------------------------------------
245	//	cart init
246	// ---------------------------------------
247	function cartInit(){
248		if($(window).width() > 700){
249			$('.mx-cart-list').mouseenter(function() {
250				$('.cart-list-contents-container').show();
251			});
252			$('.mx-cart-list').mouseleave(function() {
253				$('.cart-list-contents-container').hide();
254			});
255		}
256		
257	}
258	// ---------------------------------------
259	//	wishlist init
260	// ---------------------------------------
261	function wishlistInit(){
262		if($(window).width() > 700){
263			$('.mx-wish-list').mouseenter(function() {
264				$('.wish-list-contents').show();
265			});
266			$('.mx-wish-list').mouseleave(function() {
267				$('.wish-list-contents').hide();
268			});
269		}
270		
271	}
272	// ---------------------------------------
273	//	login init
274	// ---------------------------------------
275	function loginInit(){
276		if($(window).width() > 700){
277			$('.mx-wc-login').mouseenter(function() {
278				$('.user-contents-container').show();
279			});
280			$('.mx-wc-login').mouseleave(function() {
281				$('.user-contents-container').hide();
282			});
283		}
284		
285	}
286	// ---------------------------------------
287	//	run animation elements
288	// ---------------------------------------	
289	function animationRun(){
290		// check all single animate element
291		$('.animate').each(function(){
292			if($(this).hasClass('animated')){
293				return false;
294			}
295			if (checkPosition(this)) {
296				$(this).removeClass('animate');
297				exAnimate(this);
298			}
299		});
300		
301		// check all animate list element
302		$('.animate-list').each(function() {
303            var items = $(this).find('.animate-item');
304			var count = 0;			
305			for(var i=0;i<items.length;i++){
306				if($(items[i]).hasClass('animating') || $(items[i]).hasClass('animated')){
307					if(!$(items[i]).hasClass('animated')){
308						count++;
309					}else{
310						$(items[i]).removeClass('animating');
311						$(items[i]).removeClass('animate-item');
312					}
313					continue;
314				}
315				if (checkPosition(items[i])) {
316					listItemDelayEx(items[i],count);
317					count++;
318				}
319			}			
320        });
321		
322		// list item delay time and execute
323		function listItemDelayEx(element,count){
324			$(element).addClass('animating').delay(300*count).queue(function(){exAnimate(this);});
325		}
326		
327		// check element position
328		function checkPosition(element){
329			var imagePos = $(element).offset().top;
330			var topOfWindow = $(window).scrollTop();
331			var heightOfWindow = $(window).height();
332			if (imagePos < topOfWindow+heightOfWindow - 50) {
333				return true;
334			}
335			return false;
336		}
337		
338		// add class for element run animation
339		function exAnimate(element){
340			var effect = 'fadeIn';
341			if($(element).attr('data-effect') && $(element).attr('data-effect') !== ""){
342				effect = $(element).attr('data-effect');
343			}
344			$(element).addClass('animated '+effect);
345		}
346	}
347	
348	// ---------------------------------------
349	//	ajax get posts
350	// ---------------------------------------
351	function ajaxGetPostsInit(){
352		// check all ajax module
353		$('.ajax-main-area').each(function() {
354			
355			if($(this).children('.ajax-isotope').length === 0){
356				return;
357			}
358			
359			var layout_mode = "masonry";
360			var iso = $(this).children('.ajax-isotope');
361			
362			if($(this).children('.portfolio-ajax-type').length > 0){
363				var layoutMode = iso.attr('data-layoutmode');
364				if(!layoutMode || layoutMode === ""){
365					layout_mode = 'fitRows';
366				}else{
367					layout_mode = layoutMode;
368				}
369			}
370			
371			iso.isotope({
372				itemSelector: '.post-ajax-element',
373				layoutMode : layout_mode ,
374				transitionDuration : '0.8s',
375			});
376
377			iso.find('img').load(function() {
378				iso.isotope('layout');
379			});
380			 
381			// have no more posts
382			if($(this).find('.ajax-load-content').length === 0){
383				return false;
384			}
385
386			var ajax_main = $(this);
387			var ajax_load_content = $(ajax_main).find('.ajax-load-content');
388			var ajax_paged = parseInt(ajax_load_content.attr('data-page'));
389			var ajax_max_paged = parseInt(ajax_load_content.attr('data-max'));
390			var ajax_next_link = ajax_load_content.attr('data-link');
391			var ajax_loading	= false;
392			
393			// auto load posts
394			if($(ajax_main).find('.post-ajax-load-btn').length === 0){
395				$(window).scroll(function() {
396					if(ajax_loading || ajax_paged > ajax_max_paged) {return false;}
397					var imagePos = $(ajax_main).find('.ajax-load-btn-container').offset().top;
398					var topOfWindow = $(window).scrollTop();
399					var heightOfWindow = $(window).height();
400					if (imagePos < topOfWindow+heightOfWindow - 50) {
401						loadPostsContent();
402					}
403				});
404			}
405			
406			// load post content
407			function loadPostsContent(){
408				ajax_loading = true;
409				
410				$(ajax_main).find('.post-ajax-load-btn').hide();
411				$(ajax_main).find('.post-ajax-scroll-load').hide();
412				$(ajax_main).find('.post-ajax-loading').show();
413				
414				ajax_load_content.load(ajax_next_link + ' .post-ajax-element' , function(responseText, textStatus, XMLHttpRequest){
415					
416					if ( textStatus == "error" ) {
417						$(ajax_main).find('.post-ajax-loading').hide();
418						$(ajax_main).find('.post-ajax-load-btn').show();
419						$(ajax_main).find('.post-ajax-scroll-load').show();
420
421						ajax_loading = false;
422						return false;
423					}
424					
425					var new_elements = $($(ajax_load_content).html());
426					
427					ajax_load_content.html('');
428					
429					new_elements.find('.mx-fl').flexslider({slideshow:false,
430						start: function(){
431							iso.isotope( 'layout' );
432						}
433					});
434
435					new_elements.find('img').load(function() { iso.isotope('layout');	});
436					
437					iso.append(new_elements).isotope( 'appended',new_elements);
438					
439					ajax_paged++;
440					
441					if(ajax_paged <= ajax_max_paged) {
442						ajax_next_link = ajax_next_link.replace(/\/page\/[0-9]*/, '/page/'+ ajax_paged);
443						ajax_next_link = ajax_next_link.replace(/paged=[0-9]*/, 'paged='+ ajax_paged);
444						$(ajax_main).find('.post-ajax-loading').hide();
445						$(ajax_main).find('.post-ajax-load-btn').show();
446						$(ajax_main).find('.post-ajax-scroll-load').show();
447						ajax_loading = false;
448					}else{
449						$(ajax_main).find('.ajax-load-btn-container').remove();
450					}
451				
452				});
453			}
454			
455			// button click load posts
456			$(ajax_main).find('.post-ajax-load-btn').click(function() {
457				if(ajax_loading || ajax_paged > ajax_max_paged) {return false;}
458				loadPostsContent();
459            });
460        });
461	}
462	
463	// ---------------------------------------
464	//	post comment submit check
465	// ---------------------------------------
466	function postCommentCheck(){
467		checkElement("#comment-form", postCommentFieldCheck);
468		
469		function postCommentFieldCheck(params){
470			if($(params).find('#comment-alert-error').length > 0){
471				$(params).find('#comment-submit button[type=submit]').click(function() {
472					$(params).find('#comment-alert-error').removeClass('show');
473					$(params).find('#comment-alert-error span').removeClass('show');
474							
475					if($(params).find('.comment-alert-error-name').length > 0){
476						if($(params).find('#author').attr('value').length === 0){
477							$(params).find('#comment-alert-error').addClass('show');
478							$(params).find('.comment-alert-error-name').addClass('show');
479							return false;
480						}
481					}
482					if($(params).find('.comment-alert-error-email').length > 0){
483						if($(params).find('#email').attr('value').length === 0){
484							$(params).find('#comment-alert-error').addClass('show');
485							$(params).find('.comment-alert-error-email').addClass('show');
486							return false;
487						}
488						var reg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
489						
490						if(!reg.test($(params).find('#email').attr('value'))){
491							$(params).find('#comment-alert-error').addClass('show');
492							$(params).find('.comment-alert-error-email').addClass('show');
493							return false;
494						}
495					}
496					if($(params).find('.comment-alert-error-message').length > 0){
497						if($(params).find('#comment').attr('value').length === 0){
498							$(params).find('#comment-alert-error').addClass('show');
499							$(params).find('.comment-alert-error-message').addClass('show');
500							return false;
501						}
502					}
503					return true;
504				});
505			}
506		}
507	}
508	
509	// ---------------------------------------
510	//	button init
511	// ---------------------------------------
512	function buttonsInit(){
513		$('.btn-custom').each(function() {
514			if( $(this).attr('data-txtcolor') ) {
515				$(this).css('color',$(this).attr('data-txtcolor'));
516			}
517			if( $(this).attr('data-bgcolor') ) {
518				$(this).css('background',$(this).attr('data-bgcolor'));
519			}
520			
521			if( !$(this).hasClass('disabled') ){
522			
523				$(this).hover(function(){
524					if( $(this).attr('data-txthovercolor') ) {
525						$(this).css('color',$(this).attr('data-txthovercolor'));
526					}
527					if( $(this).attr('data-bghovercolor') ) {
528						$(this).css('background',$(this).attr('data-bghovercolor'));
529					}
530				},function(){
531					if( $(this).attr('data-txtcolor') ) {
532						$(this).css('color',$(this).attr('data-txtcolor'));
533					}
534					if( $(this).attr('data-bgcolor') ) {
535						$(this).css('background',$(this).attr('data-bgcolor'));
536					}
537					
538				});
539			}else{
540				$(this).click(function() {
541					return false;
542				});
543			}
544		});
545	}
546	
547	// ---------------------------------------
548	//	tooltip 
549	// ---------------------------------------
550	function tooltipInit(){
551		checkElement(".show-tooltip", tooltipCheck);
552		if($('.tagcloud a').length > 0){
553			$('.tagcloud a').tooltip();
554		}
555		function tooltipCheck(params){
556			var obj = {};
557			if($(params).attr('data-trigger') && $(params).attr('data-trigger') !== ""){
558				obj.trigger = $(params).attr('data-trigger');
559			}
560			if($(params).attr('data-placement') && $(params).attr('data-placement') !== ""){
561				obj.placement = $(params).attr('data-placement');
562			}
563			$(params).tooltip(obj);
564		}
565	}
566	// ---------------------------------------
567	//	popover 
568	// ---------------------------------------
569	function popoverInit(){
570		checkElement(".mx-popover", popoverCheck);
571		checkElement(".show-popover", popoverCheck);
572		
573		function popoverCheck(params){
574			var obj = {};
575			if($(params).attr('data-trigger') && $(params).attr('data-trigger') !== ""){
576				obj.trigger = $(params).attr('data-trigger');
577			}
578			if($(params).attr('data-placement') && $(params).attr('data-placement') !== ""){
579				obj.placement = $(params).attr('data-placement');
580			}
581			if($(params).attr('title') && $(params).attr('title') !== ""){
582				obj.title = $(params).attr('title');
583			}
584			if($(params).find('.mx-popover-content').length > 0){
585				obj.html = true;
586				obj.content = $(params).find('.mx-popover-content').html();
587			}
588			$(params).popover(obj);
589		}
590	}
591	// ---------------------------------------
592	//	Total Count 
593	// ---------------------------------------
594	
595	function totalcountInit(){
596		checkElement(".totalcount", totalcountCheck);
597		
598		function totalcountCheck(params){
599			if( $(params).hasClass('totalcount-complete') || $(params).hasClass('totalcount-run')){
600				return;
601			}
602			var currentValue = parseInt($(params).attr('data-from'));
603			var endValue = parseInt($(params).attr('data-end'));
604			
605			if(currentValue >= endValue){return;}
606			
607			var pos = $(params).offset().top;
608			var topOfWindow = $(window).scrollTop();
609			var heightOfWindow = $(window).height();
610			
611			if (pos < topOfWindow+heightOfWindow - 60) {
612				$(params).addClass('totalcount-run');
613				$(params).find('.totalnumber').text(milliFormat(String(currentValue)));
614				if(totalCountTimerId === ""){
615					totalCountTimerId = setInterval( totalcountTimerCheck ,100);
616				}
617			}
618		}
619	}
620	
621	function totalcountTimerCheck(){
622		var items = $('.totalcount-run');
623		for(var i=0; i<items.length;i++){
624			var currentValue = parseInt($(items[i]).attr('data-from'));
625			var stepValue = parseInt($(items[i]).attr('data-step'));
626			var endValue = parseInt($(items[i]).attr('data-end'));
627			currentValue += stepValue;
628			if(currentValue >= endValue){
629				currentValue = endValue;
630				$(items[i]).addClass('totalcount-complete');
631				$(items[i]).removeClass('totalcount-run');
632			}
633			$(items[i]).attr('data-from', currentValue);
634			$(items[i]).find('.totalnumber').text(milliFormat(String(currentValue)));
635		}
636		if($('.totalcount-run').length === 0){
637			clearInterval(totalCountTimerId);
638			totalCountTimerId = "";
639		}
640	}
641	function milliFormat(s){
642		if(/[^0-9\.]/.test(s)) return "invalid value";  
643		s=s.replace(/^(\d*)$/,"$1.");  
644		s=(s+"00").replace(/(\d*\.\d\d)\d*/,"$1");  
645		s=s.replace(".",",");  
646		var re=/(\d)(\d{3},)/;  
647		while(re.test(s)){  
648			s=s.replace(re,"$1,$2");  
649		}  
650		s=s.replace(/,(\d\d)$/,".$1");  
651		s=s.replace(/^\./,"0.");
652		s=s.replace(".00","");
653		return s;
654	}
655	
656	// ---------------------------------------
657	//	accordion
658	// ---------------------------------------
659	function accordionInit(){
660		$('.mx-accordion-main .accordion-toggle').click(function() {
661			if($(this).hasClass('collapsed')){
662				$($(this).attr('href')).parent().prevAll().find('.accordion-toggle').addClass('collapsed');
663				$($(this).attr('href')).parent().nextAll().find('.accordion-toggle').addClass('collapsed');
664			}
665		});
666	}
667	
668	// ---------------------------------------
669	//	one page Navigation
670	// ---------------------------------------
671	function onepageNavInit(){
672		checkElement(".mx-pagenav", pageNavCheck);
673		
674		function pageNavCheck(params){
675			var items = $(params).find('a');
676			if( $(params).hasClass('right')){
677				$(params).find('a').tooltip({placement:'left'});
678				$(params).css({ 'margin-top': -($(params).outerHeight()/2) });
679			}else if( $(params).hasClass('left')){
680				$(params).find('a').tooltip({placement:'right'});
681				$(params).css({ 'margin-top': -($(params).outerHeight()/2) });
682			}else{
683				$(params).find('a').tooltip({placement:'top'});
684				$(params).css({ 'margin-right': -($(params).outerWidth()/2) });
685			}
686			
687			$(items).click(function() {
688                if($(this).hasClass('current')){ return false; }
689				
690				if($(this).attr('href') == '#home'){
691					
692					$('body,html').animate({
693						scrollTop: 0
694					}, 800 , '', refreshPageNav);
695				}else if($($(this).attr('href')).length > 0){
696					var pos = $($(this).attr('href')).offset().top;
697					var target_position = pos -100;
698					$('body,html').animate({
699						scrollTop: target_position
700					}, 800 , '', refreshPageNav);
701				}
702				return false;
703            });
704		}
705		
706		//add one page scroll
707		$('.mx-nav-menu > li > a').each(function() {
708			menuItemClick(this);
709		});
710		
711		$('.mx-nav-mobile-menu > li > a').each(function() {
712			menuItemClick(this);
713		});
714		
715		function menuItemClick(element){
716			var str = $(element).attr('href');
717			if(str !== "" && String(str).substring(0,1) == "#" && ($(element).attr('href') == "#home" || $($(element).attr('href')).length > 0)){
718				$(element).click(function() {
719					if($(element).attr('href') == "#home"){
720						$('body,html').animate({
721							scrollTop: 0
722						}, 800 , '', refreshPageNav);
723					}else{
724						var pos = $($(element).attr('href')).offset().top;
725						var target_position = pos -100;
726						$('body,html').animate({
727							scrollTop: target_position
728						}, 800 , '', refreshPageNav);
729					}
730					return false;
731				});
732			}
733		}
734		
735		refreshPageNav();
736	}
737	function refreshPageNav(){
738		var navitems = $('.mx-pagenav');
739		var topOfWindow = $(window).scrollTop();
740		for(var i=0; i<navitems.length; i++){
741			var index = 0;
742			var items = $(navitems[i]).find('a');
743			for(var j=0;j<items.length;j++){
744				if($($(items[j]).attr('href')).length > 0 && $($(items[j]).attr('href')).offset().top -100 <= topOfWindow){
745					index = j;
746				}
747			}
748			$(items).removeClass('current');
749			$(items[index]).addClass('current');
750		}
751	}
752	// ---------------------------------------
753	//	services
754	// ---------------------------------------
755	function servicesInit(){
756		$('.services').each(function() {
757			
758			var max_screen_width = $(this).width();
759			var items = $(this).children('li');
760			var item_width = max_screen_width/items.length;
761			var count = items.length;
762			var max_height = 0;
763			
764			if(item_width < 170){
765				for(var i=0;i<items.length;i++){
766					count--;
767					if(max_screen_width/count > 170){
768						break;
769					}
770				}
771			}
772			
773			$(items).css('width',max_screen_width/count);
774			
775			for(var j=0; j<items.length; j++){
776				if($(items[j]).outerHeight() > max_height){
777					max_height = $(items[j]).outerHeight();
778				}
779			}
780			$(items).css('height',max_height);
781			
782        });
783	}
784	// ---------------------------------------
785	//	client
786	// ---------------------------------------
787	function clientsInit(){
788		$('.clients').each(function() {
789			var client =  $(this);
790			var max_screen_width = $(this).width();
791			var items = $(this).find('li');
792			var item_width = 60;
793			var count = 5;
794			var index = 0;
795
796			if($(window).width() > 900){
797				count = 5;
798			}else if($(window).width() > 700){
799				count = 4;
800			}else if($(window).width() > 400){
801				count = 2;
802			}else{
803				count = 1;
804			}
805			
806			item_width = max_screen_width/count;
807			
808			refreshItem(client, items, item_width);
809			refreshArrowEvent(client, index, count, items.length);
810			
811			$(this).find('.client-arrow-left').click(function() {
812				index--;
813				moveClientItems(client, index, item_width);
814				refreshArrowEvent(client, index, count, items.length);
815            });
816			
817			$(this).find('.client-arrow-right').click(function() {
818				index++;
819				moveClientItems(client, index, item_width);
820				refreshArrowEvent(client, index, count, items.length);
821            });
822			
823			$(window).resize(function() {
824				if($(window).width() > 900){
825					count = 5;
826				}else if($(window).width() > 700){
827					count = 4;
828				}else if($(window).width() > 400){
829					count = 2;
830				}else{
831					count = 1;
832				}
833				
834				index = 0;
835				
836				item_width = $(client).width()/count;
837			
838				refreshItem(client, items, item_width);
839				moveClientItems(client, index, item_width);
840				refreshArrowEvent(client, index, count, items.length);
841			
842			});
843			
844        });
845		
846		//refresh item width, height 
847		function refreshItem(element,items, width){
848			var max_height = 70;
849			$(items).css('width',width);
850			for(var j=0;j<items.length;j++){
851				$(items[j]).css('left',j*width);
852			}
853			for(var i=0;i<items.length;i++){
854				if($(items[i]).find('.a').height() > max_height){
855					max_height = $(items[i]).find('.a').outerHeight();
856				}
857			}
858			$(element).find('ul').css('height',max_height);
859		}
860		
861		//refresh items
862		function moveClientItems(element, index, width){
863			$(element).find('ul').animate({'margin-left':-index*width});
864		}
865		// change arrow
866		function refreshArrowEvent(element, index,count, length){
867			if(index <= 0){
868				$(element).find('.client-arrow-left').hide();
869			}else{
870				$(element).find('.client-arrow-left').show();
871			}
872			if(index+count > length-1){
873				$(element).find('.client-arrow-right').hide();
874			}else if(index + length > count){
875				$(element).find('.client-arrow-right').show();
876			}
877		}
878	}
879	// ---------------------------------------
880	//	testimonials
881	// ---------------------------------------
882	function testimonialsInit(){
883		
884		checkElement(".testimonials",openFeedback);
885
886		function openFeedback(params){
887			
888			var testimonial = $(params);
889			var cfb_items = $(params).find(".testimonials-item");
890			var nav = $(params).find(".testimonials-nav a");
891			var cfb_id = 0;
892			var cfb_max = cfb_items.length;
893			var run = false;
894			var intervalObj = null;
895			var auto = false;
896			var delay = 5000;
897			var cur_index = 0;
898			
899			function showPrevElement(){
900				if(run)	{return false;}
901				run = true;
902				closeInterval();
903				hideElement($(cfb_items[cfb_id]),prevElement);
904			}
905			
906			function showNextElement(){
907				if(run) {return false;}
908				run = true;
909				closeInterval();
910				hideElement($(cfb_items[cfb_id]),nextElement);
911			}
912			
913			function prevElement(){
914				cfb_id--;
915				if(cfb_id < 0)	{
916					cfb_id = cfb_max-1;
917				}
918				showElement();
919			}
920			
921			function nextElement(){
922				cfb_id++;
923				if(cfb_id >= cfb_max)	{
924					cfb_id = 0;
925				}
926				showElement();
927			}
928			
929			if(cfb_max <= 1){
930				$(params).find(".testimonials-nav").css('display','none');
931			}else{
932				$(params).find(".testimonials-prev").click(function() {
933					showPrevElement();
934				});
935				$(params).find(".testimonials-next").click(function() {
936					showNextElement();
937				});
938				$(params).find(".testimonials-nav a").click(function() {
939					if(run || $(this).index() == cfb_id) {return false;}
940					run = true;
941					closeInterval();
942					cur_index = cfb_id;
943                    cfb_id = $(this).index();
944					hideElement($(cfb_items[cur_index]),showElement);
945                });
946				
947				// auto play
948				if( $(params).hasClass('testimonials-auto') ){
949					auto = true;
950					if(parseInt(testimonial.attr('data-delay')) > 0){
951						delay = parseInt(testimonial.attr('data-delay'));
952					}
953				}
954			}
955			
956			showElement();
957			
958			function showElement(){
959				if($(cfb_items[cfb_id]).css("display") !== "block"){
960					$(cfb_items[cfb_id]).fadeIn("fast");
961				}
962				if(nav.length > 0){
963					$(nav).removeClass('current');
964					$(nav[cfb_id]).addClass('current');
965				}
966				run = false;
967				if(auto) { startInterval(); }
968			}
969			
970			//hide text slider elements effect
971			function hideElement(params,nextElement){
972				if($(params).css("display") === "block"){
973					$(params).fadeOut("fast","",nextElement);
974				}
975			}
976			
977			function startInterval(){
978				intervalObj = setInterval(showNextElement , delay);
979			}
980			
981			function closeInterval(){
982				if(intervalObj !== null) { clearInterval(intervalObj); }
983				intervalObj = null;
984			}
985		}
986	}
987	
988	// ---------------------------------------
989	//	Carousel Auto Play
990	// ---------------------------------------
991	function carouselInit(){
992		$('.carousel-auto').each(function() {
993			if($(this).attr('data-delay')){
994				$(this).carousel({interval: $(this).attr('data-delay')});
995			}
996		});
997		$('.carousel-stop').each(function() {
998			$(this).carousel({interval: false});
999		});
1000	}
1001	
1002	// ---------------------------------------
1003	//	skills animation run
1004	// ---------------------------------------
1005	function skillsAnimationRun(){
1006		$(".skills").each(function() {
1007			if($(this).hasClass('skill-animation-complete')){
1008				return;
1009			}
1010			if($(this).children('li').length == $(this).find('.skill-animation-run').length){
1011				$(this).addClass('skill-animation-complete');
1012				$(this).find('.skill-animation-run').removeClass('skill-animation-run');
1013				return;
1014			}
1015			var items = $(this).children('li');
1016			var count = 0;
1017			for(var i=0;i<items.length;i++){
1018				if($(items[i]).find('.skill-cover').hasClass('.skill-animation-run')){
1019					continue;
1020				}
1021				var pos = $(this).offset().top;
1022				var topOfWindow = $(window).scrollTop();
1023				var heightOfWindow = $(window).height();
1024				if (pos < topOfWindow+heightOfWindow - 60) {
1025					$(items[i]).find('.skill-cover').addClass('skill-animation-run').animate({width:$(items[i]).find('.skill-cover').attr('data-percent')},{duration:(400*count + 500)});
1026				}
1027				count++;
1028			}
1029           
1030        });
1031	}
1032	
1033	// ---------------------------------------
1034	//	Tabs & SideTabs
1035	// ---------------------------------------
1036	function tabsInit(){
1037			
1038		/* tabs */
1039		checkElement(".tabs",tabsBack);
1040		
1041		/* side tabs */
1042		checkElement(".sidetabs",sideTabsBack);
1043		
1044		/* back fun */
1045		function tabsBack(params){
1046			openTabs(params,".tabs-nav li",".tabs-content");
1047		}
1048		
1049		function sideTabsBack(params){
1050			openTabs(params,".sidetabs-nav li",".sidetabs-content");
1051		}
1052		
1053		function openTabs(params,pname1,pname2){
1054			var ot_items = $(params).find(pname1);
1055			var citems = $(params).find(pname2);
1056			var ot_s1 = 0;
1057			var ot_sm = ot_items.length;
1058			var ot_new;
1059			
1060			$(ot_items).click(function() {
1061				if(ot_s1 === $(this).index()) {
1062					return false;
1063				}
1064				
1065				$(citems[ot_s1]).stop(true,true);
1066				$(citems[ot_s1]).css("opacity",1);
1067				
1068				ot_new = $(this).index();
1069				
1070				$(ot_items[ot_s1]).removeClass("current");
1071				$(ot_items[ot_new]).addClass("current");
1072				
1073				if($(citems[ot_s1]) !== null) {
1074					$(citems[ot_s1]).fadeOut("fast","",runNewTabs);
1075				}
1076			});
1077			
1078			function runNewTabs(){
1079				ot_s1 = ot_new;
1080				showElement(ot_s1,citems);
1081			}
1082			
1083			for(var k=0; k<ot_sm;k++) {
1084				if(ot_s1 === k){
1085					if($(ot_items[k]).hasClass("current") === false) {
1086						$(ot_items[k]).addClass("current");
1087					}
1088					showElement(k,citems);
1089				}else{
1090					if($(ot_items[k]).hasClass("current") === true)	{
1091						$(ot_items[k]).removeClass("current");
1092					}
1093					hideElement(k,citems);
1094				}
1095			}
1096		}
1097		
1098		function showElement(k,citems){
1099			if($(citems[k]) !== null)	{
1100				$(citems[k]).fadeIn("fast");
1101			}
1102		}
1103		
1104		function hideElement(k,citems){
1105			if($(citems[k]) !== null)	{
1106				$(citems[k]).fadeOut("fast");
1107			}
1108		}
1109	}/* end tabs */
1110	
1111	// ---------------------------------------
1112	//	minibarInit
1113	// ---------------------------------------
1114	function minibarInit(){
1115		
1116		if($('.mx-mini-bar').length == 0){
1117			return;
1118		}
1119		
1120		if($('.mx-mini-bar').hasClass('open')){
1121			$('.mx-mini-bar').animate({'left':0},300);
1122		}else{
1123			$('.mini-bar-open').animate({'left':0},300);
1124		}
1125		
1126		var run = false;
1127		$('.mini-bar-open').click(function() {
1128			if(run){return;}
1129			run = true;
1130			$('.mini-bar-open').animate({'left':-36},300);
1131            $('.mx-mini-bar').delay(300).animate({'left':0},300,'',function(){run = false;});
1132        });
1133		
1134		$('.mini-bar-close').click(function() {
1135			if(run){return;}
1136			run = true;
1137            $('.mx-mini-bar').animate({'left':-36},300);
1138            $('.mini-bar-open').delay(300).animate({'left':0},300,'',function(){run = false;});
1139        });
1140		
1141		$('.mx-mini-bar-btns').css('margin-top',-$('.mx-mini-bar-btns').height()/2);
1142		
1143		$('.mx-mini-bar-btns > ul > li').mouseenter(function() {
1144            $(this).find('.minibar-content').show();
1145			var top = $(this).offset().top - $(window).scrollTop();
1146			var screen_height = $(window).height();
1147			if( $(this).find('.minibar-content').outerHeight() + top > screen_height){
1148				var move_value = screen_height - $(this).find('.minibar-content').outerHeight() - top;
1149				if(move_value + top < 0){
1150					move_value = -top;
1151					$(this).find('.minibar-content').css({'overflow-y':'scroll','height':screen_height});
1152				}else{
1153					$(this).find('.minibar-content').css({'overflow-y':'hidden','height':'auto'});
1154				}
1155			$(this).find('.minibar-content').css('margin-top', move_value);
1156			}
1157			return false;
1158        });
1159		
1160		$('.mx-mini-bar-btns > ul > li').mouseleave(function() {
1161              $(this).find('.minibar-content').hide();
1162			  $(this).find('.minibar-content').css({'overflow-y':'hidden','height':'auto','margin-top':0});
1163			  return false;
1164        });
1165	}
1166	
1167	// ---------------------------------------
1168	//	Scroll & Resize Window 
1169	// ---------------------------------------
1170	function scrollResizeInit(){
1171		$("body").append('<a id="back-top" href="#top" ><i class="fa fa-arrow-up"></i></a>');
1172			
1173		$(window).resize(function() {
1174			// service resize
1175			servicesInit();
1176			// isotope
1177			refreshIsotope();
1178			if($('.header-fixed-support').length > 0)	{fixedHeader();}
1179			$('#mobile-menu').css('height',$(window).height());
1180		});
1181			
1182		$(window).scroll(function() {
1183			// fixed header
1184			if($('.header-fixed-support').length > 0)	{fixedHeader();}
1185			// skills bar
1186			skillsAnimationRun();
1187			// total count
1188			totalcountInit();
1189			// one page nav 
1190			if($('.mx-pagenav').length > 0){refreshPageNav();}
1191			// animation element
1192			animationRun();
1193			// back top button
1194			if($(window).scrollTop() > 200){
1195				$("#back-top").fadeIn("slow");
1196			}else{
1197				$("#back-top").fadeOut("slow");
1198			}
1199		});
1200		
1201		// scroll body to 0px on click
1202		$('#back-top').click(function () {
1203			$('body,html').animate({
1204				scrollTop: 0
1205			}, 800);
1206			return false;
1207		});
1208		
1209		// refresh fixed menu style
1210		function fixedHeader(){
1211			var top_height = $('#header-wrap').outerHeight();
1212			if($(window).width() > 979 && $(window).scrollTop() > top_height) {
1213				if($('.header-fixed-support').hasClass('fixed-enabled')){
1214					return;
1215				}
1216				$('.header-fixed-support').addClass('fixed-enabled');
1217				if($('#wpadminbar').length > 0){
1218					if($('#mx-nav').length > 0){
1219						$('#mx-nav').stop(true,true).animate({'top':$('#wpadminbar').height()},500);
1220					}else{
1221						$('#site-header').stop(true,true).animate({'top':$('#wpadminbar').height()},300);
1222					}
1223				}else{
1224					if($('#mx-nav').length > 0){
1225						$('#mx-nav').stop(true,true).css('top','-100px').animate({'top':'0px'},500);
1226					}else{
1227						$('#site-header').stop(true,true).css('top','-100px').animate({'top':'0px'},300);
1228					}
1229				}
1230
1231			}else{
1232				if(!$('.header-fixed-support').hasClass('fixed-enabled') && $('#mx-nav').css('top') === 0){
1233					return;
1234				}
1235				$('.header-fixed-support').removeClass('fixed-enabled');
1236				if($('#mx-nav').length > 0){
1237					$('#mx-nav').stop(true,true).css({'top':0});
1238				}else{
1239					$('#site-header').stop(true,true).css({'top':0});
1240				}
1241			}
1242		}
1243	} 
1244	// ---------------------------------------
1245	//	Touch Hover Effect -----------
1246	// ---------------------------------------
1247	function touchHoverSolve(){
1248		if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) {
1249			$('.post-tip').remove();
1250			$('.post-mask-content').remove();
1251			$('.mx-fl').addClass('touch');
1252			
1253			$('#header-topbar .wpml').click(function() {
1254				if($(this).hasClass('touch')){
1255					$(this).removeClass('touch');
1256				}else{
1257					$(this).addClass('touch');
1258				}
1259			});
1260		}
1261	}
1262	// ---------------------------------------
1263	//	headerBannerInit -----------
1264	// ---------------------------------------
1265	function headerBannerInit(){
1266		if(navigator.cookieEnabled){
1267			if($('#header-banner').length > 0){
1268				var cookie = getCookie("mx-header-banner");
1269				//show header banner
1270				if(cookie === null || cookie !== $('#header-banner').attr('data-id') ){
1271					$('#header-banner').css({marginTop:-($('#header-banner').height() + 1), display:'block'});
1272					$('#header-banner').animate({marginTop:0},600);
1273					$('#header-banner .close-btn').click(function() {
1274						$('#header-banner').animate({marginTop:-($('#header-banner').height() + 1)},600,'',function(){ $('#header-banner').remove(); });
1275						addCookie("mx-header-banner", $('#header-banner').attr('data-id') , 24);
1276						return false;
1277					});
1278				}else{
1279					$('#header-banner').remove();
1280				}
1281			}
1282		}
1283	}
1284	// ---------------------------------------
1285	//	COMMON -----------  check element and ex fun
1286	// ---------------------------------------
1287	function checkElement(params,fun){
1288		var list = $(params);
1289	
1290		if(list.length <= 0) {return false;}
1291		
1292		for (var w=0; w<list.length; w++)	{
1293			fun(list[w]);
1294		}
1295	}
1296	// ---------------------------------------
1297	//	Cookie ----------- save ,delete ,get cookie
1298	// ---------------------------------------
1299	function addCookie(name,value,hours){
1300		var str = name + "=" + value; 
1301		if(hours > 0){
1302			var date = new Date();
1303			var ms = hours*3600*1000;
1304			date.setTime(date.getTime() + ms);
1305			str += "; expires=" + date.toGMTString();
1306		}
1307		document.cookie = str;
1308	}
1309	function getCookie(name){
1310		var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
1311		if(arr !== null) {
1312			return arr[2]; 
1313		}
1314		return null;
1315	}
1316	
1317	menuInit();
1318	megaMenuInit();
1319	titleLineInit();
1320	quicklySearchToolsInit();
1321	ajaxGetPostsInit();
1322	postCommentCheck();
1323	buttonsInit();
1324	accordionInit();
1325	testimonialsInit();
1326	servicesInit();
1327	clientsInit();
1328	carouselInit();
1329	tooltipInit();
1330	popoverInit();
1331	totalcountInit();
1332	tabsInit();
1333	onepageNavInit();
1334	skillsAnimationRun();
1335	cartInit();
1336	wishlistInit();
1337	loginInit();
1338	minibarInit();
1339	touchHoverSolve();
1340	animationRun();
1341	scrollResizeInit();
1342	headerBannerInit();
1343
1344	// flexslide
1345	$('.mx-fl').each(function() {
1346		$(this).addClass('mx-fl-init');
1347		if($(this).attr('data-delay')){
1348			$(this).flexslider({slideshow: true , slideshowSpeed:$(this).attr('data-delay') });
1349		}else{
1350			$(this).flexslider({slideshow: false });
1351		}
1352	});
1353	
1354	//fancybox
1355	if($.fn.fancybox !== null)	{
1356		$("a[class^='fancyBox']").fancybox();
1357		$("a[class^='fancybox-thumb']").fancybox({helpers: {title: {type: 'outside'},thumbs: {width: 50,height	: 50}}});
1358	}
1359
1360	// isotope filters
1361	$('.portfolio-main-area').each(function() {
1362		if($(this).find('.portfolio-isotope').length === 0){return false;}
1363		var portfolio = $(this);
1364		var cat_ul = '';
1365		var cat_select = '';
1366		
1367		$(portfolio).find('.portfolio-filters-cats a').click(function() {
1368			if($(this).hasClass('active'))	{return false;}
1369			$(this).addClass('active');
1370			$(this).parent().prevAll().find('a').removeClass('active');
1371			$(this).parent().nextAll().find('a').removeClass('active');
1372			var filters = $(this).attr('data-filters');
1373			if(filters != '*'){
1374				cat_ul = filters;
1375			}else{
1376				cat_ul = "";
1377			}
1378			if(cat_select !== ''){
1379				if(filters == "*"){
1380					filters = "";
1381				}
1382				filters += cat_select;
1383			}
1384			$(portfolio).find('.portfolio-isotope').isotope({ filter: filters });
1385		});
1386		
1387		$(portfolio).find('.portfolio-filters-cats-select select').change(function() {
1388			var filters = $(this).find('option').get($(this).get(0).selectedIndex).getAttribute('value');
1389			if(filters != '*'){
1390						cat_select = filters;
1391			}else{
1392					cat_select = "";
1393			}
1394			if(cat_ul !== ''){
1395				if(filters == "*"){
1396					filters = "";
1397				}
1398				filters += cat_ul;
1399			}
1400			$(portfolio).find('.portfolio-isotope').isotope({ filter: filters });
1401		});
1402	});
1403
1404	$('.portfolio-isotope').each(function() {
1405		var layoutMode = $(this).attr('data-layoutmode');
1406		if(!layoutMode || layoutMode === ""){
1407			layoutMode = 'fitRows';
1408		}
1409        $(this).isotope({
1410			itemSelector: '.portfolio-element',
1411			layoutMode : layoutMode,
1412			transitionDuration : '0.8s'
1413		});
1414    });
1415	
1416	$('.portfolio-isotope').find('img').load(function() {
1417        refreshIsotope();
1418    });
1419	
1420});
1421
1422jQuery(window).on("load", function() {
1423	refreshIsotope();
1424});
1425
1426function refreshIsotope(){
1427	jQuery('.portfolio-isotope').isotope( 'layout' );
1428	jQuery('.ajax-isotope').isotope( 'layout' );
1429}
1430
1431// Description: MX Theme for WooCommerce
1432(function($) {
1433	
1434	var mxpreviewInit = false;
1435	var MxPreview = function(){
1436
1437		if(!$('.product .woocommerce-main-image') || mxpreviewInit){
1438			return false;
1439		}
1440		
1441		mxpreviewInit = true;
1442		
1443		// sort list
1444		
1445		$('.woocommerce-ordering .orderby-list > li > .list-name').click(function() {
1446            if($(this).parent().hasClass('open')){
1447				$(this).parent().removeClass('open');
1448			}else{
1449				$(this).parent().addClass('open');
1450			}
1451        });
1452		
1453		$('.woocommerce-ordering .orderby-list li li').click(function() {
1454			if($(this).hasClass('select')){return false;}
1455			
1456            $('.woocommerce-ordering input.orderby-name').attr('value',$(this).attr('data-value'));
1457			
1458			$('.woocommerce-ordering').submit();
1459        });
1460		
1461		$('.orderby-list-page-number li li').click(function() {
1462            if($(this).hasClass('select')){return false;}
1463			if($('.woocommerce-ordering input[name=woo-per-page-num]').length === 0){
1464				$('.woocommerce-ordering').append('<input type="hidden" name="woo-per-page-num" value="'+ $(this).attr('data-value') + '" />');
1465			}else{
1466				$('.woocommerce-ordering input[name=woo-per-page-num]').attr('value',$(this).attr('data-value'));
1467			}
1468			if($('.woocommerce-ordering input[name=paged]').length !== 0){
1469				$('.woocommerce-ordering input[name=paged]').attr('value','1');
1470			}
1471			
1472			$('.woocommerce-ordering').submit();
1473        });
1474		
1475		$('.woocommerce-ordering-listorder a').click(function() {
1476            if($(this).hasClass('select') && $(this).find('i').length === 0){
1477				return false;
1478			}
1479			
1480			if($(this).hasClass('listorder-price')){
1481				if($(this).hasClass('up')){
1482					$('.woocommerce-ordering input.orderby-name').attr('value','price-desc');
1483				}else{
1484					$('.woocommerce-ordering input.orderby-name').attr('value','price');
1485				}
1486				
1487			}else if($(this).hasClass('listorder-popularity')){
1488				
1489				$('.woocommerce-ordering input.orderby-name').attr('value','popularity');
1490				
1491			}else if($(this).hasClass('listorder-rate')){
1492				$('.woocommerce-ordering input.orderby-name').attr('value','rating');
1493			}
1494			
1495			$('.woocommerce-ordering').submit();
1496			
1497        });
1498		
1499		
1500		// image move 
1501		
1502		var supportMove = true;
1503		
1504		if($(window).width() < 768){
1505			supportMove = false;
1506		}
1507		
1508		
1509		var moveLeave = true;
1510		var canMove = false;
1511		var percent = 1;
1512		var main_x;
1513		var main_y;
1514		var main_w;
1515		var main_h;
1516		var cover_w;
1517		var cover_h;
1518		var e_x;
1519		var e_y;
1520		var had_load = false;
1521		
1522		if( $('.thumbnails-ul li').length > 0 ){
1523			$('.product .woocommerce-main-image').click(function() {
1524				$($('.thumbnails-ul li').get(0)).find('a').click();
1525				return false;
1526			});
1527			$($('.thumbnails-ul li').get(0)).find('a').addClass('current');
1528		}
1529		
1530		if(supportMove){
1531			// support zoom effect
1532			$('.product .woocommerce-main-image').addClass('move');
1533
1534			// mouse enter
1535			$('.product .woocommerce-main-image').mouseenter(function(e) {
1536				
1537				checkImageRefresh();
1538				
1539				removeAllElement();
1540				e_x = e.pageX;
1541				e_y = e.pageY;
1542				moveLeave = false;
1543				had_load = false;
1544				$('.preview_loading').addClass('show');
1545				$('.preview_zoom').append('<img src="'+ $('.product .woocommerce-main-image').attr('data-url') + '" alt="" />');
1546				$('.preview_zoom').css({width:$(this).width(),height:$(this).height(),'left':$(this).width() + 5});
1547				if($('.preview_zoom').find('img').width() > 0){
1548					$('.preview_zoom').addClass('show');
1549					imgLoaded();
1550					had_load = true;
1551				}else{
1552					$('.preview_zoom').addClass('show');
1553					$('.preview_zoom').find('img').bind('load', imgLoaded);
1554					had_load = true;
1555				}
1556			});
1557			
1558			// mouse move
1559			$('.product .woocommerce-main-image').mousemove(function(e) {
1560				e_x = e.pageX;
1561				e_y = e.pageY;
1562				
1563				if(canMove || had_load){
1564					refreshCoverPosition($('.preview_cover'),$('.preview_zoom').find('img'));
1565				}
1566				
1567				return false;
1568			});
1569			
1570			// mouse out
1571			$('.product .woocommerce-main-image').mouseleave(function() {
1572				removeAllElement();
1573			});
1574		}else{
1575			// mouse enter
1576			$('.product .woocommerce-main-image').mouseenter(function() {
1577				checkImageRefresh();
1578			});
1579		}
1580		
1581		// thumbnails items mouse over
1582		$('.thumbnails-ul li a').mouseenter(function() {
1583			if( $(this).hasClass('current') ){return false;}
1584			mouseEnterThumbs($(this));
1585			return false;
1586		});
1587		
1588		// thumbnails mouse over fun
1589		function mouseEnterThumbs(element){
1590			$('.thumbnails-ul li a').removeClass('current');
1591			$(element).addClass('current');
1592			$('.product .woocommerce-main-image img').attr('src',$(element).attr('data-single'));
1593			$('.product .woocommerce-main-image').attr('data-url',$(element).attr('href'));
1594		}
1595		
1596		// delete element as not need show
1597		function removeAllElement(){
1598			$('.preview_loading').removeClass('show');
1599			$('.preview_cover').removeClass('show');
1600			$('.preview_zoom').removeClass('show');
1601			$('.preview_zoom').children('img').remove();
1602			canMove = false;
1603			moveLeave = true;
1604		}
1605		
1606		// image load show zoom
1607		function imgLoaded(){
1608			$('.preview_loading').removeClass('show');
1609			if(moveLeave){
1610				removeAllElement();
1611				return;
1612			}
1613			percent = $('.preview_zoom').find('img').width()/$('.preview_zoom').width();
1614			main_x = $('.product .woocommerce-main-image').offset().left;
1615			main_y = $('.product .woocommerce-main-image').offset().top;
1616			main_w = $('.product .woocommerce-main-image').width();
1617			main_h = $('.product .woocommerce-main-image').height();
1618			cover_w = main_w/ percent;
1619			cover_h = main_h/ percent;
1620			$('.preview_cover').css({'width':cover_w , 'height': cover_h});
1621			$('.preview_cover').addClass('show');
1622			refreshCoverPosition($('.preview_cover'),$('.preview_zoom').find('img'));
1623			canMove = true;
1624		}
1625		
1626		//refresh image position
1627		function refreshCoverPosition(target,target2){
1628			var c_x = e_x - main_x;
1629			var c_y = e_y - main_y;
1630			var p_x = c_x - cover_w/2;
1631			var p_y = c_y - cover_h/2;
1632			if(p_x <= 0){ 
1633				p_x = 0;
1634			}else if(p_x+cover_w >= main_w){
1635				p_x = main_w - cover_w;
1636			}
1637			if(p_y <= 0){ 
1638				p_y = 0;
1639			}else if(p_y+cover_h >= main_h){
1640				p_y = main_h - cover_h;
1641			}
1642			$(target).css({'left':p_x , 'top': p_y});
1643			$(target2).css({'margin-left':-p_x*percent , 'margin-top':-p_y*percent});
1644		}
1645
1646		// product variations change
1647		function checkImageRefresh(){
1648			if($('.product .woocommerce-main-image img').attr('src') != $('.thumbnails-ul li a.current').attr('data-single')){
1649				var items = $('.thumbnails-ul li a');
1650				for(var i=0;i<items.length;i++){
1651					if($(items[i]).attr('data-single') == $('.product .woocommerce-main-image img').attr('src')){
1652						mouseEnterThumbs($(items[i]));
1653						break;
1654					}
1655				}
1656			}
1657		}
1658	};
1659	
1660	$.fn.mxpreview = function(){
1661      var mxpre = new MxPreview();
1662	};
1663
1664})(jQuery);

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.