inspinia.js 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. /*
  2. *
  3. * INSPINIA - Responsive Admin Theme
  4. * version 2.9.3
  5. *
  6. */
  7. $(document).ready(function () {
  8. // Fast fix bor position issue with Propper.js
  9. // Will be fixed in Bootstrap 4.1 - https://github.com/twbs/bootstrap/pull/24092
  10. //Popper.Defaults.modifiers.computeStyle.gpuAcceleration = false;
  11. // Add body-small class if window less than 768px
  12. if (window.innerWidth < 769) {
  13. $('body').addClass('body-small')
  14. } else {
  15. $('body').removeClass('body-small')
  16. }
  17. // MetisMenu
  18. //var sideMenu = $('#side-menu').metisMenu();
  19. // Collapse ibox function
  20. $('.collapse-link').on('click', function (e) {
  21. e.preventDefault();
  22. var ibox = $(this).closest('div.ibox');
  23. var button = $(this).find('i');
  24. var content = ibox.children('.ibox-content');
  25. content.slideToggle(200);
  26. button.toggleClass('fa-chevron-up').toggleClass('fa-chevron-down');
  27. ibox.toggleClass('').toggleClass('border-bottom');
  28. setTimeout(function () {
  29. ibox.resize();
  30. ibox.find('[id^=map-]').resize();
  31. }, 50);
  32. });
  33. // Close ibox function
  34. $('.close-link').on('click', function (e) {
  35. e.preventDefault();
  36. var content = $(this).closest('div.ibox');
  37. content.remove();
  38. });
  39. // Fullscreen ibox function
  40. $('.fullscreen-link').on('click', function (e) {
  41. e.preventDefault();
  42. var ibox = $(this).closest('div.ibox');
  43. var button = $(this).find('i');
  44. $('body').toggleClass('fullscreen-ibox-mode');
  45. button.toggleClass('fa-expand').toggleClass('fa-compress');
  46. ibox.toggleClass('fullscreen');
  47. setTimeout(function () {
  48. $(window).trigger('resize');
  49. }, 100);
  50. });
  51. // Close menu in canvas mode
  52. $('.close-canvas-menu').on('click', function (e) {
  53. e.preventDefault();
  54. $("body").toggleClass("mini-navbar");
  55. SmoothlyMenu();
  56. });
  57. // Run menu of canvas
  58. //$('body.canvas-menu .sidebar-collapse').slimScroll({
  59. // height: '100%',
  60. // railOpacity: 0.9
  61. //});
  62. // Open close right sidebar
  63. $('.right-sidebar-toggle').on('click', function (e) {
  64. e.preventDefault();
  65. $('#right-sidebar').toggleClass('sidebar-open');
  66. });
  67. // Initialize slimscroll for right sidebar
  68. //$('.sidebar-container').slimScroll({
  69. // height: '100%',
  70. // railOpacity: 0.4,
  71. // wheelStep: 10
  72. //});
  73. // Open close small chat
  74. $('.open-small-chat').on('click', function (e) {
  75. e.preventDefault();
  76. $(this).children().toggleClass('fa-comments').toggleClass('fa-times');
  77. $('.small-chat-box').toggleClass('active');
  78. });
  79. // Initialize slimscroll for small chat
  80. //$('.small-chat-box .content').slimScroll({
  81. // height: '234px',
  82. // railOpacity: 0.4
  83. //});
  84. // Small todo handler
  85. $('.check-link').on('click', function () {
  86. var button = $(this).find('i');
  87. var label = $(this).next('span');
  88. button.toggleClass('fa-check-square').toggleClass('fa-square-o');
  89. label.toggleClass('todo-completed');
  90. return false;
  91. });
  92. // Append config box / Only for demo purpose
  93. // Uncomment on server mode to enable XHR calls
  94. //$.get("skin-config2.html", function (data) {
  95. // if (!$('body').hasClass('no-skin-config'))
  96. // $('body').append(data);
  97. //});
  98. // Minimalize menu
  99. $('.navbar-minimalize').on('click', function (event) {
  100. event.preventDefault();
  101. $("body").toggleClass("mini-navbar");
  102. SmoothlyMenu();
  103. });
  104. // Tooltips demo
  105. //$('.tooltip-demo').tooltip({
  106. // selector: "[data-toggle=tooltip]",
  107. // container: "body"
  108. //});
  109. // Move right sidebar top after scroll
  110. $(window).scroll(function () {
  111. if ($(window).scrollTop() > 0 && !$('body').hasClass('fixed-nav')) {
  112. $('#right-sidebar').addClass('sidebar-top');
  113. } else {
  114. $('#right-sidebar').removeClass('sidebar-top');
  115. }
  116. });
  117. //$("[data-toggle=popover]")
  118. // .popover();
  119. // Add slimscroll to element
  120. //$('.full-height-scroll').slimscroll({
  121. // height: '100%'
  122. //})
  123. });
  124. // Minimalize menu when screen is less than 768px
  125. $(window).bind("resize", function () {
  126. if (window.innerWidth < 769) {
  127. $('body').addClass('body-small')
  128. } else {
  129. $('body').removeClass('body-small')
  130. }
  131. });
  132. // Fixed Sidebar
  133. $(window).bind("load", function () {
  134. if ($("body").hasClass('fixed-sidebar')) {
  135. $('.sidebar-collapse').slimScroll({
  136. height: '100%',
  137. railOpacity: 0.9
  138. });
  139. }
  140. });
  141. // check if browser support HTML5 local storage
  142. function localStorageSupport() {
  143. return (('localStorage' in window) && window['localStorage'] !== null)
  144. }
  145. // Local Storage functions
  146. // Set proper body class and plugins based on user configuration
  147. $(document).ready(function () {
  148. if (localStorageSupport()) {
  149. var collapse = localStorage.getItem("collapse_menu");
  150. var fixedsidebar = localStorage.getItem("fixedsidebar");
  151. var fixednavbar = localStorage.getItem("fixednavbar");
  152. var boxedlayout = localStorage.getItem("boxedlayout");
  153. var fixedfooter = localStorage.getItem("fixedfooter");
  154. var body = $('body');
  155. if (fixedsidebar == 'on') {
  156. body.addClass('fixed-sidebar');
  157. $('.sidebar-collapse').slimScroll({
  158. height: '100%',
  159. railOpacity: 0.9
  160. });
  161. }
  162. if (collapse == 'on') {
  163. if (body.hasClass('fixed-sidebar')) {
  164. if (!body.hasClass('body-small')) {
  165. body.addClass('mini-navbar');
  166. }
  167. } else {
  168. if (!body.hasClass('body-small')) {
  169. body.addClass('mini-navbar');
  170. }
  171. }
  172. }
  173. if (fixednavbar == 'on') {
  174. $(".navbar-static-top").removeClass('navbar-static-top').addClass('navbar-fixed-top');
  175. body.addClass('fixed-nav');
  176. }
  177. if (boxedlayout == 'on') {
  178. body.addClass('boxed-layout');
  179. }
  180. if (fixedfooter == 'on') {
  181. $(".footer").addClass('fixed');
  182. }
  183. }
  184. });
  185. // For demo purpose - animation css script
  186. //function animationHover(element, animation) {
  187. // element = $(element);
  188. // element.hover(
  189. // function () {
  190. // element.addClass('animated ' + animation);
  191. // },
  192. // function () {
  193. // //wait for animation to finish before removing classes
  194. // window.setTimeout(function () {
  195. // element.removeClass('animated ' + animation);
  196. // }, 2000);
  197. // });
  198. //}
  199. function SmoothlyMenu() {
  200. if (!$('body').hasClass('mini-navbar') || $('body').hasClass('body-small')) {
  201. // Hide menu in order to smoothly turn on when maximize menu
  202. $('#side-menu').hide();
  203. // For smoothly turn on menu
  204. setTimeout(
  205. function () {
  206. $('#side-menu').fadeIn(400);
  207. }, 200);
  208. } else if ($('body').hasClass('fixed-sidebar')) {
  209. $('#side-menu').hide();
  210. setTimeout(
  211. function () {
  212. $('#side-menu').fadeIn(400);
  213. }, 100);
  214. } else {
  215. // Remove all inline style from jquery fadeIn function to reset menu state
  216. $('#side-menu').removeAttr('style');
  217. }
  218. }
  219. // Dragable panels
  220. function WinMove() {
  221. var element = "[class*=col]";
  222. var handle = ".ibox-title";
  223. var connect = "[class*=col]";
  224. $(element).sortable(
  225. {
  226. handle: handle,
  227. connectWith: connect,
  228. tolerance: 'pointer',
  229. forcePlaceholderSize: true,
  230. opacity: 0.8
  231. })
  232. .disableSelection();
  233. }