PageSourceSearch

http://vnhow.vn/js/script.js

js vnhow.vn collected 2026-10-08 07:51:31 UTC 22,123 bytes, 929 lines download raw bytes

1(function($){
2	"use strict";
3
4	$(function(){
5
6		// ie9 placeholder
7
8		if($('html').hasClass('ie9')) {
9			$('input[placeholder]').each(function(){
10				$(this).val($(this).attr('placeholder'));
11				var v = $(this).val();
12				$(this).on('focus',function(){
13					if($(this).val() === v){
14						$(this).val("");
15					}
16				}).on("blur",function(){
17					if($(this).val() == ""){
18						$(this).val(v);
19					}
20				});
21			});
22			
23		}
24
25		// remove products from shopping cart
26		
27		$('[role="banner"]').on('click','.close_product',function(){
28			$(this).closest('li').animate({'opacity':'0'},function(){
29				$(this).slideUp(500);
30			});
31		});
32
33
34		// responsive menu
35
36		window.rmenu = function(){
37
38			var	nav = $('nav[role="navigation"]'),
39				header = $('[role="banner"]');
40
41			var rMenu = new Object();
42
43			rMenu.init = function(){
44				rMenu.checkWindowSize();
45				$(window).on('resize',rMenu.checkWindowSize);
46			}
47
48			rMenu.checkWindowSize = function(){
49
50				if($(window).width() < 992){
51					rMenu.Activate();
52				}
53				else{
54					rMenu.Deactivate();
55				}
56
57			}
58			// add click events
59			rMenu.Activate = function(){
60				if($('html').hasClass('md_touch')) header.off('.touch');
61				header.off('click').on('click.responsivemenu','#menu_button',rMenu.openClose);
62				header.on('click.responsivemenu','.main_menu li a',rMenu.openCloseSubMenu);
63				nav.find('.touch_open_sub').removeClass('touch_open_sub').children('a').removeClass('prevented');
64			}
65			// remove click events
66			rMenu.Deactivate = function(){
67				header.off('.responsivemenu');
68				nav.removeAttr('style').find('li').removeClass('current_click')
69				.end().find('.sub_menu_wrap').removeAttr('style').end().find('.prevented').removeClass('prevented').end()
70				if($('html').hasClass('md_touch')) header.off('click').on('click.touch','.main_menu li a',rMenu.touchOpenSubMenu);
71			}
72
73			rMenu.openClose = function(){
74
75				$(this).toggleClass('active');
76				nav.stop().slideToggle();
77
78			}
79
80			rMenu.openCloseSubMenu = function(e){
81
82				var self = $(this);
83
84				if(self.next('.sub_menu_wrap').length){
85					self.parent()
86						.addClass('current_click')
87						.siblings()
88						.removeClass('current_click')
89						.children(':not(span,a)')
90						.slideUp();
91					self.next().stop().slideToggle();
92					self.parent().siblings().children('a').removeClass('prevented');
93
94					if(!(self.hasClass('prevented'))){
95						e.preventDefault();
96						self.addClass('prevented');
97					}else{
98						self.removeClass('prevented');
99					}
100				}
101
102			}
103
104			rMenu.touchOpenSubMenu = function(event){
105				var self = $(this);
106
107				if(self.next('.sub_menu_wrap').length){
108
109					if(!(self.hasClass('prevented'))){
110						event.preventDefault();
111						self.addClass('prevented');
112					}else{
113						self.removeClass('prevented');
114					}
115
116				}
117				
118			}
119
120			rMenu.init();
121		}
122
123		rmenu();
124
125		/*Search_holder*/
126
127		window.search_holder = function(){
128
129			var searchHolder = $('.search-holder');
130
131			if (searchHolder.length) {
132				searchHolder.searchClick();
133			}
134
135		}
136
137		search_holder();
138
139		// twitter feed
140/*
141		window.tweet_slider = function(){
142
143			if($(".tweets").length){
144
145				var follow = $(".tweets").next('.tw_follow'),
146					config = {
147						username : 'fanfbmltemplate',
148						modpath: 'plugins/twitter/',
149						loading_text : '<img src="images/loader2.gif" alt="">',
150						template : '<p>{text}</p><p>{time}</p>'
151					}
152
153				$(".tweets").each(function(){
154
155					var self = $(this);
156
157					if(self.hasClass('single')){
158						config.template = '<p>{text}</p><p>{time}</p>';
159					}
160					self.tweet(config);
161					if(self.hasClass('single')){
162						var owl = self.data('owlCarousel');
163
164						$('.twc_prev').on('click',function(){owl.trigger('owl.prev');});
165						$('.twc_next').on('click',function(){owl.trigger('owl.next');});
166					}
167
168					var owlConfig = {
169						navSpeed : 800,
170						nav:true,
171						loop:true,
172						autoplay:true,
173	      				autoplaySpeed: 800,
174			    		navText:false,
175						items: 1,
176						onInitialized : function(){
177							self.find('.tweet_odd').parent().remove();
178						}
179					}
180
181					self.children('.tweet_list').owlCarousel(owlConfig);
182
183				});
184				follow.attr('href','https://twitter.com/'+config.username);
185			}
186
187			// twitter  
188
189		    jQuery('#twitter').tweet({
190		        username : 'fanfbmltemplate',
191				modpath: 'plugins/twitter/',
192				loading_text : '<img src="images/loader2.gif" alt="">',
193				template : '<li><p>{text}</p><p>{time}</p></li>'
194	    	})
195
196	    }
197
198	    tweet_slider();
199		*/
200		// News carousel
201
202		$("#owl-demo").owlCarousel({
203	      nav : true,
204	      navText:false,
205	      navSpeed: 800,
206	      loop:true,
207	      autoplay:true,
208	      autoplaySpeed: 800,
209	      items : 1
210	  	});
211
212		// Gallery carousel
213
214		window.footer_slider = function(){
215
216			$(".owl-demo-2").owlCarousel({
217			  items : 1,
218		      navigation : true, // Show next and prev buttons
219		      nav : true,
220		      loop:true,
221		      navSpeed: 800,
222		      navText:false
223		  	});
224
225		}
226
227		footer_slider();
228
229		// Gallery carousel-2
230
231		$("#owl-demo-3").owlCarousel({
232	      nav : true,
233	      navText: false,
234	      navSpeed: 800,
235	      loop:true,
236	      items : 1
237	  	});
238
239		// Gallery carousel-3
240
241		$("#owl-demo-4").owlCarousel({
242	      items : 3,
243	      navSpeed: 800,
244	      nav : true,
245	      loop:true,
246	      navText:false,
247	      responsive:{
248		        0:{
249		            items:1
250		        },
251		        481:{
252		            items:2
253		        },
254		        980:{
255		            items:3
256		        }
257		    }
258	  	});
259
260		// Gallery carousel-4
261
262		$("#owl-demo-5").owlCarousel({
263	      items : 5,
264	      navSpeed: 800,
265	      nav : true,
266	      navText:false,
267	      loop:true,
268	      autoplay: true,
269	      autoplaySpeed: 800,
270	        responsive:{
271		        0:{
272		            items:1
273		        },
274		        481:{
275		            items:3
276		        },
277		        992:{
278		            items:5
279		        }
280		    }
281	  	});
282
283		// Gallery carousel-5
284
285		$("#owl-demo-6").owlCarousel({
286	      items : 3,
287	      navSpeed : 800,
288	      nav : true,
289	      loop: true,
290	      navText:false,
291	      responsive:{
292		        0:{
293		            items:2
294		        },
295		        481:{
296		            items:3
297		        },
298		        980:{
299		            items:3
300		        }
301		    }
302	  	});
303
304		// Gallery carousel-6
305
306		$("#owl-demo-7").owlCarousel({
307		  items : 3,
308		  navSpeed : 800,
309		  nav : true,
310		  loop: true,
311	      navText:false,
312		  responsive:{
313		        0:{
314		            items:2
315		        },
316		        481:{
317		            items:3
318		        },
319		        980:{
320		            items:3
321		        }
322		    }
323		});
324
325		// Gallery carousel-7
326
327		$("#owl-demo-9").owlCarousel({
328	      items : 1,
329	      navSpeed : 800,
330	      nav: true,
331	      navText: false,
332	      loop: true
333	 	});
334
335	 	// Gallery carousel-8
336
337		$("#owl-demo-10").owlCarousel({
338	      items : 4,
339	      navSpeed : 800,
340	      nav : true,
341	      loop: true,
342	      navText:false,
343	      responsive:{
344		        0:{
345		            items:2
346		        },
347		        481:{
348		            items:3
349		        },
350		        980:{
351		            items:4
352		        }
353		    }
354	 	});
355
356		//===================fixed header================
357
358		// ie9 placeholder
359
360		if($('html').hasClass('ie9')) {
361			$('input[placeholder]').each(function(){
362				$(this).val($(this).attr('placeholder'));
363				var v = $(this).val();
364				$(this).on('focus',function(){
365					if($(this).val() === v){
366						$(this).val("");
367					}
368				}).on("blur",function(){
369					if($(this).val() == ""){
370						$(this).val(v);
371					}
372				});
373			});
374			
375		}
376
377		// tabs
378
379		var tabs = $('.tabs');
380		if(tabs.length){
381			tabs.tabs({
382				beforeActivate: function(event, ui) {
383			        var hash = ui.newTab.children("li a").attr("href");
384			   	},
385				hide : {
386					effect : "fadeOut",
387					duration : 450
388				},
389				show : {
390					effect : "fadeIn",
391					duration : 450
392				},
393				updateHash : false
394			});
395		}
396
397		// newsletter
398		/*
399	    var subscribe = $('[id^="newsletter"]');
400	      subscribe.append('<div class="message_container_subscribe"></div>');
401	      var message = $('.message_container_subscribe'),text;
402
403	      subscribe.on('submit',function(e){
404	        var self = $(this);
405	        
406	        if(self.find('input[type="email"]').val() == ''){
407	          text = "Please enter your e-mail!";
408	          message.html('<div class="alert_box warning"><p>'+text+'</p></div>')
409	            .slideDown()
410	            .delay(4000)
411	            .slideUp(function(){
412	              $(this).html("");
413	            });
414
415	        } else {
416	          self.find('span.error').hide();
417			  
418	          $.ajax({
419	            type: "POST",
420	            url: "bat/newsletter.php",
421	            data: self.serialize(), 
422	            success: function(data){
423	              if(data == '1'){
424	                text = "Your email has been sent successfully!";
425	                message.html('<div class="alert_box success"><p>'+text+'</p></div>')
426	                  .slideDown()
427	                  .delay(4000)
428	                  .slideUp(function(){
429	                    $(this).html("");
430	                  })
431	                  .prevAll('input[type="email"]').val("");
432	              }else{
433	                text = "Invalid email address!";
434	                message.html('<div class="alert_box error"></i><p>'+text+'</p></div>')
435	                  .slideDown()
436	                  .delay(4000)
437	                  .slideUp(function(){
438	                    $(this).html("");
439	                  });
440	              }
441	            }
442	          });
443			  
444	        }
445	        e.preventDefault();
446	    });
447		*/
448	    // open dropdown
449
450		$('#sort_button').css3Animate($('#sort_button').next('.sort_list'));
451
452
453		// load more
454
455		$("#load_more").click(function(){
456	        $(".load_more_block").slideToggle("slow");
457	        $(this).toggleClass("active");
458	        return false;
459	    });
460	    $(".more_news_button").click(function(){
461	        $(".more_news").slideToggle("slow");
462	        $(this).toggleClass("active");
463	        return false;
464	    });
465
466		// Loader
467		/*
468		$("body").queryLoader2({
469	        backgroundColor: '#fff',
470	        barColor : '#ff680d',
471	        barHeight: 4,
472	        deepSearch:true,
473	        minimumTime:100,
474	        onComplete: function(){
475	        	$(".loader").fadeOut('100');
476	        }
477      	});
478*/
479	    // flexslider
480			
481		if($("#flexslider").length){
482			$("#flexslider").flexslider({
483				controlNav:false,
484				smoothHeight:true,
485				animationSpeed:500,
486				slideshow:false,
487				prevText:'',
488				keyboard : false,
489				nextText:'',
490				start:function(el){
491					var slshow = el,
492						thumbnails = $('.thumbnails_container').children('ul');
493					slshow.find('.flex-direction-nav a').addClass('flex_nav_buttons');
494					var currIndex = slshow.data('flexslider').currentSlide;
495					thumbnails.children('li').eq(currIndex).addClass('active');
496					thumbnails.children('li').on('click',function(){
497						var self = $(this),
498							index = self.index();
499						self.addClass('active').siblings().removeClass('active');
500						slshow.data('flexslider').flexAnimate(index);
501					});
502					slshow.find('.flex-prev,.flex-next').on('click',function(){
503						var ci = slshow.children('.slides').children('.flex-active-slide').index();
504						thumbnails.children('li').eq(ci).addClass('active').siblings().removeClass('active');
505					});
506				}
507			});
508		}
509
510		if($('#scroll_sidebar').length) $('#scroll_sidebar').scrollSidebar();
511
512		$(window).load(function(){
513			if($('.flexslider').length){
514			$(window).trigger('resize');
515			}
516
517		});
518    
519		// Sticky and Go-top
520
521		(function ($, window) {
522
523			function Temp(el, options) {
524				this.el = $(el);
525				this.init(options);
526			}
527
528			Temp.DEFAULTS = {
529				sticky: true
530			}
531
532			Temp.prototype = {
533				init: function (options) {
534					var base = this;
535						base.window = $(window);
536						base.options = $.extend({}, Temp.DEFAULTS, options);
537						base.menuWrap = $('.menu_wrap');
538						base.goTop = $('<button class="go-to-top" id="go-to-top"></button>').appendTo(base.el);
539
540					// Sticky
541					if (base.options.sticky) {
542						base.sticky.stickySet.call(base, base.window);
543					}
544
545					// Scroll Event
546					base.window.on('scroll', function (e) {
547						if (base.options.sticky) {
548							base.sticky.stickyInit.call(base, e.currentTarget);
549						}
550						base.gotoTop.scrollHandler.call(base, e.currentTarget);
551					});
552
553					// Click Handler Button GotoTop
554					base.gotoTop.clickHandler(base);
555				},
556				sticky: {
557					stickySet: function () {
558						var menuWrap = this.menuWrap, offset;
559						if (menuWrap.length) {
560							offset = menuWrap.offset().top;
561							$.data(menuWrap, 'data', {
562								offset: offset,
563								height: menuWrap.outerHeight(true)
564							});
565							this.spacer = $('<div/>', { 'class': 'spacer' }).insertBefore(menuWrap);
566						}
567					},
568					stickyInit: function (win) {
569						var base = this, data;
570						if (base.menuWrap.length) {
571							data = $.data(base.menuWrap, 'data');
572							base.sticky.stickyAction(data, win, base);
573						}
574					},
575					stickyAction: function (data, win, base) {
576						var scrollTop = $(win).scrollTop();
577						if (scrollTop > data.offset) {
578							base.spacer.css({ height: data.height });
579							if (!base.menuWrap.hasClass('sticky')) {
580								base.menuWrap.addClass('sticky');
581							}
582						} else {
583							base.spacer.css({ height: 'auto' });
584							if (base.menuWrap.hasClass('sticky')) {
585								base.menuWrap.removeClass('sticky');
586							}
587						}
588					}
589				},
590				gotoTop: {
591					scrollHandler: function (win) {
592						$(win).scrollTop() > 200 ?
593							this.goTop.addClass('go-top-visible'):
594							this.goTop.removeClass('go-top-visible');
595					},
596					clickHandler: function (self) {
597						self.goTop.on('click', function (e) {
598							e.preventDefault();
599							$('html, body').animate({ scrollTop: 0 }, 800);
600						});
601					}
602				}
603			}
604
605			/* Temp Plugin
606			 * ================================== */
607
608			$.fn.Temp = function (option) {
609				return this.each(function () {
610					var $this = $(this), data = $this.data('Temp'),
611						options = typeof option == 'object' && option;
612					if (!data) {
613						$this.data('Temp', new Temp(this, options));
614					}
615				});
616			}
617
618			$('body').Temp({
619				sticky: true
620			});
621
622		})(jQuery, window);
623
624		/* ---------------------------------------------------- */
625        /*	SmoothScroll										*/
626        /* ---------------------------------------------------- */
627
628		try {
629			$.browserSelector();
630			var $html = $('html');
631			if ( $html.hasClass('chrome') || $html.hasClass('ie11') || $html.hasClass('ie10') ) {
632				$.smoothScroll();
633			}
634		} catch(err) {}
635
636		// custom select
637
638		$('.custom_select').each(function(){
639			var list = $(this).children('ul'),
640				select = $(this).find('select'),
641				title = $(this).find('.select_title');
642		 
643
644			// select items to list items
645
646			if($(this).find('[data-filter]').length){
647				for(var i = 0,len = select.children('option').length;i < len;i++){
648					list.append('<li data-filter="'+select.children('option').eq(i).data('filter')+'">'+select.children('option').eq(i).text()+'</li>')
649				}
650			}
651			else{
652				for(var i = 0,len = select.children('option').length;i < len;i++){
653					list.append('<li>'+select.children('option').eq(i).text()+'</li>')
654				}
655			}
656			select.hide();
657
658			// open list
659			
660			title.on('click',function(){
661				list.slideToggle(400);
662				$(this).toggleClass('active');
663			});
664
665			// selected option
666
667			list.on('click','li',function(){
668				var val = $(this).text();
669				title.text(val);
670				list.slideUp(400);
671				select.val(val);
672				title.toggleClass('active');
673			});
674
675		});
676
677
678		// accordion & toggle
679
680		var aItem = $('.accordion:not(.toggle) .accordion_item'),
681			link = aItem.find('.a_title'),
682			$label = aItem.find('label'),
683			aToggleItem = $('.accordion.toggle .accordion_item'),
684			tLink = aToggleItem.find('.a_title');
685
686			aItem.add(aToggleItem).children('.a_title').not('.active').next().hide();
687
688		function triggerAccordeon($item) {
689			$item
690				.addClass('active')
691				.next().stop().slideDown()
692				.parent().siblings()
693				.children('.a_title')
694				.removeClass('active')
695				.next().stop().slideUp();
696		}
697
698
699		if ($label.length) {
700			$label.on('click',function(){
701				triggerAccordeon($(this).closest('.a_title'))
702			});
703		} else {
704			link.on('click',function(){
705				triggerAccordeon($(this))
706			});
707		}
708			
709
710		tLink.on('click',function(){
711			$(this).toggleClass('active')
712					.next().stop().slideToggle();
713
714		})
715
716		// contact form
717		/*
718		var cf = $('#contactform');
719		cf.append('<div class="message_container"></div>');
720
721		cf.on("submit",function(event){
722
723			var self = $(this),text;
724
725			var request = $.ajax({
726				url:"bat/mail.php",
727				type : "post",
728				data : self.serialize()
729			});
730
731			request.then(function(data){
732				if(data == "1"){
733
734					text = "Your message has been sent successfully!";
735
736					cf.find('input:not([type="submit"]),textarea').val('');
737
738					$('.message_container').html('<div class="alert_box success"><i class="fa fa-smile-o"></i><p>'+text+'</p></div>')
739						.delay(150)
740						.slideDown(300)
741						.delay(4000)
742						.slideUp(300,function(){
743							$(this).html("");
744						});
745
746				}
747				else{
748					if(cf.find('textarea').val().length < 20){
749						text = "Message must contain at least 20 characters!"
750					}
751					if(cf.find('input').val() == ""){
752						text = "All required fields must be filled!";
753					}
754					$('.message_container').html('<div class="alert_box error"><i class="fa fa-exclamation-triangle"></i><p>'+text+'</p></div>')
755						.delay(150)
756						.slideDown(300)
757						.delay(4000)
758						.slideUp(300,function(){
759							$(this).html("");
760						});
761				}
762			},function(){
763				$('.message_container').html('<div class="alert_box error"><i class="fa fa-exclamation-triangle"></i><p>Connection to server failed!</p></div>')
764						.delay(150)
765						.slideDown(300)
766						.delay(4000)
767						.slideUp(300,function(){
768							$(this).html("");
769						});
770			});
771
772
773			event.preventDefault();
774		});
775		*/
776		// jackbox
777
778		if($(".jackbox[data-group]").length){
779			jQuery(".jackbox[data-group]").jackBox("init",{
780			    showInfoByDefault: false,
781			    preloadGraphics: false, 
782			    fullscreenScalesContent: true,
783			    autoPlayVideo: false,
784			    flashVideoFirst: false,
785			    defaultVideoWidth: 960,
786			    defaultVideoHeight: 540,
787			    baseName: ".jackbox",
788			    className: ".jackbox",
789			    useThumbs: true,
790			    thumbsStartHidden: false,
791			    thumbnailWidth: 75,
792			    thumbnailHeight: 50,
793			    useThumbTooltips: false,
794			    showPageScrollbar: false,
795			    useKeyboardControls: true 
796			});
797		}
798
799		// Price Scale
800
801		var slider;
802		if($('#price').length){
803			slider = $('#price').slider({ 
804			 	orientation: "horizontal",
805				range: true,
806				values: [ 0, 250 ],
807				min: 0,
808				max: 250,
809				slide : function(event ,ui){
810					$(this).next().find('.first_limit').val('$' + ui.values[0]);
811					$(this).next().find('.last_limit').val('$' + ui.values[1]);
812				}
813			});
814		}
815
816		// Quantity
817
818		var q = $('.quantity');
819
820		q.each(function(){
821			var $this = $(this),
822				button = $this.children('button'),
823				input = $this.children('input[type="text"]'),
824				val = +input.val();
825
826			button.on('click',function(){
827				if($(this).hasClass('minus')){
828					if(val === 1) return false;
829					input.val(--val);
830				}
831				else{
832					input.val(++val);
833				}
834			});
835		});
836
837		// appear animation
838
839	    function animate(){
840	    	
841	     $("[data-appear-animation]").each(function() {
842
843	         var self = $(this);
844
845	         self.addClass("appear-animation");
846
847	         if($(window).width() > 800) {
848	          self.appear(function() {
849
850	           var delay = (self.attr("data-appear-animation-delay") ? self.attr("data-appear-animation-delay") : 1);
851
852	           if(delay > 1) self.css("animation-delay", delay + "ms");
853	           self.addClass(self.attr("data-appear-animation"));
854
855	           setTimeout(function() {
856	            self.addClass("appear-animation-visible");
857	           }, delay);
858
859	          }, {accX: 0, accY: -150});
860	         } else {
861	          self.addClass("appear-animation-visible");
862	         }
863	        });
864	    }
865
866	    //animate();
867
868	    //$(window).on('resize',animate);
869
870		//elevate zoom
871
872		(function(){
873
874			if($('#thumbnails').length){
875		    $('#thumbnails').owlCarousel({
876		      items : 3,
877	    	  stagePadding : 40,
878		      margin : 10,
879		      URLhashListener : false,
880		      navSpeed : 800,
881		      nav : true,
882		      navText:false,
883		      responsive : {
884			      "0" : {
885			       "items" : 4
886			      },
887			      "481" : {
888			       "items" : 3
889			      },
890			      "769" : {
891			       "items" : 3
892			      },
893			      "992" : {
894			       "items" : 3
895			      }
896		      }
897		    });
898		   }
899
900			if($('[data-zoom-image]').length){
901
902				var button = $('.qv_preview [class*="button"]');
903
904				$("#zoom_image").elevateZoom({
905					gallery:'thumbnails',
906					galleryActiveClass: 'active',
907					zoomType: "inner",
908					cursor: "crosshair",
909					responsive:true,
910				    zoomWindowFadeIn: 500,
911					zoomWindowFadeOut: 500,
912					easing:true,
913					lensFadeIn: 500,
914					lensFadeOut: 500
915				}); 
916
917				button.on("click", function(e){
918				  var ez = $('#zoom_image').data('elevateZoom');
919					$.fancybox(ez.getGalleryList());
920				  	e.preventDefault();
921				});
922
923			}
924
925		})();
926    
927	});
928
929})(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.