adminlte-extend.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. (function () {
  2. var controller = $("#sidebar-menu").attr("route_controller");
  3. var action = $("#sidebar-menu").attr("route_action");
  4. var menus = $("#sidebar-menu").find("li[flag='menu']");
  5. $.each(menus,
  6. function (i, sub) {
  7. var controllerText = $(sub).find("span").eq(0).html();
  8. if (controllerText === controller) {
  9. $(sub).addClass("active");
  10. $(sub).addClass("menu-open");
  11. var actionTexts = $(sub).find(".treeview-menu").find("li");
  12. $.each(actionTexts, function (i, obj) {
  13. var txt = $(obj).text().trim();
  14. if (txt === action) {
  15. $(obj).addClass("active");
  16. }
  17. });
  18. }
  19. });
  20. })();
  21. $(function () {
  22. 'use strict';
  23. $('[data-toggle="control-sidebar"]').controlSidebar();
  24. $('[data-toggle="push-menu"]').pushMenu();
  25. var $pushMenu = $('[data-toggle="push-menu"]').data('lte.pushmenu');
  26. var $controlSidebar = $('[data-toggle="control-sidebar"]').data('lte.controlsidebar');
  27. var $layout = $('body').data('lte.layout');
  28. $(window).on('load',
  29. function () {
  30. // Reinitialize variables on load
  31. $pushMenu = $('[data-toggle="push-menu"]').data('lte.pushmenu');
  32. $controlSidebar = $('[data-toggle="control-sidebar"]').data('lte.controlsidebar');
  33. $layout = $('body').data('lte.layout');
  34. });
  35. function changeLayout(cls) {
  36. if (cls === "full") {
  37. if (!window.ScreenFull) {
  38. window.ScreenFull = "full";
  39. launchFullscreen(document.documentElement);
  40. } else {
  41. window.ScreenFull = undefined;
  42. exitFullscreen();
  43. }
  44. return;
  45. }
  46. $('body').toggleClass(cls);
  47. $layout.fixSidebar();
  48. if ($('body').hasClass('fixed') && cls === 'fixed') {
  49. $pushMenu.expandOnHover();
  50. $layout.activate();
  51. }
  52. $controlSidebar.fix();
  53. }
  54. });