demo.js 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. var my_skins = [
  2. "skin-blue",
  3. "skin-black",
  4. "skin-red",
  5. "skin-yellow",
  6. "skin-purple",
  7. "skin-green",
  8. "skin-blue-light",
  9. "skin-black-light",
  10. "skin-red-light",
  11. "skin-yellow-light",
  12. "skin-purple-light",
  13. "skin-green-light"
  14. ];
  15. $(function () {
  16. /* For demo purposes */
  17. var demo = $("<div />").css({
  18. position: "fixed",
  19. top: "70px",
  20. right: "0",
  21. background: "#fff",
  22. "border-radius": "5px 0px 0px 5px",
  23. padding: "10px 15px",
  24. "font-size": "16px",
  25. "z-index": "99999",
  26. cursor: "pointer",
  27. color: "#3c8dbc",
  28. "box-shadow": "0 1px 3px rgba(0,0,0,0.1)"
  29. }).html("<i class='fa fa-gear'></i>").addClass("no-print");
  30. var demo_settings = $("<div />").css({
  31. "padding": "10px",
  32. position: "fixed",
  33. top: "70px",
  34. right: "-250px",
  35. background: "#fff",
  36. border: "0px solid #ddd",
  37. "width": "250px",
  38. "z-index": "99999",
  39. "box-shadow": "0 1px 3px rgba(0,0,0,0.1)"
  40. }).addClass("no-print");
  41. demo_settings.append(
  42. "<h4 class='text-light-blue' style='margin: 0 0 5px 0; border-bottom: 1px solid #ddd; padding-bottom: 15px;'>Layout Options</h4>"
  43. //Fixed layout
  44. + "<div class='form-group'>"
  45. + "<div class='checkbox'>"
  46. + "<label>"
  47. + "<input type='checkbox' onchange='change_layout(\"fixed\");'/> "
  48. + "Fixed layout"
  49. + "</label>"
  50. + "</div>"
  51. + "</div>"
  52. //Boxed layout
  53. + "<div class='form-group'>"
  54. + "<div class='checkbox'>"
  55. + "<label>"
  56. + "<input type='checkbox' onchange='change_layout(\"layout-boxed\");'/> "
  57. + "Boxed Layout"
  58. + "</label>"
  59. + "</div>"
  60. + "</div>"
  61. //Sidebar Collapse
  62. + "<div class='form-group'>"
  63. + "<div class='checkbox'>"
  64. + "<label>"
  65. + "<input type='checkbox' onchange='change_layout(\"sidebar-collapse\");'/> "
  66. + "Collapsed Sidebar"
  67. + "</label>"
  68. + "</div>"
  69. + "</div>"
  70. );
  71. var skins_list = $("<ul />", {"class": 'list-unstyled'});
  72. var skin_blue =
  73. $("<li />", {style: "float:left; width: 50%; padding: 5px;"})
  74. .append("<a href='javascript:void(0);' onclick='change_skin(\"skin-blue\")' style='display: block; box-shadow: -1px 1px 2px rgba(0,0,0,0.0);' class='clearfix full-opacity-hover'>"
  75. + "<div><span style='display:block; width: 20%; float: left; height: 10px; background: #367fa9;'></span><span class='bg-light-blue' style='display:block; width: 80%; float: left; height: 10px;'></span></div>"
  76. + "<div><span style='display:block; width: 20%; float: left; height: 40px; background: #222d32;'></span><span style='display:block; width: 80%; float: left; height: 40px; background: #f4f5f7;'></span></div>"
  77. + "<p class='text-center'>Skin Blue</p>"
  78. + "</a>");
  79. skins_list.append(skin_blue);
  80. var skin_black =
  81. $("<li />", {style: "float:left; width: 50%; padding: 5px;"})
  82. .append("<a href='javascript:void(0);' onclick='change_skin(\"skin-black\")' style='display: block; box-shadow: -1px 1px 2px rgba(0,0,0,0.0);' class='clearfix full-opacity-hover'>"
  83. + "<div style='box-shadow: 0 0 2px rgba(0,0,0,0.1)' class='clearfix'><span style='display:block; width: 20%; float: left; height: 10px; background: #fefefe;'></span><span style='display:block; width: 80%; float: left; height: 10px; background: #fefefe;'></span></div>"
  84. + "<div><span style='display:block; width: 20%; float: left; height: 40px; background: #222;'></span><span style='display:block; width: 80%; float: left; height: 40px; background: #f4f5f7;'></span></div>"
  85. + "<p class='text-center'>Skin Black</p>"
  86. + "</a>");
  87. skins_list.append(skin_black);
  88. var skin_purple =
  89. $("<li />", {style: "float:left; width: 50%; padding: 5px;"})
  90. .append("<a href='javascript:void(0);' onclick='change_skin(\"skin-purple\")' style='display: block; box-shadow: -1px 1px 2px rgba(0,0,0,0.0);' class='clearfix full-opacity-hover'>"
  91. + "<div><span style='display:block; width: 20%; float: left; height: 10px;' class='bg-purple-active'></span><span class='bg-purple' style='display:block; width: 80%; float: left; height: 10px;'></span></div>"
  92. + "<div><span style='display:block; width: 20%; float: left; height: 40px; background: #222d32;'></span><span style='display:block; width: 80%; float: left; height: 40px; background: #f4f5f7;'></span></div>"
  93. + "<p class='text-center'>Skin Purple</p>"
  94. + "</a>");
  95. skins_list.append(skin_purple);
  96. var skin_green =
  97. $("<li />", {style: "float:left; width: 50%; padding: 5px;"})
  98. .append("<a href='javascript:void(0);' onclick='change_skin(\"skin-green\")' style='display: block; box-shadow: -1px 1px 2px rgba(0,0,0,0.0);' class='clearfix full-opacity-hover'>"
  99. + "<div><span style='display:block; width: 20%; float: left; height: 10px;' class='bg-green-active'></span><span class='bg-green' style='display:block; width: 80%; float: left; height: 10px;'></span></div>"
  100. + "<div><span style='display:block; width: 20%; float: left; height: 40px; background: #222d32;'></span><span style='display:block; width: 80%; float: left; height: 40px; background: #f4f5f7;'></span></div>"
  101. + "<p class='text-center'>Skin Green</p>"
  102. + "</a>");
  103. skins_list.append(skin_green);
  104. var skin_red =
  105. $("<li />", {style: "float:left; width: 50%; padding: 5px;"})
  106. .append("<a href='javascript:void(0);' onclick='change_skin(\"skin-red\")' style='display: block; box-shadow: -1px 1px 2px rgba(0,0,0,0.0);' class='clearfix full-opacity-hover'>"
  107. + "<div><span style='display:block; width: 20%; float: left; height: 10px;' class='bg-red-active'></span><span class='bg-red' style='display:block; width: 80%; float: left; height: 10px;'></span></div>"
  108. + "<div><span style='display:block; width: 20%; float: left; height: 40px; background: #222d32;'></span><span style='display:block; width: 80%; float: left; height: 40px; background: #f4f5f7;'></span></div>"
  109. + "<p class='text-center'>Skin Red</p>"
  110. + "</a>");
  111. skins_list.append(skin_red);
  112. var skin_yellow =
  113. $("<li />", {style: "float:left; width: 50%; padding: 5px;"})
  114. .append("<a href='javascript:void(0);' onclick='change_skin(\"skin-yellow\")' style='display: block; box-shadow: -1px 1px 2px rgba(0,0,0,0.0);' class='clearfix full-opacity-hover'>"
  115. + "<div><span style='display:block; width: 20%; float: left; height: 10px;' class='bg-yellow-active'></span><span class='bg-yellow' style='display:block; width: 80%; float: left; height: 10px;'></span></div>"
  116. + "<div><span style='display:block; width: 20%; float: left; height: 40px; background: #222d32;'></span><span style='display:block; width: 80%; float: left; height: 40px; background: #f4f5f7;'></span></div>"
  117. + "<p class='text-center'>Skin Yellow</p>"
  118. + "</a>");
  119. skins_list.append(skin_yellow);
  120. demo_settings.append("<h4 class='text-light-blue' style='margin: 0 0 5px 0; border-bottom: 1px solid #ddd; padding-bottom: 15px;'>Skins</h4>");
  121. demo_settings.append(skins_list);
  122. demo.click(function () {
  123. if (!$(this).hasClass("open")) {
  124. $(this).animate({"right": "250px"});
  125. demo_settings.animate({"right": "0"});
  126. $(this).addClass("open");
  127. } else {
  128. $(this).animate({"right": "0"});
  129. demo_settings.animate({"right": "-250px"});
  130. $(this).removeClass("open");
  131. }
  132. });
  133. $("body").append(demo);
  134. $("body").append(demo_settings);
  135. setup();
  136. });
  137. function change_layout(cls) {
  138. $("body").toggleClass(cls);
  139. $.AdminLTE.layout.fixSidebar();
  140. }
  141. function change_skin(cls) {
  142. $.each(my_skins, function (i) {
  143. $("body").removeClass(my_skins[i]);
  144. });
  145. $("body").addClass(cls);
  146. store('skin', cls);
  147. return false;
  148. }
  149. function store(name, val) {
  150. if (typeof (Storage) !== "undefined") {
  151. localStorage.setItem(name, val);
  152. } else {
  153. alert('Please use a modern browser to properly view this template!');
  154. }
  155. }
  156. function get(name) {
  157. if (typeof (Storage) !== "undefined") {
  158. return localStorage.getItem(name);
  159. } else {
  160. alert('Please use a modern browser to properly view this template!');
  161. }
  162. }
  163. function setup() {
  164. var tmp = get('skin');
  165. if (tmp && $.inArray(tmp, my_skins))
  166. change_skin(tmp);
  167. change_skin('skin-blue-light');
  168. }