design.html 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. <include file="public@header"/>
  2. <style>
  3. html, body {
  4. padding: 0;
  5. height: 100%;
  6. margin: 0;
  7. overflow: hidden;
  8. background: #eee;
  9. }
  10. #simulator {
  11. margin: 0 auto;
  12. display: block;
  13. }
  14. #setting-iframe {
  15. width: 100%;
  16. height: 100%;
  17. }
  18. .setting-panel-wrap {
  19. position: fixed;
  20. left: 0;
  21. bottom: 0;
  22. top: 0;
  23. width: 420px;
  24. border-right: 1px solid #eee;
  25. display: none;
  26. background: #fff;
  27. z-index: 999;
  28. }
  29. #setting-iframe-wrap {
  30. position: absolute;
  31. top: 0;
  32. bottom: 50px;
  33. right: 0;
  34. left: 0;
  35. }
  36. .setting-panel-wrap .panel {
  37. }
  38. .setting-panel-wrap .footer {
  39. position: absolute;
  40. bottom: 0;
  41. width: 100%;
  42. height: 50px;
  43. border-top: 1px solid #eee;
  44. padding: 8px;
  45. }
  46. #close-setting-panel {
  47. position: absolute;
  48. top: 10px;
  49. right: 10px;
  50. z-index: 99;
  51. font-size: 18px;
  52. }
  53. #update-theme-btn:focus {
  54. outline: none;
  55. }
  56. #think_page_trace {
  57. display: none !important;
  58. }
  59. #think_page_trace_open {
  60. display: none !important;
  61. }
  62. .simulator-pc {
  63. width: 100%;
  64. height: 100%;
  65. }
  66. .simulator-pad {
  67. width: 1180px;
  68. height: 820px;
  69. transform: scale(0.7);
  70. border: 1px solid #aaa;
  71. }
  72. .simulator-mobile {
  73. width: 375px;
  74. height: 667px;
  75. transform: scale(0.9);
  76. border: 1px solid #aaa;
  77. }
  78. .design-btn {
  79. position: fixed;
  80. z-index: 99;
  81. font-size: 20px;
  82. line-height: 50px;
  83. width: 50px;
  84. border: 1px solid #eee;
  85. text-align: center;
  86. border-radius: 50%;
  87. cursor: pointer;
  88. background: #fff;
  89. }
  90. .design-btn:hover {
  91. background: #eee;
  92. border-color: #ddd;
  93. }
  94. #update-theme-btn {
  95. top: 30px;
  96. right: 30px;
  97. }
  98. #show-setting-panel {
  99. top: 100px;
  100. right: 30px;
  101. }
  102. #simulator-pc-btn {
  103. top: 170px;
  104. right: 30px;
  105. }
  106. #simulator-pad-btn {
  107. top: 240px;
  108. right: 30px;
  109. }
  110. #simulator-mobile-btn {
  111. top: 310px;
  112. right: 30px;
  113. }
  114. </style>
  115. <script>
  116. setInterval(function () {
  117. $.ajax({
  118. url: "{:url('Theme/design')}?theme={:input('param.theme')}&status=1",
  119. type: 'post'
  120. });
  121. }, 2000);
  122. </script>
  123. </head>
  124. <body>
  125. <a class="design-btn" id="show-setting-panel" title="编辑当前页" data-toggle="tooltip"><i class="fa fa-pencil"></i></a>
  126. <a class="design-btn" id="update-theme-btn" title="刷新当前页" data-toggle="tooltip"><i class="fa fa-refresh"></i></a>
  127. <a class="design-btn" id="simulator-mobile-btn" title="手机" data-toggle="tooltip"><i class="fa fa-mobile"></i></a>
  128. <a class="design-btn" id="simulator-pad-btn" title="Pad" data-toggle="tooltip"><i class="fa fa-tablet"></i></a>
  129. <a class="design-btn" id="simulator-pc-btn" title="PC" data-toggle="tooltip"><i class="fa fa-desktop"></i></a>
  130. <div class="setting-panel-wrap">
  131. <a href="javascript:;" id="close-setting-panel"><i class="fa fa-close"></i></a>
  132. <div id="setting-iframe-wrap">
  133. <iframe frameborder="0" id="setting-iframe"></iframe>
  134. </div>
  135. <div class="footer text-center">
  136. <a id="save-btn" class="btn btn-primary">保存</a>
  137. </div>
  138. </div>
  139. <iframe src="__ROOT__/?_design_theme={:input('param.theme')}" frameborder="0" id="simulator"
  140. class="simulator-pc"></iframe>
  141. <script src="__STATIC__/js/admin.js?v={$_static_version}"></script>
  142. <script>
  143. var simulator = $('#simulator').get(0).contentWindow;
  144. var $simulator = $(simulator);
  145. var $settingIframe = $('#setting-iframe');
  146. var simulatorNeedRefresh = true;
  147. $('#update-theme-btn').click(function () {
  148. simulator.location.reload(true);
  149. });
  150. $('#simulator-pc-btn').click(function () {
  151. $('#simulator').attr('class', '').addClass('simulator-pc');
  152. });
  153. $('#simulator-pad-btn').click(function () {
  154. $('#simulator').attr('class', '').addClass('simulator-pad');
  155. });
  156. $('#simulator-mobile-btn').click(function () {
  157. $('#simulator').attr('class', '');
  158. $('#simulator').addClass('simulator-mobile');
  159. });
  160. $('#save-btn').click(function () {
  161. $settingIframe.get(0).contentWindow.confirm();
  162. });
  163. $('#close-setting-panel').click(function () {
  164. hideSettingPanel();
  165. });
  166. $('#show-setting-panel').click(function () {
  167. showSettingPanel();
  168. });
  169. function hideSettingPanel() {
  170. $('.setting-panel-wrap').fadeOut(function () {
  171. $('#show-setting-panel').show();
  172. });
  173. }
  174. function showSettingPanel() {
  175. $('.setting-panel-wrap').fadeIn();
  176. // $('#show-setting-panel').hide();
  177. }
  178. function showDesignBtn() {
  179. if (!$('.setting-panel-wrap').is(':visible')) {
  180. $('#show-setting-panel').show();
  181. }
  182. }
  183. function hideDesignBtn() {
  184. $('.setting-panel-wrap').hide();
  185. $('#show-setting-panel').hide();
  186. }
  187. function settingIframeRefresh() {
  188. $settingIframe.attr('src', "{:url('Theme/fileSetting')}?theme={:input('param.theme')}&file=" + encodeURIComponent(simulator._themeFile));
  189. }
  190. function simulatorRefresh() {
  191. if (simulatorNeedRefresh) {
  192. settingIframeRefresh();
  193. $simulator.load(function () {
  194. $(simulator.document).on('click', 'a', function () {
  195. var target = $(this).attr('target');
  196. var href = $(this).attr('href');
  197. if (target == '_blank' && href.indexOf('http') < 0) {
  198. simulator.location.href = href;
  199. return false;
  200. }
  201. });
  202. });
  203. }
  204. simulatorNeedRefresh = true;
  205. }
  206. function afterSaveSetting() {
  207. simulatorNeedRefresh = false;
  208. simulator.location.reload();
  209. }
  210. </script>
  211. </body>
  212. </html>