You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

413 lines
12 KiB

  1. /**
  2. * AdminLTE Demo Menu
  3. * ------------------
  4. * You should not use this file in production.
  5. * This file is for demo purposes only.
  6. */
  7. (function ($) {
  8. 'use strict'
  9. var $sidebar = $('.control-sidebar')
  10. var $container = $('<div />', {
  11. class: 'p-3 control-sidebar-content'
  12. })
  13. $sidebar.append($container)
  14. var navbar_dark_skins = [
  15. 'navbar-primary',
  16. 'navbar-secondary',
  17. 'navbar-info',
  18. 'navbar-success',
  19. 'navbar-danger',
  20. 'navbar-indigo',
  21. 'navbar-purple',
  22. 'navbar-pink',
  23. 'navbar-teal',
  24. 'navbar-cyan',
  25. 'navbar-dark',
  26. 'navbar-gray-dark',
  27. 'navbar-gray',
  28. ]
  29. var navbar_light_skins = [
  30. 'navbar-light',
  31. 'navbar-warning',
  32. 'navbar-white',
  33. 'navbar-orange',
  34. ]
  35. $container.append(
  36. '<h5>Customize AdminLTE</h5><hr class="mb-2"/>'
  37. )
  38. var $no_border_checkbox = $('<input />', {
  39. type : 'checkbox',
  40. value : 1,
  41. checked: $('.main-header').hasClass('border-bottom-0'),
  42. 'class': 'mr-1'
  43. }).on('click', function () {
  44. if ($(this).is(':checked')) {
  45. $('.main-header').addClass('border-bottom-0')
  46. } else {
  47. $('.main-header').removeClass('border-bottom-0')
  48. }
  49. })
  50. var $no_border_container = $('<div />', {'class': 'mb-1'}).append($no_border_checkbox).append('<span>No Navbar border</span>')
  51. $container.append($no_border_container)
  52. var $text_sm_body_checkbox = $('<input />', {
  53. type : 'checkbox',
  54. value : 1,
  55. checked: $('body').hasClass('text-sm'),
  56. 'class': 'mr-1'
  57. }).on('click', function () {
  58. if ($(this).is(':checked')) {
  59. $('body').addClass('text-sm')
  60. } else {
  61. $('body').removeClass('text-sm')
  62. }
  63. })
  64. var $text_sm_body_container = $('<div />', {'class': 'mb-1'}).append($text_sm_body_checkbox).append('<span>Body small text</span>')
  65. $container.append($text_sm_body_container)
  66. var $text_sm_header_checkbox = $('<input />', {
  67. type : 'checkbox',
  68. value : 1,
  69. checked: $('.main-header').hasClass('text-sm'),
  70. 'class': 'mr-1'
  71. }).on('click', function () {
  72. if ($(this).is(':checked')) {
  73. $('.main-header').addClass('text-sm')
  74. } else {
  75. $('.main-header').removeClass('text-sm')
  76. }
  77. })
  78. var $text_sm_header_container = $('<div />', {'class': 'mb-1'}).append($text_sm_header_checkbox).append('<span>Navbar small text</span>')
  79. $container.append($text_sm_header_container)
  80. var $text_sm_sidebar_checkbox = $('<input />', {
  81. type : 'checkbox',
  82. value : 1,
  83. checked: $('.nav-sidebar').hasClass('text-sm'),
  84. 'class': 'mr-1'
  85. }).on('click', function () {
  86. if ($(this).is(':checked')) {
  87. $('.nav-sidebar').addClass('text-sm')
  88. } else {
  89. $('.nav-sidebar').removeClass('text-sm')
  90. }
  91. })
  92. var $text_sm_sidebar_container = $('<div />', {'class': 'mb-1'}).append($text_sm_sidebar_checkbox).append('<span>Sidebar nav small text</span>')
  93. $container.append($text_sm_sidebar_container)
  94. var $text_sm_footer_checkbox = $('<input />', {
  95. type : 'checkbox',
  96. value : 1,
  97. checked: $('.main-footer').hasClass('text-sm'),
  98. 'class': 'mr-1'
  99. }).on('click', function () {
  100. if ($(this).is(':checked')) {
  101. $('.main-footer').addClass('text-sm')
  102. } else {
  103. $('.main-footer').removeClass('text-sm')
  104. }
  105. })
  106. var $text_sm_footer_container = $('<div />', {'class': 'mb-1'}).append($text_sm_footer_checkbox).append('<span>Footer small text</span>')
  107. $container.append($text_sm_footer_container)
  108. var $flat_sidebar_checkbox = $('<input />', {
  109. type : 'checkbox',
  110. value : 1,
  111. checked: $('.nav-sidebar').hasClass('nav-flat'),
  112. 'class': 'mr-1'
  113. }).on('click', function () {
  114. if ($(this).is(':checked')) {
  115. $('.nav-sidebar').addClass('nav-flat')
  116. } else {
  117. $('.nav-sidebar').removeClass('nav-flat')
  118. }
  119. })
  120. var $flat_sidebar_container = $('<div />', {'class': 'mb-1'}).append($flat_sidebar_checkbox).append('<span>Sidebar nav flat style</span>')
  121. $container.append($flat_sidebar_container)
  122. var $legacy_sidebar_checkbox = $('<input />', {
  123. type : 'checkbox',
  124. value : 1,
  125. checked: $('.nav-sidebar').hasClass('nav-legacy'),
  126. 'class': 'mr-1'
  127. }).on('click', function () {
  128. if ($(this).is(':checked')) {
  129. $('.nav-sidebar').addClass('nav-legacy')
  130. } else {
  131. $('.nav-sidebar').removeClass('nav-legacy')
  132. }
  133. })
  134. var $legacy_sidebar_container = $('<div />', {'class': 'mb-1'}).append($legacy_sidebar_checkbox).append('<span>Sidebar nav legacy style</span>')
  135. $container.append($legacy_sidebar_container)
  136. var $compact_sidebar_checkbox = $('<input />', {
  137. type : 'checkbox',
  138. value : 1,
  139. checked: $('.nav-sidebar').hasClass('nav-compact'),
  140. 'class': 'mr-1'
  141. }).on('click', function () {
  142. if ($(this).is(':checked')) {
  143. $('.nav-sidebar').addClass('nav-compact')
  144. } else {
  145. $('.nav-sidebar').removeClass('nav-compact')
  146. }
  147. })
  148. var $compact_sidebar_container = $('<div />', {'class': 'mb-1'}).append($compact_sidebar_checkbox).append('<span>Sidebar nav compact</span>')
  149. $container.append($compact_sidebar_container)
  150. var $child_indent_sidebar_checkbox = $('<input />', {
  151. type : 'checkbox',
  152. value : 1,
  153. checked: $('.nav-sidebar').hasClass('nav-child-indent'),
  154. 'class': 'mr-1'
  155. }).on('click', function () {
  156. if ($(this).is(':checked')) {
  157. $('.nav-sidebar').addClass('nav-child-indent')
  158. } else {
  159. $('.nav-sidebar').removeClass('nav-child-indent')
  160. }
  161. })
  162. var $child_indent_sidebar_container = $('<div />', {'class': 'mb-1'}).append($child_indent_sidebar_checkbox).append('<span>Sidebar nav child indent</span>')
  163. $container.append($child_indent_sidebar_container)
  164. var $no_expand_sidebar_checkbox = $('<input />', {
  165. type : 'checkbox',
  166. value : 1,
  167. checked: $('.main-sidebar').hasClass('sidebar-no-expand'),
  168. 'class': 'mr-1'
  169. }).on('click', function () {
  170. if ($(this).is(':checked')) {
  171. $('.main-sidebar').addClass('sidebar-no-expand')
  172. } else {
  173. $('.main-sidebar').removeClass('sidebar-no-expand')
  174. }
  175. })
  176. var $no_expand_sidebar_container = $('<div />', {'class': 'mb-1'}).append($no_expand_sidebar_checkbox).append('<span>Main Sidebar disable hover/focus auto expand</span>')
  177. $container.append($no_expand_sidebar_container)
  178. var $text_sm_brand_checkbox = $('<input />', {
  179. type : 'checkbox',
  180. value : 1,
  181. checked: $('.brand-link').hasClass('text-sm'),
  182. 'class': 'mr-1'
  183. }).on('click', function () {
  184. if ($(this).is(':checked')) {
  185. $('.brand-link').addClass('text-sm')
  186. } else {
  187. $('.brand-link').removeClass('text-sm')
  188. }
  189. })
  190. var $text_sm_brand_container = $('<div />', {'class': 'mb-4'}).append($text_sm_brand_checkbox).append('<span>Brand small text</span>')
  191. $container.append($text_sm_brand_container)
  192. $container.append('<h6>Navbar Variants</h6>')
  193. var $navbar_variants = $('<div />', {
  194. 'class': 'd-flex'
  195. })
  196. var navbar_all_colors = navbar_dark_skins.concat(navbar_light_skins)
  197. var $navbar_variants_colors = createSkinBlock(navbar_all_colors, function (e) {
  198. var color = $(this).data('color')
  199. var $main_header = $('.main-header')
  200. $main_header.removeClass('navbar-dark').removeClass('navbar-light')
  201. navbar_all_colors.map(function (color) {
  202. $main_header.removeClass(color)
  203. })
  204. if (navbar_dark_skins.indexOf(color) > -1) {
  205. $main_header.addClass('navbar-dark')
  206. } else {
  207. $main_header.addClass('navbar-light')
  208. }
  209. $main_header.addClass(color)
  210. })
  211. $navbar_variants.append($navbar_variants_colors)
  212. $container.append($navbar_variants)
  213. var sidebar_colors = [
  214. 'bg-primary',
  215. 'bg-warning',
  216. 'bg-info',
  217. 'bg-danger',
  218. 'bg-success',
  219. 'bg-indigo',
  220. 'bg-navy',
  221. 'bg-purple',
  222. 'bg-fuchsia',
  223. 'bg-pink',
  224. 'bg-maroon',
  225. 'bg-orange',
  226. 'bg-lime',
  227. 'bg-teal',
  228. 'bg-olive'
  229. ]
  230. var accent_colors = [
  231. 'accent-primary',
  232. 'accent-warning',
  233. 'accent-info',
  234. 'accent-danger',
  235. 'accent-success',
  236. 'accent-indigo',
  237. 'accent-navy',
  238. 'accent-purple',
  239. 'accent-fuchsia',
  240. 'accent-pink',
  241. 'accent-maroon',
  242. 'accent-orange',
  243. 'accent-lime',
  244. 'accent-teal',
  245. 'accent-olive'
  246. ]
  247. var sidebar_skins = [
  248. 'sidebar-dark-primary',
  249. 'sidebar-dark-warning',
  250. 'sidebar-dark-info',
  251. 'sidebar-dark-danger',
  252. 'sidebar-dark-success',
  253. 'sidebar-dark-indigo',
  254. 'sidebar-dark-navy',
  255. 'sidebar-dark-purple',
  256. 'sidebar-dark-fuchsia',
  257. 'sidebar-dark-pink',
  258. 'sidebar-dark-maroon',
  259. 'sidebar-dark-orange',
  260. 'sidebar-dark-lime',
  261. 'sidebar-dark-teal',
  262. 'sidebar-dark-olive',
  263. 'sidebar-light-primary',
  264. 'sidebar-light-warning',
  265. 'sidebar-light-info',
  266. 'sidebar-light-danger',
  267. 'sidebar-light-success',
  268. 'sidebar-light-indigo',
  269. 'sidebar-light-navy',
  270. 'sidebar-light-purple',
  271. 'sidebar-light-fuchsia',
  272. 'sidebar-light-pink',
  273. 'sidebar-light-maroon',
  274. 'sidebar-light-orange',
  275. 'sidebar-light-lime',
  276. 'sidebar-light-teal',
  277. 'sidebar-light-olive'
  278. ]
  279. $container.append('<h6>Accent Color Variants</h6>')
  280. var $accent_variants = $('<div />', {
  281. 'class': 'd-flex'
  282. })
  283. $container.append($accent_variants)
  284. $container.append(createSkinBlock(accent_colors, function () {
  285. var color = $(this).data('color')
  286. var accent_class = color
  287. var $body = $('body')
  288. accent_colors.map(function (skin) {
  289. $body.removeClass(skin)
  290. })
  291. $body.addClass(accent_class)
  292. }))
  293. $container.append('<h6>Dark Sidebar Variants</h6>')
  294. var $sidebar_variants = $('<div />', {
  295. 'class': 'd-flex'
  296. })
  297. $container.append($sidebar_variants)
  298. $container.append(createSkinBlock(sidebar_colors, function () {
  299. var color = $(this).data('color')
  300. var sidebar_class = 'sidebar-dark-' + color.replace('bg-', '')
  301. var $sidebar = $('.main-sidebar')
  302. sidebar_skins.map(function (skin) {
  303. $sidebar.removeClass(skin)
  304. })
  305. $sidebar.addClass(sidebar_class)
  306. }))
  307. $container.append('<h6>Light Sidebar Variants</h6>')
  308. var $sidebar_variants = $('<div />', {
  309. 'class': 'd-flex'
  310. })
  311. $container.append($sidebar_variants)
  312. $container.append(createSkinBlock(sidebar_colors, function () {
  313. var color = $(this).data('color')
  314. var sidebar_class = 'sidebar-light-' + color.replace('bg-', '')
  315. var $sidebar = $('.main-sidebar')
  316. sidebar_skins.map(function (skin) {
  317. $sidebar.removeClass(skin)
  318. })
  319. $sidebar.addClass(sidebar_class)
  320. }))
  321. var logo_skins = navbar_all_colors
  322. $container.append('<h6>Brand Logo Variants</h6>')
  323. var $logo_variants = $('<div />', {
  324. 'class': 'd-flex'
  325. })
  326. $container.append($logo_variants)
  327. var $clear_btn = $('<a />', {
  328. href: 'javascript:void(0)'
  329. }).text('clear').on('click', function () {
  330. var $logo = $('.brand-link')
  331. logo_skins.map(function (skin) {
  332. $logo.removeClass(skin)
  333. })
  334. })
  335. $container.append(createSkinBlock(logo_skins, function () {
  336. var color = $(this).data('color')
  337. var $logo = $('.brand-link')
  338. logo_skins.map(function (skin) {
  339. $logo.removeClass(skin)
  340. })
  341. $logo.addClass(color)
  342. }).append($clear_btn))
  343. function createSkinBlock(colors, callback) {
  344. var $block = $('<div />', {
  345. 'class': 'd-flex flex-wrap mb-3'
  346. })
  347. colors.map(function (color) {
  348. var $color = $('<div />', {
  349. 'class': (typeof color === 'object' ? color.join(' ') : color).replace('navbar-', 'bg-').replace('accent-', 'bg-') + ' elevation-2'
  350. })
  351. $block.append($color)
  352. $color.data('color', color)
  353. $color.css({
  354. width : '40px',
  355. height : '20px',
  356. borderRadius: '25px',
  357. marginRight : 10,
  358. marginBottom: 10,
  359. opacity : 0.8,
  360. cursor : 'pointer'
  361. })
  362. $color.hover(function () {
  363. $(this).css({ opacity: 1 }).removeClass('elevation-2').addClass('elevation-4')
  364. }, function () {
  365. $(this).css({ opacity: 0.8 }).removeClass('elevation-4').addClass('elevation-2')
  366. })
  367. if (callback) {
  368. $color.on('click', callback)
  369. }
  370. })
  371. return $block
  372. }
  373. })(jQuery)