front.js 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. /*
  2. author: Boostraptheme
  3. author URL: https://boostraptheme.com
  4. License: Creative Commons Attribution 4.0 Unported
  5. License URL: https://creativecommons.org/licenses/by/4.0/
  6. */
  7. $(document).ready(function () {
  8. 'use strict';
  9. // ------------------------------------------------------- //
  10. // For demo purposes only
  11. // ------------------------------------------------------ //
  12. if ($.cookie("theme_csspath")) {
  13. $('link#theme-stylesheet').attr("href", $.cookie("theme_csspath"));
  14. }
  15. $("#colour").change(function () {
  16. if ($(this).val() !== '') {
  17. var theme_csspath = 'css/style.' + $(this).val() + '.css';
  18. $('link#theme-stylesheet').attr("href", theme_csspath);
  19. $.cookie("theme_csspath", theme_csspath, { expires: 365, path: document.URL.substr(0, document.URL.lastIndexOf('/')) });
  20. }
  21. return false;
  22. });
  23. // ------------------------------------------------------- //
  24. // Search Box
  25. // ------------------------------------------------------ //
  26. $('#search').on('click', function (e) {
  27. e.preventDefault();
  28. $('.search-box').fadeIn();
  29. });
  30. $('.dismiss').on('click', function () {
  31. $('.search-box').fadeOut();
  32. });
  33. // ------------------------------------------------------- //
  34. // Card Close
  35. // ------------------------------------------------------ //
  36. $('.card-close a.remove').on('click', function (e) {
  37. e.preventDefault();
  38. $(this).parents('.card').fadeOut();
  39. });
  40. // ------------------------------------------------------- //
  41. // Adding fade effect to dropdowns
  42. // ------------------------------------------------------ //
  43. $('.dropdown').on('show.bs.dropdown', function () {
  44. $(this).find('.dropdown-menu').first().stop(true, true).fadeIn();
  45. });
  46. $('.dropdown').on('hide.bs.dropdown', function () {
  47. $(this).find('.dropdown-menu').first().stop(true, true).fadeOut();
  48. });
  49. // ------------------------------------------------------- //
  50. // Login form validation
  51. // ------------------------------------------------------ //
  52. $('#login-form').validate({
  53. messages: {
  54. loginUsername: 'please enter your username',
  55. loginPassword: 'please enter your password'
  56. }
  57. });
  58. // ------------------------------------------------------- //
  59. // Right side navbar
  60. // ------------------------------------------------------ //
  61. $("#menu-close").click(function(e) {
  62. e.preventDefault();
  63. $("#sidebar-wrapper").toggleClass("active");
  64. });
  65. $("#menu-toggle-right").click(function(e) {
  66. e.preventDefault();
  67. $("#sidebar-wrapper").toggleClass("active");
  68. });
  69. // ------------------------------------------------------- //
  70. // Register form validation
  71. // ------------------------------------------------------ //
  72. $('#register-form').validate({
  73. messages: {
  74. registerUsername: 'please enter your first name',
  75. registerEmail: 'please enter a vaild Email Address',
  76. registerPassword: 'please enter your password'
  77. }
  78. });
  79. // ------------------------------------------------------- //
  80. // Sidebar Functionality
  81. // ------------------------------------------------------ //
  82. $('#toggle-btn').on('click', function (e) {
  83. e.preventDefault();
  84. $(this).toggleClass('active');
  85. $('.side-navbar').toggleClass('shrinked');
  86. $('.content-inner').toggleClass('active');
  87. if ($(window).outerWidth() > 1183) {
  88. if ($('#toggle-btn').hasClass('active')) {
  89. $('.navbar-header .brand-small').hide();
  90. $('.navbar-header .brand-big').show();
  91. } else {
  92. $('.navbar-header .brand-small').show();
  93. $('.navbar-header .brand-big').hide();
  94. }
  95. }
  96. if ($(window).outerWidth() < 1183) {
  97. $('.navbar-header .brand-small').show();
  98. }
  99. });
  100. // ------------------------------------------------------- //
  101. // Transition Placeholders
  102. // ------------------------------------------------------ //
  103. $('input.input-material').on('focus', function () {
  104. $(this).siblings('.label-material').addClass('active');
  105. });
  106. $('input.input-material').on('blur', function () {
  107. $(this).siblings('.label-material').removeClass('active');
  108. if ($(this).val() !== '') {
  109. $(this).siblings('.label-material').addClass('active');
  110. } else {
  111. $(this).siblings('.label-material').removeClass('active');
  112. }
  113. });
  114. // ------------------------------------------------------- //
  115. // External links to new window
  116. // ------------------------------------------------------ //
  117. $('.external').on('click', function (e) {
  118. e.preventDefault();
  119. window.open($(this).attr("href"));
  120. });
  121. });
  122. // ------------------------------------------------------- //
  123. // Extend window in fullscreen
  124. // ------------------------------------------------------ //
  125. function toggleFullScreen(elem) {
  126. if ((document.fullScreenElement !== undefined && document.fullScreenElement === null) || (document.msFullscreenElement !== undefined && document.msFullscreenElement === null) || (document.mozFullScreen !== undefined && !document.mozFullScreen) || (document.webkitIsFullScreen !== undefined && !document.webkitIsFullScreen)) {
  127. if (elem.requestFullScreen) {
  128. elem.requestFullScreen();
  129. } else if (elem.mozRequestFullScreen) {
  130. elem.mozRequestFullScreen();
  131. } else if (elem.webkitRequestFullScreen) {
  132. elem.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
  133. } else if (elem.msRequestFullscreen) {
  134. elem.msRequestFullscreen();
  135. }
  136. } else {
  137. if (document.cancelFullScreen) {
  138. document.cancelFullScreen();
  139. } else if (document.mozCancelFullScreen) {
  140. document.mozCancelFullScreen();
  141. } else if (document.webkitCancelFullScreen) {
  142. document.webkitCancelFullScreen();
  143. } else if (document.msExitFullscreen) {
  144. document.msExitFullscreen();
  145. }
  146. }
  147. }