1/* 2 Project Name : Business 3 Author Company : SpecThemes 4 Project Date: 5 Feb, 2017 5 Template Developer: [email protected] 6*/ 7 8 9/* 10============================================== 11TABLE OF CONTENT 12============================================== 13 141. Owl Carousels 152. CountUp 163. Slider 174. Hover Drop Down 185. Youtube Video Section 196. Video Modal 207. Preloader 218. Scroll To Top 229. Isotop 2310. WOW 2411. Serach 2512. Input Number, Shopping Cart 2613. Tabs 2714. Pie Chart 2815. Charts.js 29 30============================================== 31[END] TABLE OF CONTENT 32============================================== 33*/ 34 35 36"use strict"; 37 38 39$('#preloader').fadeOut('normall', function () { 40 $(this).remove(); 41}); 42 43 44$(document).ready(function () { 45 46 47 /*------------------------------------ 48 1. Owl Carousel 49 --------------------------------------*/ 50 51 52 /*--------------------- 53 Testmonials carousel 54 -----------------------*/ 55 $('#testmonials-carousel').owlCarousel({ 56 loop: false, 57 smartSpeed: 850, 58 responsiveClass: true, 59 nav: true, 60 navText: ["<i class='fa fa-angle-left'></i>", "<i class='fa fa-angle-right'></i>"], 61 responsive: { 62 0: { 63 items: 1, 64 nav: false, 65 dots: true, 66 margin: 10, 67 }, 68 600: { 69 items: 1, 70 nav: false, 71 dots: true, 72 margin: 15, 73 }, 74 1000: { 75 items: 1, 76 dots: false, 77 margin: 40, 78 } 79 } 80 }) 81 82 83 /*--------------------- 84 Testmonials carousel 2 85 -----------------------*/ 86 $('#testmonials-carousel-2').owlCarousel({ 87 loop: false, 88 smartSpeed: 850, 89 responsiveClass: true, 90 nav: true, 91 navText: ["<i class='fa fa-angle-left'></i>", "<i class='fa fa-angle-right'></i>"], 92 responsive: { 93 0: { 94 items: 1, 95 nav: false, 96 dots: true, 97 margin: 30, 98 }, 99 600: { 100 items: 2, 101 nav: false, 102 dots: true, 103 margin: 0, 104 }, 105 1000: { 106 items: 3, 107 dots: false, 108 margin: 0, 109 } 110 } 111 }) 112 113 114 /*--------------------- 115 Testmonials carousel 3 116 -----------------------*/ 117 $('#testmonial-item').owlCarousel({ 118 loop: true, 119 nav: false, 120 responsiveClass: true, 121 startPosition: 0, 122 smartSpeed: 850, 123 center: true, 124 autoplay: true, 125 autoplayTimeout: 3000, 126 autoplayHoverPause: true, 127 responsive: { 128 0: { 129 items: 1, 130 margin: 15, 131 dots: false, 132 }, 133 600: { 134 items: 1, 135 margin: 20, 136 dots: false, 137 }, 138 1000: { 139 items: 3, 140 margin: 30, 141 dots: false, 142 } 143 } 144 }); 145 146 /*--------------------- 147 Testmonials box 4 148 -----------------------*/ 149 $('#testmonials-box-4').owlCarousel({ 150 loop: false, 151 smartSpeed: 850, 152 responsiveClass: true, 153 nav: true, 154 dots: false, 155 responsive: { 156 0: { 157 items: 1, 158 nav: false, 159 dots: true, 160 margin: 30, 161 }, 162 600: { 163 items: 1, 164 nav: false, 165 dots: true, 166 margin: 15, 167 }, 168 1000: { 169 items: 2, 170 nav: false, 171 dots: true, 172 margin: 45, 173 } 174 } 175 }) 176 177 178 /*--------------------- 179 Services carousel 180 -----------------------*/ 181 $('#services-carousel').owlCarousel({ 182 loop: false, 183 smartSpeed: 850, 184 responsiveClass: true, 185 dots: false, 186 nav: true, 187 navText: ["<i class='fa fa-angle-left'></i>", "<i class='fa fa-angle-right'></i>"], 188 responsive: { 189 0: { 190 items: 1, 191 margin: 15, 192 }, 193 600: { 194 items: 2, 195 margin: 30, 196 }, 197 1000: { 198 items: 3, 199 margin: 0, 200 } 201 } 202 }) 203 204 205 /*--------------------- 206 Services carousel 2 207 -----------------------*/ 208 $('#services-carousel-2').owlCarousel({ 209 loop: false, 210 responsiveClass: true, 211 dots: false, 212 nav: true, 213 smartSpeed: 850, 214 navText: ["<i class='fa fa-angle-left'></i>", "<i class='fa fa-angle-right'></i>"], 215 responsive: { 216 0: { 217 items: 1, 218 margin: 15, 219 }, 220 767: { 221 items: 2, 222 margin: 30, 223 }, 224 991: { 225 items: 3, 226 margin: 30, 227 }, 228 1200: { 229 items: 4, 230 margin: 0, 231 } 232 } 233 }) 234 235 236 /*--------------------- 237 Blog Grid carousel
238 -----------------------*/ 239 $('#blog-grid').owlCarousel({ 240 loop: false, 241 dots: true, 242 nav: false, 243 smartSpeed: 850, 244 autoplay: true, 245 autoplayTimeout: 2500, 246 responsiveClass: true, 247 autoplayHoverPause: false, 248 responsive: { 249 0: { 250 items: 1, 251 margin: 0, 252 }, 253 600: { 254 items: 2, 255 margin: 0, 256 }, 257 1000: { 258 items: 3, 259 margin: 0, 260 } 261 } 262 }) 263 264 265 /*--------------------- 266 Clients carousel 267 -----------------------*/ 268 269 $('#clients').owlCarousel({ 270 loop: true, 271 nav: false, 272 dots: false, 273 smartSpeed: 850, 274 autoplay: true, 275 autoplayTimeout: 3000, 276 responsiveClass: true, 277 autoplayHoverPause: false, 278 responsive: { 279 0: { 280 items: 2, 281 margin: 50, 282 }, 283 600: { 284 items: 3, 285 margin: 30, 286 }, 287 1000: { 288 items: 6, 289 margin: 40, 290 } 291 } 292 }) 293 294 295 /*--------------------- 296 Project Single carousel 297 -----------------------*/ 298 $('#project-single').owlCarousel({ 299 loop: false, 300 nav: false, 301 smartSpeed: 850, 302 responsiveClass: true, 303 dots: false, 304 responsive: { 305 0: { 306 items: 1, 307 margin: 15, 308 }, 309 600: { 310 items: 2, 311 margin: 15, 312 }, 313 1000: { 314 items: 3, 315 margin: 15 316 } 317 } 318 }) 319 320 321 /*------------------------------------ 322 2. CountUp 323 --------------------------------------*/ 324 325 $('.countup').counterUp({ 326 delay: 25, 327 time: 2000 328 }); 329 330 331 /*------------------------------------ 332 3. Slider 333 --------------------------------------*/ 334 335 /*--------------------- 336 Main Slider 337 -----------------------*/ 338 if ($(".swiper-main-slider").length !== 0) { 339 //Slider Animated Caption 340 var swiper = new Swiper('.swiper-container', { 341 navigation: { 342 nextEl: '.swiper-button-next', 343 prevEl: '.swiper-button-prev', 344 }, 345 pagination: { 346 el: '.swiper-pagination', 347 dynamicBullets: true, 348 }, 349 pagination: '.swiper-pagination', 350 paginationClickable: true, 351 nextButton: '.swiper-button-next', 352 prevButton: '.swiper-button-prev', 353 spaceBetween: 0, 354 loop: true, 355 simulateTouch: true, 356 autoplay: 5000, 357 speed: 1000, 358 onSlideChangeEnd: function (swiper) { 359 $('.swiper-slide').each(function () { 360 if ($(this).index() === swiper.activeIndex) { 361 // Fadein in active slide 362 $(this).find('.slider-content').fadeIn(300); 363 } else { 364 // Fadeout in inactive slides 365 $(this).find('.slider-content').fadeOut(300); 366 } 367 }); 368 } 369 }); 370 } 371 372 /*--------------------- 373 Main Slider Fade Effect 374 -----------------------*/ 375 if ($(".swiper-main-slider-fade").length !== 0) { 376 //Slider Animated Caption 377 var swiper = new Swiper('.swiper-container', { 378 effect: 'fade', 379 navigation: { 380 nextEl: '.swiper-button-next', 381 prevEl: '.swiper-button-prev', 382 }, 383 pagination: { 384 el: '.swiper-pagination', 385 dynamicBullets: true, 386 }, 387 pagination: '.swiper-pagination', 388 paginationClickable: true, 389 nextButton: '.swiper-button-next', 390 prevButton: '.swiper-button-prev', 391 spaceBetween: 0, 392 loop: true, 393 simulateTouch: true, 394 autoplay: 5000, 395 speed: 1000, 396 onSlideChangeEnd: function (swiper) { 397 $('.swiper-slide').each(function () { 398 if ($(this).index() === swiper.activeIndex) { 399 // Fadein in active slide 400 $(this).find('.slider-content').fadeIn(300); 401 } else { 402 // Fadeout in inactive slides 403 $(this).find('.slider-content').fadeOut(300); 404 } 405 }); 406 } 407 }); 408 } 409 410 /*--------------------- 411 Parallax Slider 412 -----------------------*/ 413 if ($("#swiper-parallax").length !== 0) { 414 var swiper = new Swiper('.swiper-container', { 415 parallax: true, 416 navigation: { 417 nextEl: '.swiper-button-next', 418 prevEl: '.swiper-button-prev', 419 }, 420 pagination: { 421 el: '.swiper-pagination', 422 dynamicBullets: true, 423 }, 424 pagination: '.swiper-pagination', 425 paginationClickable: true, 426 nextButton: '.swiper-button-next', 427 prevButton: '.swiper-button-prev', 428 spaceBetween: 0, 429 loop: false, 430 simulateTouch: true, 431 autoplay: false, 432 speed: 1000, 433 }); 434 } 435 436 /*--------------------- 437 Revolution Slider 438 -----------------------*/ 439 if ($("#rev_slider_24_1").length !== 0) { 440 var tpj = jQuery; 441 var revapi24; 442 tpj(document).ready(function () { 443 if (tpj("#rev_slider_24_1").revolution == undefined) { 444 revslider_showDoubleJqueryError("#rev_slider_24_1"); 445 } else { 446 revapi24 = tpj("#rev_slider_24_1").show().revolution({ 447 sliderType: "standard", 448 jsFileLocation: "revolution/js/", 449 sliderLayout: "fullscreen", 450 dottedOverlay: "none", 451 delay: 9000, 452 navigation: { 453 keyboardNavigation: "off", 454 keyboard_direction: "horizontal", 455 mouseScrollNavigation: "off", 456 mouseScrollReverse: "default", 457 onHoverStop: "off", 458 bullets: { 459 enable: true, 460 hide_onmobile: false, 461 style: "bullet-bar", 462 hide_onleave: false, 463 direction: "horizontal", 464 h_align: "center", 465 v_align: "bottom", 466 h_offset: 0, 467 v_offset: 50, 468 space: 5, 469 tmp: '' 470 } 471 }, 472 responsiveLevels: [1240, 1024, 778, 480], 473 visibilityLevels: [1240, 1024, 778, 480], 474 gridwidth: [1240, 1024, 778, 480], 475 gridheight: [868, 768, 960, 720], 476 lazyType: "none", 477 shadow: 0, 478 spinner: "off", 479 stopLoop: "off", 480 stopAfterLoops: -1, 481 stopAtSlide: -1, 482 shuffle: "off", 483 autoHeight: "off", 484 fullScreenAutoWidth: "off", 485 fullScreenAlignForce: "off", 486 fullScreenOffsetContainer: "", 487 fullScreenOffset: "60px", 488 hideThumbsOnMobile: "off", 489 hideSliderAtLimit: 0, 490 hideCaptionAtLimit: 0, 491 hideAllCaptionAtLilmit: 0, 492 debugMode: false, 493 fallbacks: { 494 simplifyAll: "off", 495 nextSlideOnWindowFocus: "off", 496 disableFocusListener: false, 497 } 498 }); 499 } 500 501 if (revapi24) revapi24.revSliderSlicey(); 502 }); /*ready*/ 503 } 504 505 if (typeof $.fn.revolution !== 'undefined') { 506 $("#rev_slider").revolution({ 507 sliderType: "standard", 508 sliderLayout: "fullscreen", 509 dottedOverlay: "none", 510 delay: 7000, 511 navigation: { 512 keyboardNavigation: "off", 513 keyboard_direction: "horizontal", 514 onHoverStop: "off", 515 touch: { 516 touchenabled: "on", 517 swipe_threshold: 75, 518 swipe_min_touches: 1, 519 swipe_direction: "horizontal", 520 drag_block_vertical: false 521 } 522 }, 523 viewPort: { 524 enable: true, 525 outof: "pause", 526 visible_area: "80%" 527 }, 528 navigation: { 529 arrows: { 530 enable: true, 531 style: 'hesperiden', 532 tmp: '', 533 rtl: false, 534 hide_onleave: false, 535 hide_onmobile: true, 536 hide_under: 0, 537 hide_over: 9999, 538 hide_delay: 200, 539 hide_delay_mobile: 1200, 540 541 left: { 542 container: 'slider', 543 h_align: 'left', 544 v_align: 'center', 545 h_offset: 20, 546 v_offset: 0 547 }, 548 549 right: { 550 container: 'slider', 551 h_align: 'right', 552 v_align: 'center', 553 h_offset: 20, 554 v_offset: 0 555 } 556 } 557 }, 558 responsiveLevels: [2048, 1750, 1192], 559 gridwidth: [1180, 1180, 980], 560 gridheight: [550], 561 lazyType: "none", 562 shadow: 0, 563 spinner: "off", 564 stopLoop: "on", 565 stopAfterLoops: 0, 566 shuffle: "off", 567 autoHeight: "on", 568 fullScreenAlignForce: "off", 569 fullScreenOffsetContainer: "", 570 fullScreenOffset: "", 571 disableProgressBar: "on", 572 hideThumbsOnMobile: "off", 573 hideSliderAtLimit: 0, 574 hideCaptionAtLimit: 0, 575 hideAllCaptionAtLilmit: 0, 576 debugMode: false, 577 fallbacks: { 578 simplifyAll: "off", 579 nextSlideOnWindowFocus: "off", 580 disableFocusListener: false, 581 } 582 }); 583 } 584 /*------------------------------------ 585 4. Navbar 586 --------------------------------------*/ 587 588 /*--------------------- 589 Fixed Nav 590 -----------------------*/ 591 $("#navigation1").navigation(); 592 $("#navigation1").fixed(); 593 594 /*--------------------- 595 Transparent Nav Options 596 -----------------------*/ 597 if ($("#nav-transparent").length !== 0) { 598 if ($(window).width() > 991) { 599 $("#nav-transparent #main_logo").css("display", "none"); 600 } else { 601 $("#nav-transparent #light_logo").css("display", "none"); 602 } 603 $(window).scroll(function () { 604 var scroll = $(window).scrollTop(); 605 if ($(window).width() > 991) { 606 if (scroll > 30) { 607 $(".navigation-fixed-wrapper").addClass("nav-white-bg"); 608 $("#nav-transparent #main_logo").css("display", "inline-block"); 609 $("#nav-transparent #light_logo").css("display", "none"); 610 } else { 611 $(".navigation-fixed-wrapper").removeClass("nav-white-bg"); 612 $("#nav-transparent #light_logo").css("display", "inline-block"); 613 $("#nav-transparent #main_logo").css("display", "none"); 614 } 615 } 616 }) 617 } 618 619 /*--------------------- 620 Nav Slide Effect 621 -----------------------*/ 622 $("#navigation2").navigation({ 623 effect: "slide" 624 }); 625 626 /*--------------------- 627 Nav Zoom Effect 628 -----------------------*/ 629 $("#navigation3").navigation({ 630 animationOnShow: "zoom-in", 631 animationOnHide: "zoom-out" 632 }); 633 634 /*--------------------- 635 Overlay Nav 636 -----------------------*/ 637 $("#navigation4").navigation({ 638 offset: 20, 639 overlayColor: "rgba(0,0,0,0.6)", 640 effect: "slide" 641 }); 642 643 /*--------------------- 644 Affix Nav 645 -----------------------*/ 646 $("#navigation4").fixed({ 647 offset: 20 648 }); 649 650 /*--------------------- 651 Hidden Nav 652 -----------------------*/ 653 $("#navigation5").navigation({ 654 hidden: true 655 }); 656 657 if ($("#navigation-push").length !== 0) { 658 if ($(window).width() > 991) { 659 $("#navigation-push").find($(".nav-menus-wrapper").addClass("nav-menus-wrapper-open")); 660 $("#navigation-push").find($(".nav-menus-wrapper-close-button").hide()); 661 $("#navigation-push").find($(".small-size-header").hide()); 662 } else { 663 $("#navigation5 #main_logo").clone().appendTo(".small-size-header-logo"); 664 $("#main_logo").css("display", "none"); 665 $("#navigation-push").find($(".nav-menus-wrapper").removeClass("nav-menus-wrapper-open")); 666 } 667 } 668 669 /*--------------------- 670 Button Nav 671 -----------------------*/ 672 $(".btn-show").on('click', function () { 673 $("#navigation5").data("navigation").toggleOffcanvas(); 674 }); 675 676 $("#navigation6").navigation({ 677 offCanvasSide: "right" 678 }); 679 680 /*--------------------- 681 Simple Nav 682 -----------------------*/ 683 $("#navigation7").navigation(); 684 685 686 /*------------------------------------ 687 5. Youtube Video Section 688 --------------------------------------*/ 689 if ($(".video-section").length !== 0) { 690 $('.player').mb_YTPlayer(); 691 } 692 693 if ($(".main-video-section").length !== 0) { 694 $('#main-video-play').mb_YTPlayer(); 695 } 696 697 698 /*------------------------------------ 699 6. Video Modal 700 --------------------------------------*/ 701 702 $('.modal').on('hidden.bs.modal', function () { 703 var $this = $(this).find('iframe'), 704 tempSrc = $this.attr('src'); 705 $this.attr('src', ""); 706 $this.attr('src', tempSrc); 707 }); 708 709 710 /*------------------------------------ 711 7. Preloader 712 --------------------------------------*/ 713 714 715 /*------------------------------------ 716 8. Scroll To Top 717 --------------------------------------*/ 718 719 $(window).scroll(function () { 720 if ($(this).scrollTop() > 500) { 721 $(".scroll-to-top").fadeIn(400); 722 723 } else { 724 $(".scroll-to-top").fadeOut(400); 725 } 726 }); 727 728 $(".scroll-to-top").on('click', function (event) { 729 event.preventDefault(); 730 $("html, body").animate({scrollTop: 0}, 600); 731 }); 732 733 734 /*------------------------------------ 735 9. Isotop 736 --------------------------------------*/ 737 738// external js: isotope.pkgd.js 739// init Isotope 740 var $grid = $('.isotope-grid').isotope({ 741 itemSelector: '.isotope-item', 742 layoutMode: 'fitRows', 743 getSortData: { 744 name: '.name', 745 symbol: '.symbol', 746 number: '.number parseInt', 747 category: '[data-category]', 748 weight: function (itemElem) { 749 var weight = $(itemElem).find('.weight').text(); 750 return parseFloat(weight.replace(/[\(\)]/g, '')); 751 } 752 } 753 }); 754 755// filter functions
756 var filterFns = { 757 // show if name ends with -ium 758 ium: function () { 759 var name = $(this).find('.name').text(); 760 return name.match(/ium$/); 761 } 762 }; 763 764// bind filter button click 765 $('#filters').on('click', 'button', function () { 766 var filterValue = $(this).attr('data-filter'); 767 // use filterFn if matches value 768 filterValue = filterFns[filterValue] || filterValue; 769 $grid.isotope({filter: filterValue}); 770 }); 771 772 773// change is-checked class on buttons 774 $('.parent-isotope').each(function (i, buttonGroup) { 775 var $buttonGroup = $(buttonGroup); 776 $buttonGroup.on('click', 'button', function () { 777 $buttonGroup.find('.is-checked').removeClass('is-checked'); 778 $(this).addClass('is-checked'); 779 }); 780 }); 781 782 783 /*------------------------------------ 784 10. WOW 785 --------------------------------------*/ 786 new WOW().init(); 787 788 789}); 790 791 792/*------------------------------------ 793 11. Seacrh 794--------------------------------------*/ 795function openNav() { 796 document.getElementById("search_nav").style.width = "100%"; 797} 798 799function closeNav() { 800 document.getElementById("search_nav").style.width = "0%"; 801} 802 803 804/*------------------------------------ 805 12. Input Number, Shopping Cart 806--------------------------------------*/ 807 808/*--------------------- 809Input Number 810-----------------------*/ 811jQuery('<div class="quantity-nav"><div class="quantity-button quantity-up">+</div><div class="quantity-button quantity-down">-</div></div>').insertAfter('.quantity input'); 812jQuery('.quantity').each(function () { 813 var spinner = jQuery(this), 814 input = spinner.find('input[type="number"]'), 815 btnUp = spinner.find('.quantity-up'), 816 btnDown = spinner.find('.quantity-down'), 817 min = input.attr('min'), 818 max = input.attr('max'); 819 820 btnUp.on("click", function () { 821 var oldValue = parseFloat(input.val()); 822 if (oldValue >= max) { 823 var newVal = oldValue; 824 } else { 825 var newVal = oldValue + 1; 826 } 827 spinner.find("input").val(newVal); 828 spinner.find("input").trigger("change"); 829 }); 830 831 btnDown.on("click", function () { 832 var oldValue = parseFloat(input.val()); 833 if (oldValue <= min) { 834 var newVal = oldValue; 835 } else { 836 var newVal = oldValue - 1; 837 } 838 spinner.find("input").val(newVal); 839 spinner.find("input").trigger("change"); 840 }); 841 842}); 843 844 845/*--------------------- 846Shopping Cart 847-----------------------*/ 848$('.close-box').on("click", function () { 849 $(this).parentsUntil('.row').slideToggle(); 850 return false; 851}); 852 853 854/*------------------------------------ 855 13. Tabs 856--------------------------------------*/ 857 858$('.tabs_animate').tabslet({ 859 mouseevent: 'click', 860 attribute: 'href', 861 animation: true 862}); 863 864 865/*------------------------------------ 866 14. Pie Chart 867--------------------------------------*/ 868 869 870/*------------------------------------ 871 9. Pie Chart 872--------------------------------------*/ 873if ($('.chart').length > 0) { 874 var $pieChart = $('.chart'); 875 $pieChart.each(function () { 876 var $elem = $(this), 877 pieChartSize = $elem.attr('data-size') || "120", 878 pieChartAnimate = $elem.attr('data-animate') || "2100", 879 pieChartWidth = $elem.attr('data-width') || "6", 880 pieChartColor = $elem.attr('data-color') || "#2e52c2", 881 pieChartTrackColor = $elem.attr('data-trackcolor') || "rgba(0,0,0,0.1)"; 882 $elem.find('span, i').css({ 883 'width': pieChartSize + 'px', 884 'height': pieChartSize + 'px', 885 'line-height': pieChartSize + 'px' 886 }); 887 $elem.appear(function () { 888 $elem.easyPieChart({ 889 size: Number(pieChartSize), 890 animate: Number(pieChartAnimate), 891 trackColor: pieChartTrackColor, 892 lineWidth: Number(pieChartWidth), 893 barColor: pieChartColor, 894 scaleColor: false, 895 lineCap: 'round', 896 onStep: function (from, to, percent) { 897 $elem.find('span.percent').text(Math.round(percent)); 898 } 899 }); 900 }); 901 }); 902} 903; 904 905 906if ($(".chartjs-render-monitor").length !== 0) { 907 var randomScalingFactor = function () { 908 return Math.round(Math.random() * 100); 909 }; 910 911 var config = { 912 type: 'pie', 913 data: { 914 datasets: [{ 915 data: [ 916 randomScalingFactor(), 917 randomScalingFactor(), 918 randomScalingFactor(), 919 randomScalingFactor(), 920 ], 921 backgroundColor: [ 922 window.chartColors.red, 923 window.chartColors.orange, 924 window.chartColors.green, 925 window.chartColors.blue, 926 ], 927 label: 'Dataset 1' 928 }], 929 labels: [ 930 "Red", 931 "Orange", 932 "Green", 933 "Blue" 934 ] 935 }, 936 options: { 937 responsive: true 938 } 939 }; 940 941 window.onload = function () { 942 var ctx = document.getElementById("chart-area").getContext("2d"); 943 window.myPie = new Chart(ctx, config); 944 }; 945 946 document.getElementById('randomizeData').addEventListener('click', function () {
947 config.data.datasets.forEach(function (dataset) { 948 dataset.data = dataset.data.map(function () { 949 return randomScalingFactor(); 950 }); 951 }); 952 953 window.myPie.update(); 954 }); 955 956 var colorNames = Object.keys(window.chartColors); 957 document.getElementById('addDataset').addEventListener('click', function () { 958 var newDataset = { 959 backgroundColor: [], 960 data: [], 961 label: 'New dataset ' + config.data.datasets.length, 962 }; 963 964 for (var index = 0; index < config.data.labels.length; ++index) { 965 newDataset.data.push(randomScalingFactor()); 966 967 var colorName = colorNames[index % colorNames.length]; 968 ; 969 var newColor = window.chartColors[colorName]; 970 newDataset.backgroundColor.push(newColor); 971 } 972 973 config.data.datasets.push(newDataset); 974 window.myPie.update(); 975 }); 976 977 document.getElementById('removeDataset').addEventListener('click', function () { 978 config.data.datasets.splice(0, 1); 979 window.myPie.update(); 980 }); 981} 982 983 984/*------------------------------------ 985 15. Charts.js 986--------------------------------------*/ 987if ($(".chartjs").length !== 0) { 988 /*---------------- 989 Chart style 1 990 ------------------*/ 991 var presets = window.chartColors; 992 var utils = Samples.utils; 993 var inputs = { 994 min: -100, 995 max: 100, 996 count: 8, 997 decimals: 2, 998 continuity: 1 999 }; 1000 1001 function generateData(config) { 1002 return utils.numbers(Chart.helpers.merge(inputs, config || {})); 1003 } 1004 1005 function generateLabels(config) { 1006 return utils.months(Chart.helpers.merge({ 1007 count: inputs.count, 1008 section: 3 1009 }, config || {})); 1010 } 1011 1012 var options = { 1013 maintainAspectRatio: false, 1014 spanGaps: false, 1015 elements: { 1016 line: { 1017 tension: 0.000001 1018 } 1019 }, 1020 plugins: { 1021 filler: { 1022 propagate: false 1023 } 1024 }, 1025 scales: { 1026 xAxes: [{ 1027 ticks: { 1028 autoSkip: false, 1029 maxRotation: 0 1030 } 1031 }] 1032 } 1033 }; 1034 1035 [false, 'origin', 'start', 'end'].forEach(function (boundary, index) { 1036 1037 // reset the random seed to generate the same data for all charts 1038 utils.srand(8); 1039 1040 new Chart('chart-' + index, { 1041 type: 'line', 1042 data: { 1043 labels: generateLabels(), 1044 datasets: [{ 1045 backgroundColor: utils.transparentize(presets.red), 1046 borderColor: presets.red, 1047 data: generateData(), 1048 label: 'Dataset', 1049 fill: boundary 1050 }] 1051 }, 1052 options: Chart.helpers.merge(options, { 1053 title: { 1054 text: 'fill: ' + boundary, 1055 display: false 1056 } 1057 }) 1058 }); 1059 }); 1060 1061 // eslint-disable-next-line no-unused-vars 1062 function toggleSmooth(btn) { 1063 var value = btn.classList.toggle('btn-on'); 1064 Chart.helpers.each(Chart.instances, function (chart) { 1065 chart.options.elements.line.tension = value ? 0.4 : 0.000001; 1066 chart.update(); 1067 }); 1068 } 1069 1070 // eslint-disable-next-line no-unused-vars 1071 function randomize() { 1072 var seed = utils.rand(); 1073 Chart.helpers.each(Chart.instances, function (chart) { 1074 utils.srand(seed); 1075 1076 chart.data.datasets.forEach(function (dataset) { 1077 dataset.data = generateData(); 1078 }); 1079 1080 chart.update(); 1081 }); 1082 } 1083 1084 1085 /*---------------- 1086 Chart style 2 1087 ------------------*/ 1088 var config = { 1089 type: 'line', 1090 data: { 1091 labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'], 1092 datasets: [{ 1093 label: 'My First dataset', 1094 borderColor: window.chartColors.red, 1095 backgroundColor: window.chartColors.red, 1096 data: [ 1097 randomScalingFactor(), 1098 randomScalingFactor(), 1099 randomScalingFactor(), 1100 randomScalingFactor(), 1101 randomScalingFactor(), 1102 randomScalingFactor(), 1103 randomScalingFactor() 1104 ], 1105 fill: false, 1106 }, { 1107 label: 'My Second dataset', 1108 borderColor: window.chartColors.black, 1109 backgroundColor: window.chartColors.black, 1110 data: [ 1111 randomScalingFactor(), 1112 randomScalingFactor(), 1113 randomScalingFactor(), 1114 randomScalingFactor(), 1115 randomScalingFactor(), 1116 randomScalingFactor(), 1117 randomScalingFactor() 1118 ], 1119 fill: false, 1120 }] 1121 }, 1122 options: { 1123 responsive: true, 1124 title: { 1125 display: false, 1126 text: 'Chart.js Line Chart - Custom Information in Tooltip' 1127 }, 1128 tooltips: { 1129 mode: 'index', 1130 callbacks: { 1131 // Use the footer callback to display the sum of the items showing in the tooltip 1132 footer: function (tooltipItems, data) { 1133 var sum = 0; 1134
1135 tooltipItems.forEach(function (tooltipItem) { 1136 sum += data.datasets[tooltipItem.datasetIndex].data[tooltipItem.index]; 1137 }); 1138 return 'Sum: ' + sum; 1139 }, 1140 }, 1141 footerFontStyle: 'normal' 1142 }, 1143 hover: { 1144 mode: 'index', 1145 intersect: true 1146 }, 1147 scales: { 1148 xAxes: [{ 1149 display: true, 1150 scaleLabel: { 1151 show: true, 1152 labelString: 'Month' 1153 } 1154 }], 1155 yAxes: [{ 1156 display: true, 1157 scaleLabel: { 1158 show: true, 1159 labelString: 'Value' 1160 } 1161 }] 1162 } 1163 } 1164 }; 1165 1166 window.onload = function () { 1167 var ctx = document.getElementById('canvas').getContext('2d'); 1168 window.myLine = new Chart(ctx, config); 1169 }; 1170}
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.