demo.js 16 KB

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