demo.js 8.2 KB

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