inspinia.js 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  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. // Append config box / Only for demo purpose
  84. // Uncomment on server mode to enable XHR calls
  85. // 右侧工具栏 颜色等 http://webapplayers.com/inspinia_admin-v2.7.1/skin-config.html
  86. /*$.get("skin-config.html", function (data) {
  87. if (!$('body').hasClass('no-skin-config'))
  88. $('body').append(data);
  89. });*/
  90. // Minimalize menu
  91. $('.navbar-minimalize').click(function () {
  92. $("body").toggleClass("mini-navbar");
  93. SmoothlyMenu();
  94. });
  95. // Tooltips demo
  96. $('.tooltip-demo').tooltip({
  97. selector: "[data-toggle=tooltip]",
  98. container: "body"
  99. });
  100. // Move modal to body
  101. // Fix Bootstrap backdrop issu with animation.css
  102. $('.modal').appendTo("body");
  103. // Full height of sidebar
  104. function fix_height() {
  105. var heightWithoutNavbar = $("body > #wrapper").height() - 61;
  106. $(".sidebard-panel").css("min-height", heightWithoutNavbar + "px");
  107. var navbarHeigh = $('nav.navbar-default').height();
  108. var wrapperHeigh = $('#page-wrapper').height();
  109. if (navbarHeigh > wrapperHeigh) {
  110. $('#page-wrapper').css("min-height", navbarHeigh + "px");
  111. }
  112. if (navbarHeigh < wrapperHeigh) {
  113. $('#page-wrapper').css("min-height", $(window).height() + "px");
  114. }
  115. if ($('body').hasClass('fixed-nav')) {
  116. if (navbarHeigh > wrapperHeigh) {
  117. $('#page-wrapper').css("min-height", navbarHeigh - 60 + "px");
  118. } else {
  119. $('#page-wrapper').css("min-height", $(window).height() - 60 + "px");
  120. }
  121. }
  122. }
  123. fix_height();
  124. // Fixed Sidebar
  125. $(window).bind("load", function () {
  126. if ($("body").hasClass('fixed-sidebar')) {
  127. $('.sidebar-collapse').slimScroll({
  128. height: '100%',
  129. railOpacity: 0.9
  130. });
  131. }
  132. });
  133. // Move right sidebar top after scroll
  134. $(window).scroll(function () {
  135. if ($(window).scrollTop() > 0 && !$('body').hasClass('fixed-nav')) {
  136. $('#right-sidebar').addClass('sidebar-top');
  137. } else {
  138. $('#right-sidebar').removeClass('sidebar-top');
  139. }
  140. });
  141. $(window).bind("load resize scroll", function () {
  142. if (!$("body").hasClass('body-small')) {
  143. fix_height();
  144. }
  145. });
  146. $("[data-toggle=popover]")
  147. .popover();
  148. // Add slimscroll to element
  149. $('.full-height-scroll').slimscroll({
  150. height: '100%'
  151. })
  152. });
  153. // Minimalize menu when screen is less than 768px
  154. $(window).bind("resize", function () {
  155. if ($(this).width() < 769) {
  156. $('body').addClass('body-small')
  157. } else {
  158. $('body').removeClass('body-small')
  159. }
  160. });
  161. // Local Storage functions
  162. // Set proper body class and plugins based on user configuration
  163. $(document).ready(function () {
  164. if (localStorageSupport) {
  165. var collapse = localStorage.getItem("collapse_menu");
  166. var fixedsidebar = localStorage.getItem("fixedsidebar");
  167. var fixednavbar = localStorage.getItem("fixednavbar");
  168. var boxedlayout = localStorage.getItem("boxedlayout");
  169. var fixedfooter = localStorage.getItem("fixedfooter");
  170. var body = $('body');
  171. //if (fixedsidebar == 'on') {
  172. body.addClass('fixed-sidebar');
  173. $('.sidebar-collapse').slimScroll({
  174. height: '100%',
  175. railOpacity: 0.9
  176. });
  177. //}
  178. if (collapse == 'on') {
  179. if (body.hasClass('fixed-sidebar')) {
  180. if (!body.hasClass('body-small')) {
  181. body.addClass('mini-navbar');
  182. }
  183. } else {
  184. if (!body.hasClass('body-small')) {
  185. body.addClass('mini-navbar');
  186. }
  187. }
  188. }
  189. if (fixednavbar == 'on') {
  190. $(".navbar-static-top").removeClass('navbar-static-top').addClass('navbar-fixed-top');
  191. body.addClass('fixed-nav');
  192. }
  193. if (boxedlayout == 'on') {
  194. body.addClass('boxed-layout');
  195. }
  196. if (fixedfooter == 'on') {
  197. $(".footer").addClass('fixed');
  198. }
  199. }
  200. });
  201. // check if browser support HTML5 local storage
  202. function localStorageSupport() {
  203. return (('localStorage' in window) && window['localStorage'] !== null)
  204. }
  205. // For demo purpose - animation css script
  206. function animationHover(element, animation) {
  207. element = $(element);
  208. element.hover(
  209. function () {
  210. element.addClass('animated ' + animation);
  211. },
  212. function () {
  213. //wait for animation to finish before removing classes
  214. window.setTimeout(function () {
  215. element.removeClass('animated ' + animation);
  216. }, 2000);
  217. });
  218. }
  219. function SmoothlyMenu() {
  220. if (!$('body').hasClass('mini-navbar') || $('body').hasClass('body-small')) {
  221. // Hide menu in order to smoothly turn on when maximize menu
  222. $('#side-menu').hide();
  223. // For smoothly turn on menu
  224. setTimeout(
  225. function () {
  226. $('#side-menu').fadeIn(400);
  227. }, 200);
  228. } else if ($('body').hasClass('fixed-sidebar')) {
  229. $('#side-menu').hide();
  230. setTimeout(
  231. function () {
  232. $('#side-menu').fadeIn(400);
  233. }, 100);
  234. } else {
  235. // Remove all inline style from jquery fadeIn function to reset menu state
  236. $('#side-menu').removeAttr('style');
  237. }
  238. }
  239. // Dragable panels
  240. function WinMove() {
  241. var element = "[class*=col]";
  242. var handle = ".ibox-title";
  243. var connect = "[class*=col]";
  244. $(element).sortable(
  245. {
  246. handle: handle,
  247. connectWith: connect,
  248. tolerance: 'pointer',
  249. forcePlaceholderSize: true,
  250. opacity: 0.8
  251. })
  252. .disableSelection();
  253. }