demo.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689
  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. /* eslint-disable camelcase */
  8. (function ($) {
  9. 'use strict'
  10. setTimeout(function () {
  11. if (window.___browserSync___ === undefined && Number(localStorage.getItem('AdminLTE:Demo:MessageShowed')) < Date.now()) {
  12. localStorage.setItem('AdminLTE:Demo:MessageShowed', (Date.now()) + (15 * 60 * 1000))
  13. // eslint-disable-next-line no-alert
  14. alert('You load AdminLTE\'s "demo.js", \nthis file is only created for testing purposes!')
  15. }
  16. }, 1000)
  17. function capitalizeFirstLetter(string) {
  18. return string.charAt(0).toUpperCase() + string.slice(1)
  19. }
  20. function createSkinBlock(colors, callback, noneSelected) {
  21. var $block = $('<select />', {
  22. class: noneSelected ? 'custom-select mb-3 border-0' : 'custom-select mb-3 text-light border-0 ' + colors[0].replace(/accent-|navbar-/, 'bg-')
  23. })
  24. if (noneSelected) {
  25. var $default = $('<option />', {
  26. text: 'None Selected'
  27. })
  28. $block.append($default)
  29. }
  30. colors.forEach(function (color) {
  31. var $color = $('<option />', {
  32. class: (typeof color === 'object' ? color.join(' ') : color).replace('navbar-', 'bg-').replace('accent-', 'bg-'),
  33. text: capitalizeFirstLetter((typeof color === 'object' ? color.join(' ') : color).replace(/navbar-|accent-|bg-/, '').replace('-', ' '))
  34. })
  35. $block.append($color)
  36. })
  37. if (callback) {
  38. $block.on('change', callback)
  39. }
  40. return $block
  41. }
  42. var $sidebar = $('.control-sidebar')
  43. var $container = $('<div />', {
  44. class: 'p-3 control-sidebar-content'
  45. })
  46. $sidebar.append($container)
  47. // Checkboxes
  48. $container.append(
  49. '<h5>Customize AdminLTE</h5><hr class="mb-2"/>'
  50. )
  51. var $dark_mode_checkbox = $('<input />', {
  52. type: 'checkbox',
  53. value: 1,
  54. checked: $('body').hasClass('dark-mode'),
  55. class: 'mr-1'
  56. }).on('click', function () {
  57. if ($(this).is(':checked')) {
  58. $('body').addClass('dark-mode')
  59. } else {
  60. $('body').removeClass('dark-mode')
  61. }
  62. })
  63. var $dark_mode_container = $('<div />', { class: 'mb-4' }).append($dark_mode_checkbox).append('<span>Dark Mode</span>')
  64. $container.append($dark_mode_container)
  65. $container.append('<h6>Header Options</h6>')
  66. var $header_fixed_checkbox = $('<input />', {
  67. type: 'checkbox',
  68. value: 1,
  69. checked: $('body').hasClass('layout-navbar-fixed'),
  70. class: 'mr-1'
  71. }).on('click', function () {
  72. if ($(this).is(':checked')) {
  73. $('body').addClass('layout-navbar-fixed')
  74. } else {
  75. $('body').removeClass('layout-navbar-fixed')
  76. }
  77. })
  78. var $header_fixed_container = $('<div />', { class: 'mb-1' }).append($header_fixed_checkbox).append('<span>Fixed</span>')
  79. $container.append($header_fixed_container)
  80. var $dropdown_legacy_offset_checkbox = $('<input />', {
  81. type: 'checkbox',
  82. value: 1,
  83. checked: $('.main-header').hasClass('dropdown-legacy'),
  84. class: 'mr-1'
  85. }).on('click', function () {
  86. if ($(this).is(':checked')) {
  87. $('.main-header').addClass('dropdown-legacy')
  88. } else {
  89. $('.main-header').removeClass('dropdown-legacy')
  90. }
  91. })
  92. var $dropdown_legacy_offset_container = $('<div />', { class: 'mb-1' }).append($dropdown_legacy_offset_checkbox).append('<span>Dropdown Legacy Offset</span>')
  93. $container.append($dropdown_legacy_offset_container)
  94. var $no_border_checkbox = $('<input />', {
  95. type: 'checkbox',
  96. value: 1,
  97. checked: $('.main-header').hasClass('border-bottom-0'),
  98. class: 'mr-1'
  99. }).on('click', function () {
  100. if ($(this).is(':checked')) {
  101. $('.main-header').addClass('border-bottom-0')
  102. } else {
  103. $('.main-header').removeClass('border-bottom-0')
  104. }
  105. })
  106. var $no_border_container = $('<div />', { class: 'mb-4' }).append($no_border_checkbox).append('<span>No border</span>')
  107. $container.append($no_border_container)
  108. $container.append('<h6>Sidebar Options</h6>')
  109. var $sidebar_collapsed_checkbox = $('<input />', {
  110. type: 'checkbox',
  111. value: 1,
  112. checked: $('body').hasClass('sidebar-collapse'),
  113. class: 'mr-1'
  114. }).on('click', function () {
  115. if ($(this).is(':checked')) {
  116. $('body').addClass('sidebar-collapse')
  117. $(window).trigger('resize')
  118. } else {
  119. $('body').removeClass('sidebar-collapse')
  120. $(window).trigger('resize')
  121. }
  122. })
  123. var $sidebar_collapsed_container = $('<div />', { class: 'mb-1' }).append($sidebar_collapsed_checkbox).append('<span>Collapsed</span>')
  124. $container.append($sidebar_collapsed_container)
  125. $(document).on('collapsed.lte.pushmenu', '[data-widget="pushmenu"]', function () {
  126. $sidebar_collapsed_checkbox.prop('checked', true)
  127. })
  128. $(document).on('shown.lte.pushmenu', '[data-widget="pushmenu"]', function () {
  129. $sidebar_collapsed_checkbox.prop('checked', false)
  130. })
  131. var $sidebar_fixed_checkbox = $('<input />', {
  132. type: 'checkbox',
  133. value: 1,
  134. checked: $('body').hasClass('layout-fixed'),
  135. class: 'mr-1'
  136. }).on('click', function () {
  137. if ($(this).is(':checked')) {
  138. $('body').addClass('layout-fixed')
  139. $(window).trigger('resize')
  140. } else {
  141. $('body').removeClass('layout-fixed')
  142. $(window).trigger('resize')
  143. }
  144. })
  145. var $sidebar_fixed_container = $('<div />', { class: 'mb-1' }).append($sidebar_fixed_checkbox).append('<span>Fixed</span>')
  146. $container.append($sidebar_fixed_container)
  147. var $sidebar_mini_checkbox = $('<input />', {
  148. type: 'checkbox',
  149. value: 1,
  150. checked: $('body').hasClass('sidebar-mini'),
  151. class: 'mr-1'
  152. }).on('click', function () {
  153. if ($(this).is(':checked')) {
  154. $('body').addClass('sidebar-mini')
  155. } else {
  156. $('body').removeClass('sidebar-mini')
  157. }
  158. })
  159. var $sidebar_mini_container = $('<div />', { class: 'mb-1' }).append($sidebar_mini_checkbox).append('<span>Sidebar Mini</span>')
  160. $container.append($sidebar_mini_container)
  161. var $sidebar_mini_md_checkbox = $('<input />', {
  162. type: 'checkbox',
  163. value: 1,
  164. checked: $('body').hasClass('sidebar-mini-md'),
  165. class: 'mr-1'
  166. }).on('click', function () {
  167. if ($(this).is(':checked')) {
  168. $('body').addClass('sidebar-mini-md')
  169. } else {
  170. $('body').removeClass('sidebar-mini-md')
  171. }
  172. })
  173. var $sidebar_mini_md_container = $('<div />', { class: 'mb-1' }).append($sidebar_mini_md_checkbox).append('<span>Sidebar Mini MD</span>')
  174. $container.append($sidebar_mini_md_container)
  175. var $sidebar_mini_xs_checkbox = $('<input />', {
  176. type: 'checkbox',
  177. value: 1,
  178. checked: $('body').hasClass('sidebar-mini-xs'),
  179. class: 'mr-1'
  180. }).on('click', function () {
  181. if ($(this).is(':checked')) {
  182. $('body').addClass('sidebar-mini-xs')
  183. } else {
  184. $('body').removeClass('sidebar-mini-xs')
  185. }
  186. })
  187. var $sidebar_mini_xs_container = $('<div />', { class: 'mb-1' }).append($sidebar_mini_xs_checkbox).append('<span>Sidebar Mini XS</span>')
  188. $container.append($sidebar_mini_xs_container)
  189. var $flat_sidebar_checkbox = $('<input />', {
  190. type: 'checkbox',
  191. value: 1,
  192. checked: $('.nav-sidebar').hasClass('nav-flat'),
  193. class: 'mr-1'
  194. }).on('click', function () {
  195. if ($(this).is(':checked')) {
  196. $('.nav-sidebar').addClass('nav-flat')
  197. } else {
  198. $('.nav-sidebar').removeClass('nav-flat')
  199. }
  200. })
  201. var $flat_sidebar_container = $('<div />', { class: 'mb-1' }).append($flat_sidebar_checkbox).append('<span>Nav Flat Style</span>')
  202. $container.append($flat_sidebar_container)
  203. var $legacy_sidebar_checkbox = $('<input />', {
  204. type: 'checkbox',
  205. value: 1,
  206. checked: $('.nav-sidebar').hasClass('nav-legacy'),
  207. class: 'mr-1'
  208. }).on('click', function () {
  209. if ($(this).is(':checked')) {
  210. $('.nav-sidebar').addClass('nav-legacy')
  211. } else {
  212. $('.nav-sidebar').removeClass('nav-legacy')
  213. }
  214. })
  215. var $legacy_sidebar_container = $('<div />', { class: 'mb-1' }).append($legacy_sidebar_checkbox).append('<span>Nav Legacy Style</span>')
  216. $container.append($legacy_sidebar_container)
  217. var $compact_sidebar_checkbox = $('<input />', {
  218. type: 'checkbox',
  219. value: 1,
  220. checked: $('.nav-sidebar').hasClass('nav-compact'),
  221. class: 'mr-1'
  222. }).on('click', function () {
  223. if ($(this).is(':checked')) {
  224. $('.nav-sidebar').addClass('nav-compact')
  225. } else {
  226. $('.nav-sidebar').removeClass('nav-compact')
  227. }
  228. })
  229. var $compact_sidebar_container = $('<div />', { class: 'mb-1' }).append($compact_sidebar_checkbox).append('<span>Nav Compact</span>')
  230. $container.append($compact_sidebar_container)
  231. var $child_indent_sidebar_checkbox = $('<input />', {
  232. type: 'checkbox',
  233. value: 1,
  234. checked: $('.nav-sidebar').hasClass('nav-child-indent'),
  235. class: 'mr-1'
  236. }).on('click', function () {
  237. if ($(this).is(':checked')) {
  238. $('.nav-sidebar').addClass('nav-child-indent')
  239. } else {
  240. $('.nav-sidebar').removeClass('nav-child-indent')
  241. }
  242. })
  243. var $child_indent_sidebar_container = $('<div />', { class: 'mb-1' }).append($child_indent_sidebar_checkbox).append('<span>Nav Child Indent</span>')
  244. $container.append($child_indent_sidebar_container)
  245. var $child_hide_sidebar_checkbox = $('<input />', {
  246. type: 'checkbox',
  247. value: 1,
  248. checked: $('.nav-sidebar').hasClass('nav-collapse-hide-child'),
  249. class: 'mr-1'
  250. }).on('click', function () {
  251. if ($(this).is(':checked')) {
  252. $('.nav-sidebar').addClass('nav-collapse-hide-child')
  253. } else {
  254. $('.nav-sidebar').removeClass('nav-collapse-hide-child')
  255. }
  256. })
  257. var $child_hide_sidebar_container = $('<div />', { class: 'mb-1' }).append($child_hide_sidebar_checkbox).append('<span>Nav Child Hide on Collapse</span>')
  258. $container.append($child_hide_sidebar_container)
  259. var $no_expand_sidebar_checkbox = $('<input />', {
  260. type: 'checkbox',
  261. value: 1,
  262. checked: $('.main-sidebar').hasClass('sidebar-no-expand'),
  263. class: 'mr-1'
  264. }).on('click', function () {
  265. if ($(this).is(':checked')) {
  266. $('.main-sidebar').addClass('sidebar-no-expand')
  267. } else {
  268. $('.main-sidebar').removeClass('sidebar-no-expand')
  269. }
  270. })
  271. var $no_expand_sidebar_container = $('<div />', { class: 'mb-4' }).append($no_expand_sidebar_checkbox).append('<span>Disable Hover/Focus Auto-Expand</span>')
  272. $container.append($no_expand_sidebar_container)
  273. $container.append('<h6>Footer Options</h6>')
  274. var $footer_fixed_checkbox = $('<input />', {
  275. type: 'checkbox',
  276. value: 1,
  277. checked: $('body').hasClass('layout-footer-fixed'),
  278. class: 'mr-1'
  279. }).on('click', function () {
  280. if ($(this).is(':checked')) {
  281. $('body').addClass('layout-footer-fixed')
  282. } else {
  283. $('body').removeClass('layout-footer-fixed')
  284. }
  285. })
  286. var $footer_fixed_container = $('<div />', { class: 'mb-4' }).append($footer_fixed_checkbox).append('<span>Fixed</span>')
  287. $container.append($footer_fixed_container)
  288. $container.append('<h6>Small Text Options</h6>')
  289. var $text_sm_body_checkbox = $('<input />', {
  290. type: 'checkbox',
  291. value: 1,
  292. checked: $('body').hasClass('text-sm'),
  293. class: 'mr-1'
  294. }).on('click', function () {
  295. if ($(this).is(':checked')) {
  296. $('body').addClass('text-sm')
  297. } else {
  298. $('body').removeClass('text-sm')
  299. }
  300. })
  301. var $text_sm_body_container = $('<div />', { class: 'mb-1' }).append($text_sm_body_checkbox).append('<span>Body</span>')
  302. $container.append($text_sm_body_container)
  303. var $text_sm_header_checkbox = $('<input />', {
  304. type: 'checkbox',
  305. value: 1,
  306. checked: $('.main-header').hasClass('text-sm'),
  307. class: 'mr-1'
  308. }).on('click', function () {
  309. if ($(this).is(':checked')) {
  310. $('.main-header').addClass('text-sm')
  311. } else {
  312. $('.main-header').removeClass('text-sm')
  313. }
  314. })
  315. var $text_sm_header_container = $('<div />', { class: 'mb-1' }).append($text_sm_header_checkbox).append('<span>Navbar</span>')
  316. $container.append($text_sm_header_container)
  317. var $text_sm_brand_checkbox = $('<input />', {
  318. type: 'checkbox',
  319. value: 1,
  320. checked: $('.brand-link').hasClass('text-sm'),
  321. class: 'mr-1'
  322. }).on('click', function () {
  323. if ($(this).is(':checked')) {
  324. $('.brand-link').addClass('text-sm')
  325. } else {
  326. $('.brand-link').removeClass('text-sm')
  327. }
  328. })
  329. var $text_sm_brand_container = $('<div />', { class: 'mb-1' }).append($text_sm_brand_checkbox).append('<span>Brand</span>')
  330. $container.append($text_sm_brand_container)
  331. var $text_sm_sidebar_checkbox = $('<input />', {
  332. type: 'checkbox',
  333. value: 1,
  334. checked: $('.nav-sidebar').hasClass('text-sm'),
  335. class: 'mr-1'
  336. }).on('click', function () {
  337. if ($(this).is(':checked')) {
  338. $('.nav-sidebar').addClass('text-sm')
  339. } else {
  340. $('.nav-sidebar').removeClass('text-sm')
  341. }
  342. })
  343. var $text_sm_sidebar_container = $('<div />', { class: 'mb-1' }).append($text_sm_sidebar_checkbox).append('<span>Sidebar Nav</span>')
  344. $container.append($text_sm_sidebar_container)
  345. var $text_sm_footer_checkbox = $('<input />', {
  346. type: 'checkbox',
  347. value: 1,
  348. checked: $('.main-footer').hasClass('text-sm'),
  349. class: 'mr-1'
  350. }).on('click', function () {
  351. if ($(this).is(':checked')) {
  352. $('.main-footer').addClass('text-sm')
  353. } else {
  354. $('.main-footer').removeClass('text-sm')
  355. }
  356. })
  357. var $text_sm_footer_container = $('<div />', { class: 'mb-4' }).append($text_sm_footer_checkbox).append('<span>Footer</span>')
  358. $container.append($text_sm_footer_container)
  359. // Color Arrays
  360. var navbar_dark_skins = [
  361. 'navbar-primary',
  362. 'navbar-secondary',
  363. 'navbar-info',
  364. 'navbar-success',
  365. 'navbar-danger',
  366. 'navbar-indigo',
  367. 'navbar-purple',
  368. 'navbar-pink',
  369. 'navbar-navy',
  370. 'navbar-lightblue',
  371. 'navbar-teal',
  372. 'navbar-cyan',
  373. 'navbar-dark',
  374. 'navbar-gray-dark',
  375. 'navbar-gray'
  376. ]
  377. var navbar_light_skins = [
  378. 'navbar-light',
  379. 'navbar-warning',
  380. 'navbar-white',
  381. 'navbar-orange'
  382. ]
  383. var sidebar_colors = [
  384. 'bg-primary',
  385. 'bg-warning',
  386. 'bg-info',
  387. 'bg-danger',
  388. 'bg-success',
  389. 'bg-indigo',
  390. 'bg-lightblue',
  391. 'bg-navy',
  392. 'bg-purple',
  393. 'bg-fuchsia',
  394. 'bg-pink',
  395. 'bg-maroon',
  396. 'bg-orange',
  397. 'bg-lime',
  398. 'bg-teal',
  399. 'bg-olive'
  400. ]
  401. var accent_colors = [
  402. 'accent-primary',
  403. 'accent-warning',
  404. 'accent-info',
  405. 'accent-danger',
  406. 'accent-success',
  407. 'accent-indigo',
  408. 'accent-lightblue',
  409. 'accent-navy',
  410. 'accent-purple',
  411. 'accent-fuchsia',
  412. 'accent-pink',
  413. 'accent-maroon',
  414. 'accent-orange',
  415. 'accent-lime',
  416. 'accent-teal',
  417. 'accent-olive'
  418. ]
  419. var sidebar_skins = [
  420. 'sidebar-dark-primary',
  421. 'sidebar-dark-warning',
  422. 'sidebar-dark-info',
  423. 'sidebar-dark-danger',
  424. 'sidebar-dark-success',
  425. 'sidebar-dark-indigo',
  426. 'sidebar-dark-lightblue',
  427. 'sidebar-dark-navy',
  428. 'sidebar-dark-purple',
  429. 'sidebar-dark-fuchsia',
  430. 'sidebar-dark-pink',
  431. 'sidebar-dark-maroon',
  432. 'sidebar-dark-orange',
  433. 'sidebar-dark-lime',
  434. 'sidebar-dark-teal',
  435. 'sidebar-dark-olive',
  436. 'sidebar-light-primary',
  437. 'sidebar-light-warning',
  438. 'sidebar-light-info',
  439. 'sidebar-light-danger',
  440. 'sidebar-light-success',
  441. 'sidebar-light-indigo',
  442. 'sidebar-light-lightblue',
  443. 'sidebar-light-navy',
  444. 'sidebar-light-purple',
  445. 'sidebar-light-fuchsia',
  446. 'sidebar-light-pink',
  447. 'sidebar-light-maroon',
  448. 'sidebar-light-orange',
  449. 'sidebar-light-lime',
  450. 'sidebar-light-teal',
  451. 'sidebar-light-olive'
  452. ]
  453. // Navbar Variants
  454. $container.append('<h6>Navbar Variants</h6>')
  455. var $navbar_variants = $('<div />', {
  456. class: 'd-flex'
  457. })
  458. var navbar_all_colors = navbar_dark_skins.concat(navbar_light_skins)
  459. var $navbar_variants_colors = createSkinBlock(navbar_all_colors, function () {
  460. var color = $(this).find('option:selected').attr('class')
  461. var $main_header = $('.main-header')
  462. $main_header.removeClass('navbar-dark').removeClass('navbar-light')
  463. navbar_all_colors.forEach(function (color) {
  464. $main_header.removeClass(color)
  465. })
  466. $(this).removeClass().addClass('custom-select mb-3 text-light border-0 ')
  467. if (navbar_dark_skins.indexOf(color) > -1) {
  468. $main_header.addClass('navbar-dark')
  469. $(this).addClass(color).addClass('text-light')
  470. } else {
  471. $main_header.addClass('navbar-light')
  472. $(this).addClass(color)
  473. }
  474. $main_header.addClass(color)
  475. })
  476. var active_navbar_color = null
  477. $('.main-header')[0].classList.forEach(function (className) {
  478. if (navbar_all_colors.indexOf(className) > -1 && active_navbar_color === null) {
  479. active_navbar_color = className.replace('navbar-', 'bg-')
  480. }
  481. })
  482. $navbar_variants_colors.find('option.' + active_navbar_color).prop('selected', true)
  483. $navbar_variants_colors.removeClass().addClass('custom-select mb-3 text-light border-0 ').addClass(active_navbar_color)
  484. $navbar_variants.append($navbar_variants_colors)
  485. $container.append($navbar_variants)
  486. // Sidebar Colors
  487. $container.append('<h6>Accent Color Variants</h6>')
  488. var $accent_variants = $('<div />', {
  489. class: 'd-flex'
  490. })
  491. $container.append($accent_variants)
  492. $container.append(createSkinBlock(accent_colors, function () {
  493. var color = $(this).find('option:selected').attr('class')
  494. var $body = $('body')
  495. accent_colors.forEach(function (skin) {
  496. $body.removeClass(skin)
  497. })
  498. var accent_color_class = color.replace('bg-', 'accent-')
  499. $body.addClass(accent_color_class)
  500. }, true))
  501. var active_accent_color = null
  502. $('body')[0].classList.forEach(function (className) {
  503. if (accent_colors.indexOf(className) > -1 && active_accent_color === null) {
  504. active_accent_color = className.replace('navbar-', 'bg-')
  505. }
  506. })
  507. // $accent_variants.find('option.' + active_accent_color).prop('selected', true)
  508. // $accent_variants.removeClass().addClass('custom-select mb-3 text-light border-0 ').addClass(active_accent_color)
  509. $container.append('<h6>Dark Sidebar Variants</h6>')
  510. var $sidebar_variants_dark = $('<div />', {
  511. class: 'd-flex'
  512. })
  513. $container.append($sidebar_variants_dark)
  514. var $sidebar_dark_variants = createSkinBlock(sidebar_colors, function () {
  515. var color = $(this).find('option:selected').attr('class')
  516. var sidebar_class = 'sidebar-dark-' + color.replace('bg-', '')
  517. var $sidebar = $('.main-sidebar')
  518. sidebar_skins.forEach(function (skin) {
  519. $sidebar.removeClass(skin)
  520. $sidebar_light_variants.removeClass(skin.replace('sidebar-dark-', 'bg-')).removeClass('text-light')
  521. })
  522. $(this).removeClass().addClass('custom-select mb-3 text-light border-0').addClass(color)
  523. $sidebar_light_variants.find('option').prop('selected', false)
  524. $sidebar.addClass(sidebar_class)
  525. $('.sidebar').removeClass('os-theme-dark').addClass('os-theme-light')
  526. }, true)
  527. $container.append($sidebar_dark_variants)
  528. var active_sidebar_dark_color = null
  529. $('.main-sidebar')[0].classList.forEach(function (className) {
  530. var color = className.replace('sidebar-dark-', 'bg-')
  531. if (sidebar_colors.indexOf(color) > -1 && active_sidebar_dark_color === null) {
  532. active_sidebar_dark_color = color
  533. }
  534. })
  535. $sidebar_dark_variants.find('option.' + active_sidebar_dark_color).prop('selected', true)
  536. $sidebar_dark_variants.removeClass().addClass('custom-select mb-3 text-light border-0 ').addClass(active_sidebar_dark_color)
  537. $container.append('<h6>Light Sidebar Variants</h6>')
  538. var $sidebar_variants_light = $('<div />', {
  539. class: 'd-flex'
  540. })
  541. $container.append($sidebar_variants_light)
  542. var $sidebar_light_variants = createSkinBlock(sidebar_colors, function () {
  543. var color = $(this).find('option:selected').attr('class')
  544. var sidebar_class = 'sidebar-light-' + color.replace('bg-', '')
  545. var $sidebar = $('.main-sidebar')
  546. sidebar_skins.forEach(function (skin) {
  547. $sidebar.removeClass(skin)
  548. $sidebar_dark_variants.removeClass(skin.replace('sidebar-light-', 'bg-')).removeClass('text-light')
  549. })
  550. $(this).removeClass().addClass('custom-select mb-3 text-light border-0').addClass(color)
  551. $sidebar_dark_variants.find('option').prop('selected', false)
  552. $sidebar.addClass(sidebar_class)
  553. $('.sidebar').removeClass('os-theme-light').addClass('os-theme-dark')
  554. }, true)
  555. $container.append($sidebar_light_variants)
  556. var active_sidebar_light_color = null
  557. $('.main-sidebar')[0].classList.forEach(function (className) {
  558. var color = className.replace('sidebar-light-', 'bg-')
  559. if (sidebar_colors.indexOf(color) > -1 && active_sidebar_light_color === null) {
  560. active_sidebar_light_color = color
  561. }
  562. })
  563. if (active_sidebar_light_color !== null) {
  564. $sidebar_light_variants.find('option.' + active_sidebar_light_color).prop('selected', true)
  565. $sidebar_light_variants.removeClass().addClass('custom-select mb-3 text-light border-0 ').addClass(active_sidebar_light_color)
  566. }
  567. var logo_skins = navbar_all_colors
  568. $container.append('<h6>Brand Logo Variants</h6>')
  569. var $logo_variants = $('<div />', {
  570. class: 'd-flex'
  571. })
  572. $container.append($logo_variants)
  573. var $clear_btn = $('<a />', {
  574. href: '#'
  575. }).text('clear').on('click', function (e) {
  576. e.preventDefault()
  577. var $logo = $('.brand-link')
  578. logo_skins.forEach(function (skin) {
  579. $logo.removeClass(skin)
  580. })
  581. })
  582. var $brand_variants = createSkinBlock(logo_skins, function () {
  583. var color = $(this).find('option:selected').attr('class')
  584. var $logo = $('.brand-link')
  585. if (color === 'navbar-light' || color === 'navbar-white') {
  586. $logo.addClass('text-black')
  587. } else {
  588. $logo.removeClass('text-black')
  589. }
  590. logo_skins.forEach(function (skin) {
  591. $logo.removeClass(skin)
  592. })
  593. if (color) {
  594. $(this).removeClass().addClass('custom-select mb-3 border-0').addClass(color).addClass(color !== 'navbar-light' && color !== 'navbar-white' ? 'text-light' : '')
  595. } else {
  596. $(this).removeClass().addClass('custom-select mb-3 border-0')
  597. }
  598. $logo.addClass(color)
  599. }, true).append($clear_btn)
  600. $container.append($brand_variants)
  601. var active_brand_color = null
  602. $('.brand-link')[0].classList.forEach(function (className) {
  603. if (logo_skins.indexOf(className) > -1 && active_brand_color === null) {
  604. active_brand_color = className.replace('navbar-', 'bg-')
  605. }
  606. })
  607. if (active_brand_color) {
  608. $brand_variants.find('option.' + active_brand_color).prop('selected', true)
  609. $brand_variants.removeClass().addClass('custom-select mb-3 text-light border-0 ').addClass(active_brand_color)
  610. }
  611. })(jQuery)