1/* 2* Re-structure JS 3* */ 4(function($) { 5 'use strict'; 6 7 /* 8 * Helper vars 9 * */ 10 11 /* 12 * Helper functions 13 * */ 14 function thim_get_url_parameters(sParam) { 15 var sPageURL = window.location.search.substring(1); 16 17 var sURLVariables = sPageURL.split('&'); 18 for (var i = 0; i < sURLVariables.length; i++) { 19 var sParameterName = sURLVariables[i].split('='); 20 21 if (sParameterName[0] === sParam) { 22 return sParameterName[1]; 23 } 24 } 25 26 } 27 28 var thim_eduma = { 29 ready: function() { 30 this.register_ajax(); 31 this.login_ajax(); 32 this.login_form_popup(); 33 this.form_submission_validate(); 34 this.thim_TopHeader(); 35 this.ctf7_input_effect(); 36 this.thim_course_filter(); 37 this.mobile_menu_toggle(); 38 }, 39 40 load: function() { 41 this.thim_menu(); 42 this.thim_carousel(); 43 this.thim_contentslider(); 44 this.counter_box(); 45 }, 46 47 resize: function() { 48 49 }, 50 51 validate_form: function(form) { 52 var valid = true, 53 email_valid = /[A-Z0-9._%+-]+@[A-Z0-9.-]+.[A-Z]{2,4}/igm; 54 55 form.find('input.required').each(function() { 56 // Check empty value 57 if (!$(this).val()) { 58 $(this).addClass('invalid'); 59 valid = false; 60 } 61 62 // Uncheck 63 if ($(this).is(':checkbox') && !$(this).is(':checked')) { 64 $(this).addClass('invalid'); 65 valid = false; 66 } 67 68 // Check email format 69 if ('email' === $(this).attr('type')) { 70 if (!email_valid.test($(this).val())) { 71 $(this).addClass('invalid'); 72 valid = false; 73 } 74 } 75 76 // Check captcha 77 if ($(this).hasClass('captcha-result')) { 78 let captcha_1 = parseInt($(this).data('captcha1')), 79 captcha_2 = parseInt($(this).data('captcha2')); 80 81 if ((captcha_1 + captcha_2) !== parseInt($(this).val())) { 82 $(this).addClass('invalid').val(''); 83 valid = false; 84 } 85 } 86 }); 87 88 // Check repeat password 89 if (form.hasClass('auto_login')) { 90 let $pw = form.find('input[name=password]'), 91 $repeat_pw = form.find('input[name=repeat_password]'); 92 93 if ($pw.val() !== $repeat_pw.val()) { 94 $pw.addClass('invalid'); 95 $repeat_pw.addClass('invalid'); 96 valid = false; 97 } 98 } 99 100 $('form input.required').on('focus', function() { 101 $(this).removeClass('invalid'); 102 }); 103 104 return valid; 105 }, 106 107 login_form_popup: function() { 108 $(document).on('click', 'body:not(".loggen-in") .thim-button-checkout', 109 function(e) { 110 if ($(window).width() > 767) { 111 e.preventDefault(); 112 if ($('#thim-popup-login').length) { 113 $('body').addClass('thim-popup-active'); 114 $('#thim-popup-login').addClass('active'); 115 } else { 116 var redirect = $(this).data('redirect'); 117 window.location = redirect; 118 } 119 } else { 120 e.preventDefault(); 121 var redirect = $(this).data('redirect'); 122 window.location = redirect; 123 } 124 }); 125 126 $(document).on('click', '#thim-popup-login .close-popup', function(event) { 127 event.preventDefault(); 128 $('body').removeClass('thim-popup-active'); 129 $('#thim-popup-login').removeClass(); 130 }); 131 132 $('body .thim-login-popup a.js-show-popup').on('click', function(event) { 133 event.preventDefault(); 134 135 let $popup = $('#thim-popup-login'); 136 $('body').addClass('thim-popup-active'); 137 $popup.addClass('active'); 138 if ($(this).hasClass('login')) { 139 $popup.addClass('sign-in'); 140 } else { 141 $popup.addClass('sign-up'); 142 } 143 }); 144 145 $('#thim-popup-login .link-bottom a').on('click', function(e) { 146 e.preventDefault(); 147 148 if ($(this).hasClass('login')) { 149 $('#thim-popup-login').removeClass('sign-up').addClass('sign-in'); 150 } else { 151 $('#thim-popup-login').removeClass('sign-in').addClass('sign-up'); 152 } 153 }); 154 155 // Show login popup when click to LP buttons 156 $('body:not(".logged-in") .enroll-course .button-enroll-course, body:not(".logged-in") form.purchase-course:not(".guest_checkout") .button:not(.button-add-to-cart)'). 157 on('click', function(e) { 158 e.preventDefault(); 159 160 // if ($(window).width() > 1024) { 161 if ($('body').hasClass('thim-popup-feature')) { 162 $('.thim-link-login.thim-login-popup .login').trigger('click'); 163 } else { 164 window.location.href = $(this).parent().find('input[name=redirect_to]').val(); 165 } 166 // } else { 167 // window.location.href = $(this).parent().find('input[name=redirect_to]').val(); 168 // } 169 }); 170 171 $(document).on('click', '#thim-popup-login', function(e) { 172 if ($(e.target).attr('id') === 'thim-popup-login') { 173 $('body').removeClass('thim-popup-active'); 174 $('#thim-popup-login').removeClass(); 175 } 176 }); 177 }, 178 179 register_ajax: function() { 180 $('#thim-popup-login form[name=registerformpopup]').on('submit', function(e) { 181 e.preventDefault(); 182 183 if (!thim_eduma.validate_form($(this))) { 184 return false;
185 } 186 187 var $form = $(this), 188 data = { 189 action : 'thim_register_ajax', 190 data : $form.serialize() + '&wp-submit=' + 191 $form.find('input[type=submit]').val(), 192 register_security: $form.find('#register_security'). 193 val(), 194 }, 195 redirect_url = $form.find('input[name=redirect_to]').val(), 196 $elem = $('#thim-popup-login .thim-login-container'); 197 198 $elem.addClass('loading'); 199 $elem.find('.message').slideDown().remove(); 200 201 $.ajax({ 202 type : 'POST', 203 url : ajaxurl, 204 data : data, 205 success: function(response) { 206 $elem.removeClass('loading'); 207 if (typeof response.data !== 'undefined') { 208 $elem.find('.popup-message').html(response.data.message); 209 } 210 if (response.success === true) { 211 if ($form.hasClass('auto_login')) { 212 window.location.href = redirect_url; 213 } 214 } else { 215 var $captchaIframe = $('#thim-popup-login .gglcptch iframe'); 216 if ($captchaIframe.length > 0) { 217 $captchaIframe.attr('src', $captchaIframe.attr('src')); // reload iframe 218 } 219 } 220 }, 221 }); 222 }); 223 }, 224 225 login_ajax: function() { 226 $('#thim-popup-login form[name=loginpopopform]').submit(function(event) { 227 event.preventDefault(); 228 229 if (!thim_eduma.validate_form($(this))) { 230 return false; 231 } 232 233 var form = $(this), 234 $elem = $('#thim-popup-login .thim-login-container'), 235 wp_submit = $elem.find('input[type=submit]').val(); 236 237 $elem.addClass('loading'); 238 $elem.find('.message').slideDown().remove(); 239 240 var data = { 241 action: 'thim_login_ajax', 242 data : form.serialize() + '&wp-submit=' + wp_submit, 243 }; 244 245 $.post(ajaxurl, data, function(response) { 246 try { 247 response = JSON.parse(response); 248 $elem.find('.thim-login').append(response.message); 249 if (response.code == '1') { 250 if (response.redirect) { 251 if (window.location.href == response.redirect) { 252 location.reload(); 253 } else { 254 window.location.href = response.redirect; 255 } 256 } else { 257 location.reload(); 258 } 259 } else { 260 var $captchaIframe = $('#thim-popup-login .gglcptch iframe'); 261 if ($captchaIframe.length > 0) { 262 $captchaIframe.attr('src', $captchaIframe.attr('src')); // reload iframe 263 } 264 } 265 } catch (e) { 266 return false; 267 } 268 $elem.removeClass('loading'); 269 }); 270 271 return false; 272 }); 273 }, 274 275 form_submission_validate: function() { 276 // Form login 277 $('.form-submission-login form[name=loginform]').on('submit', function(e) { 278 if (!thim_eduma.validate_form($(this))) { 279 e.preventDefault(); 280 return false; 281 } 282 }); 283 284 // Form register 285 $('.form-submission-register form[name=registerform]').on('submit', function(e) { 286 if (!thim_eduma.validate_form($(this))) { 287 e.preventDefault(); 288 return false;
289 } 290 }); 291 292 // Form lost password 293 $('.form-submission-lost-password form[name=lostpasswordform]').on('submit', function(e) { 294 if (!thim_eduma.validate_form($(this))) { 295 e.preventDefault(); 296 return false; 297 } 298 }); 299 }, 300 301 thim_TopHeader: function() { 302 var header = $('#masthead'), 303 height_sticky_header = header.outerHeight(true), 304 content_pusher = $('#wrapper-container .content-pusher'), 305 top_site_main = $('#wrapper-container .top_site_main'); 306 307 if (header.hasClass('header_overlay')) { // Header overlay 308 top_site_main.css({'padding-top': height_sticky_header + 'px'}); 309 $(window).resize(function() { 310 let height_sticky_header = header.outerHeight(true); 311 top_site_main.css({'padding-top': height_sticky_header + 'px'}); 312 }); 313 } else { // Header default 314 content_pusher.css({'padding-top': height_sticky_header + 'px'}); 315 $(window).resize(function() { 316 let height_sticky_header = header.outerHeight(true); 317 content_pusher.css({'padding-top': height_sticky_header + 'px'}); 318 }); 319 320 } 321 }, 322 323 ctf7_input_effect: function() { 324 let $ctf7_edtech = $('.form_developer_course'), 325 $item_input = $ctf7_edtech.find('.field_item input'), 326 $submit_wrapper = $ctf7_edtech.find('.submit_row'); 327 328 $item_input.focus(function() { 329 $(this).parent().addClass('focusing'); 330 }).blur(function() { 331 $(this).parent().removeClass('focusing'); 332 }); 333 334 $submit_wrapper.on('click', function() { 335 $(this).closest('form').submit(); 336 }); 337 }, 338 339 thim_course_filter: function() { 340 let $body = $('body'); 341 342 if (!$body.hasClass('learnpress') || !$body.hasClass('archive')) { 343 return; 344 } 345 346 let ajaxCall = function(data) { 347 return $.ajax({ 348 url : $('#lp-archive-courses').data('allCoursesUrl'), //using for course category page 349 type : 'POST', 350 data : data, 351 dataType : 'html', 352 beforeSend: function() { 353 $('#thim-course-archive').addClass('loading'); 354 }, 355 }).fail(function() { 356 $('#thim-course-archive').removeClass('loading'); 357 }).done(function(data) { 358 /*if (typeof history.pushState === 'function') { 359 history.pushState(orderby, null, url); 360 }*/ 361 let $document = $($.parseHTML(data)); 362 363 $('#thim-course-archive').replaceWith($document.find('#thim-course-archive')); 364 $('.learn-press-pagination ul.page-numbers'). 365 replaceWith($document.find('.learn-press-pagination ul.page-numbers')); 366 $('.thim-course-top .course-index span'). 367 replaceWith($document.find('.thim-course-top .course-index span')); 368 }); 369 }; 370 371 let sendData = { 372 s : '', 373 ref : 'course', 374 post_type : 'lp_course', 375 course_orderby: 'newly-published', 376 course_paged : 1, 377 }; 378 379 /* 380 * Handle courses sort ajax 381 * */ 382 $(document).on('change', '.thim-course-order > select', function() { 383 sendData.s = $('.courses-searching .course-search-filter').val(); 384 sendData.course_orderby = $(this).val(); 385 sendData.course_paged = 1; 386 387 ajaxCall(sendData); 388 }); 389 390 /* 391 * Handle pagination ajax 392 * */ 393 $(document).on('click', '#lp-archive-courses > .learn-press-pagination a.page-numbers', function(e) { 394 e.preventDefault(); 395 396 $('html, body').animate({ 397 'scrollTop': $('.site-content').offset().top - 140, 398 }, 1000); 399 400 let pageNum = parseInt($(this).text()), 401 paged = pageNum ? pageNum : 1, 402 cateArr = [], instructorArr = []; 403 404 $('form.thim-course-filter').find('input.filtered').each(function() { 405 switch ($(this).attr('name')) { 406 case 'course-cate-filter': 407 cateArr.push($(this).val()); 408 break; 409 case 'course-instructor-filter': 410 instructorArr.push($(this).val()); 411 break; 412 case 'course-price-filter': 413 sendData.course_price_filter = $(this).val(); 414 break; 415 default: 416 break; 417 } 418 }); 419 420 if ($body.hasClass('category') && $('.list-cate-filter').length <= 0) { 421 let bodyClass = $body.attr('class'), 422 cateClass = bodyClass.match(/category\-\d+/gi)[0], 423 cateID = cateClass.split('-').pop(); 424 425 cateArr.push(cateID); 426 } 427 428 sendData.course_cate_filter = cateArr; 429 sendData.course_instructor_filter = instructorArr; 430 431 sendData.s = $('.courses-searching .course-search-filter').val(); 432 sendData.course_orderby = $('.thim-course-order > select').val(); 433 sendData.course_paged = paged; 434 435 ajaxCall(sendData); 436 }); 437 438 /* 439 * Handle filter form click ajax 440 * */ 441 $('form.thim-course-filter').on('submit', function(e) { 442 e.preventDefault(); 443 444 let formData = $(this).serializeArray(), 445 cateArr = [], instructorArr = []; 446 447 if (!formData.length) { 448 return; 449 } 450 451 $('html, body').animate({ 452 'scrollTop': $('.site-content').offset().top - 140, 453 }, 1000); 454 455 $(this).find('input').each(function() { 456 let form_input = $(this); 457 form_input.removeClass('filtered'); 458 459 if (form_input.is(':checked')) { 460 form_input.addClass('filtered'); 461 } 462 }); 463 464 $.each(formData, function(index, filter) { 465 switch (filter.name) { 466 case 'course-cate-filter': 467 cateArr.push(filter.value); 468 break; 469 case 'course-instructor-filter': 470 instructorArr.push(filter.value); 471 break; 472 case 'course-price-filter':
473 sendData.course_price_filter = filter.value; 474 break; 475 default: 476 break; 477 } 478 }); 479 480 if ($body.hasClass('category') && $('.list-cate-filter').length <= 0) { 481 let bodyClass = $body.attr('class'), 482 cateClass = bodyClass.match(/category\-\d+/gi)[0], 483 cateID = cateClass.split('-').pop(); 484 485 cateArr.push(cateID); 486 } 487 488 sendData.course_cate_filter = cateArr; 489 sendData.course_instructor_filter = instructorArr; 490 sendData.course_paged = 1; 491 492 ajaxCall(sendData); 493 }); 494 }, 495 496 mobile_menu_toggle: function() { 497 $(document).on('click', '.menu-mobile-effect', function(e) { 498 e.stopPropagation(); 499 $('body').toggleClass('mobile-menu-open'); 500 }); 501 502 $(document).on('click', '.mobile-menu-wrapper', function(e) { 503 $('body').removeClass('mobile-menu-open'); 504 }); 505 506 $(document).on('click', '.mobile-menu-inner', function(e) { 507 e.stopPropagation(); 508 }); 509 }, 510 511 thim_menu: function() { 512 513 //Add class for masthead 514 var $header = $('#masthead.sticky-header'), 515 off_Top = ($('.content-pusher').length > 0) ? $('.content-pusher'). 516 offset().top : 0, 517 menuH = $header.outerHeight(), 518 latestScroll = 0; 519 if ($(window).scrollTop() > 2) { 520 $header.removeClass('affix-top').addClass('affix'); 521 } 522 $(window).scroll(function() { 523 var current = $(this).scrollTop(); 524 if (current > 2) { 525 $header.removeClass('affix-top').addClass('affix'); 526 } else { 527 $header.removeClass('affix').addClass('affix-top'); 528 } 529 530 if (current > latestScroll && current > menuH + off_Top) { 531 if (!$header.hasClass('menu-hidden')) { 532 $header.addClass('menu-hidden'); 533 } 534 } else { 535 if ($header.hasClass('menu-hidden')) { 536 $header.removeClass('menu-hidden'); 537 } 538 } 539 540 latestScroll = current; 541 }); 542 543 //Submenu position 544 $('.wrapper-container:not(.mobile-menu-open) .site-header .navbar-nav > .menu-item').each(function() { 545 if ($('>.sub-menu', this).length <= 0) { 546 return; 547 } 548 549 let elm = $('>.sub-menu', this), 550 off = elm.offset(), 551 left = off.left, 552 width = elm.width(); 553 554 let navW = $('.thim-nav-wrapper').width(), 555 isEntirelyVisible = (left + width <= navW); 556 557 if (!isEntirelyVisible) { 558 elm.addClass('dropdown-menu-right'); 559 } else { 560 let subMenu2 = elm.find('>.menu-item>.sub-menu'); 561 562 if (subMenu2.length <= 0) { 563 return; 564 } 565 566 let off = subMenu2.offset(), 567 left = off.left, 568 width = subMenu2.width(); 569 570 let isEntirelyVisible = (left + width <= navW); 571 572 if (!isEntirelyVisible) { 573 elm.addClass('dropdown-left-side'); 574 } 575 } 576 }); 577 578 //Show submenu when hover 579 // var $menuItem = $( 580 // '.wrapper-container:not(.mobile-menu-open) .site-header .navbar-nav >li,' + 581 // '.wrapper-container:not(.mobile-menu-open) .site-header .navbar-nav li,' + 582 // '.site-header .navbar-nav li ul li'); 583 // 584 // $menuItem.on({ 585 // 'mouseenter': function() { 586 // $(this).children('.sub-menu').stop(true, false).fadeIn(250); 587 // }, 588 // 'mouseleave': function() { 589 // $(this). 590 // children('.sub-menu'). 591 // stop(true, false). 592 // fadeOut(250); 593 // }, 594 // }); 595 596 let $headerLayout = $('header#masthead'); 597 let magicLine = function() { 598 if ($(window).width() > 768) { 599 //Magic Line 600 var menu_active = $( 601 '#masthead .navbar-nav>li.menu-item.current-menu-item,#masthead .navbar-nav>li.menu-item.current-menu-parent, #masthead .navbar-nav>li.menu-item.current-menu-ancestor'); 602 if (menu_active.length > 0) { 603 menu_active.before('<span id="magic-line"></span>'); 604 var menu_active_child = menu_active.find( 605 '>a,>span.disable_link,>span.tc-menu-inner'), 606 menu_left = menu_active.position().left, 607 menu_child_left = parseInt(menu_active_child.css('padding-left')), 608 magic = $('#magic-line'); 609 610 magic.width(menu_active_child.width()). 611 css('left', Math.round(menu_child_left + menu_left)). 612 data('magic-width', magic.width()). 613 data('magic-left', magic.position().left); 614 615 } else { 616 var first_menu = $( 617 '#masthead .navbar-nav>li.menu-item:first-child'); 618 first_menu.before('<span id="magic-line"></span>'); 619 var magic = $('#magic-line'); 620 magic.data('magic-width', 0); 621 } 622 623 var nav_H = parseInt($('.site-header .navigation').outerHeight()); 624 magic.css('bottom', nav_H - (nav_H - 90) / 2 - 64); 625 626 $('#masthead .navbar-nav>li.menu-item').on({ 627 'mouseenter': function() { 628 var elem = $(this). 629 find('>a,>span.disable_link,>span.tc-menu-inner'), 630 new_width = elem.width(), 631 parent_left = elem.parent().position().left, 632 left = parseInt(elem.css('padding-left')); 633 if (!magic.data('magic-left')) { 634 magic.css('left', Math.round(parent_left + left)); 635 magic.data('magic-left', 'auto'); 636 } 637 magic.stop().animate({ 638 left : Math.round(parent_left + left), 639 width: new_width, 640 }); 641 }, 642 'mouseleave': function() { 643 magic.stop().animate({ 644 left : magic.data('magic-left'), 645 width: magic.data('magic-width'), 646 }); 647 }, 648 }); 649 } 650 }; 651 652 if (!$headerLayout.hasClass('header_v4')) { 653 magicLine(); 654 } 655 656 var subMenuPosition = function(menuItem) { 657 var $menuItem = menuItem, 658 $container = $menuItem.closest('.container, .header_full'), 659 $subMenu = $menuItem.find('>.sub-menu'), 660 $menuItemWidth = $menuItem.width(), 661 $containerWidth = $container.width(), 662 $subMenuWidth = $subMenu.width(), 663 $subMenuDistance = $subMenuWidth / 2, 664 paddingContainer = 15; 665 666 }; 667 }, 668 669 thim_carousel: function($scope) { 670 if (jQuery().owlCarousel) { 671 $('.thim-gallery-images').owlCarousel({ 672 autoPlay : false, 673 singleItem : true, 674 stopOnHover: true, 675 pagination : true, 676 autoHeight : false, 677 }); 678 679 $('.thim-carousel-wrapper').each(function() { 680 var item_visible = $(this).data('visible') ? parseInt( 681 $(this).data('visible')) : 4, 682 item_desktopsmall = $(this).data('desktopsmall') ? parseInt( 683 $(this).data('desktopsmall')) : item_visible, 684 itemsTablet = $(this).data('itemtablet') ? parseInt( 685 $(this).data('itemtablet')) : 2, 686 itemsMobile = $(this).data('itemmobile') ? parseInt( 687 $(this).data('itemmobile')) : 1, 688 pagination = !!$(this).data('pagination'), 689 navigation = !!$(this).data('navigation'), 690 autoplay = $(this).data('autoplay') ? parseInt( 691 $(this).data('autoplay')) : false, 692 navigation_text = ($(this).data('navigation-text') && 693 $(this).data('navigation-text') === '2') ? [ 694 '<i class=\'fa fa-long-arrow-left \'></i>', 695 '<i class=\'fa fa-long-arrow-right \'></i>', 696 ] : [ 697 '<i class=\'fa fa-chevron-left \'></i>', 698 '<i class=\'fa fa-chevron-right \'></i>', 699 ]; 700 701 $(this).owlCarousel({ 702 items : item_visible, 703 itemsDesktop : [1200, item_visible], 704 itemsDesktopSmall: [1024, item_desktopsmall], 705 itemsTablet : [768, itemsTablet], 706 itemsMobile : [480, itemsMobile], 707 navigation : navigation, 708 pagination : pagination, 709 lazyLoad : true, 710 autoPlay : autoplay, 711 navigationText : navigation_text, 712 }); 713 }); 714 715 $('.thim-carousel-course-categories .thim-course-slider, .thim-carousel-course-categories-tabs .thim-course-slider'). 716 each(function() { 717 var item_visible = $(this).data('visible') ? parseInt($(this).data('visible')) : 7, 718 item_desktop = $(this).data('desktop') ? parseInt($(this).data('desktop')) : 7, 719 item_desktopsmall = $(this).data('desktopsmall') 720 ? parseInt($(this).data('desktopsmall')) 721 : 6, 722 item_tablet = $(this).data('tablet') ? parseInt($(this).data('tablet')) : 4, 723 item_mobile = $(this).data('mobile') ? parseInt($(this).data('mobile')) : 2, 724 pagination = !!$(this).data('pagination'), 725 navigation = !!$(this).data('navigation'), 726 autoplay = $(this).data('autoplay') ? parseInt($(this).data('autoplay')) : false, 727 is_rtl = $('body').hasClass('rtl'); 728 729 $(this).owlCarousel({ 730 items : item_visible, 731 itemsDesktop : [1800, item_desktop], 732 itemsDesktopSmall: [1024, item_desktopsmall], 733 itemsTablet : [768, item_tablet], 734 itemsMobile : [480, item_mobile], 735 navigation : navigation, 736 pagination : pagination, 737 autoPlay : autoplay, 738 navigationText : [ 739 '<i class=\'fa fa-chevron-left \'></i>', 740 '<i class=\'fa fa-chevron-right \'></i>', 741 ], 742 }); 743 }); 744 } 745 }, 746 747 thim_contentslider: function($scope) { 748 $('.thim-testimonial-slider').each(function() { 749 var elem = $(this), 750 item_visible = parseInt(elem.data('visible')), 751 item_time = parseInt(elem.data('time')), 752 autoplay = elem.data('auto') ? true : false, 753 item_ratio = elem.data('ratio') ? elem.data('ratio') : 1.18, 754 item_padding = elem.data('padding') ? elem.data('padding') : 15, 755 item_activepadding = elem.data('activepadding') ? elem.data( 756 'activepadding') : 0, 757 item_width = elem.data('width') ? elem.data('width') : 100, 758 mousewheel = !!elem.data('mousewheel'); 759 760 var testimonial_slider = $(this).thimContentSlider({ 761 items : elem, 762 itemsVisible : item_visible, 763 mouseWheel : mousewheel, 764 autoPlay : autoplay, 765 pauseTime : item_time, 766 itemMaxWidth : item_width, 767 itemMinWidth : item_width, 768 activeItemRatio : item_ratio, 769 activeItemPadding: item_activepadding, 770 itemPadding : item_padding, 771 }); 772 773 }); 774 }, 775 776 counter_box: function() { 777 if (jQuery().waypoint) { 778 jQuery('.counter-box').waypoint(function() { 779 jQuery(this).find('.display-percentage').each(function() { 780 var percentage = jQuery(this).data('percentage'); 781 jQuery(this). 782 countTo({ 783 from : 0, 784 to : percentage, 785 refreshInterval: 40, 786 speed : 2000, 787 }); 788 }); 789 }, { 790 triggerOnce: true, 791 offset : '80%', 792 }); 793 } 794 } 795 796 }; 797 798 $(document).ready(function() { 799 thim_eduma.ready(); 800 }); 801 802 $(window).load(function() { 803 thim_eduma.load(); 804 }); 805 806 $(window).resize(function() { 807 thim_eduma.resize(); 808 }); 809 810 $(window).on('elementor/frontend/init', function() { 811 elementorFrontend.hooks.addAction('frontend/element_ready/thim-carousel-post.default', 812 thim_eduma.thim_carousel); 813 814 elementorFrontend.hooks.addAction('frontend/element_ready/thim-courses.default', 815 thim_eduma.thim_carousel); 816 817 elementorFrontend.hooks.addAction('frontend/element_ready/thim-course-categories.default', 818 thim_eduma.thim_carousel); 819 820 elementorFrontend.hooks.addAction('frontend/element_ready/thim-our-team.default', 821 thim_eduma.thim_carousel); 822 823 elementorFrontend.hooks.addAction('frontend/element_ready/thim-gallery-images.default', 824 thim_eduma.thim_carousel); 825 826 elementorFrontend.hooks.addAction('frontend/element_ready/thim-list-instructors.default', 827 thim_eduma.thim_carousel); 828 829 elementorFrontend.hooks.addAction('frontend/element_ready/thim-testimonials.default', 830 thim_eduma.thim_contentslider); 831 832 elementorFrontend.hooks.addAction('frontend/element_ready/thim-counters-box.default', 833 thim_eduma.counter_box); 834 }); 835})(jQuery); 836 837(function($) { 838 'use strict'; 839 840 // Fungsi DateTime yang sudah ada 841 function thimDateTime() { 842 var dateTimeElement = $('#thim-date-time'); 843 if (dateTimeElement.length === 0) { return; } 844 var days = ['Minggu', 'Senin', 'Selasa', 'Rabu', 'Kamis', 'Jumat', 'Sabtu']; 845
845var months = ['Januari', 'Februari', 'Maret', 'April', 'Mei', 'Juni', 'Juli', 'Agustus', 'September', 'Oktober', 'November', 'Desember']; 846 var now = new Date(); 847 var day = days[now.getDay()]; 848 var date = now.getDate(); 849 var month = months[now.getMonth()]; 850 var year = now.getFullYear(); 851 var hours = now.getHours(); 852 var minutes = now.getMinutes(); 853 var seconds = now.getSeconds(); 854 hours = hours < 10 ? '0' + hours : hours; 855 minutes = minutes < 10 ? '0' + minutes : minutes; 856 seconds = seconds < 10 ? '0' + seconds : seconds; 857 var dateString = day + ', ' + date + ' ' + month + ' ' + year; 858 var timeString = hours + ':' + minutes + ':' + seconds; 859 dateTimeElement.html(dateString + ' | ' + timeString + ' WIB'); 860 } 861 862 // FUNGSI MOBILE MENU - TAMBAHAN BARU 863 function initMobileMenu() { 864 var $body = $('body'); 865 var $mobileToggle = $('.menu-mobile-effect'); 866 var $mobileMenu = $('.mobile-menu-wrapper');
867 var $overlay = $('<div class="mobile-menu-overlay"></div>'); 868 var $closeBtn = $('.mobile-menu-inner .close-icon'); 869 870 // Tambahkan overlay ke body jika belum ada 871 if (!$('.mobile-menu-overlay').length) { 872 $body.append($overlay); 873 } 874 875 // Buka mobile menu 876 $mobileToggle.on('click', function(e) { 877 e.preventDefault(); 878 $(this).addClass('active'); 879 $mobileMenu.addClass('show'); 880 $overlay.addClass('show'); 881 $body.addClass('mobile-menu-open').css('overflow', 'hidden'); 882 }); 883 884 // Tutup mobile menu 885 function closeMobileMenu() { 886 $mobileToggle.removeClass('active'); 887 $mobileMenu.removeClass('show'); 888 $overlay.removeClass('show'); 889 $body.removeClass('mobile-menu-open').css('overflow', ''); 890 } 891 892 // Tutup dengan tombol close 893 $closeBtn.on('click', closeMobileMenu); 894 895 // Tutup dengan klik overlay 896 $overlay.on('click', closeMobileMenu); 897 898 // Tutup dengan ESC key 899 $(document).on('keydown', function(e) { 900 if (e.keyCode === 27 && $mobileMenu.hasClass('show')) { 901 closeMobileMenu(); 902 } 903 }); 904 905 // Handle submenu mobile 906 $('.mobile-menu-container .menu-item-has-children > a').on('click', function(e) { 907 e.preventDefault(); 908 var $submenu = $(this).next('.sub-menu'); 909 var $parent = $(this).parent(); 910 911 if ($submenu.is(':visible')) { 912 $submenu.slideUp(300); 913 $parent.removeClass('active'); 914 } else { 915 // Tutup submenu lain 916 $('.mobile-menu-container .sub-menu').slideUp(300); 917 $('.mobile-menu-container .menu-item-has-children').removeClass('active'); 918 919 // Buka submenu ini 920 $submenu.slideDown(300); 921 $parent.addClass('active'); 922 } 923 }); 924 925 // Tutup mobile menu saat resize ke desktop 926 $(window).on('resize', function() { 927 if ($(window).width() > 1024 && $mobileMenu.hasClass('show')) { 928 closeMobileMenu(); 929 } 930 }); 931 } 932 933 // SMOOTH SCROLL untuk anchor links 934 function initSmoothScroll() { 935 $('a[href*="#"]:not([href="#"])').on('click', function() { 936 if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) { 937 var target = $(this.hash); 938 target = target.length ? target : $('[name=' + this.hash.slice(1) + ']'); 939 if (target.length) { 940 $('html, body').animate({ 941 scrollTop: target.offset().top - 80 942 }, 1000); 943 return false; 944 } 945 } 946 }); 947 } 948 949 // STICKY HEADER 950 function initStickyHeader() { 951 var $header = $('.site-header'); 952 var headerHeight = $header.outerHeight(); 953 var scrollThreshold = headerHeight + 100; 954 955 $(window).on('scroll', function() { 956 var scrollTop = $(this).scrollTop(); 957 958 if (scrollTop > scrollThreshold) { 959 $header.addClass('affix'); 960 } else { 961 $header.removeClass('affix'); 962 } 963 }); 964 } 965 966 // SEARCH FORM Enhancement 967 function initSearchEnhancement() { 968 // Auto-focus search ketika klik icon 969 $('.search-submit, .search-icon').on('click', function() { 970 var $searchField = $(this).siblings('.search-field'); 971 if ($searchField.length) { 972 $searchField.focus(); 973 } 974 }); 975 976 // Placeholder animation 977 $('.search-field').on('focus blur', function() { 978 $(this).parent().toggleClass('focused'); 979 }); 980 } 981 982 // DROPDOWN HOVER DELAY (untuk mencegah dropdown menutup terlalu cepat) 983 function initDropdownHover() { 984 var hoverTimeout; 985 986 $('.navigation .menu-item-has-children').hover( 987 function() { 988 clearTimeout(hoverTimeout); 989 $(this).addClass('hover'); 990 }, 991 function() { 992 var $this = $(this); 993 hoverTimeout = setTimeout(function() { 994 $this.removeClass('hover'); 995 }, 300); 996 } 997 ); 998 } 999 1000 // LOADING ANIMATION 1001 function initLoadingStates() { 1002 // Loading state untuk search form 1003 $('.search-form').on('submit', function() { 1004 var $submitBtn = $(this).find('.search-submit'); 1005 $submitBtn.html('<i class="fa fa-spinner fa-spin"></i>'); 1006 }); 1007 1008 // Loading state untuk AJAX requests jika ada 1009 $(document).ajaxStart(function() { 1010 $('body').addClass('loading'); 1011 }).ajaxStop(function() { 1012 $('body').removeClass('loading'); 1013 }); 1014 } 1015 1016 // ACCESSIBILITY IMPROVEMENTS 1017 function initAccessibility() { 1018 // Keyboard navigation untuk menu 1019 $('.navigation .menu-main-menu a').on('keydown', function(e) { 1020 if (e.which === 13 || e.which === 32) { // Enter atau Space 1021 e.preventDefault(); 1022 $(this)[0].click(); 1023 } 1024 }); 1025 1026 // Focus management 1027 $('.menu-mobile-effect').on('keydown', function(e) { 1028 if (e.which === 13 || e.which === 32) { 1029 e.preventDefault(); 1030 $(this).click(); 1031 } 1032 }); 1033 } 1034 1035 // INIT SEMUA FUNGSI 1036 $(document).ready(function() { 1037 // Fungsi yang sudah ada 1038 thimDateTime(); 1039 setInterval(thimDateTime, 1000); 1040 1041 // Fungsi-fungsi baru 1042 initMobileMenu(); 1043 initSmoothScroll(); 1044 initStickyHeader(); 1045 initSearchEnhancement(); 1046 initDropdownHover(); 1047 initLoadingStates(); 1048 initAccessibility(); 1049 1050 // Fade in animation saat page load 1051 $('body').addClass('loaded'); 1052 }); 1053 1054 // OPTIMASI PERFORMANCE 1055 var throttle = function(func, limit) { 1056 var inThrottle; 1057 return function() { 1058 var args = arguments; 1059 var context = this; 1060 if (!inThrottle) {
1061 func.apply(context, args); 1062 inThrottle = true; 1063 setTimeout(function() { inThrottle = false; }, limit); 1064 } 1065 }; 1066 }; 1067 1068 // Throttle scroll events 1069 $(window).on('scroll', throttle(function() { 1070 // Additional scroll handlers dapat ditambahkan di sini 1071 }, 16)); // ~60fps 1072 1073})(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.