demo.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  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"
  31. });
  32. //Create the tab button
  33. var tab_button = $("<li />")
  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>Toggles between slide over content and push content effects.</p>"
  79. + "</div>"
  80. );
  81. var skins_list = $("<ul />", {"class": 'list-unstyled clearfix'});
  82. //Dark sidebar skins
  83. var skin_blue =
  84. $("<li />", {style: "float:left; width: 33.33333%; padding: 5px;"})
  85. .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'>"
  86. + "<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>"
  87. + "<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>"
  88. + "</a>"
  89. + "<p class='text-center no-margin'>Blue</p>");
  90. skins_list.append(skin_blue);
  91. var skin_black =
  92. $("<li />", {style: "float:left; width: 33.33333%; padding: 5px;"})
  93. .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'>"
  94. + "<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>"
  95. + "<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>"
  96. + "</a>"
  97. + "<p class='text-center no-margin'>Black</p>");
  98. skins_list.append(skin_black);
  99. var skin_purple =
  100. $("<li />", {style: "float:left; width: 33.33333%; padding: 5px;"})
  101. .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'>"
  102. + "<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>"
  103. + "<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>"
  104. + "</a>"
  105. + "<p class='text-center no-margin'>Purple</p>");
  106. skins_list.append(skin_purple);
  107. var skin_green =
  108. $("<li />", {style: "float:left; width: 33.33333%; padding: 5px;"})
  109. .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'>"
  110. + "<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>"
  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'>Green</p>");
  114. skins_list.append(skin_green);
  115. var skin_red =
  116. $("<li />", {style: "float:left; width: 33.33333%; padding: 5px;"})
  117. .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'>"
  118. + "<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>"
  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'>Red</p>");
  122. skins_list.append(skin_red);
  123. var skin_yellow =
  124. $("<li />", {style: "float:left; width: 33.33333%; padding: 5px;"})
  125. .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'>"
  126. + "<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>"
  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'>Yellow</p>");
  130. skins_list.append(skin_yellow);
  131. //Light sidebar skins
  132. var skin_blue_light =
  133. $("<li />", {style: "float:left; width: 33.33333%; padding: 5px;"})
  134. .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'>"
  135. + "<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>"
  136. + "<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>"
  137. + "</a>"
  138. + "<p class='text-center no-margin' style='font-size: 12px'>Blue Light</p>");
  139. skins_list.append(skin_blue_light);
  140. var skin_black_light =
  141. $("<li />", {style: "float:left; width: 33.33333%; padding: 5px;"})
  142. .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'>"
  143. + "<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>"
  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'>Black Light</p>");
  147. skins_list.append(skin_black_light);
  148. var skin_purple_light =
  149. $("<li />", {style: "float:left; width: 33.33333%; padding: 5px;"})
  150. .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'>"
  151. + "<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>"
  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'>Purple Light</p>");
  155. skins_list.append(skin_purple_light);
  156. var skin_green_light =
  157. $("<li />", {style: "float:left; width: 33.33333%; padding: 5px;"})
  158. .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'>"
  159. + "<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>"
  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'>Green Light</p>");
  163. skins_list.append(skin_green_light);
  164. var skin_red_light =
  165. $("<li />", {style: "float:left; width: 33.33333%; padding: 5px;"})
  166. .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'>"
  167. + "<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>"
  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'>Red Light</p>");
  171. skins_list.append(skin_red_light);
  172. var skin_yellow_light =
  173. $("<li />", {style: "float:left; width: 33.33333%; padding: 5px;"})
  174. .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'>"
  175. + "<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>"
  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;'>Yellow Light</p>");
  179. skins_list.append(skin_yellow_light);
  180. demo_settings.append("<h4 class='control-sidebar-heading'>Skins</h4>");
  181. demo_settings.append(skins_list);
  182. tab_pane.append(demo_settings);
  183. $("#control-sidebar-settings-tab").before(tab_pane);
  184. setup();
  185. /**
  186. * Toggles layout classes
  187. *
  188. * @param String cls the layout class to toggle
  189. * @returns void
  190. */
  191. function change_layout(cls) {
  192. $("body").toggleClass(cls);
  193. AdminLTE.layout.fixSidebar();
  194. //Fix the problem with right sidebar and layout boxed
  195. if(cls == "layout-boxed")
  196. AdminLTE.controlSidebar._fix($(".control-sidebar-bg"));
  197. }
  198. /**
  199. * Replaces the old skin with the new skin
  200. * @param String cls the new skin class
  201. * @returns Boolean false to prevent link's default action
  202. */
  203. function change_skin(cls) {
  204. $.each(my_skins, function (i) {
  205. $("body").removeClass(my_skins[i]);
  206. });
  207. $("body").addClass(cls);
  208. store('skin', cls);
  209. return false;
  210. }
  211. /**
  212. * Store a new settings in the browser
  213. *
  214. * @param String name Name of the setting
  215. * @param String val Value of the setting
  216. * @returns void
  217. */
  218. function store(name, val) {
  219. if (typeof (Storage) !== "undefined") {
  220. localStorage.setItem(name, val);
  221. } else {
  222. alert('Please use a modern browser to properly view this template!');
  223. }
  224. }
  225. /**
  226. * Get a prestored setting
  227. *
  228. * @param String name Name of of the setting
  229. * @returns String The value of the setting | null
  230. */
  231. function get(name) {
  232. if (typeof (Storage) !== "undefined") {
  233. return localStorage.getItem(name);
  234. } else {
  235. alert('Please use a modern browser to properly view this template!');
  236. }
  237. }
  238. /**
  239. * Retrieve default settings and apply them to the template
  240. *
  241. * @returns void
  242. */
  243. function setup() {
  244. var tmp = get('skin');
  245. if (tmp && $.inArray(tmp, my_skins))
  246. change_skin(tmp);
  247. //Add the change skin listener
  248. $("[data-skin]").on('click', function (e) {
  249. e.preventDefault();
  250. change_skin($(this).data('skin'));
  251. });
  252. //Add the layout manager
  253. $("[data-layout]").on('click', function () {
  254. change_layout($(this).data('layout'));
  255. });
  256. $("[data-controlsidebar]").on('click', function () {
  257. change_layout($(this).data('controlsidebar'));
  258. var slide = !AdminLTE.options.controlSidebarOptions.slide;
  259. AdminLTE.options.controlSidebarOptions.slide = slide;
  260. if (!slide)
  261. $('.control-sidebar').removeClass('control-sidebar-open');
  262. });
  263. }
  264. })(jQuery, $.AdminLTE);