inspinia.js 8.0 KB

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