1/* Validation form */ 2validateForm('validation-contact'); 3validateForm('validation-newsletter'); 4// validateForm('validation-cart'); 5// validateForm('validation-user'); 6 7/* Load name input file */ 8NN_FRAMEWORK.loadNameInputFile = function () { 9 if (isExist($('.custom-file input[type=file]'))) { 10 $('body').on('change', '.custom-file input[type=file]', function () { 11 var fileName = $(this).val(); 12 fileName = fileName.substr(fileName.lastIndexOf('\\') + 1, fileName.length); 13 $(this).siblings('label').html(fileName); 14 }); 15 } 16}; 17 18/* Back to top */ 19NN_FRAMEWORK.GoTop = function () { 20 $(document).ready(function () { 21 var progressPath = document.querySelector(".progress-wrap path"); 22 var pathLength = progressPath.getTotalLength(); 23 progressPath.style.transition = progressPath.style.WebkitTransition = 24 "none"; 25 progressPath.style.strokeDasharray = pathLength + " " + pathLength; 26 progressPath.style.strokeDashoffset = pathLength; 27 progressPath.getBoundingClientRect(); 28 progressPath.style.transition = progressPath.style.WebkitTransition = 29 "stroke-dashoffset 10ms linear"; 30 var updateProgress = function () { 31 var scroll = $(window).scrollTop(); 32 var height = $(document).height() - $(window).height(); 33 var progress = pathLength - (scroll * pathLength) / height; 34 progressPath.style.strokeDashoffset = progress; 35 }; 36 updateProgress(); 37 $(window).scroll(updateProgress); 38 var offset = 50; 39 var duration = 50; 40 $(window).on("scroll", function () { 41 if ($(this).scrollTop() > offset) { 42 $(".progress-wrap").addClass("active-progress"); 43 } else { 44 $(".progress-wrap").removeClass("active-progress"); 45 } 46 }); 47 $(".progress-wrap").on("click", function (event) { 48 event.preventDefault(); 49 $("html, body").animate( 50 { 51 scrollTop: 0, 52 }, 53 duration 54 ); 55 return false; 56 }); 57 $(".scrollToTopMobile").on("click", function (event) { 58 event.preventDefault(); 59 $("html, body").animate( 60 { 61 scrollTop: 0, 62 }, 63 duration 64 ); 65 return false; 66 }); 67 }); 68}; 69 70/* Menu */ 71NN_FRAMEWORK.Menu = function () { 72 if (isExist($('.menu-mobile'))) { 73 $('.menu-mobile ul li span').click(function (e) { 74 e.stopPropagation(); 75 // $(this).toggleClass('active'); 76 var icon = $(this).find('i'); 77 78 if ($(this).hasClass('active')) { 79 $(this).removeClass('active'); 80 icon.css('transform', 'rotate(0deg)'); 81 } else { 82 $(this).addClass('active'); 83 icon.css('transform', 'rotate(90deg)'); 84 85 } 86 }); 87 } 88 89 /* Menu Has Scroll */ 90 if (isExist($(".header"))) { 91 $(window).scroll(function () { 92 var headerHeight = $(".header").outerHeight() + 0.0001; 93 if ($(window).scrollTop() >= headerHeight) { 94 $(".menu-res").addClass('has-scroll'); 95 } else { 96 $(".menu-res").removeClass('has-scroll'); 97 }; 98 99 if ($(window).scrollTop() >= headerHeight) { 100 $(".navigation").addClass('has-scroll'); 101 } else { 102 $(".navigation").removeClass('has-scroll'); 103 }; 104 }); 105 } else { 106 if (isExist($(".navigation"))) { 107 $(".navigation").addClass('has-scroll'); 108 $(window).scroll(function () { 109 if ($(window).scrollTop() >= 60) { 110 $(".navigation").addClass('scroll-active'); 111 } else { 112 $(".navigation").removeClass('scroll-active'); 113 }; 114 }); 115 } else { 116 $(".menu-res").addClass('has-scroll'); 117 }; 118 }; 119 120 function handleResponsiveResize() { 121 var menuHeight = isExist($(".navigation")) 122 ? $(".navigation").innerHeight() 123 : $(".menu-res").innerHeight(); 124 125 var w = $(window).width(); 126 127 if (isExist($(".header"))) { 128 $(window).scroll(function () { 129 var headerHeight = $(".header").innerHeight() + 0.0001; 130 if ($(window).scrollTop() >= headerHeight) { 131 $(".top-space").css({ 132 marginTop: menuHeight + "px", 133 }); 134 } else { 135 $(".top-space").css({ 136 marginTop: "0px", 137 }); 138 } 139 }); 140 } else { 141 if (w < 1024) { 142 $('.slideshow').addClass('top-space'); 143 } 144 $(".top-space").css({ 145 marginTop: menuHeight + "px", 146 }); 147 } 148 } 149 handleResponsiveResize(); 150 $(window).on('resize', function () { 151 handleResponsiveResize(); 152 }); 153}; 154 155/* Tools */ 156NN_FRAMEWORK.Tools = function () { 157 if (isExist($('.toolbar'))) { 158 $('.footer').css({ marginBottom: $('.toolbar').innerHeight() }); 159 } 160}; 161 162/* Popup */ 163NN_FRAMEWORK.Popup = function () { 164 if (isExist($('#popup'))) { 165 validateForm('validation-popup'); 166 $('#popup').modal('show'); 167 } 168}; 169 170/* Wow */ 171NN_FRAMEWORK.Wows = function () { 172 new WOW().init(); 173}; 174 175/* Search */ 176NN_FRAMEWORK.Search = function () { 177 if (isExist($('.icon-search'))) { 178 $('.icon-search').click(function () { 179 if ($(this).hasClass('active')) { 180 $(this).removeClass('active'); 181 $('.search-grid').stop(true, true).animate({ opacity: '0', width: '0p
181x' }, 200); 182 } else { 183 $(this).addClass('active'); 184 $('.search-grid').stop(true, true).animate({ opacity: '1', width: '230px' }, 200); 185 } 186 document.getElementById($(this).next().find('input').attr('id')).focus(); 187 $('.icon-search i').toggleClass('bi bi-x-lg'); 188 }); 189 } 190 191 if (isExist($('.search-auto'))) { 192 $('.show-search').hide(); 193 $('.search-auto').keyup(function () { 194 $keyword = $(this).val(); 195 if ($keyword.length >= 2) { 196 $.get('tim-kiem-goi-y?keyword=' + $keyword, function (data) { 197 if (data) { 198 $('.show-search').show(); 199 $('.show-search').html(data); 200 } 201 }); 202 } 203 }); 204 } 205}; 206 207/* Videos */ 208NN_FRAMEWORK.Videos = function () { 209 Fancybox.bind('[data-fancybox]', {}); 210}; 211 212/* Dom Change */ 213NN_FRAMEWORK.DomChange = function () { 214 /* Video Fotorama */ 215 if (isExist($('#fotorama-videos'))) { 216 $('#fotorama-videos').fotorama(); 217 } 218 /* Video Select */ 219 if (isExist($('.list-video'))) { 220 $('.list-video').change(function () { 221 var id = $(this).val(); 222 $.ajax({ 223 url: 'load-video', 224 type: 'GET', 225 dataType: 'html', 226 data: { 227 id: id 228 }, 229 beforeSend: function () { 230 holdonOpen(); 231 }, 232 success: function (result) { 233 $('.video-main').html(result); 234 holdonClose(); 235 } 236 }); 237 }); 238 } 239 240 /* Chat Facebook */ 241 $('#messages-facebook').one('DOMSubtreeModified', function () { 242 $('.js-facebook-messenger-box').on('click', function () { 243 $('.js-facebook-messenger-box, .js-facebook-messenger-container').toggleClass('open'), 244 $('.js-facebook-messenger-tooltip').length && $('.js-facebook-messenger-tooltip').toggle(); 245 }), 246 $('.js-facebook-messenger-box').hasClass('cfm') && 247 setTimeout(function () { 248 $('.js-facebook-messenger-box').addClass('rubberBand animated'); 249 }, 3500), 250 $('.js-facebook-messenger-tooltip').length && 251 ($('.js-facebook-messenger-tooltip').hasClass('fixed') 252 ? $('.js-facebook-messenger-tooltip').show() 253 : $('.js-facebook-messenger-box').on('hover', function () { 254 $('.js-facebook-messenger-tooltip').show(); 255 }), 256 $('.js-facebook-messenger-close-tooltip').on('click', function () { 257 $('.js-facebook-messenger-tooltip').addClass('closed'); 258 })); 259 $('.search_open').click(function () { 260 $('.search_box_hide').toggleClass('opening'); 261 }); 262 }); 263}; 264 265NN_FRAMEWORK.SwiperData = function (obj) { 266 if (!isExist(obj)) return false; 267 var name = obj.attr('data-swiper-name') || 'swiper'; 268 var thumbs = obj.attr('data-swiper-thumbs'); 269 var more = obj.attr('data-swiper'); 270 271 if (more && more.search('|') >= 0) { 272 more = more.split('|'); 273 var on = more.reduce((a, b) => { 274 if (b.search('{') < 0) { 275 var c = { 276 [b.split(':')[0]]: useStrict(b.split(':')[1]) 277 }; 278 } else { 279 const b1 = String(b.split(':', 1)); 280 const b2 = useStrict(b.slice(String(b.split(':', 1)).length + 1).trim()); 281 var c = { 282 [b1]: b2 283 }; 284 } 285 return Object.assign({}, a, c); 286 }, {}); 287 } else { 288 on = ''; 289 } 290 if (thumbs) { 291 on.thumbs = { swiper: window[thumbs] }; 292 } 293 294 window[name] = new Swiper(obj[0], on); 295 296 if (window[name].passedParams.breakpoints) { 297 if (window[name].params.direction == 'vertical') { 298 const entries = Object.entries(window[name].passedParams.breakpoints); 299 function setHeight() { 300 var height = obj.find('.item').outerHeight(); 301 var countItem = obj.find('.item').length; 302 entries.forEach((v) => { 303 const Breakpoint = v[0] > 0 ? v[0] : 0; 304 if (Breakpoint > 0 && Breakpoint == window[name].currentBreakpoint) { 305 const items = v[1].slidesPerView || 1; 306 const margin = v[1].spaceBetween || 0; 307 const direction = v[1].direction || 'horizontal'; 308 309 window[name].params.direction = direction; 310 311 if (direction === 'vertical') { 312 if (countItem < items) { 313 obj.css({ 314 height: height * countItem + (countItem - 1) * margin, 315 }); 316 obj.find('.swiper-slide').addClass('h-auto'); 317 } else { 318 obj.css({ 319 height: height * items + (items - 1) * margin, 320 }); 321 } 322 } else { 323 obj.css({ height: '' }); 324 } 325 326 window[name].update(); 327 } 328 }); 329 } 330 setHeight(); 331 $(window).resize(setHeight()); 332 } 333 } else { 334 if (window[name].params.direction == 'vertical') { 335 function setHeight() { 336 var height = obj.find('.item').outerHeight(); 337 var countItem = obj.find('.item').length; 338 var items = window[name].passedParams.slidesPerView; 339 var margin = window[name].passedParams.spaceBetween; 340 if (countItem < items) { 341 obj.css({ 342 height: height * countItem + (countItem - 1) * margin 343 }); 344 obj.find('.swiper-slide').addClass('h-auto'); 345 } else { 346 obj.css({ height: height * items + (items - 1) * margin }); 347 } 348 window[name].update(); 349 } 350 setHeight(); 351 $(window).resize(setHeight()); 352 } 353 } 354 return window[name]; 355}; 356 357/* Swiper */ 358NN_FRAMEWORK.Swiper = function () { 359 if (isExist($('.swiper-auto'))) { 360 $('.swiper-auto[data-swiper-name]').each(function () { 361 NN_FRAMEWORK.SwiperData($(this)); 362 }); 363 $('.swiper-auto:not([data-swiper-name])').each(function () { 364 NN_FRAMEWORK.SwiperData($(this)); 365 }); 366 } 367}; 368 369/* AnimateText */ 370// NN_FRAMEWORK.AnimateText = function () { 371// $(document).ready(function () { 372// $(".title__animate").textillate({ 373// in: { 374// effect: "bounceIn", 375// }, 376// out: { 377// effect: "bounceOut", 378// }, 379// loop: true, 380// }); 381// }); 382// }; 383 384// NN_FRAMEWORK.Counter = function () { 385// if (isExist($("#counter"))) { 386// var a = 0; 387// $(window).scroll(function () { 388// var oTop = $("#counter").offset().top - window.innerHeight; 389// if (a == 0 && $(window).scrollTop() > oTop) { 390// $(".counter-value").each(function () { 391// var $this = $(this), 392// countTo = $this.attr("data-count"); 393// $({ 394// countNum: $this.text(), 395// }).animate( 396// {
397// countNum: countTo, 398// }, 399// { 400// duration: 3000, 401// easing: "swing", 402// step: function () { 403// $this.text(Math.floor(this.countNum)); 404// }, 405// complete: function () { 406// $this.text("+" + this.countNum); 407// }, 408// } 409// ); 410// }); 411// a = 1; 412// } 413// }); 414// } 415// }; 416 417/* Logo mã mà u Äặc biá»t: monoHL, oceanHL, fireHL */ 418// NN_FRAMEWORK.shinerLogo = function () { 419// jQuery.browser = {}; 420// (function () { 421// jQuery.browser.msie = false; 422// jQuery.browser.version = 0; 423// if (navigator.userAgent.match(/MSIE ([0-9]+)\./)) { 424// jQuery.browser.msie = true; 425// jQuery.browser.version = RegExp.$1; 426// } 427// })(); 428// $(window).bind("load", function () { 429// $(".peShiner").each(function () { 430// var api = $(this).peShiner({ 431// api: true, 432// paused: true, 433// reverse: true, 434// repeat: 1, 435// color: "oceanHL", 436// }); 437// api.resume(); 438// }); 439// }); 440// }; 441 442 443NN_FRAMEWORK.Api = function () { 444 445 /* Phân trang không danh mục 446 if (isExist($('.choose__list'))) { 447 $('.load-ajax').each(function () { 448 var thisClass = $(this); 449 var url = thisClass.data('url'); 450 var table = thisClass.data('table'); 451 var paginate = thisClass.data('paginate'); 452 var type = thisClass.data('type'); 453 var list = thisClass.data('list'); //0 454 var cat = thisClass.data('cat'); //0 455 var show = '.' + thisClass.attr('class').split(' ')[0]; 456 loadPaging(url + '?type=' + type + '&paginate=' + paginate + '&table=' + table + '&list=' + list + '&cat=' + cat, show ); 457 }); 458 } 459 */ 460 461 /* Tab danh mục || Load sản phẩm nhìu danh mục 462 if (isExist($('.choose__list'))) { 463 $('.choose__item.active').each(function () { 464 var thisClass = $(this); 465 var url = thisClass.data('url'); 466 var table = thisClass.data('table'); 467 var paginate = thisClass.data('paginate'); 468 var type = thisClass.data('type'); 469 var list = thisClass.data('list'); 470 var cat = thisClass.data('cat'); 471 var show = '.travelList__main'; 472 loadPaging(url + '?type=' + type + '&paginate=' + paginate + '&table=' + table + '&list=' + list + '&cat=' + cat, show); 473 }); 474 475 $('.choose__item').click(function (e) { 476 $(this).parents(".choose__list").find(".choose__item.active").removeClass("active"); 477 $(this).addClass("active"); 478 var thisClass = $(this); 479 var url = thisClass.data('url'); 480 var table = thisClass.data('table'); 481 var paginate = thisClass.data('paginate'); 482 var type = thisClass.data('type'); 483 var list = thisClass.data('list'); 484 var cat = thisClass.data('cat'); 485 var show = '.travelList__main'; 486 loadPaging(url + '?type=' + type + '&paginate=' + paginate + '&table=' + table + '&list=' + list + '&cat=' + cat, show); 487 }); 488 } 489 */ 490 491 if (isExist($('.item-search'))) { 492 $('.item-search input').click(function () { 493 Filter(); 494 }); 495 } 496 497 if (isExist($('.sort-select-main'))) { 498 $('.sort-select-main p a').click(function () { 499 $('.sort-select-main p a').removeClass('check'); 500 $(this).addClass('check'); 501 Filter(); 502 }); 503 } 504 505 $('.filter').click(function (e) { 506 $('.left-product').toggleClass('show'); 507 }); 508 TextSort(); 509}; 510 511NN_FRAMEWORK.Properties = function () { 512 if (isExist($('.grid-properties'))) { 513 $('.properties').click(function (e) { 514 $(this).parents('.grid-properties').find('.properties').removeClass('active'); 515 // $('.properties').removeClass('outstock'); 516 $(this).addClass('active'); 517 }); 518 } 519}; 520 521NN_FRAMEWORK.Main = function () { 522 // Lấy tất cả các thẻ <img> trên trang 523 var imgElements = document.querySelectorAll('img'); 524 imgElements.forEach(function (img) { 525 if (!img.hasAttribute('alt')) { 526 img.alt = WEBSITE_NAME; // Thêm thuá»c tÃnh alt 527 } 528 }); 529 var anchorElements = document.querySelectorAll('a'); 530 anchorElements.forEach(function (anchor) { 531 if (!anchor.hasAttribute('aria-label')) { 532 anchor.setAttribute('aria-label', WEBSITE_NAME); 533 } 534 }); 535 536 $('.tt-toc').click(function (e) { 537 $('.box-readmore ul').slideToggle(); 538 }); 539 540}; 541 542NN_FRAMEWORK.Img = function () { 543 const images = document.querySelectorAll('img');
544 images.forEach((img) => { 545 const handleImageLoad = () => { 546 const width = img.clientWidth; 547 const height = img.clientHeight; 548 const hw = img.getAttribute('width'); 549 if (width > 0 && height > 0 && !hw) { 550 img.setAttribute('width', width); 551 img.setAttribute('height', height); 552 } 553 }; 554 555 img.addEventListener('load', handleImageLoad); 556 if (img.complete) { 557 handleImageLoad(); 558 } 559 }); 560}; 561 562/* Ready */ 563$(document).ready(function () { 564 NN_FRAMEWORK.Api(); 565 NN_FRAMEWORK.Popup(); 566 NN_FRAMEWORK.Swiper(); 567 NN_FRAMEWORK.GoTop(); 568 NN_FRAMEWORK.Menu(); 569 NN_FRAMEWORK.Videos(); 570 NN_FRAMEWORK.Search(); 571 NN_FRAMEWORK.DomChange(); 572 NN_FRAMEWORK.loadNameInputFile(); 573 NN_FRAMEWORK.Properties(); 574 NN_FRAMEWORK.Main(); 575 // NN_FRAMEWORK.Counter(); 576 // NN_FRAMEWORK.AnimateText(); 577 // NN_FRAMEWORK.shinerLogo(); 578 if (isExist($('.comment-page'))) { 579 new Comments('.comment-page', BASE); 580 } 581 new Cart(BASE); 582 if (isExist($('.validation-form'))) { 583 $('.validation-form .check-btn').click(function(){ 584 var loai = $(this).data('loai'); 585 var ten = $('#fullname-'+loai); 586 var phone = $('#phone-'+loai); 587 var email = $('#email-'+loai); 588 var address = $('#address-'+loai); 589 var subject = $('#subject-'+loai); 590 if(isEmpty(ten.val(), LANG['nhaphoten'])){ ten.focus(); return false; } 591 if(isEmpty(phone.val(), LANG['nhapdienthoai'])){ phone.focus(); return false; } 592 if(isPhone(phone.val(), LANG['nhapdienthoaihople'])){ phone.focus(); return false; } 593 if(loai == 'contact' && isEmpty(address.val(), LANG['nhapdiachi'])){ address.focus(); return false; } 594 if(isEmpty(email.val(), LANG['nhapemail'])){email.focus(); return false; } 595 if(isEmail(email.val(), LANG['nhapemailhople'])){ email.focus(); return false; } 596 if(loai == 'contact' && isEmpty(subject.val(), LANG['nhaptieude'])){ subject.focus(); return false; } 597 }); 598 } 599}); 600 601window.addEventListener('load', () => { 602 NN_FRAMEWORK.Img(); 603});
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.