PageSourceSearch

https://vdream.vn/cms/static/site/bahadi/template/default/js/main-script3459.js

js vdream.vn collected 2026-09-27 15:29:55 UTC 20,134 bytes, 670 lines download raw bytes

1window.dqdt = window.dqdt || {};
2dqdt.init = function () {
3	dqdt.showPopup();
4	dqdt.hidePopup();	
5};
6
7$('span.caretfooter').click(function(){
8	$(this).parents('.footer-fix-mb').toggleClass('active');
9})
10$('i.icon-cart.fa.fa-shopping-cart').click(function(e){
11
12	if($(window).width() < 992){
13		window.location.href='/cart'
14	}
15})
16
17$('.filter-icon').click(function(e){
18	$(this).toggleClass('active');
19	$('.filter-container').toggleClass('active');
20})
21/********************************************************
22# SHOW NOITICE
23********************************************************/
24dqdt.showNoitice = function (selector) {   
25	$(selector).animate({right: '0'}, 500);
26	setTimeout(function() {
27		$(selector).animate({right: '-300px'}, 500);
28	}, 3500);
29};
30
31/********************************************************
32# SHOW LOADING
33********************************************************/
34dqdt.showLoading = function (selector) {    
35	var loading = $('.loader').html();
36	$(selector).addClass("loading").append(loading);  
37}
38
39/********************************************************
40# HIDE LOADING
41********************************************************/
42dqdt.hideLoading = function (selector) {  
43	$(selector).removeClass("loading"); 
44	$(selector + ' .loading-icon').remove();
45}
46
47
48/********************************************************
49# SHOW POPUP
50********************************************************/
51dqdt.showPopup = function (selector) {
52	$(selector).addClass('active');
53};
54
55/********************************************************
56# HIDE POPUP
57********************************************************/
58dqdt.hidePopup = function (selector) {
59	$(selector).removeClass('active');
60}
61
62
63
64/********************************************************
65# Quickview
66********************************************************/
67initQuickView();
68var product = {};
69var currentLinkQuickView = '';
70var option1 = '';
71var option2 = '';
72function setButtonNavQuickview() {
73	$("#quickview-nav-button a").hide();
74	$("#quickview-nav-button a").attr("data-index", "");
75	var listProducts = $(currentLinkQuickView).closest(".slide").find("a.quick-view");
76	if(listProducts.length > 0) {
77		var currentPosition = 0;
78		for(var i = 0; i < listProducts.length; i++) {
79			if($(listProducts[i]).data("handle") == $(currentLinkQuickView).data("handle")) {
80				currentPosition = i;
81				break;
82			}
83		}
84		if(currentPosition < listProducts.length - 1) {
85			$("#quickview-nav-button .btn-next-product").show();
86			$("#quickview-nav-button .btn-next-product").attr("data-index", currentPosition + 1);
87		}
88		if(currentPosition > 0) {
89			$("#quickview-nav-button .btn-previous-product").show();
90			$("#quickview-nav-button .btn-previous-product").attr("data-index", currentPosition - 1);
91		}
92	}
93	$("#quickview-nav-button a").click(function() {
94		$("#quickview-nav-button a").hide();
95		var indexLink = parseInt($(this).data("index"));
96		if(!isNaN(indexLink) && indexLink >= 0) {
97			var listProducts = $(currentLinkQuickView).closest(".slide").find("a.quick-view");
98			if(listProducts.length > 0 && indexLink < listProducts.length) {
99				//$(".quickview-close").trigger("click");
100				$(listProducts[indexLink]).trigger("click");
101			}
102		}
103	});
104}
105function initQuickView(){
106	$(document).on("click", "#thumblist_quickview li", function() {		
107		changeImageQuickView($(this).find("img:first-child"), ".product-featured-image-quickview");
108		$(this).parent().parent().find('li').removeClass('active');
109		$(this).addClass('active');
110	});
111	/*
112	$(document).on("click", ".btn-quickview", function(e) {
113		e.preventDefault();		
114		$("#quick-view-product").hide();
115		var form = $(this).parents('form');			
116		$.ajax({
117			type: 'POST',
118			url: '/cart/add.js',
119			async: false,
120			data: form.serialize(),
121			dataType: 'json',
122			error: addToCartFail,
123			beforeSend: function() {  				
124				if(window.theme_load == "icon"){
125					dqdt.showLoading('.btn-addToCart');
126				} else{
127					dqdt.showPopup('.loading');
128				}
129			},
130			success: addToCartSuccess,
131			cache: false
132		});
133
134	});
135	*/
136
137	$(document).on('click', '.quick-view', function(e) {
138		if($(window).width() > 1025){
139			e.preventDefault();
140			dqdt.showPopup('.loading');
141			var producthandle = $(this).data("handle");
142			currentLinkQuickView = $(this);
143			Bizweb.getProduct(producthandle,function(product) {
144				var qvhtml = $("#quickview-modal").html();
145				$(".quick-view-product").html(qvhtml);
146				var quickview= $(".quick-view-product");
147
148				if(product.summary != null && product.summary !=""){
149					var productdes = product.summary;
150
151				}else{
152
153					if(product.content != null){
154						var productdes = product.content.replace(/(<([^>]+)>)/ig,"");
155					}else{
156						var productdes = "";
157					}
158				}
159				var featured_image = product.featured_image;
160				if(featured_image == null){
161					featured_image = 'http://bizweb.dktcdn.net/thumb/grande/assets/themes_support/noimage.gif';
162				}
163
164				// Reset current link quickview and button navigate in Quickview
165				setButtonNavQuickview();
166				productdes = productdes.split(" ").splice(0,60).join(" ")+"...";	
167				if(featured_image != null){
168					quickview.find(".view_full_size img").attr("src",featured_image);
169				}
170
171
172				if(product.price < 1 && product.variants.length < 2){				
173					quickview.find(".price").html('Liên hệ');
174					quickview.find("del").html('');
175					quickview.find("#quick-view-product form").hide();
176
177
178					quickview.find(".prices").html('<span class="price h2">Liên hệ</span>');
179
180					quickview.find(".add_to_cart_detail span").html('Liên hệ');
181
182				}
183				else{
184					quickview.find("#quick-view-product form").show();
185					quickview.find(".price").html(Bizweb.formatMoney(product.price, "{{amount_no_decimals_with_comma_separator}}₫" ));
186				}
187				quickview.find(".product-item").attr("id", "product-" + product.id);
188				quickview.find(".qv-link").attr("href",product.url);
189				quickview.find(".variants").attr("id", "product-actions-" + product.id);
190				quickview.find(".variants select").attr("id", "product-select-" + product.id);
191
192				quickview.find(".qwp-name").text(product.name);
193				quickview.find(".review .shopify-product-reviews-badge").attr("data-id",product.id);
194				if(product.vendor){
195					quickview.find(".brand").append("<b>Nhãn hiệu: </b>"+product.vendor);
196				}else{
197					quickview.find(".brand").append("<b>Nhãn hiệu: </b>Không có");
198				}
199				if(product.available){
200					quickview.find(".availability").append("<b>&nbsp;Tình trạng: </b>Còn hàng");
201				}else{                            
202					quickview.find(".availability").append("<b>&nbsp;Tình trạng: </b>̀Hết hàng");
203				}
204				if(product.variants[0].sku){
205					quickview.find(".product-sku").append("<b>Mã sản phẩm: </b>"+product.variants[0].sku);
206				}else{
207					quickview.find(".product-sku").append("<b>Mã sản phẩm: </b>Không có");
208				}
209				quickview.find(".product-description").html(productdes);
210
211				if (product.compare_at_price_max > product.price) {
212
213					quickview.find(".old-price").html(Bizweb.formatMoney(product.compare_at_price_max, "{{amount_no_decimals_with_comma_separator}}₫" )).show();
214					quickview.find(".price").addClass("sale-price")
215				}
216				else {
217					quickview.find(".old-price").html("");
218					quickview.find(".price").removeClass("sale-price")
219				}
220				if (!product.available) {
221
222
223					quickViewVariantsSwatch(product, quickview);
224
225					quickview.find(".add_to_cart_detail").text("Hết hàng").addClass("disabled").attr("disabled", "disabled");				
226					if(product.variants.length > 1){
227
228						quickview.find("select, .dec, .inc, .variants label").show();
229
230					}else{
231						quickview.find("select, .dec, .inc, .variants label").hide();
232					}
233
234				}
235				else {
236					quickViewVariantsSwatch(product, quickview);
237					if(product.variants.length > 1){
238						$('#quick-view-product form').show();
239
240					}else{
241						if(product.price < 1){
242
243							$('#quick-view-product form').hide();
244						}else{
245							$('#quick-view-product form').show();
246						}
247					}
248				}
249				quickview.find('.more_info_block .page-product-heading li:first, .more_info_block .tab-content section:first').addClass('active');
250
251				$("#quick-view-product").modal();
252
253				$(".view_scroll_spacer").removeClass("hidden");
254
255
256				loadQuickViewSlider(product, quickview);
257
258				//initQuickviewAddToCart();
259
260				$(".quick-view").fadeIn(500);
261				if ($(".quick-view .total-price").length > 0) {
262					$(".quick-view input[name=quantity]").on("change", updatePricingQuickView)
263				}			
264				updatePricingQuickView();
265				// Setup listeners to add/subtract from the input
266				$(".js-qty__adjust").on("click", function() {
267					var el = $(this),
268						id = el.data("id"),
269						qtySelector = el.siblings(".js-qty__num"),
270						qty = parseInt(qtySelector.val().replace(/\D/g, ''));
271
272					var qty = validateQty(qty);
273
274					// Add or subtract from the current quantity
275					if (el.hasClass("js-qty__adjust--plus")) {
276						qty = qty + 1;
277					} else {
278						qty = qty - 1;
279						if (qty <= 1) qty = 1;
280					}
281
282					// Update the input's number
283					qtySelector.val(qty);
284					updatePricingQuickView();
285				});
286				$(".js-qty__num").on("change", function() {
287					updatePricingQuickView();
288				});
289			});
290
291
292			var numInput = document.querySelector('.quantity_wanted_p input');
293			numInput.addEventListener('input', function(){
294				// Let's match only digits.
295				var num = this.value.match(/^\d+$/);
296				if (num === null) {
297					// If we have no match, value will be empty.
298					this.value = "";
299				}		
300				if (num ==0) {
301					// If we have no match, value will be empty.
302					this.value = 1;
303				}	
304			}, false)
305
306			return false;
307		}
308	});
309}
310
311function loadQuickViewSlider(n, r) {
312	productImage();
313	var loadingImgQuickView = $('.loading-imgquickview');
314	var s = Bizweb.resizeImage(n.featured_image, "grande");
315	r.find(".quickview-featured-image").append('<a href="' + n.url + '"><img src="' + s + '" title="' + n.title + '"/><div style="height: 100%; width: 100%; top:0; left:0 z-index: 2000; position: absolute; display: none; background: url(' + window.loading_url + ') 50% 50% no-repeat;"></div></a>');
316	if (n.images.length > 1) {
317		var o = r.find(".more-view-wrapper ul");
318		for (i in n.images) {
319			var u = Bizweb.resizeImage(n.images[i], "grande");
320			var a = Bizweb.resizeImage(n.images[i], "compact");
321			var f = '<li><a href="javascript:void(0)" data-imageid="' + n.id + '"" data-zoom-image="' + u + '" ><img src="' + u + '" alt="Proimage" /></a></li>';
322			o.append(f)
323		}
324		o.find("a").click(function() {
325			var t = r.find("#product-featured-image-quickview");
326			if (t.attr("src") != $(this).attr("data-image")) {
327				t.attr("src", $(this).attr("data-image"));
328				loadingImgQuickView.show();
329				t.load(function(t) {
330					loadingImgQuickView.hide();
331					$(this).unbind("load");
332					loadingImgQuickView.hide()
333				})
334			}
335		});
336		o.owlCarousel({
337			navigation: true,
338			items: 4,
339			margin:10,
340			itemsDesktop: [1199, 4],
341			itemsDesktopSmall: [979, 3],
342			itemsTablet: [768, 3],
343			itemsTabletSmall: [540, 3],
344			itemsMobile: [360, 3]
345		}).css("visibility", "visible")
346	} else {        
347		r.find(".quickview-more-views").remove();
348		r.find(".quickview-more-view-wrapper-jcarousel").remove()
349	}
350}
351function quickViewVariantsSwatch(t, quickview) {
352
353	var v = '<input type="hidden" name="id" value="' + t.id + '">';
354	quickview.find("form.variants").append(v);
355	if (t.variants.length > 1) {	
356		for (var r = 0; r < t.variants.length; r++) {
357			var i = t.variants[r];
358			var s = '<option value="' + i.id + '">' + i.title + "</option>";
359			quickview.find("form.variants > select").append(s)
360		}
361		var ps = "product-select-" + t.id;
362		new Bizweb.OptionSelectors( ps, { 
363			product: t, 
364			onVariantSelected: selectCallbackQuickView
365		});
366		if (t.options.length == 1) {
367
368			quickview.find(".selector-wrapper:eq(0)").prepend("<label>" + t.options[0].name + "</label>")
369
370		}
371		quickview.find("form.variants .selector-wrapper label").each(function(n, r) {
372			$(this).html(t.options[n].name)
373		})
374	}
375	else {
376		quickview.find("form.variants > select").remove();
377		var q = '<input type="hidden" name="variantId" value="' + t.variants[0].id + '">';
378		quickview.find("form.variants").append(q);
379	}
380}
381function productImage() {
382	$('#thumblist').owlCarousel({
383		navigation: true,
384		items: 4,
385		itemsDesktop: [1199, 4],
386		itemsDesktopSmall: [979, 4],
387		itemsTablet: [768, 4],
388		itemsTabletSmall: [540, 4],
389		itemsMobile: [360, 4]
390	});
391
392	if (!!$.prototype.fancybox){
393		$('li:visible .fancybox, .fancybox.shown').fancybox({
394			'hideOnContentClick': true,
395			'openEffect'	: 'elastic',
396			'closeEffect'	: 'elastic'
397		});
398	}
399}
400/* Quick View ADD TO CART */
401
402function updatePricingQuickView() {
403
404	//Currency.convertAll(window.shop_currency, $("#currencies a.selected").data("currency"), "span.money", "money_format")
405
406	var regex = /([0-9]+[.|,][0-9]+[.|,][0-9]+)/g;
407	var unitPriceTextMatch = jQuery('.quick-view-product .price').text().match(regex);
408	if (!unitPriceTextMatch) {
409		regex = /([0-9]+[.|,][0-9]+)/g;
410		unitPriceTextMatch = jQuery('.quick-view-product .price').text().match(regex);
411	}
412	if (unitPriceTextMatch) {
413		var unitPriceText = unitPriceTextMatch[0];
414		var unitPrice = unitPriceText.replace(/[.|,]/g,'');
415		var quantity = parseInt(jQuery('.quick-view-product input[name=quantity]').val());
416		var totalPrice = unitPrice * quantity;
417		var totalPriceText = Bizweb.formatMoney(totalPrice, "{{amount_no_decimals_with_comma_separator}}₫" );
418		totalPriceText = totalPriceText.match(regex)[0];
419		var regInput = new RegExp(unitPriceText, "g");
420		var totalPriceHtml = jQuery('.quick-view-product .price').html().replace(regInput ,totalPriceText);
421		jQuery('.quick-view-product .total-price span').html(totalPriceHtml);
422	}
423}
424
425
426function validate(evt) {
427	var theEvent = evt || window.event;
428	var key = theEvent.keyCode || theEvent.which;
429	key = String.fromCharCode( key );
430	var regex = /[0-9]|\./;
431	if( !regex.test(key) ) {
432		theEvent.returnValue = false;
433		if(theEvent.preventDefault) theEvent.preventDefault();
434	}
435}
436
437$(document).on('click', '.quickview-close, #quick-view-product .quickview-overlay, .fancybox-overlay', function(e){
438	$('#quick-view-product').modal('hide');
439	dqdt.hidePopup('.loading');
440
441});
442
443$(document).on('click','.quantity_wanted_p span.input-group-btn.data-up',function(e){
444	var va = parseInt($(this).parent().find('input').val());
445	if(va > 1){
446		$(this).parent().find('input').val(va - 1);
447	}
448});
449
450$(document).on('click','.quantity_wanted_p span.input-group-btn.data-dwn',function(e){
451	var va = parseInt($(this).parent().find('input').val());	
452	$(this).parent().find('input').val(va + 1);
453
454});
455//tab slide
456$(document).ready(function () {
457	
458	
459	
460	if($(window).width() < 767){
461		$('.fix-xs-filter').text('Bộ lọc');
462		$('a.btn.btn-quaylai').text('Quay lại');
463	}
464
465
466	$('.entry-month').each(function(e){
467		var t =$(this).text();
468		$(this).text(t.replace('Tháng',""));
469	});
470
471	if($(window).width() < 768){
472
473		
474		$('.swiper-wrapper').owlCarousel({				  
475			items: 4,
476			itemsDesktop: [1199, 6],
477			itemsDesktopSmall: [980, 5],
478			itemsTablet: [768, 3],
479			itemsMobile: [360, 4],
480			margin: 10,
481			navigation : true,
482			navigationText : ["<i class='fa fa-angle-left'></i>","<i class='fa fa-angle-right'></i>"]
483		});
484	}
485
486	var owl1 = $("#owl-prod-t1");
487	var owl2 = $("#owl-prod-t2");
488	var owl3 = $("#owl-prod-t3");
489	$('#owl-prod-t1xxx').owlCarousel({
490		autoPlay: 3000,
491		items: 6,
492		itemsDesktop: [1199, 6],
493		itemsDesktopSmall: [980, 5],
494		itemsTablet: [768, 3],
495		itemsMobile: [360, 2],
496
497		navigation : false,
498		navigationText : ["<i class='fa fa-angle-left'></i>","<i class='fa fa-angle-right'></i>"]
499	});
500	owl1.owlCarousel({
501		autoPlay: 3000,
502		items: 4,
503		itemsDesktop: [1199, 4],
504		itemsDesktopSmall: [980, 2],
505		itemsTablet: [768, 2],
506		itemsMobile: [360, 1],
507
508		navigation : true,
509		navigationText : ["<i class='fa fa-angle-left'></i>","<i class='fa fa-angle-right'></i>"]
510	});
511	owl2.owlCarousel({
512		autoPlay: 3000,
513		items: 4,
514		itemsDesktop: [1199, 3],
515		itemsDesktopSmall: [980, 4],
516		itemsTablet: [768, 2],
517		itemsMobile: [360, 1],
518		navigation : true,
519		navigationText : ["<i class='fa fa-angle-left'></i>","<i class='fa fa-angle-right'></i>"]
520	})
521	owl3.owlCarousel({
522		autoPlay: 3000,
523		items: 4,
524		itemsDesktop: [1199, 4],
525		itemsDesktopSmall: [980, 2],
526		itemsTablet: [768, 2],
527		itemsMobile: [360, 1],
528		navigation : true,
529		navigationText : ["<i class='fa fa-angle-left'></i>","<i class='fa fa-angle-right'></i>"]
530	});
531	var owlcol = $("#owl-col"); 
532	owlcol.owlCarousel({
533		autoPlay: 3000,
534		stopOnHover: true,
535		items: 6,
536		itemsDesktop: [1140, 6],
537		itemsDesktopSmall: [980, 3],
538		itemsTablet: [768, 2],
539		itemsMobile: [360, 1]
540	});
541	var owlimages = $("#owl-imgs"); 
542	owlimages.owlCarousel({
543		autoPlay: 3000,
544		stopOnHover: true,
545		items: 5,
546		itemsDesktop: [1199, 5],
547		itemsDesktopSmall: [980, 5],
548		itemsTablet: [768, 3],
549		itemsMobile: [320, 2]
550	});
551	var owlrelate = $("#owl-relate");
552	owlrelate.owlCarousel({
553		autoPlay: 3000,
554		stopOnHover: true,
555		items: 4,
556		itemsDesktop: [1199, 3],
557		itemsDesktopSmall: [980, 2],
558		itemsTablet: [768, 2],
559		itemsMobile: [360, 1]
560	});
561	$('.col-carousel').owlCarousel({
562		autoPlay: 3000,
563		stopOnHover: true,
564		items: 6,
565		itemsDesktop: [1199, 3],
566		itemsDesktopSmall: [980, 3],
567		itemsTablet: [768, 3],
568		itemsMobile: [360, 2]
569	});
570
571	$('.product-image-block .images .item-imgs a').click(function() {
572		var newImage = $(this).attr('href');
573		$( '.product-image-block .featured-image img' ).attr({ src: newImage }); 
574		return false;
575	});
576
577	//deal slide    
578
579	$('.more-view-wrapper-jcarousel ul').jcarousel({
580		vertical: true
581	}).css("visibility", "visible");
582
583
584
585	//Search
586	$('.search-form #search-btn').click(function() { 
587		$('.search-form #hidden-search').slideToggle(200); 
588		$(this).toggleClass('active'); 
589	}); 
590	$('.search-form #search-btn,.search-form #hidden-search').click(function(e) { e.stopPropagation(); });
591	$(document).click(function() { 
592		$('.search-form #hidden-search').hide(); 
593		$('.search-form #search-btn').removeClass('active');
594	});
595
596});
597
598
599
600jQuery(function($) {
601	"use strict";
602	$(".sidebar-blog-menu").accordion({
603		accordion:false,
604		speed: 300,
605		closedSign: '+',
606		openedSign: '-'
607	});
608	$('.banner-custom').hover(function(e){
609		$(this).parent().find('.banner-custom').removeClass('active');
610		$(this).addClass('active');
611	})
612});
613(function($){
614	$.fn.extend({ 
615		accordion: function(options) {  
616			var defaults = {
617				accordion: 'true',
618				speed: 300,
619				closedSign: '[-]',
620				openedSign: '[+]'
621			};  
622			var opts = $.extend(defaults, options); 
623			var $this = $(this);  
624			$this.find("li").each(function() {
625				if($(this).find("ul").size() != 0){
626					$(this).find("a:first").after("<em>"+ opts.closedSign +"</em>");  
627					if($(this).find("a:first").attr('href') == "#"){
628						$(this).find("a:first").click(function(){return false;});
629					}
630				}
631			}); 
632			$this.find("li em").click(function() {
633				if($(this).parent().find("ul").size() != 0){
634					if(opts.accordion){
635						//Do nothing when the list is open
636						if(!$(this).parent().find("ul").is(':visible')){
637							parents = $(this).parent().parents("ul");
638							visible = $this.find("ul:visible");
639							visible.each(function(visibleIndex){
640								var close = true;
641								parents.each(function(parentIndex){
642									if(parents[parentIndex] == visible[visibleIndex]){
643										close = false;
644										return false;
645									}
646								});
647								if(close){
648									if($(this).parent().find("ul") != visible[visibleIndex]){
649										$(visible[visibleIndex]).slideUp(opts.speed, function(){
650											$(this).parent("li").find("em:first").html(opts.closedSign);
651										});   
652									}
653								}
654							});
655						}
656					}
657					if($(this).parent().find("ul:first").is(":visible")){
658						$(this).parent().find("ul:first").slideUp(opts.speed, function(){
659							$(this).parent("li").find("em:first").delay(opts.speed).html(opts.closedSign);
660						}); 
661					}else{
662						$(this).parent().find("ul:first").slideDown(opts.speed, function(){
663							$(this).parent("li").find("em:first").delay(opts.speed).html(opts.openedSign);
664						});
665					}
666				}
667			});
668		}
669	});
670})(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.