demo.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  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 ($, AdminLTE) {
  8. 'use strict';
  9. /**
  10. * List of all the available skins
  11. *
  12. * @type Array
  13. */
  14. var mySkins = [
  15. 'skin-blue',
  16. 'skin-black',
  17. 'skin-red',
  18. 'skin-yellow',
  19. 'skin-purple',
  20. 'skin-green',
  21. 'skin-blue-light',
  22. 'skin-black-light',
  23. 'skin-red-light',
  24. 'skin-yellow-light',
  25. 'skin-purple-light',
  26. 'skin-green-light'
  27. ];
  28. /**
  29. * Get a prestored setting
  30. *
  31. * @param String name Name of of the setting
  32. * @returns String The value of the setting | null
  33. */
  34. function get(name) {
  35. if (typeof (Storage) !== 'undefined') {
  36. return localStorage.getItem(name);
  37. } else {
  38. window.alert('Please use a modern browser to properly view this template!');
  39. }
  40. }
  41. /**
  42. * Store a new settings in the browser
  43. *
  44. * @param String name Name of the setting
  45. * @param String val Value of the setting
  46. * @returns void
  47. */
  48. function store(name, val) {
  49. if (typeof (Storage) !== 'undefined') {
  50. localStorage.setItem(name, val);
  51. } else {
  52. window.alert('Please use a modern browser to properly view this template!');
  53. }
  54. }
  55. /**
  56. * Toggles layout classes
  57. *
  58. * @param String cls the layout class to toggle
  59. * @returns void
  60. */
  61. function changeLayout(cls) {
  62. $('body').toggleClass(cls);
  63. AdminLTE.layout.fixSidebar();
  64. // Fix the problem with right sidebar and layout boxed
  65. if (cls == 'layout-boxed')
  66. AdminLTE.controlSidebar._fix($('.control-sidebar-bg'));
  67. if ($('body').hasClass('fixed') && cls == 'fixed') {
  68. AdminLTE.pushMenu.expandOnHover();
  69. AdminLTE.layout.activate();
  70. }
  71. AdminLTE.controlSidebar._fix($('.control-sidebar-bg'));
  72. AdminLTE.controlSidebar._fix($('.control-sidebar'));
  73. }
  74. /**
  75. * Replaces the old skin with the new skin
  76. * @param String cls the new skin class
  77. * @returns Boolean false to prevent link's default action
  78. */
  79. function changeSkin(cls) {
  80. $.each(mySkins, function (i) {
  81. $('body').removeClass(mySkins[i]);
  82. });
  83. $('body').addClass(cls);
  84. store('skin', cls);
  85. return false;
  86. }
  87. /**
  88. * Retrieve default settings and apply them to the template
  89. *
  90. * @returns void
  91. */
  92. function setup() {
  93. var tmp = get('skin');
  94. if (tmp && $.inArray(tmp, mySkins))
  95. changeSkin(tmp);
  96. // Add the change skin listener
  97. $('[data-skin]').on('click', function (e) {
  98. if ($(this).hasClass('knob'))
  99. return;
  100. e.preventDefault();
  101. changeSkin($(this).data('skin'));
  102. });
  103. // Add the layout manager
  104. $('[data-layout]').on('click', function () {
  105. changeLayout($(this).data('layout'));
  106. });
  107. $('[data-controlsidebar]').on('click', function () {
  108. changeLayout($(this).data('controlsidebar'));
  109. var slide = !AdminLTE.options.controlSidebarOptions.slide;
  110. AdminLTE.options.controlSidebarOptions.slide = slide;
  111. if (!slide)
  112. $('.control-sidebar').removeClass('control-sidebar-open');
  113. });
  114. $('[data-sidebarskin="toggle"]').on('click', function () {
  115. var $sidebar = $('.control-sidebar');
  116. if ($sidebar.hasClass('control-sidebar-dark')) {
  117. $sidebar.removeClass('control-sidebar-dark')
  118. $sidebar.addClass('control-sidebar-light')
  119. } else {
  120. $sidebar.removeClass('control-sidebar-light')
  121. $sidebar.addClass('control-sidebar-dark')
  122. }
  123. });
  124. $('[data-enable="expandOnHover"]').on('click', function () {
  125. $(this).attr('disabled', true);
  126. AdminLTE.pushMenu.expandOnHover();
  127. if (!$('body').hasClass('sidebar-collapse'))
  128. $('[data-layout="sidebar-collapse"]').click();
  129. });
  130. // Reset options
  131. if ($('body').hasClass('fixed')) {
  132. $('[data-layout="fixed"]').attr('checked', 'checked');
  133. }
  134. if ($('body').hasClass('layout-boxed')) {
  135. $('[data-layout="layout-boxed"]').attr('checked', 'checked');
  136. }
  137. if ($('body').hasClass('sidebar-collapse')) {
  138. $('[data-layout="sidebar-collapse"]').attr('checked', 'checked');
  139. }
  140. }
  141. // Create the new tab
  142. var $tabPane = $('<div />', {
  143. 'id' : 'control-sidebar-theme-demo-options-tab',
  144. 'class': 'tab-pane active'
  145. });
  146. // Create the tab button
  147. var $tabButton = $('<li />', { 'class': 'active' })
  148. .html('<a href=\'#control-sidebar-theme-demo-options-tab\' data-toggle=\'tab\'>'
  149. + '<i class="fa fa-wrench"></i>'
  150. + '</a>');
  151. // Add the tab button to the right sidebar tabs
  152. $('[href="#control-sidebar-home-tab"]')
  153. .parent()
  154. .before($tabButton);
  155. // Create the menu
  156. var $demoSettings = $('<div />');
  157. // Layout options
  158. $demoSettings.append(
  159. '<h4 class="control-sidebar-heading">'
  160. + 'Layout Options'
  161. + '</h4>'
  162. // Fixed layout
  163. + '<div class="form-group">'
  164. + '<label class="control-sidebar-subheading">'
  165. + '<input type="checkbox"data-layout="fixed"class="pull-right"/> '
  166. + 'Fixed layout'
  167. + '</label>'
  168. + '<p>Activate the fixed layout. You can\'t use fixed and boxed layouts together</p>'
  169. + '</div>'
  170. // Boxed layout
  171. + '<div class="form-group">'
  172. + '<label class="control-sidebar-subheading">'
  173. + '<input type="checkbox"data-layout="layout-boxed" class="pull-right"/> '
  174. + 'Boxed Layout'
  175. + '</label>'
  176. + '<p>Activate the boxed layout</p>'
  177. + '</div>'
  178. // Sidebar Toggle
  179. + '<div class="form-group">'
  180. + '<label class="control-sidebar-subheading">'
  181. + '<input type="checkbox"data-layout="sidebar-collapse"class="pull-right"/> '
  182. + 'Toggle Sidebar'
  183. + '</label>'
  184. + '<p>Toggle the left sidebar\'s state (open or collapse)</p>'
  185. + '</div>'
  186. // Sidebar mini expand on hover toggle
  187. + '<div class="form-group">'
  188. + '<label class="control-sidebar-subheading">'
  189. + '<input type="checkbox"data-enable="expandOnHover"class="pull-right"/> '
  190. + 'Sidebar Expand on Hover'
  191. + '</label>'
  192. + '<p>Let the sidebar mini expand on hover</p>'
  193. + '</div>'
  194. // Control Sidebar Toggle
  195. + '<div class="form-group">'
  196. + '<label class="control-sidebar-subheading">'
  197. + '<input type="checkbox"data-controlsidebar="control-sidebar-open"class="pull-right"/> '
  198. + 'Toggle Right Sidebar Slide'
  199. + '</label>'
  200. + '<p>Toggle between slide over content and push content effects</p>'
  201. + '</div>'
  202. // Control Sidebar Skin Toggle
  203. + '<div class="form-group">'
  204. + '<label class="control-sidebar-subheading">'
  205. + '<input type="checkbox"data-sidebarskin="toggle"class="pull-right"/> '
  206. + 'Toggle Right Sidebar Skin'
  207. + '</label>'
  208. + '<p>Toggle between dark and light skins for the right sidebar</p>'
  209. + '</div>'
  210. );
  211. var $skinsList = $('<ul />', { 'class': 'list-unstyled clearfix' });
  212. // Dark sidebar skins
  213. var $skinBlue =
  214. $('<li />', { style: 'float:left; width: 33.33333%; padding: 5px;' })
  215. .append('<a href="javascript:void(0);" data-skin="skin-blue" style="display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)" class="clearfix full-opacity-hover">'
  216. + '<div><span style="display:block; width: 20%; float: left; height: 7px; background: #367fa9;"></span><span class="bg-light-blue" style="display:block; width: 80%; float: left; height: 7px;"></span></div>'
  217. + '<div><span style="display:block; width: 20%; float: left; height: 20px; background: #222d32;"></span><span style="display:block; width: 80%; float: left; height: 20px; background: #f4f5f7;"></span></div>'
  218. + '</a>'
  219. + '<p class="text-center no-margin">Blue</p>');
  220. $skinsList.append($skinBlue);
  221. var $skinBlack =
  222. $('<li />', { style: 'float:left; width: 33.33333%; padding: 5px;' })
  223. .append('<a href="javascript:void(0);" data-skin="skin-black" style="display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)" class="clearfix full-opacity-hover">'
  224. + '<div style="box-shadow: 0 0 2px rgba(0,0,0,0.1)" class="clearfix"><span style="display:block; width: 20%; float: left; height: 7px; background: #fefefe;"></span><span style="display:block; width: 80%; float: left; height: 7px; background: #fefefe;"></span></div>'
  225. + '<div><span style="display:block; width: 20%; float: left; height: 20px; background: #222;"></span><span style="display:block; width: 80%; float: left; height: 20px; background: #f4f5f7;"></span></div>'
  226. + '</a>'
  227. + '<p class="text-center no-margin">Black</p>');
  228. $skinsList.append($skinBlack);
  229. var $skinPurple =
  230. $('<li />', { style: 'float:left; width: 33.33333%; padding: 5px;' })
  231. .append('<a href="javascript:void(0);" data-skin="skin-purple" style="display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)" class="clearfix full-opacity-hover">'
  232. + '<div><span style="display:block; width: 20%; float: left; height: 7px;" class="bg-purple-active"></span><span class="bg-purple" style="display:block; width: 80%; float: left; height: 7px;"></span></div>'
  233. + '<div><span style="display:block; width: 20%; float: left; height: 20px; background: #222d32;"></span><span style="display:block; width: 80%; float: left; height: 20px; background: #f4f5f7;"></span></div>'
  234. + '</a>'
  235. + '<p class="text-center no-margin">Purple</p>');
  236. $skinsList.append($skinPurple);
  237. var $skinGreen =
  238. $('<li />', { style: 'float:left; width: 33.33333%; padding: 5px;' })
  239. .append('<a href="javascript:void(0);" data-skin="skin-green" style="display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)" class="clearfix full-opacity-hover">'
  240. + '<div><span style="display:block; width: 20%; float: left; height: 7px;" class="bg-green-active"></span><span class="bg-green" style="display:block; width: 80%; float: left; height: 7px;"></span></div>'
  241. + '<div><span style="display:block; width: 20%; float: left; height: 20px; background: #222d32;"></span><span style="display:block; width: 80%; float: left; height: 20px; background: #f4f5f7;"></span></div>'
  242. + '</a>'
  243. + '<p class="text-center no-margin">Green</p>');
  244. $skinsList.append($skinGreen);
  245. var $skinRed =
  246. $('<li />', { style: 'float:left; width: 33.33333%; padding: 5px;' })
  247. .append('<a href="javascript:void(0);" data-skin="skin-red" style="display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)" class="clearfix full-opacity-hover">'
  248. + '<div><span style="display:block; width: 20%; float: left; height: 7px;" class="bg-red-active"></span><span class="bg-red" style="display:block; width: 80%; float: left; height: 7px;"></span></div>'
  249. + '<div><span style="display:block; width: 20%; float: left; height: 20px; background: #222d32;"></span><span style="display:block; width: 80%; float: left; height: 20px; background: #f4f5f7;"></span></div>'
  250. + '</a>'
  251. + '<p class="text-center no-margin">Red</p>');
  252. $skinsList.append($skinRed);
  253. var $skinYellow =
  254. $('<li />', { style: 'float:left; width: 33.33333%; padding: 5px;' })
  255. .append('<a href="javascript:void(0);" data-skin="skin-yellow" style="display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)" class="clearfix full-opacity-hover">'
  256. + '<div><span style="display:block; width: 20%; float: left; height: 7px;" class="bg-yellow-active"></span><span class="bg-yellow" style="display:block; width: 80%; float: left; height: 7px;"></span></div>'
  257. + '<div><span style="display:block; width: 20%; float: left; height: 20px; background: #222d32;"></span><span style="display:block; width: 80%; float: left; height: 20px; background: #f4f5f7;"></span></div>'
  258. + '</a>'
  259. + '<p class="text-center no-margin">Yellow</p>');
  260. $skinsList.append($skinYellow);
  261. // Light sidebar skins
  262. var $skinBlueLight =
  263. $('<li />', { style: 'float:left; width: 33.33333%; padding: 5px;' })
  264. .append('<a href="javascript:void(0);" data-skin="skin-blue-light" style="display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)" class="clearfix full-opacity-hover">'
  265. + '<div><span style="display:block; width: 20%; float: left; height: 7px; background: #367fa9;"></span><span class="bg-light-blue" style="display:block; width: 80%; float: left; height: 7px;"></span></div>'
  266. + '<div><span style="display:block; width: 20%; float: left; height: 20px; background: #f9fafc;"></span><span style="display:block; width: 80%; float: left; height: 20px; background: #f4f5f7;"></span></div>'
  267. + '</a>'
  268. + '<p class="text-center no-margin" style="font-size: 12px">Blue Light</p>');
  269. $skinsList.append($skinBlueLight);
  270. var $skinBlackLight =
  271. $('<li />', { style: 'float:left; width: 33.33333%; padding: 5px;' })
  272. .append('<a href="javascript:void(0);" data-skin="skin-black-light" style="display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)" class="clearfix full-opacity-hover">'
  273. + '<div style="box-shadow: 0 0 2px rgba(0,0,0,0.1)" class="clearfix"><span style="display:block; width: 20%; float: left; height: 7px; background: #fefefe;"></span><span style="display:block; width: 80%; float: left; height: 7px; background: #fefefe;"></span></div>'
  274. + '<div><span style="display:block; width: 20%; float: left; height: 20px; background: #f9fafc;"></span><span style="display:block; width: 80%; float: left; height: 20px; background: #f4f5f7;"></span></div>'
  275. + '</a>'
  276. + '<p class="text-center no-margin" style="font-size: 12px">Black Light</p>');
  277. $skinsList.append($skinBlackLight);
  278. var $skinPurpleLight =
  279. $('<li />', { style: 'float:left; width: 33.33333%; padding: 5px;' })
  280. .append('<a href="javascript:void(0);" data-skin="skin-purple-light" style="display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)" class="clearfix full-opacity-hover">'
  281. + '<div><span style="display:block; width: 20%; float: left; height: 7px;" class="bg-purple-active"></span><span class="bg-purple" style="display:block; width: 80%; float: left; height: 7px;"></span></div>'
  282. + '<div><span style="display:block; width: 20%; float: left; height: 20px; background: #f9fafc;"></span><span style="display:block; width: 80%; float: left; height: 20px; background: #f4f5f7;"></span></div>'
  283. + '</a>'
  284. + '<p class="text-center no-margin" style="font-size: 12px">Purple Light</p>');
  285. $skinsList.append($skinPurpleLight);
  286. var $skinGreenLight =
  287. $('<li />', { style: 'float:left; width: 33.33333%; padding: 5px;' })
  288. .append('<a href="javascript:void(0);" data-skin="skin-green-light" style="display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)" class="clearfix full-opacity-hover">'
  289. + '<div><span style="display:block; width: 20%; float: left; height: 7px;" class="bg-green-active"></span><span class="bg-green" style="display:block; width: 80%; float: left; height: 7px;"></span></div>'
  290. + '<div><span style="display:block; width: 20%; float: left; height: 20px; background: #f9fafc;"></span><span style="display:block; width: 80%; float: left; height: 20px; background: #f4f5f7;"></span></div>'
  291. + '</a>'
  292. + '<p class="text-center no-margin" style="font-size: 12px">Green Light</p>');
  293. $skinsList.append($skinGreenLight);
  294. var $skinRedLight =
  295. $('<li />', { style: 'float:left; width: 33.33333%; padding: 5px;' })
  296. .append('<a href="javascript:void(0);" data-skin="skin-red-light" style="display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)" class="clearfix full-opacity-hover">'
  297. + '<div><span style="display:block; width: 20%; float: left; height: 7px;" class="bg-red-active"></span><span class="bg-red" style="display:block; width: 80%; float: left; height: 7px;"></span></div>'
  298. + '<div><span style="display:block; width: 20%; float: left; height: 20px; background: #f9fafc;"></span><span style="display:block; width: 80%; float: left; height: 20px; background: #f4f5f7;"></span></div>'
  299. + '</a>'
  300. + '<p class="text-center no-margin" style="font-size: 12px">Red Light</p>');
  301. $skinsList.append($skinRedLight);
  302. var $skinYellowLight =
  303. $('<li />', { style: 'float:left; width: 33.33333%; padding: 5px;' })
  304. .append('<a href="javascript:void(0);" data-skin="skin-yellow-light" style="display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)" class="clearfix full-opacity-hover">'
  305. + '<div><span style="display:block; width: 20%; float: left; height: 7px;" class="bg-yellow-active"></span><span class="bg-yellow" style="display:block; width: 80%; float: left; height: 7px;"></span></div>'
  306. + '<div><span style="display:block; width: 20%; float: left; height: 20px; background: #f9fafc;"></span><span style="display:block; width: 80%; float: left; height: 20px; background: #f4f5f7;"></span></div>'
  307. + '</a>'
  308. + '<p class="text-center no-margin" style="font-size: 12px;">Yellow Light</p>');
  309. $skinsList.append($skinYellowLight);
  310. $demoSettings.append('<h4 class="control-sidebar-heading">Skins</h4>');
  311. $demoSettings.append($skinsList);
  312. $tabPane.append($demoSettings);
  313. $('#control-sidebar-home-tab').after($tabPane);
  314. setup();
  315. })(jQuery, $.AdminLTE);