common.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. $(document).ready(function(){
  2. "use strict";
  3. //***** Progress Bar *****//
  4. var loaded = 0;
  5. var imgCounter = $("body img").length;
  6. if(imgCounter > 0){
  7. $("body img").load(function() {
  8. loaded++;
  9. var newWidthPercentage = (loaded / imgCounter) * 100;
  10. console.log('ok');
  11. animateLoader(newWidthPercentage + '%');
  12. });
  13. }else{
  14. setTimeout(function(){
  15. $("#progressBar").css({
  16. "opacity":0,
  17. "width":"100%"
  18. });
  19. },500);
  20. }
  21. function animateLoader(newWidth) {
  22. $("#progressBar").width(newWidth);
  23. if(imgCounter === loaded){
  24. setTimeout(function(){
  25. $("#progressBar").animate({opacity:0});
  26. },500);
  27. }
  28. }
  29. //***** Side Menu *****//
  30. $(".side-menus li.menu-item-has-children > a").on("click",function(){
  31. $(this).parent().siblings().children("ul").slideUp();
  32. $(this).parent().siblings().removeClass("active");
  33. $(this).parent().children("ul").slideToggle();
  34. $(this).parent().toggleClass("active");
  35. return false;
  36. });
  37. //***** Side Menu Option *****//
  38. $('.menu-options').on("click", function(){
  39. $(".side-header.opened-menu").toggleClass('slide-menu');
  40. $(".main-content").toggleClass('wide-content');
  41. $("footer").toggleClass('wide-footer');
  42. $(".menu-options").toggleClass('active');
  43. });
  44. /*** FIXED Menu APPEARS ON SCROLL DOWN ***/
  45. $(window).scroll(function() {
  46. var scroll = $(window).scrollTop();
  47. if (scroll >= 10) {
  48. $(".side-header").addClass("sticky");
  49. }
  50. else{
  51. $(".side-header").removeClass("sticky");
  52. $(".side-header").addClass("");
  53. }
  54. });
  55. $(".side-menus nav > ul > li ul li > a").on("click", function(){
  56. $(".side-header").removeClass("slide-menu");
  57. $(".menu-options").removeClass("active");
  58. });
  59. //***** Quick Stats *****//
  60. $('.show-stats').on("click", function(){
  61. $(".toggle-content").addClass('active');
  62. });
  63. //***** Quick Stats *****//
  64. $('.toggle-content > span').on("click", function(){
  65. $(".toggle-content").removeClass('active');
  66. });
  67. //***** Quick Stats *****//
  68. $('.quick-links > ul > li > a').on("click", function(){
  69. $(this).parent().siblings().find('.dialouge').fadeOut();
  70. $(this).next('.dialouge').fadeIn();
  71. return false;
  72. });
  73. $("html").on("click", function(){
  74. $(".dialouge").fadeOut();
  75. });
  76. $(".quick-links > ul > li > a, .dialouge").on("click",function(e){
  77. e.stopPropagation();
  78. });
  79. //***** Toggle Full Screen *****//
  80. function goFullScreen() {
  81. var
  82. el = document.documentElement
  83. , rfs =
  84. el.requestFullScreen
  85. || el.webkitRequestFullScreen
  86. || el.mozRequestFullScreen
  87. || el.msRequestFullscreen
  88. ;
  89. rfs.call(el);
  90. }
  91. $("#toolFullScreen").on("click",function() {
  92. goFullScreen();
  93. });
  94. //***** Side Menu *****//
  95. $(function(){
  96. $('.side-menus').slimScroll({
  97. height: '400px',
  98. wheelStep: 10,
  99. size: '2px'
  100. });
  101. });
  102. $(".data-attributes span").peity("donut");
  103. // Activates Tooltips for Social Links
  104. $('[data-toggle="tooltip"]').tooltip();
  105. // Activates Popovers for Social Links
  106. $('[data-toggle="popover"]').popover();
  107. //*** Refresh Content ***//
  108. $('.refresh-content').on("click", function(){
  109. $(this).parent().parent().addClass("loading-wait").delay(3000).queue(function(next){
  110. $(this).removeClass("loading-wait");
  111. next();
  112. });
  113. $(this).addClass("fa-spin").delay(3000).queue(function(next){
  114. $(this).removeClass("fa-spin");
  115. next();
  116. });
  117. });
  118. //*** Expand Content ***//
  119. $('.expand-content').on("click", function(){
  120. $(this).parent().parent().toggleClass("expand-this");
  121. });
  122. //*** Delete Content ***//
  123. $('.close-content').on("click", function(){
  124. $(this).parent().parent().slideUp();
  125. });
  126. // Activates Tooltips for Social Links
  127. $('.tooltip-social').tooltip({
  128. selector: "a[data-toggle=tooltip]"
  129. });
  130. });