app.js

Used with TorrentLeech Enhancer

Tento skript by neměl být instalován přímo. Jedná se o knihovnu, kterou by měly jiné skripty využívat pomocí meta příkazu // @require https://update.greatest.deepsurf.us/scripts/26687/170372/appjs.js

  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 <abdullah@almsaeedstudio.com>
  10. * @version 2.3.8
  11. * @license MIT <http://opensource.org/licenses/MIT>
  12. */
  13.  
  14. //Make sure jQuery has been loaded before app.js
  15. if (typeof jQuery === "undefined") {
  16. throw new Error("AdminLTE requires jQuery");
  17. }
  18.  
  19. /* AdminLTE
  20. *
  21. * @type Object
  22. * @description $.AdminLTE is the main object for the template's app.
  23. * It's used for implementing functions and options related
  24. * to the template. Keeping everything wrapped in an object
  25. * prevents conflict with other plugins and is a better
  26. * way to organize our code.
  27. */
  28. $.AdminLTE = {};
  29.  
  30. /* --------------------
  31. * - AdminLTE Options -
  32. * --------------------
  33. * Modify these options to suit your implementation
  34. */
  35. $.AdminLTE.options = {
  36. //Add slimscroll to navbar menus
  37. //This requires you to load the slimscroll plugin
  38. //in every page before app.js
  39. navbarMenuSlimscroll: true,
  40. navbarMenuSlimscrollWidth: "3px", //The width of the scroll bar
  41. navbarMenuHeight: "200px", //The height of the inner menu
  42. //General animation speed for JS animated elements such as box collapse/expand and
  43. //sidebar treeview slide up/down. This options accepts an integer as milliseconds,
  44. //'fast', 'normal', or 'slow'
  45. animationSpeed: 500,
  46. //Sidebar push menu toggle button selector
  47. sidebarToggleSelector: "[data-toggle='offcanvas']",
  48. //Activate sidebar push menu
  49. sidebarPushMenu: true,
  50. //Activate sidebar slimscroll if the fixed layout is set (requires SlimScroll Plugin)
  51. sidebarSlimScroll: true,
  52. //Enable sidebar expand on hover effect for sidebar mini
  53. //This option is forced to true if both the fixed layout and sidebar mini
  54. //are used together
  55. sidebarExpandOnHover: false,
  56. //BoxRefresh Plugin
  57. enableBoxRefresh: true,
  58. //Enable Fast Click. Fastclick.js creates a more
  59. //native touch experience with touch devices. If you
  60. //choose to enable the plugin, make sure you load the script
  61. //before AdminLTE's app.js
  62. enableFastclick: false,
  63. //Control Sidebar Tree views
  64. enableControlTreeView: true,
  65. //Control Sidebar Options
  66. enableControlSidebar: true,
  67. controlSidebarOptions: {
  68. //Which button should trigger the open/close event
  69. toggleBtnSelector: "[data-toggle='control-sidebar']",
  70. //The sidebar selector
  71. selector: ".control-sidebar",
  72. //Enable slide over content
  73. slide: true
  74. },
  75. //Define the set of colors to use globally around the website
  76. colors: {
  77. lightBlue: "#3c8dbc",
  78. red: "#f56954",
  79. green: "#00a65a",
  80. aqua: "#00c0ef",
  81. yellow: "#f39c12",
  82. blue: "#0073b7",
  83. navy: "#001F3F",
  84. teal: "#39CCCC",
  85. olive: "#3D9970",
  86. lime: "#01FF70",
  87. orange: "#FF851B",
  88. fuchsia: "#F012BE",
  89. purple: "#8E24AA",
  90. maroon: "#D81B60",
  91. black: "#222222",
  92. gray: "#d2d6de"
  93. },
  94. //The standard screen sizes that bootstrap uses.
  95. //If you change these in the variables.less file, change
  96. //them here too.
  97. screenSizes: {
  98. xs: 480,
  99. sm: 768,
  100. md: 992,
  101. lg: 1200
  102. }
  103. };
  104.  
  105. /* ------------------
  106. * - Implementation -
  107. * ------------------
  108. * The next block of code implements AdminLTE's
  109. * functions and plugins as specified by the
  110. * options above.
  111. */
  112. $(function () {
  113. "use strict";
  114.  
  115. //Fix for IE page transitions
  116. $("body").removeClass("hold-transition");
  117.  
  118. //Extend options if external options exist
  119. if (typeof AdminLTEOptions !== "undefined") {
  120. $.extend(true,
  121. $.AdminLTE.options,
  122. AdminLTEOptions);
  123. }
  124.  
  125. //Easy access to options
  126. var o = $.AdminLTE.options;
  127.  
  128. //Set up the object
  129. _init();
  130.  
  131. //Activate the layout maker
  132. $.AdminLTE.layout.activate();
  133.  
  134. //Enable sidebar tree view controls
  135. if (o.enableControlTreeView) {
  136. $.AdminLTE.tree('.sidebar');
  137. }
  138.  
  139. //Enable control sidebar
  140. if (o.enableControlSidebar) {
  141. $.AdminLTE.controlSidebar.activate();
  142. }
  143.  
  144. //Activate sidebar push menu
  145. if (o.sidebarPushMenu) {
  146. $.AdminLTE.pushMenu.activate(o.sidebarToggleSelector);
  147. }
  148.  
  149. //Activate fast click
  150. if (o.enableFastclick && typeof FastClick != 'undefined') {
  151. FastClick.attach(document.body);
  152. }
  153.  
  154. /*
  155. * INITIALIZE BUTTON TOGGLE
  156. * ------------------------
  157. */
  158. $('.btn-group[data-toggle="btn-toggle"]').each(function () {
  159. var group = $(this);
  160. $(this).find(".btn").on('click', function (e) {
  161. group.find(".btn.active").removeClass("active");
  162. $(this).addClass("active");
  163. e.preventDefault();
  164. });
  165.  
  166. });
  167. });
  168.  
  169. /* ----------------------------------
  170. * - Initialize the AdminLTE Object -
  171. * ----------------------------------
  172. * All AdminLTE functions are implemented below.
  173. */
  174. function _init() {
  175. 'use strict';
  176. /* Layout
  177. * ======
  178. * Fixes the layout height in case min-height fails.
  179. *
  180. * @type Object
  181. * @usage $.AdminLTE.layout.activate()
  182. * $.AdminLTE.layout.fix()
  183. * $.AdminLTE.layout.fixSidebar()
  184. */
  185. $.AdminLTE.layout = {
  186. activate: function () {
  187. var _this = this;
  188. _this.fix();
  189. _this.fixSidebar();
  190. $('body, html, .wrapper').css('height', 'auto');
  191. $(window, ".wrapper").resize(function () {
  192. _this.fix();
  193. _this.fixSidebar();
  194. });
  195. },
  196. fix: function () {
  197. // Remove overflow from .wrapper if layout-boxed exists
  198. $(".layout-boxed > .wrapper").css('overflow', 'hidden');
  199. //Get window height and the wrapper height
  200. var footer_height = $('.main-footer').outerHeight() || 0;
  201. var neg = $('.main-header').outerHeight() + footer_height;
  202. var window_height = $(window).height();
  203. var sidebar_height = $(".sidebar").height() || 0;
  204. //Set the min-height of the content and sidebar based on the
  205. //the height of the document.
  206. if ($("body").hasClass("fixed")) {
  207. $(".content-wrapper, .right-side").css('min-height', window_height - footer_height);
  208. } else {
  209. var postSetWidth;
  210. if (window_height >= sidebar_height) {
  211. $(".content-wrapper, .right-side").css('min-height', window_height - neg);
  212. postSetWidth = window_height - neg;
  213. } else {
  214. $(".content-wrapper, .right-side").css('min-height', sidebar_height);
  215. postSetWidth = sidebar_height;
  216. }
  217.  
  218. //Fix for the control sidebar height
  219. var controlSidebar = $($.AdminLTE.options.controlSidebarOptions.selector);
  220. if (typeof controlSidebar !== "undefined") {
  221. if (controlSidebar.height() > postSetWidth)
  222. $(".content-wrapper, .right-side").css('min-height', controlSidebar.height());
  223. }
  224.  
  225. }
  226. },
  227. fixSidebar: function () {
  228. //Make sure the body tag has the .fixed class
  229. if (!$("body").hasClass("fixed")) {
  230. if (typeof $.fn.slimScroll != 'undefined') {
  231. $(".sidebar").slimScroll({destroy: true}).height("auto");
  232. }
  233. return;
  234. } else if (typeof $.fn.slimScroll == 'undefined' && window.console) {
  235. window.console.error("Error: the fixed layout requires the slimscroll plugin!");
  236. }
  237. //Enable slimscroll for fixed layout
  238. if ($.AdminLTE.options.sidebarSlimScroll) {
  239. if (typeof $.fn.slimScroll != 'undefined') {
  240. //Destroy if it exists
  241. $(".sidebar").slimScroll({destroy: true}).height("auto");
  242. //Add slimscroll
  243. $(".sidebar").slimScroll({
  244. height: ($(window).height() - $(".main-header").height()) + "px",
  245. color: "rgba(0,0,0,0.2)",
  246. size: "3px"
  247. });
  248. }
  249. }
  250. }
  251. };
  252.  
  253. /* Tree()
  254. * ======
  255. * Converts the sidebar into a multilevel
  256. * tree view menu.
  257. *
  258. * @type Function
  259. * @Usage: $.AdminLTE.tree('.sidebar')
  260. */
  261. $.AdminLTE.tree = function (menu) {
  262. var _this = this;
  263. var animationSpeed = $.AdminLTE.options.animationSpeed;
  264. $(document).off('click', menu + ' li a')
  265. .on('click', menu + ' li a', function (e) {
  266. //Get the clicked link and the next element
  267. var $this = $(this);
  268. var checkElement = $this.next();
  269.  
  270. //Check if the next element is a menu and is visible
  271. if ((checkElement.is('.treeview-menu')) && (checkElement.is(':visible')) && (!$('body').hasClass('sidebar-collapse'))) {
  272. //Close the menu
  273. checkElement.slideUp(animationSpeed, function () {
  274. checkElement.removeClass('menu-open');
  275. //Fix the layout in case the sidebar stretches over the height of the window
  276. //_this.layout.fix();
  277. });
  278. checkElement.parent("li").removeClass("active");
  279. }
  280. //If the menu is not visible
  281. else if ((checkElement.is('.treeview-menu')) && (!checkElement.is(':visible'))) {
  282. //Get the parent menu
  283. var parent = $this.parents('ul').first();
  284. //Close all open menus within the parent
  285. var ul = parent.find('ul:visible').slideUp(animationSpeed);
  286. //Remove the menu-open class from the parent
  287. ul.removeClass('menu-open');
  288. //Get the parent li
  289. var parent_li = $this.parent("li");
  290.  
  291. //Open the target menu and add the menu-open class
  292. checkElement.slideDown(animationSpeed, function () {
  293. //Add the class active to the parent li
  294. checkElement.addClass('menu-open');
  295. parent.find('li.active').removeClass('active');
  296. parent_li.addClass('active');
  297. //Fix the layout in case the sidebar stretches over the height of the window
  298. _this.layout.fix();
  299. });
  300. }
  301. //if this isn't a link, prevent the page from being redirected
  302. if (checkElement.is('.treeview-menu')) {
  303. e.preventDefault();
  304. }
  305. });
  306. };
  307.  
  308. /* ControlSidebar
  309. * ==============
  310. * Adds functionality to the right sidebar
  311. *
  312. * @type Object
  313. * @usage $.AdminLTE.controlSidebar.activate(options)
  314. */
  315. $.AdminLTE.controlSidebar = {
  316. //instantiate the object
  317. activate: function () {
  318. //Get the object
  319. var _this = this;
  320. //Update options
  321. var o = $.AdminLTE.options.controlSidebarOptions;
  322. //Get the sidebar
  323. var sidebar = $(o.selector);
  324. //The toggle button
  325. var btn = $(o.toggleBtnSelector);
  326.  
  327. //Listen to the click event
  328. btn.on('click', function (e) {
  329. e.preventDefault();
  330. //If the sidebar is not open
  331. if (!sidebar.hasClass('control-sidebar-open')
  332. && !$('body').hasClass('control-sidebar-open')) {
  333. //Open the sidebar
  334. _this.open(sidebar, o.slide);
  335. } else {
  336. _this.close(sidebar, o.slide);
  337. }
  338. });
  339.  
  340. //If the body has a boxed layout, fix the sidebar bg position
  341. var bg = $(".control-sidebar-bg");
  342. _this._fix(bg);
  343.  
  344. //If the body has a fixed layout, make the control sidebar fixed
  345. if ($('body').hasClass('fixed')) {
  346. _this._fixForFixed(sidebar);
  347. } else {
  348. //If the content height is less than the sidebar's height, force max height
  349. if ($('.content-wrapper, .right-side').height() < sidebar.height()) {
  350. _this._fixForContent(sidebar);
  351. }
  352. }
  353. },
  354. //Open the control sidebar
  355. open: function (sidebar, slide) {
  356. //Slide over content
  357. if (slide) {
  358. sidebar.addClass('control-sidebar-open');
  359. } else {
  360. //Push the content by adding the open class to the body instead
  361. //of the sidebar itself
  362. $('body').addClass('control-sidebar-open');
  363. }
  364. },
  365. //Close the control sidebar
  366. close: function (sidebar, slide) {
  367. if (slide) {
  368. sidebar.removeClass('control-sidebar-open');
  369. } else {
  370. $('body').removeClass('control-sidebar-open');
  371. }
  372. },
  373. _fix: function (sidebar) {
  374. var _this = this;
  375. if ($("body").hasClass('layout-boxed')) {
  376. sidebar.css('position', 'absolute');
  377. sidebar.height($(".wrapper").height());
  378. if (_this.hasBindedResize) {
  379. return;
  380. }
  381. $(window).resize(function () {
  382. _this._fix(sidebar);
  383. });
  384. _this.hasBindedResize = true;
  385. } else {
  386. sidebar.css({
  387. 'position': 'fixed',
  388. 'height': 'auto'
  389. });
  390. }
  391. },
  392. _fixForFixed: function (sidebar) {
  393. sidebar.css({
  394. 'position': 'fixed',
  395. 'max-height': '100%',
  396. 'overflow': 'auto',
  397. 'padding-bottom': '50px'
  398. });
  399. },
  400. _fixForContent: function (sidebar) {
  401. $(".content-wrapper, .right-side").css('min-height', sidebar.height());
  402. }
  403. };
  404.  
  405. }
  406.  
  407. })(jQuery);