inspinia.js 8.4 KB

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