/js/common-scripts.js

https://gitlab.com/umakantverma/LicExamApp · JavaScript · 119 lines · 84 code · 26 blank · 9 comment · 8 complexity · 636a4955607b9e9d84e495ecb2a4db33 MD5 · raw file

  1. /*---LEFT BAR ACCORDION----*/
  2. $(function() {
  3. $('#nav-accordion').dcAccordion({
  4. eventType: 'click',
  5. autoClose: true,
  6. saveState: true,
  7. disableLink: true,
  8. speed: 'slow',
  9. showCount: false,
  10. autoExpand: true,
  11. // cookie: 'dcjq-accordion-1',
  12. classExpand: 'dcjq-current-parent'
  13. });
  14. });
  15. var Script = function () {
  16. // sidebar dropdown menu auto scrolling
  17. jQuery('#sidebar .sub-menu > a').click(function () {
  18. var o = ($(this).offset());
  19. diff = 250 - o.top;
  20. if(diff>0)
  21. $("#sidebar").scrollTo("-="+Math.abs(diff),500);
  22. else
  23. $("#sidebar").scrollTo("+="+Math.abs(diff),500);
  24. });
  25. // sidebar toggle
  26. $(function() {
  27. function responsiveView() {
  28. var wSize = $(window).width();
  29. if (wSize <= 768) {
  30. $('#container').addClass('sidebar-close');
  31. $('#sidebar > ul').hide();
  32. }
  33. if (wSize > 768) {
  34. $('#container').removeClass('sidebar-close');
  35. $('#sidebar > ul').show();
  36. }
  37. }
  38. $(window).on('load', responsiveView);
  39. $(window).on('resize', responsiveView);
  40. });
  41. $('.fa-bars').click(function () {
  42. if ($('#sidebar > ul').is(":visible") === true) {
  43. $('#main-content').css({
  44. 'margin-left': '0px'
  45. });
  46. $('#sidebar').css({
  47. 'margin-left': '-210px'
  48. });
  49. $('#sidebar > ul').hide();
  50. $("#container").addClass("sidebar-closed");
  51. } else {
  52. $('#main-content').css({
  53. 'margin-left': '210px'
  54. });
  55. $('#sidebar > ul').show();
  56. $('#sidebar').css({
  57. 'margin-left': '0'
  58. });
  59. $("#container").removeClass("sidebar-closed");
  60. }
  61. });
  62. // custom scrollbar
  63. $("#sidebar").niceScroll({styler:"fb",cursorcolor:"#4ECDC4", cursorwidth: '3', cursorborderradius: '10px', background: '#404040', spacebarenabled:false, cursorborder: ''});
  64. $("html").niceScroll({styler:"fb",cursorcolor:"#4ECDC4", cursorwidth: '6', cursorborderradius: '10px', background: '#404040', spacebarenabled:false, cursorborder: '', zindex: '1000'});
  65. // widget tools
  66. jQuery('.panel .tools .fa-chevron-down').click(function () {
  67. var el = jQuery(this).parents(".panel").children(".panel-body");
  68. if (jQuery(this).hasClass("fa-chevron-down")) {
  69. jQuery(this).removeClass("fa-chevron-down").addClass("fa-chevron-up");
  70. el.slideUp(200);
  71. } else {
  72. jQuery(this).removeClass("fa-chevron-up").addClass("fa-chevron-down");
  73. el.slideDown(200);
  74. }
  75. });
  76. jQuery('.panel .tools .fa-times').click(function () {
  77. jQuery(this).parents(".panel").parent().remove();
  78. });
  79. // tool tips
  80. $('.tooltips').tooltip();
  81. // popovers
  82. $('.popovers').popover();
  83. // custom bar chart
  84. if ($(".custom-bar-chart")) {
  85. $(".bar").each(function () {
  86. var i = $(this).find(".value").html();
  87. $(this).find(".value").html("");
  88. $(this).find(".value").animate({
  89. height: i
  90. }, 2000)
  91. })
  92. }
  93. }();