demo.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  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. /**
  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. /**
  28. * CSS rules for the menu
  29. *
  30. * @type Object
  31. */
  32. var menu_css = {
  33. "padding": "10px",
  34. "position": "fixed",
  35. "top": "70px",
  36. "right": "-250px",
  37. "background": "#fff",
  38. "border": "0px solid #ddd",
  39. "width": "250px",
  40. "z-index": "99999",
  41. "box-shadow": "0 1px 3px rgba(0,0,0,0.1)"
  42. };
  43. /**
  44. * CSS rules for the demo handle button
  45. *
  46. * @type Object
  47. */
  48. var handle_css = {
  49. "position": "fixed",
  50. "top": "70px",
  51. "right": "0",
  52. "background": "#fff",
  53. "border-radius": "5px 0px 0px 5px",
  54. "padding": "10px 15px",
  55. "font-size": "16px",
  56. "z-index": "99999",
  57. "cursor": "pointer",
  58. "color": "#3c8dbc",
  59. "box-shadow": "0 1px 3px rgba(0,0,0,0.1)"
  60. };
  61. //Create the handle
  62. var demo = $("<div />")
  63. .css(handle_css)
  64. .html("<i class='fa fa-gear'></i>")
  65. .addClass("no-print");
  66. //Create the menu
  67. var demo_settings = $("<div />")
  68. .css(menu_css)
  69. .addClass("no-print");
  70. demo_settings.append(
  71. "<h4 class='text-light-blue' style='margin: 0 0 5px 0; border-bottom: 1px solid #ddd; padding-bottom: 15px;'>"
  72. + "Layout Options"
  73. + "</h4>"
  74. //Fixed layout
  75. + "<div class='form-group'>"
  76. + "<div class='checkbox'>"
  77. + "<label>"
  78. + "<input type='checkbox' data-layout='layout-fixed'/> "
  79. + "Fixed layout"
  80. + "</label>"
  81. + "</div>"
  82. + "</div>"
  83. //Boxed layout
  84. + "<div class='form-group'>"
  85. + "<div class='checkbox'>"
  86. + "<label>"
  87. + "<input type='checkbox' data-layout='layout-boxed'/> "
  88. + "Boxed Layout"
  89. + "</label>"
  90. + "</div>"
  91. + "</div>"
  92. //Sidebar Toggle
  93. + "<div class='form-group'>"
  94. + "<div class='checkbox'>"
  95. + "<label>"
  96. + "<input type='checkbox' data-layout='sidebar-collapse'/> "
  97. + "Toggle Sidebar"
  98. + "</label>"
  99. + "</div>"
  100. + "</div>"
  101. //Control Sidebar Toggle
  102. + "<div class='form-group'>"
  103. + "<div class='checkbox'>"
  104. + "<label>"
  105. + "<input type='checkbox' data-controlsidebar='control-sidebar-open'/> "
  106. + "Toggle Control Sidebar Slide Effect"
  107. + "</label>"
  108. + "</div>"
  109. + "</div>"
  110. );
  111. var skins_list = $("<ul />", {"class": 'list-unstyled'});
  112. //Dark sidebar skins
  113. var skin_blue =
  114. $("<li />", {style: "float:left; width: 33.33333%; padding: 5px;"})
  115. .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'>"
  116. + "<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>"
  117. + "<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>"
  118. + "</a>"
  119. + "<p class='text-center'>Blue</p>");
  120. skins_list.append(skin_blue);
  121. var skin_black =
  122. $("<li />", {style: "float:left; width: 33.33333%; padding: 5px;"})
  123. .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'>"
  124. + "<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>"
  125. + "<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>"
  126. + "</a>"
  127. + "<p class='text-center'>Black</p>");
  128. skins_list.append(skin_black);
  129. var skin_purple =
  130. $("<li />", {style: "float:left; width: 33.33333%; padding: 5px;"})
  131. .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'>"
  132. + "<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>"
  133. + "<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>"
  134. + "</a>"
  135. + "<p class='text-center'>Purple</p>");
  136. skins_list.append(skin_purple);
  137. var skin_green =
  138. $("<li />", {style: "float:left; width: 33.33333%; padding: 5px;"})
  139. .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'>"
  140. + "<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>"
  141. + "<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>"
  142. + "</a>"
  143. + "<p class='text-center'>Green</p>");
  144. skins_list.append(skin_green);
  145. var skin_red =
  146. $("<li />", {style: "float:left; width: 33.33333%; padding: 5px;"})
  147. .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'>"
  148. + "<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>"
  149. + "<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>"
  150. + "</a>"
  151. + "<p class='text-center'>Red</p>");
  152. skins_list.append(skin_red);
  153. var skin_yellow =
  154. $("<li />", {style: "float:left; width: 33.33333%; padding: 5px;"})
  155. .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'>"
  156. + "<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>"
  157. + "<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>"
  158. + "</a>"
  159. + "<p class='text-center'>Yellow</p>");
  160. skins_list.append(skin_yellow);
  161. //Light sidebar skins
  162. var skin_blue_light =
  163. $("<li />", {style: "float:left; width: 33.33333%; padding: 5px;"})
  164. .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'>"
  165. + "<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>"
  166. + "<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>"
  167. + "</a>"
  168. + "<p class='text-center' style='font-size: 12px'>Blue Light</p>");
  169. skins_list.append(skin_blue_light);
  170. var skin_black_light =
  171. $("<li />", {style: "float:left; width: 33.33333%; padding: 5px;"})
  172. .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'>"
  173. + "<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>"
  174. + "<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>"
  175. + "</a>"
  176. + "<p class='text-center' style='font-size: 12px'>Black Light</p>");
  177. skins_list.append(skin_black_light);
  178. var skin_purple_light =
  179. $("<li />", {style: "float:left; width: 33.33333%; padding: 5px;"})
  180. .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'>"
  181. + "<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>"
  182. + "<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>"
  183. + "</a>"
  184. + "<p class='text-center' style='font-size: 12px'>Purple Light</p>");
  185. skins_list.append(skin_purple_light);
  186. var skin_green_light =
  187. $("<li />", {style: "float:left; width: 33.33333%; padding: 5px;"})
  188. .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'>"
  189. + "<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>"
  190. + "<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>"
  191. + "</a>"
  192. + "<p class='text-center' style='font-size: 12px'>Green Light</p>");
  193. skins_list.append(skin_green_light);
  194. var skin_red_light =
  195. $("<li />", {style: "float:left; width: 33.33333%; padding: 5px;"})
  196. .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'>"
  197. + "<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>"
  198. + "<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>"
  199. + "</a>"
  200. + "<p class='text-center' style='font-size: 12px'>Red Light</p>");
  201. skins_list.append(skin_red_light);
  202. var skin_yellow_light =
  203. $("<li />", {style: "float:left; width: 33.33333%; padding: 5px;"})
  204. .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'>"
  205. + "<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>"
  206. + "<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>"
  207. + "</a>"
  208. + "<p class='text-center' style='font-size: 12px'>Yellow Light</p>");
  209. skins_list.append(skin_yellow_light);
  210. demo_settings.append("<h4 class='text-light-blue' style='margin: 0 0 5px 0; border-bottom: 1px solid #ddd; padding-bottom: 15px;'>Skins</h4>");
  211. demo_settings.append(skins_list);
  212. demo.click(function () {
  213. if (!$(this).hasClass("open")) {
  214. $(this).animate({"right": "250px"});
  215. demo_settings.animate({"right": "0"});
  216. $(this).addClass("open");
  217. } else {
  218. $(this).animate({"right": "0"});
  219. demo_settings.animate({"right": "-250px"});
  220. $(this).removeClass("open");
  221. }
  222. });
  223. $("body").append(demo);
  224. $("body").append(demo_settings);
  225. setup();
  226. /**
  227. * Toggles layout classes
  228. *
  229. * @param String cls the layout class to toggle
  230. * @returns void
  231. */
  232. function change_layout(cls) {
  233. $("body").toggleClass(cls);
  234. $.AdminLTE.layout.fixSidebar();
  235. }
  236. /**
  237. * Replaces the old skin with the new skin
  238. * @param String cls the new skin class
  239. * @returns Boolean false to prevent link's default action
  240. */
  241. function change_skin(cls) {
  242. $.each(my_skins, function (i) {
  243. $("body").removeClass(my_skins[i]);
  244. });
  245. $("body").addClass(cls);
  246. store('skin', cls);
  247. return false;
  248. }
  249. /**
  250. * Store a new settings in the browser
  251. *
  252. * @param String name Name of the setting
  253. * @param String val Value of the setting
  254. * @returns void
  255. */
  256. function store(name, val) {
  257. if (typeof (Storage) !== "undefined") {
  258. localStorage.setItem(name, val);
  259. } else {
  260. alert('Please use a modern browser to properly view this template!');
  261. }
  262. }
  263. /**
  264. * Get a prestored setting
  265. *
  266. * @param String name Name of of the setting
  267. * @returns String The value of the setting | null
  268. */
  269. function get(name) {
  270. if (typeof (Storage) !== "undefined") {
  271. return localStorage.getItem(name);
  272. } else {
  273. alert('Please use a modern browser to properly view this template!');
  274. }
  275. }
  276. /**
  277. * Retrieve default settings and apply them to the template
  278. *
  279. * @returns void
  280. */
  281. function setup() {
  282. var tmp = get('skin');
  283. if (tmp && $.inArray(tmp, my_skins))
  284. change_skin(tmp);
  285. //Add the change skin listener
  286. $("[data-skin]").on('click', function (e) {
  287. e.preventDefault();
  288. change_skin($(this).data('skin'));
  289. });
  290. //Add the layout manager
  291. $("[data-layout]").on('click', function () {
  292. change_layout($(this).data('layout'));
  293. });
  294. $("[data-controlsidebar]").on('click', function () {
  295. change_layout($(this).data('controlsidebar'));
  296. var slide = !$.AdminLTE.options.controlSidebarOptions.slide;
  297. $.AdminLTE.options.controlSidebarOptions.slide = slide;
  298. if(!slide)
  299. $('.control-sidebar').removeClass('control-sidebar-open');
  300. });
  301. }
  302. })(jQuery);