1/*========================================================================================= 2 File Name: app.js 3 Description: Template related app JS. 4==========================================================================================*/ 5 6var regexMobile = new RegExp('09(1[0-9]|3[1-9]|2[1-9])-?[0-9]{3}-?[0-9]{4}'); 7var mediumRegex = new RegExp("^(((?=.*[a-z])(?=.*[A-Z]))|((?=.*[a-z])(?=.*[0-9]))|((?=.*[A-Z])(?=.*[0-9])))(?=.{6,})"); 8var regexMail = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; 9 10 11(function (window, document, $) { 12 "use strict"; 13 var $html = $("html"); 14 var $body = $("body"); 15 var $danger = "#FF5B5C"; 16 var $primary = "#5A8DEE"; 17 var $primary_lighten = "#e7edf3"; 18 var $warning = "#FDAC41"; 19 var $textcolor = "#304156"; 20 21 function scrollTopFn() { 22 var $scrollTop = $(window).scrollTop(); 23 if ($scrollTop > 68) { 24 $("body").addClass("navbar-scrolled"); 25 } else { 26 $("body").removeClass("navbar-scrolled"); 27 } 28 if ($scrollTop > 20) { 29 $("body").addClass("page-scrolled"); 30 } else { 31 $("body").removeClass("page-scrolled"); 32 } 33 } 34 $(window).scroll(function () { 35 scrollTopFn(); 36 }); 37 38 $(window).on("load", function () { 39 var rtl; 40 var compactMenu = false; // Set it to true, if you want default menu to be compact 41 42 if ($body.hasClass("menu-collapsed")) { 43 compactMenu = true; 44 } 45 46 if ($("html").data("textdirection") == "rtl") { 47 rtl = true; 48 } 49 50 setTimeout(function () { 51 $html.removeClass("loading").addClass("loaded"); 52 }, 1200); 53 54 $.app.menu.init(compactMenu); 55 56 // Livioncs are initialized for vertical menu 57 $.each($(".menu-livicon"), function (i) { 58 var $this = $(this), 59 icon = $this.data("icon"), 60 iconStyle = $("#main-menu-navigation").data("icon-style"); 61 62 $this.addLiviconEvo({ 63 name: icon, 64 style: iconStyle, 65 duration: 0.85, 66 strokeWidth: "1.3px", 67 eventOn: "none", 68 strokeColor: menuIconColorsObj.iconStrokeColor, 69 solidColor: menuIconColorsObj.iconSolidColor,
70 fillColor: menuIconColorsObj.iconFillColor, 71 strokeColorAlt: menuIconColorsObj.iconStrokeColorAlt, 72 afterAdd: function () { 73 if (i === $(".main-menu-content .menu-livicon").length - 1) { 74 // When hover over any menu item, start animation and stop all other animation 75 $(".main-menu-content .nav-item a").on("mouseenter", function () { 76 if ($(".main-menu-content .menu-livicon").length) { 77 $(".main-menu-content .menu-livicon").stopLiviconEvo(); 78 $(this) 79 .find(".menu-livicon") 80 .playLiviconEvo(); 81 } 82 }); 83 } 84 } 85 }); 86 }); 87 88 function updateLivicon(el) { 89 el.updateLiviconEvo({ 90 strokeColor: menuActiveIconColorsObj.iconStrokeColor, 91 solidColor: menuActiveIconColorsObj.iconSolidColor, 92 fillColor: menuActiveIconColorsObj.iconFillColor, 93 strokeColorAlt: menuActiveIconColorsObj.iconStrokeColorAlt 94 }); 95 } 96 97 // Navigation configurations 98 var config = { 99 speed: 300 // set speed to expand / collpase menu 100 } 101 102 if ($.app.nav.initialized === false) { 103 $.app.nav.init(config); 104 } 105 106 Unison.on("change", function (bp) { 107 $.app.menu.change(compactMenu); 108 }); 109 110 // Tooltip Initialization 111 $('[data-toggle="tooltip"]').tooltip({ 112 container: "body" 113 }); 114 115 // Tooltip For Horizontal Layout - Bookmark Icons 116 /* tooltip-horizontal-bookmark - Add Custom Class */ 117 $(".tooltip-horizontal-bookmark").tooltip({ 118 customClass: "tooltip-horizontal-bookmark" 119 }); 120 121 // Top Navbars - Hide on Scroll 122 if ($(".navbar-hide-on-scroll").length > 0) { 123 $(".navbar-hide-on-scroll.fixed-top").headroom({ 124 offset: 205, 125 tolerance: 5, 126 classes: { 127 // when element is initialised 128 initial: "headroom", 129 // when scrolling up 130 pinned: "headroom--pinned-top", 131 // when scrolling down 132 unpinned: "headroom--unpinned-top" 133 } 134 }); 135 // Bottom Navbars - Hide on Scroll 136 $(".navbar-hide-on-scroll.fixed-bottom").headroom({ 137 offset: 205, 138 tolerance: 5, 139 classes: { 140 // when element is initialised 141 initial: "headroom", 142 // when scrolling up 143 pinned: "headroom--pinned-bottom", 144 // when scrolling down 145 unpinned: "headroom--unpinned-bottom" 146 } 147 }); 148 } 149 150 // Collapsible Card 151 $('a[data-action="collapse"]').on("click", function (e) { 152 e.preventDefault(); 153 $(this) 154 .closest(".card") 155 .children(".card-content") 156 .collapse("toggle"); 157 // Adding bottom padding on card collapse 158 $(this) 159 .closest(".card") 160 .children(".card-header") 161 .css("padding-bottom", "1.5rem"); 162 $(this) 163 .closest(".card") 164 .find('[data-action="collapse"]') 165 .toggleClass("rotate"); 166 }); 167 168 // Toggle fullscreen 169 $('a[data-action="expand"]').on("click", function (e) { 170 e.preventDefault(); 171 $(this) 172 .closest(".card") 173 .find('[data-action="expand"] i') 174 .toggleClass("bx-fullscreen bx-exit-fullscreen"); 175 $(this) 176 .closest(".card") 177 .toggleClass("card-fullscreen"); 178 }); 179 180 // Notifications & messages scrollable 181 $(".scrollable-container").each(function () { 182 var scrollable_container = new PerfectScrollbar($(this)[0], { 183 wheelPropagation: false 184 }); 185 }); 186 187 // Reload Card 188 $('a[data-action="reload"]').on("click", function () { 189 var block_ele = $(this) 190 .closest(".card") 191 .find(".card-content"); 192 var reloadActionOverlay; 193 if ($body.hasClass("dark-layout")) { 194 var reloadActionOverlay = "#10163a"; 195 } else { 196 var reloadActionOverlay = "#fff"; 197 } 198 // Block Element 199 block_ele.block({ 200 message: '<div class="bx bx-sync icon-spin font-medium-2 text-primary"></div>', 201 timeout: 2000, //unblock after 2 seconds 202 overlayCSS: { 203 backgroundColor: reloadActionOverlay, 204 cursor: "wait" 205 }, 206 css: { 207 border: 0, 208 padding: 0, 209 backgroundColor: "none" 210 } 211 }); 212 }); 213 214 // Close Card 215 $('a[data-action="close"]').on("click", function () { 216 $(this) 217 .closest(".card") 218 .removeClass() 219 .slideUp("fast"); 220 }); 221 222 // Match the height of each card in a row 223 setTimeout(function () { 224 $(".row.match-height").each(function () { 225 $(this) 226 .find(".card") 227 .not(".card .card") 228 .matchHeight(); // Not .card .card prevents collapsible cards from taking height 229 }); 230 }, 500); 231 232 $('.card .heading-elements a[data-action="collapse"]').on( 233 "click", 234 function () { 235 var $this = $(this), 236 card = $this.closest(".card"); 237 var cardHeight; 238 239 if (parseInt(card[0].style.height, 10) > 0) { 240 cardHeight = card.css("height"); 241 card.css("height", "").attr("data-height", cardHeight); 242 } else { 243 if (card.data("height")) { 244 cardHeight = card.data("height"); 245 card.css("height", cardHeight).attr("data-height", ""); 246 } 247 } 248 } 249 ); 250 251 // Add sidebar group active class to active menu 252 $(".main-menu-content") 253 .find("li.active") 254 .parents("li") 255 .addClass("sidebar-group-active"); 256 257 // Update Active Menu item Icon with active color 258 if ($(".nav-item.active .menu-livicon").length) { 259 updateLivicon( 260 $(".nav-item.active .menu-livicon") 261 ); 262 } 263 264 // Update Active sidebar group menu icon with active ccolor 265 if ($(".main-menu-content li.sidebar-group-active .menu-livicon").length) { 266 updateLivicon( 267 $(".main-menu-content li.sidebar-group-active .menu-livicon") 268 ); 269 } 270 271 // Add open class to parent list item if subitem is active except compact menu 272 var menuType = $body.data("menu"); 273 if (menuType != "horizontal-menu" && compactMenu === false) { 274 $(".main-menu-content") 275 .find("li.active") 276 .parents("li") 277 .addClass("open"); 278 } 279 if (menuType == "horizontal-menu") { 280 $(".main-menu-content") 281 .find("li.active") 282 .parents("li:not(.nav-item)") 283 .addClass("open"); 284 $(".main-menu-content") 285 .find("li.active") 286 .parents("li") 287 .addClass("active"); 288 } 289 290 //card heading actions buttons small screen support 291 $(".heading-elements-toggle").on("click", function () { 292 $(this) 293 .next(".heading-elements") 294 .toggleClass("visible"); 295 }); 296 297 // Dynamic height for the chartjs div for the chart animations to work 298 var chartjsDiv = $(".chartjs"), 299 canvasHeight = chartjsDiv.children("canvas").attr("height");
300 chartjsDiv.css("height", canvasHeight); 301 302 if ($body.hasClass("boxed-layout")) { 303 if ($body.hasClass("vertical-overlay-menu")) { 304 var menuWidth = $(".main-menu").width(); 305 var contentPosition = $(".app-content").position().left; 306 var menuPositionAdjust = contentPosition - menuWidth; 307 if ($body.hasClass("menu-flipped")) { 308 $(".main-menu").css("right", menuPositionAdjust + "px"); 309 } else { 310 $(".main-menu").css("left", menuPositionAdjust + "px"); 311 } 312 } 313 } 314 315 //Custom File Input 316 $(".custom-file input").change(function (e) { 317 $(this) 318 .next(".custom-file-label") 319 .html(e.target.files[0].name); 320 }); 321 322 /* Text Area Counter Set Start */ 323 324 $(".char-textarea").on("keyup", function (event) { 325 checkTextAreaMaxLength(this, event); 326 // to later change text color in dark layout 327 $(this).addClass("active"); 328 }); 329 330 /* 331 Checks the MaxLength of the Textarea 332 ----------------------------------------------------- 333 @prerequisite: textBox = textarea dom element 334 e = textarea event 335 length = Max length of characters 336 */ 337 function checkTextAreaMaxLength(textBox, e) { 338 var maxLength = parseInt($(textBox).data("length")); 339 340 if (!checkSpecialKeys(e)) { 341 if (textBox.value.length < maxLength - 1) 342 textBox.value = textBox.value.substring(0, maxLength); 343 } 344 $(".char-count").html(textBox.value.length); 345 346 if (textBox.value.length > maxLength) { 347 $(".counter-value").css("background-color", $danger); 348 $(".char-textarea").css("color", $danger); 349 // to change text color after limit is maxedout out 350 $(".char-textarea").addClass("max-limit"); 351 } else { 352 $(".counter-value").css("background-color", $primary); 353 $(".char-textarea").css("color", $textcolor); 354 $(".char-textarea").removeClass("max-limit"); 355 } 356 357 return true; 358 } 359 /* 360 Checks if the keyCode pressed is inside special chars 361 ------------------------------------------------------- 362 @prerequisite: e = e.keyCode object for the key pressed 363 */ 364 function checkSpecialKeys(e) { 365 if ( 366 e.keyCode != 8 && 367 e.keyCode != 46 && 368 e.keyCode != 37 && 369 e.keyCode != 38 && 370 e.keyCode != 39 && 371 e.keyCode != 40 372 ) 373 return false; 374 else return true; 375 } 376 377 $(".content-overlay").on("click", function () { 378 $(".search-list").removeClass("show"); 379 $(".app-content").removeClass("show-overlay"); 380 $(".bookmark-wrapper .bookmark-input").removeClass("show"); 381 }); 382 383 // To show shadow in main menu when menu scrolls 384 var container = document.getElementsByClassName("main-menu-content"); 385 if (container.length > 0) { 386 container[0].addEventListener("ps-scroll-y", function () { 387 if ( 388 $(this) 389 .find(".ps__thumb-y") 390 .position().top > 0 391 ) { 392 $(".shadow-bottom").css("display", "block"); 393 } else { 394 $(".shadow-bottom").css("display", "none"); 395 } 396 }); 397 } 398 }); 399 400 // Hide overlay menu on content overlay click on small screens 401 $(document).on("click", ".sidenav-overlay", function (e) { 402 // Hide menu 403 $.app.menu.hide(); 404 return false; 405 }); 406 407 // Execute below code only if we find hammer js for touch swipe feature on small screen 408 if (typeof Hammer !== "undefined") { 409 // Swipe menu gesture 410 var swipeInElement = document.querySelector(".drag-target"); 411 412 if ($(swipeInElement).length > 0) { 413 var swipeInMenu = new Hammer(swipeInElement); 414 415 swipeInMenu.on("panright", function (ev) { 416 if ($body.hasClass("vertical-overlay-menu")) { 417 $.app.menu.open(); 418 return false; 419 } 420 }); 421 } 422 423 // menu swipe out gesture 424 setTimeout(function () { 425 var swipeOutElement = document.querySelector(".main-menu"); 426 var swipeOutMenu; 427 428 if ($(swipeOutElement).length > 0) { 429 swipeOutMenu = new Hammer(swipeOutElement); 430 431 swipeOutMenu.get("pan").set({ 432 direction: Hammer.DIRECTION_ALL, 433 threshold: 100 434 }); 435 436 swipeOutMenu.on("panleft", function (ev) { 437 if ($body.hasClass("vertical-overlay-menu")) { 438 $.app.menu.hide(); 439 return false; 440 } 441 }); 442 } 443 }, 300); 444 445 // menu overlay swipe out gestrue 446 var swipeOutOverlayElement = document.querySelector(".sidenav-overlay"); 447 448 if ($(swipeOutOverlayElement).length > 0) { 449 var swipeOutOverlayMenu = new Hammer(swipeOutOverlayElement); 450 451 swipeOutOverlayMenu.on("panleft", function (ev) { 452 if ($body.hasClass("vertical-overlay-menu")) { 453 $.app.menu.hide(); 454 return false;
455 } 456 }); 457 } 458 } 459 460 $(document).on("click", ".menu-toggle, .modern-nav-toggle", function (e) { 461 e.preventDefault(); 462 463 // Toggle menu 464 $.app.menu.toggle(); 465 466 setTimeout(function () { 467 $(window).trigger("resize"); 468 }, 200); 469 470 if ($("#collapsed-sidebar").length > 0) { 471 setTimeout(function () { 472 if ($body.hasClass("menu-expanded") || $body.hasClass("menu-open")) { 473 $("#collapsed-sidebar").prop("checked", false); 474 } else { 475 $("#collapsed-sidebar").prop("checked", true); 476 } 477 }, 1000); 478 } 479 480 // Hides dropdown on click of menu toggle 481 // $('[data-toggle="dropdown"]').dropdown('hide'); 482 483 // Hides collapse dropdown on click of menu toggle 484 if ( 485 $(".vertical-overlay-menu .navbar-with-menu .navbar-container .navbar-collapse").hasClass("show") 486 ) { 487 $(".vertical-overlay-menu .navbar-with-menu .navbar-container .navbar-collapse").removeClass("show"); 488 } 489 490 return false; 491 }); 492 493 // Add Children Class 494 $(".navigation") 495 .find("li") 496 .has("ul") 497 .addClass("has-sub"); 498 499 $(".carousel").carousel({ 500 interval: 2000 501 }); 502 503 // Page full screen 504 $(".nav-link-expand").on("click", function (e) { 505 if (typeof screenfull != "undefined") { 506 if (screenfull.enabled) { 507 screenfull.toggle(); 508 } 509 } 510 }); 511 512 if (typeof screenfull != "undefined") { 513 if (screenfull.enabled) { 514 $(document).on(screenfull.raw.fullscreenchange, function () { 515 if (screenfull.isFullscreen) { 516 $(".nav-link-expand") 517 .find("i") 518 .toggleClass("bx-exit-fullscreen bx-fullscreen"); 519 $("html").addClass("full-screen"); 520 } else { 521 $(".nav-link-expand") 522 .find("i") 523 .toggleClass("bx-fullscreen bx-exit-fullscreen"); 524 $("html").removeClass("full-screen"); 525 } 526 }); 527 } 528 } 529 530 $(document).ready(function () { 531 /********************************** 532 * Form Wizard Step Icon 533 **********************************/ 534 $(".step-icon").each(function () { 535 var $this = $(this); 536 if ($this.siblings("span.step").length > 0) { 537 $this.siblings("span.step").empty(); 538 $(this).appendTo($(this).siblings("span.step")); 539 } 540 }); 541 }); 542 543 // Update manual scroller when window is resized 544 $(window).resize(function () { 545 $.app.menu.manualScroller.updateHeight(); 546 // To show shadow in main menu when menu scrolls 547 var container = document.getElementsByClassName("main-menu-content"); 548 if (container.length > 0) { 549 container[0].addEventListener("ps-scroll-y", function () { 550 if ( 551 $(this) 552 .find(".ps__thumb-y") 553 .position().top > 0 554 ) { 555 $(".shadow-bottom").css("display", "block"); 556 } else { 557 $(".shadow-bottom").css("display", "none"); 558 } 559 }); 560 } 561 }); 562 563 $("#sidebar-page-navigation").on("click", "a.nav-link", function (e) { 564 e.preventDefault(); 565 e.stopPropagation(); 566 var $this = $(this), 567 href = $this.attr("href"); 568 var offset = $(href).offset(); 569 var scrollto = offset.top - 80; // minus fixed header height 570 $("html, body").animate({ 571 scrollTop: scrollto 572 }, 0); 573 setTimeout(function () { 574 $this 575 .parent(".nav-item") 576 .siblings(".nav-item") 577 .children(".nav-link") 578 .removeClass("active"); 579 $this.addClass("active"); 580 }, 100); 581 }); 582 583 // main menu internationalization 584 585 // init i18n and load language file 586 i18next 587 .use(window.i18nextXHRBackend) 588 .init({ 589 debug: false, 590 fallbackLng: "fa", 591 backend: { 592 loadPath: "../../assets/data/locales/{{lng}}.json" 593 }, 594 returnObjects: true 595 }, 596 function (err, t) { 597 // resources have been loaded 598 jqueryI18next.init(i18next, $); 599 } 600 ); 601 602 // change language according to data-language of dropdown item 603 $(".dropdown-language .dropdown-item").on("click", function () { 604 var $this = $(this); 605 $this.siblings(".selected").removeClass("selected"); 606 $this.addClass("selected"); 607 var selectedLang = $this.text(); 608 var selectedFlag = $this.find(".flag-icon").attr("class"); 609 $("#dropdown-flag .selected-language").text(selectedLang); 610 $("#dropdown-flag .flag-icon") 611 .removeClass() 612 .addClass(selectedFlag); 613 var currentLanguage = $this.data("language"); 614 i18next.changeLanguage(currentLanguage, function (err, t) { 615 $(".main-menu-content").localize(); 616 }); 617 }); 618
619 /********************* Bookmark & Search ***********************/ 620 // This variable is used for mouseenter and mouseleave events of search list 621 var $filename = $(".search-input input").data("search"); 622 623 // Bookmark icon click 624 $(".bookmark-wrapper .bookmark-star").on("click", function (e) { 625 e.stopPropagation(); 626 $(".bookmark-wrapper .bookmark-input").toggleClass("show"); 627 $(".bookmark-wrapper .bookmark-input input").val(""); 628 $(".bookmark-wrapper .bookmark-input input").blur(); 629 $(".bookmark-wrapper .bookmark-input input").focus(); 630 $(".bookmark-wrapper .search-list").addClass("show"); 631 632 var arrList = $("ul.nav.navbar-nav.bookmark-icons li"), 633 $arrList = "", 634 $activeItemClass = ""; 635 636 $("ul.search-list li").remove(); 637 638 for (var i = 0; i < arrList.length; i++) { 639 if (i === 0) { 640 $activeItemClass = "current_item"; 641 } else { 642 $activeItemClass = ""; 643 } 644 $arrList += 645 '<li class="auto-suggestion d-flex align-items-center justify-content-between cursor-pointer ' + 646 $activeItemClass + 647 '">' + 648 '<a class="d-flex align-items-center justify-content-between w-100" href=' + 649 arrList[i].firstChild.href + 650 ">" + 651 '<div class="d-flex justify-content-start align-items-center">' + 652 '<span class="mr-75 ' + 653 arrList[i].firstChild.firstChild.className + 654 '" data-icon="' + 655 arrList[i].firstChild.firstChild.className + 656 '"></span>' + 657 "<span>" + 658 arrList[i].firstChild.dataset.originalTitle + 659 "</span>" + 660 "</div>" + 661 '<span class="float-right bookmark-icon bx bx-star warning"></span>' + 662 "</a>" + 663 "</li>"; 664 } 665 $("ul.search-list").append($arrList); 666 }); 667 668 // Navigation Search area Open 669 $(".nav-link-search").on("click", function () { 670 var $this = $(this); 671 var searchInput = $(this) 672 .parent(".nav-search") 673 .find(".search-input"); 674 searchInput.addClass("open"); 675 $(".search-input input").focus(); 676 $(".search-input .search-list li").remove(); 677 $(".search-input .search-list").addClass("show"); 678 $(".bookmark-wrapper .bookmark-input").removeClass("show"); 679 }); 680 681 // Navigation Search area Close 682 $(".search-input-close i").on("click", function () { 683 var $this = $(this), 684 searchInput = $(this).closest(".search-input"); 685 if (searchInput.hasClass("open")) { 686 searchInput.removeClass("open"); 687 $(".search-input input").val(""); 688 $(".search-input input").blur(); 689 $(".search-input .search-list").removeClass("show"); 690 if ($(".app-content").hasClass("show-overlay")) { 691 $(".app-content").removeClass("show-overlay"); 692 } 693 } 694 }); 695 696 // Navigation Search area Close on click of app-content 697 $(".app-content").on("click", function () { 698 var $this = $(".search-input-close"), 699 searchInput = $($this).parent(".search-input"); 700 if (searchInput.hasClass("open")) { 701 searchInput.removeClass("open"); 702 } 703 }); 704 705 // Filter 706 $(".search-input .input").on("keyup", function (e) { 707 if (e.keyCode !== 38 && e.keyCode !== 40 && e.keyCode !== 13) { 708 if (e.keyCode == 27) { 709 $(".app-content").removeClass("show-overlay"); 710 $(".bookmark-input input").val(""); 711 $(".bookmark-input input").blur(); 712 $(".search-input input").val(""); 713 $(".search-input input").blur(); 714 $(".search-input").removeClass("open"); 715 if ($(".search-list").hasClass("show")) { 716 $(this).removeClass("show"); 717 $(".search-input").removeClass("show"); 718 } 719 } 720 721 // Define variables 722 var value = $(this).val().toLowerCase(), //get values of inout on keyup 723 activeClass = "", 724 bookmark = false, 725 liList = $("ul.search-list li"); // get all the list items of the search 726 liList.remove(); 727 // To check if current is bookmark input 728 if ( 729 $(this) 730 .parent() 731 .hasClass("bookmark-input") 732 ) { 733 bookmark = true; 734 } 735 736 // If input value is blank 737 if (value != "") { 738 $(".app-content").addClass("show-overlay"); 739 740 // condition for bookmark and search input click 741 if ($(".bookmark-input").focus()) { 742 $(".bookmark-input .search-list").addClass("show"); 743 } else { 744 $(".search-input .search-list").addClass("show"); 745 $(".bookmark-input .search-list").removeClass("show"); 746 } 747 if (bookmark === false) { 748 $(".search-input .search-list").addClass("show"); 749 $(".bookmark-input .search-list").removeClass("show"); 750 } 751 752 var $startList = "", 753 $otherList = "", 754 $htmlList = "",
755 $activeItemClass = "", 756 $bookmarkIcon = "", 757 a = 0; 758 759 // getting json data from file for search results 760 $.getJSON("../../assets/data/" + $filename + ".json", function ( 761 data 762 ) { 763 for (var i = 0; i < data.listItems.length; i++) { 764 // if current is bookmark then give class to star icon 765 if (bookmark === true) { 766 activeClass = ""; // resetting active bookmark class 767 var arrList = $("ul.nav.navbar-nav.bookmark-icons li"), 768 $arrList = ""; 769 // Loop to check if current seach value match with the bookmarks already there in navbar 770 for (var j = 0; j < arrList.length; j++) { 771 if ( 772 data.listItems[i].name === 773 arrList[j].firstChild.dataset.originalTitle 774 ) { 775 activeClass = " warning"; 776 break; 777 } else { 778 activeClass = ""; 779 } 780 } 781 $bookmarkIcon = 782 '<span class="float-right bookmark-icon bx bx-star' + 783 activeClass + 784 '"></span>'; 785 } 786 // Search list item start with entered letters and create list 787 if ( 788 data.listItems[i].name.toLowerCase().indexOf(value) == 0 && 789 a < 10 || !(data.listItems[i].name.toLowerCase().indexOf(value) == 0) && 790 data.listItems[i].name.toLowerCase().indexOf(value) > -1 && 791 a < 10 792 ) { 793 if (a === 0) { 794 $activeItemClass = "current_item"; 795 } else { 796 $activeItemClass = ""; 797 } 798 $startList += 799 '<li class="auto-suggestion d-flex align-items-center justify-content-between cursor-pointer ' + 800 $activeItemClass + 801 '">' + 802 '<a class="d-flex align-items-center justify-content-between w-100" href=' + 803 data.listItems[i].url + 804 ">" + 805 '<div class="d-flex justify-content-start align-items-center">' + 806 '<span class="mr-75 ' + 807 data.listItems[i].icon + 808 '" data-icon="' + 809 data.listItems[i].icon + 810 '"></span>' + 811 "<span>" + 812 data.listItems[i].name + 813 "</span>" + 814 "</div>" + 815 $bookmarkIcon + 816 "</a>" + 817 "</li>"; 818 a++; 819 } 820 } 821 for (var i = 0; i < data.listItems.length; i++) { 822 if (bookmark === true) { 823 activeClass = ""; // resetting active bookmark class 824 var arrList = $("ul.nav.navbar-nav.bookmark-icons li"), 825 $arrList = ""; 826 // Loop to check if current seach value match with the bookmarks already there in navbar 827 for (var j = 0; j < arrList.length; j++) { 828 if ( 829 data.listItems[i].name === 830 arrList[j].firstChild.dataset.originalTitle 831 ) { 832 activeClass = " warning"; 833 } else { 834 activeClass = ""; 835 } 836 } 837 $bookmarkIcon = 838 '<span class="float-right bookmark-icon bx bx-star' + 839 activeClass + 840 '"></span>'; 841 } 842 // Search list item not start with letters and create list 843 if ( 844 !(data.listItems[i].name.toLowerCase().indexOf(value) == 0) && 845 data.listItems[i].name.toLowerCase().indexOf(value) > -1 && 846 a < 10 847 ) { 848 if (a === 0) { 849 $activeItemClass = "current_item"; 850 } else { 851 $activeItemClass = ""; 852 } 853 $otherList += 854 '<li class="auto-suggestion d-flex align-items-center justify-content-between cursor-pointer ' + 855 $activeItemClass + 856 '">' + 857 '<a class="d-flex align-items-center justify-content-between w-100" href=' + 858 data.listItems[i].url + 859 ">" + 860 '<div class="d-flex justify-content-start align-items-center">' + 861 '<span class="mr-75 ' + 862 data.listItems[i].icon + 863 '" data-icon="' + 864 data.listItems[i].icon + 865 '"></span>' + 866 "<span>" + 867 data.listItems[i].name + 868 "</span>" + 869 "</div>" + 870 $bookmarkIcon + 871 "</a>" + 872 "</li>"; 873 a++; 874 } 875 } 876 if ($startList == "" && $otherList == "") { 877 $otherList = 878 '<li class="auto-suggestion d-flex align-items-center justify-content-between cursor-pointer">' + 879 '<a class="d-flex align-items-center justify-content-between w-100">' + 880 '<div class="d-flex justify-content-start align-items-center">' + 881 '<span class="mr-75 bx bx-error-circle"></span>' + 882 "<span>No results found.</span>" + 883 "</div>" + 884 "</a>" + 885 "</li>"; 886 } 887 888 $htmlList = $startList.concat($otherList); // merging start with and other list 889 $("ul.search-list").html($htmlList); // Appending list to <ul> 890 }); 891 } else { 892 if (bookmark === true) { 893 var arrList = $("ul.nav.navbar-nav.bookmark-icons li"), 894 $arrList = ""; 895 for (var i = 0; i < arrList.length; i++) { 896 if (i === 0) {
897 $activeItemClass = "current_item"; 898 } else { 899 $activeItemClass = ""; 900 } 901 $arrList += 902 '<li class="auto-suggestion d-flex align-items-center justify-content-between cursor-pointer">' + 903 '<a class="d-flex align-items-center justify-content-between w-100" href=' + 904 arrList[i].firstChild.href + 905 ">" + 906 '<div class="d-flex justify-content-start align-items-center">' + 907 '<span class="mr-75 ' + 908 arrList[i].firstChild.firstChild.className + 909 '" data-icon="' + 910 arrList[i].firstChild.firstChild.className + 911 '"></span>' + 912 "<span>" + 913 arrList[i].firstChild.dataset.originalTitle + 914 "</span>" + 915 "</div>" + 916 '<span class="float-right bookmark-icon bx bx-star warning"></span>' + 917 "</a>" + 918 "</li>"; 919 } 920 $("ul.search-list").append($arrList); 921 } else { 922 // if search input blank, hide overlay 923 if ($(".app-content").hasClass("show-overlay")) { 924 $(".app-content").removeClass("show-overlay"); 925 } 926 // If filter box is empty 927 if ($(".search-list").hasClass("show")) { 928 $(".search-list").removeClass("show"); 929 } 930 } 931 } 932 } 933 }); 934 935 // Add class on hover of the list 936 $(document).on("mouseenter", ".search-list li", function (e) { 937 $(this) 938 .siblings() 939 .removeClass("current_item"); 940 $(this).addClass("current_item"); 941 }); 942 $(document).on("click", ".search-list li", function (e) { 943 e.stopPropagation(); 944 }); 945 946 $("html").on("click", function ($this) { 947 if (!$($this.target).hasClass("bookmark-icon")) { 948 if ($(".bookmark-input .search-list").hasClass("show")) { 949 $(".bookmark-input .search-list").removeClass("show"); 950 } 951 if ($(".bookmark-input").hasClass("show")) { 952 $(".bookmark-input").removeClass("show"); 953 } 954 } 955 }); 956 957 // Favorite star click
958 $(document).on( 959 "click", 960 ".bookmark-input .search-list .bookmark-icon", 961 function (e) { 962 e.stopPropagation(); 963 if ($(this).hasClass("warning")) { 964 $(this).removeClass("warning"); 965 var arrList = $("ul.nav.navbar-nav.bookmark-icons li"); 966 for (var i = 0; i < arrList.length; i++) { 967 if ( 968 arrList[i].firstChild.dataset.originalTitle == 969 $(this).parent()[0].innerText 970 ) { 971 arrList[i].remove(); 972 } 973 } 974 e.preventDefault(); 975 } else { 976 var arrList = $("ul.nav.navbar-nav.bookmark-icons li"); 977 $(this).addClass("warning"); 978 e.preventDefault(); 979 var $url = $(this).parent()[0].href, 980 $name = $(this).parent()[0].innerText, 981 $icon = $(this).parent()[0].firstChild.firstChild.dataset.icon, 982 $listItem = "", 983 $listItemDropdown = ""; 984 $listItem = 985 '<li class="nav-item d-none d-lg-block">' + 986 '<a class="nav-link" href="' + 987 $url + 988 '" data-toggle="tooltip" data-placement="top" title="' + 989 $name + 990 '">' + 991 '<i class="ficon ' + 992 $icon + 993 '"></i>' + 994 "</a>" + 995 "</li>"; 996 $("ul.nav.bookmark-icons").append($listItem); 997 $('[data-toggle="tooltip"]').tooltip(); 998 } 999 } 1000 ); 1001 1002 // If we use up key(38) Down key (40) or Enter key(13) 1003 $(window).on("keydown", function (e) { 1004 var $current = $(".search-list li.current_item"), 1005 $next, 1006 $prev; 1007 if (e.keyCode === 40) { 1008 $next = $current.next(); 1009 $current.removeClass("current_item"); 1010 $current = $next.addClass("current_item"); 1011 } else if (e.keyCode === 38) { 1012 $prev = $current.prev(); 1013 $current.removeClass("current_item"); 1014 $current = $prev.addClass("current_item"); 1015 } 1016 1017 if (e.keyCode === 13 && $(".search-list li.current_item").length > 0) { 1018 var selected_item = $(".search-list li.current_item a"); 1019 window.location = selected_item.attr("href"); 1020 $(selected_item).trigger("click"); 1021 } 1022 }); 1023 1024 // Navbar Sticky - add classes on reload of page 1025 var $scrollTop = $(window).scrollTop(); 1026 if ($scrollTop > 20) { 1027 $(".navbar-sticky .main-header-navbar").css({ 1028 "background-color": "#ffff", 1029 "box-shadow": "-8px 12px 18px 0 rgba(25, 42, 70, 0.13)" 1030 }); 1031 $(".navbar-static .main-header-navbar").css({ 1032 "background-color": "transparent", 1033 "box-shadow": "none" 1034 }); 1035 } 1036 1037 // Navbar Sticky - add classes on scroll down the page 1038 $(window).scroll(function () { 1039 if ($(this).scrollTop() > 20) { 1040 $(".navbar-sticky .main-header-navbar").css({ 1041 "background-color": "#ffff", 1042 "box-shadow": "-8px 12px 18px 0 rgba(25, 42, 70, 0.13)" 1043 }); 1044 $(".navbar-static .main-header-navbar").css({ 1045 "background-color": "transparent", 1046 "box-shadow": "none" 1047 }); 1048 } else { 1049 $(".navbar-sticky .main-header-navbar").css({ 1050 "background-color": "#f2f4f4", 1051 "box-shadow": "none" 1052 }); 1053 $(".navbar-static .main-header-navbar").css({ 1054 "background-color": "transparent", 1055 "box-shadow": "none" 1056 }); 1057 } 1058 }); 1059 1060 // Navbar Sticky - add classes on reload of page 1061 var $scrollTop = $(window).scrollTop(); 1062 if ($scrollTop > 20) { 1063 $(".dark-layout.navbar-sticky .main-header-navbar").css({ 1064 "background-color": "#272e48", 1065 "box-shadow": "rgba(26, 35, 59, .70) -8px 12px 18px 0px" 1066 }); 1067 } 1068 1069 // Navbar Sticky - add classes on scroll down the page 1070 $(window).scroll(function () { 1071 if ($(this).scrollTop() > 20) { 1072 $(".dark-layout.navbar-sticky .main-header-navbar").css({ 1073 "background-color": "#272e48", 1074 "box-shadow": "rgba(26, 35, 59, .70) -8px 12px 18px 0px" 1075 }); 1076 } else { 1077 $(".dark-layout.navbar-sticky .main-header-navbar").css({ 1078 "background-color": "transparent", 1079 "box-shadow": "none" 1080 }); 1081 } 1082 }); 1083 1084 // Header Notification Dropdown Remains Opened on click of switch Label 1085 $(".header-navbar .dropdown-notification label").on("click", function (e) { 1086 e.stopPropagation(); 1087 }); 1088 1089})(window, document, 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.