PageRenderTime 28ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 1ms

/public/dist/js/app.min.js

https://gitlab.com/filly/e-hrm
JavaScript | 230 lines | 216 code | 2 blank | 12 comment | 52 complexity | d6f11a3d9d0d773a4b72fe38bae1847e MD5 | raw file
  1. /*! AdminLTE app.js
  2. * ================
  3. * Main JS application file for AdminLTE v2. This file
  4. * should be included in all pages. It controls some layout
  5. * options and implements exclusive AdminLTE plugins.
  6. *
  7. * @Author Almsaeed Studio
  8. * @Support <http://www.almsaeedstudio.com>
  9. * @Email <support@almsaeedstudio.com>
  10. * @version 2.1.2
  11. * @license MIT <http://opensource.org/licenses/MIT>
  12. */
  13. "use strict";
  14. function _init() {
  15. $.AdminLTE.layout = {
  16. activate: function () {
  17. var a = this;
  18. a.fix(), a.fixSidebar(), $(window, ".wrapper").resize(function () {
  19. a.fix(), a.fixSidebar()
  20. })
  21. }, fix: function () {
  22. var a = $(".main-header").outerHeight() + $(".main-footer").outerHeight(), b = $(window).height(), c = $(".sidebar").height();
  23. if ($("body").hasClass("fixed"))$(".content-wrapper, .right-side").css("min-height", b - $(".main-footer").outerHeight()); else {
  24. var d;
  25. b >= c ? ($(".content-wrapper, .right-side").css("min-height", b - a), d = b - a) : ($(".content-wrapper, .right-side").css("min-height", c), d = c);
  26. var e = $($.AdminLTE.options.controlSidebarOptions.selector);
  27. "undefined" != typeof e && e.height() > d && $(".content-wrapper, .right-side").css("min-height", e.height())
  28. }
  29. }, fixSidebar: function () {
  30. return $("body").hasClass("fixed") ? ("undefined" == typeof $.fn.slimScroll && console && console.error("Error: the fixed layout requires the slimscroll plugin!"), void($.AdminLTE.options.sidebarSlimScroll && "undefined" != typeof $.fn.slimScroll && ($(".sidebar").slimScroll({destroy: !0}).height("auto"), $(".sidebar").slimscroll({
  31. height: $(window).height() - $(".main-header").height() + "px",
  32. color: "rgba(0,0,0,0.2)",
  33. size: "3px"
  34. })))) : void("undefined" != typeof $.fn.slimScroll && $(".sidebar").slimScroll({destroy: !0}).height("auto"))
  35. }
  36. }, $.AdminLTE.pushMenu = {
  37. activate: function (a) {
  38. var b = $.AdminLTE.options.screenSizes;
  39. $(a).on("click", function (a) {
  40. a.preventDefault(), $(window).width() > b.sm - 1 ? $("body").hasClass("sidebar-collapse") ? $("body").removeClass("sidebar-collapse").trigger("expanded.pushMenu") : $("body").addClass("sidebar-collapse").trigger("collapsed.pushMenu") : $("body").hasClass("sidebar-open") ? $("body").removeClass("sidebar-open").removeClass("sidebar-collapse").trigger("collapsed.pushMenu") : $("body").addClass("sidebar-open").trigger("expanded.pushMenu")
  41. }), $(".content-wrapper").click(function () {
  42. $(window).width() <= b.sm - 1 && $("body").hasClass("sidebar-open") && $("body").removeClass("sidebar-open")
  43. }), ($.AdminLTE.options.sidebarExpandOnHover || $("body").hasClass("fixed") && $("body").hasClass("sidebar-mini")) && this.expandOnHover()
  44. }, expandOnHover: function () {
  45. var a = this, b = $.AdminLTE.options.screenSizes.sm - 1;
  46. $(".main-sidebar").hover(function () {
  47. $("body").hasClass("sidebar-mini") && $("body").hasClass("sidebar-collapse") && $(window).width() > b && a.expand()
  48. }, function () {
  49. $("body").hasClass("sidebar-mini") && $("body").hasClass("sidebar-expanded-on-hover") && $(window).width() > b && a.collapse()
  50. })
  51. }, expand: function () {
  52. $("body").removeClass("sidebar-collapse").addClass("sidebar-expanded-on-hover")
  53. }, collapse: function () {
  54. $("body").hasClass("sidebar-expanded-on-hover") && $("body").removeClass("sidebar-expanded-on-hover").addClass("sidebar-collapse")
  55. }
  56. }, $.AdminLTE.tree = function (a) {
  57. var b = this, c = $.AdminLTE.options.animationSpeed;
  58. $("li a", $(a)).on("click", function (a) {
  59. var d = $(this), e = d.next();
  60. if (e.is(".treeview-menu") && e.is(":visible"))e.slideUp(c, function () {
  61. e.removeClass("menu-open")
  62. }), e.parent("li").removeClass("active"); else if (e.is(".treeview-menu") && !e.is(":visible")) {
  63. var f = d.parents("ul").first(), g = f.find("ul:visible").slideUp(c);
  64. g.removeClass("menu-open");
  65. var h = d.parent("li");
  66. e.slideDown(c, function () {
  67. e.addClass("menu-open"), f.find("li.active").removeClass("active"), h.addClass("active"), b.layout.fix()
  68. })
  69. }
  70. e.is(".treeview-menu") && a.preventDefault()
  71. })
  72. }, $.AdminLTE.controlSidebar = {
  73. activate: function () {
  74. var a = this, b = $.AdminLTE.options.controlSidebarOptions, c = $(b.selector), d = $(b.toggleBtnSelector);
  75. d.on("click", function (d) {
  76. d.preventDefault(), c.hasClass("control-sidebar-open") || $("body").hasClass("control-sidebar-open") ? a.close(c, b.slide) : a.open(c, b.slide)
  77. });
  78. var e = $(".control-sidebar-bg");
  79. a._fix(e), $("body").hasClass("fixed") ? a._fixForFixed(c) : $(".content-wrapper, .right-side").height() < c.height() && a._fixForContent(c)
  80. }, open: function (a, b) {
  81. b ? a.addClass("control-sidebar-open") : $("body").addClass("control-sidebar-open")
  82. }, close: function (a, b) {
  83. b ? a.removeClass("control-sidebar-open") : $("body").removeClass("control-sidebar-open")
  84. }, _fix: function (a) {
  85. var b = this;
  86. $("body").hasClass("layout-boxed") ? (a.css("position", "absolute"), a.height($(".wrapper").height()), $(window).resize(function () {
  87. b._fix(a)
  88. })) : a.css({position: "fixed", height: "auto"})
  89. }, _fixForFixed: function (a) {
  90. a.css({position: "fixed", "max-height": "100%", overflow: "auto", "padding-bottom": "50px"})
  91. }, _fixForContent: function (a) {
  92. $(".content-wrapper, .right-side").css("min-height", a.height())
  93. }
  94. }, $.AdminLTE.boxWidget = {
  95. selectors: $.AdminLTE.options.boxWidgetOptions.boxWidgetSelectors,
  96. icons: $.AdminLTE.options.boxWidgetOptions.boxWidgetIcons,
  97. animationSpeed: $.AdminLTE.options.animationSpeed,
  98. activate: function (a) {
  99. var b = this;
  100. a || (a = document), $(a).find(b.selectors.collapse).on("click", function (a) {
  101. a.preventDefault(), b.collapse($(this))
  102. }), $(a).find(b.selectors.remove).on("click", function (a) {
  103. a.preventDefault(), b.remove($(this))
  104. })
  105. },
  106. collapse: function (a) {
  107. var b = this, c = a.parents(".box").first(), d = c.find("> .box-body, > .box-footer, > form >.box-body, > form > .box-footer");
  108. c.hasClass("collapsed-box") ? (a.children(":first").removeClass(b.icons.open).addClass(b.icons.collapse), d.slideDown(b.animationSpeed, function () {
  109. c.removeClass("collapsed-box")
  110. })) : (a.children(":first").removeClass(b.icons.collapse).addClass(b.icons.open), d.slideUp(b.animationSpeed, function () {
  111. c.addClass("collapsed-box")
  112. }))
  113. },
  114. remove: function (a) {
  115. var b = a.parents(".box").first();
  116. b.slideUp(this.animationSpeed)
  117. }
  118. }
  119. }
  120. if ("undefined" == typeof jQuery)throw new Error("AdminLTE requires jQuery");
  121. $.AdminLTE = {}, $.AdminLTE.options = {
  122. navbarMenuSlimscroll: !0,
  123. navbarMenuSlimscrollWidth: "3px",
  124. navbarMenuHeight: "200px",
  125. animationSpeed: 500,
  126. sidebarToggleSelector: "[data-toggle='offcanvas']",
  127. sidebarPushMenu: !0,
  128. sidebarSlimScroll: !0,
  129. sidebarExpandOnHover: !1,
  130. enableBoxRefresh: !0,
  131. enableBSToppltip: !0,
  132. BSTooltipSelector: "[data-toggle='tooltip']",
  133. enableFastclick: !0,
  134. enableControlSidebar: !0,
  135. controlSidebarOptions: {
  136. toggleBtnSelector: "[data-toggle='control-sidebar']",
  137. selector: ".control-sidebar",
  138. slide: !0
  139. },
  140. enableBoxWidget: !0,
  141. boxWidgetOptions: {
  142. boxWidgetIcons: {collapse: "fa-minus", open: "fa-plus", remove: "fa-times"},
  143. boxWidgetSelectors: {remove: '[data-widget="remove"]', collapse: '[data-widget="collapse"]'}
  144. },
  145. directChat: {enable: !0, contactToggleSelector: '[data-widget="chat-pane-toggle"]'},
  146. colors: {
  147. lightBlue: "#3c8dbc",
  148. red: "#f56954",
  149. green: "#00a65a",
  150. aqua: "#00c0ef",
  151. yellow: "#f39c12",
  152. blue: "#0073b7",
  153. navy: "#001F3F",
  154. teal: "#39CCCC",
  155. olive: "#3D9970",
  156. lime: "#01FF70",
  157. orange: "#FF851B",
  158. fuchsia: "#F012BE",
  159. purple: "#8E24AA",
  160. maroon: "#D81B60",
  161. black: "#222222",
  162. gray: "#d2d6de"
  163. },
  164. screenSizes: {xs: 480, sm: 768, md: 992, lg: 1200}
  165. }, $(function () {
  166. "undefined" != typeof AdminLTEOptions && $.extend(!0, $.AdminLTE.options, AdminLTEOptions);
  167. var a = $.AdminLTE.options;
  168. _init(), $.AdminLTE.layout.activate(), $.AdminLTE.tree(".sidebar"), a.enableControlSidebar && $.AdminLTE.controlSidebar.activate(), a.navbarMenuSlimscroll && "undefined" != typeof $.fn.slimscroll && $(".navbar .menu").slimscroll({
  169. height: a.navbarMenuHeight,
  170. alwaysVisible: !1,
  171. size: a.navbarMenuSlimscrollWidth
  172. }).css("width", "100%"), a.sidebarPushMenu && $.AdminLTE.pushMenu.activate(a.sidebarToggleSelector), a.enableBSToppltip && $("body").tooltip({selector: a.BSTooltipSelector}), a.enableBoxWidget && $.AdminLTE.boxWidget.activate(), a.enableFastclick && "undefined" != typeof FastClick && FastClick.attach(document.body), a.directChat.enable && $(a.directChat.contactToggleSelector).on("click", function () {
  173. var a = $(this).parents(".direct-chat").first();
  174. a.toggleClass("direct-chat-contacts-open")
  175. }), $('.btn-group[data-toggle="btn-toggle"]').each(function () {
  176. var a = $(this);
  177. $(this).find(".btn").on("click", function (b) {
  178. a.find(".btn.active").removeClass("active"), $(this).addClass("active"), b.preventDefault()
  179. })
  180. })
  181. }), function (a) {
  182. a.fn.boxRefresh = function (b) {
  183. function c(a) {
  184. a.append(f), e.onLoadStart.call(a)
  185. }
  186. function d(a) {
  187. a.find(f).remove(), e.onLoadDone.call(a)
  188. }
  189. var e = a.extend({
  190. trigger: ".refresh-btn", source: "", onLoadStart: function (a) {
  191. }, onLoadDone: function (a) {
  192. }
  193. }, b), f = a('<div class="overlay"><div class="fa fa-refresh fa-spin"></div></div>');
  194. return this.each(function () {
  195. if ("" === e.source)return void(console && console.log("Please specify a source first - boxRefresh()"));
  196. var b = a(this), f = b.find(e.trigger).first();
  197. f.on("click", function (a) {
  198. a.preventDefault(), c(b), b.find(".box-body").load(e.source, function () {
  199. d(b)
  200. })
  201. })
  202. })
  203. }
  204. }(jQuery), function (a) {
  205. a.fn.activateBox = function () {
  206. a.AdminLTE.boxWidget.activate(this)
  207. }
  208. }(jQuery), function (a) {
  209. a.fn.todolist = function (b) {
  210. var c = a.extend({
  211. onCheck: function (a) {
  212. }, onUncheck: function (a) {
  213. }
  214. }, b);
  215. return this.each(function () {
  216. "undefined" != typeof a.fn.iCheck ? (a("input", this).on("ifChecked", function (b) {
  217. var d = a(this).parents("li").first();
  218. d.toggleClass("done"), c.onCheck.call(d)
  219. }), a("input", this).on("ifUnchecked", function (b) {
  220. var d = a(this).parents("li").first();
  221. d.toggleClass("done"), c.onUncheck.call(d)
  222. })) : a("input", this).on("change", function (b) {
  223. var d = a(this).parents("li").first();
  224. d.toggleClass("done"), c.onCheck.call(d)
  225. })
  226. })
  227. }
  228. }(jQuery);