No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

theme_tplfile_edit.htm 9.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. {include file="public/layout" /}
  2. <link rel="stylesheet" type="text/css" href="__SKIN__/js/codemirror/codemirror.css?v={$version}">
  3. <script type="text/javascript" src="__SKIN__/js/codemirror/codemirror.js?v={$version}"></script>
  4. <script type="text/javascript" src="__SKIN__/js/codemirror/mode/xml/xml.js?v={$version}"></script>
  5. <script type="text/javascript" src="__SKIN__/js/codemirror/mode/javascript/javascript.js?v={$version}"></script>
  6. <script type="text/javascript" src="__SKIN__/js/codemirror/mode/css/css.js?v={$version}"></script>
  7. <script type="text/javascript" src="__SKIN__/js/codemirror/mode/php/php.js?v={$version}"></script>
  8. <script type="text/javascript" src="__SKIN__/js/codemirror/mode/clike/clike.js?v={$version}"></script>
  9. <script type="text/javascript" src="__SKIN__/js/codemirror/mode/htmlmixed/htmlmixed.js?v={$version}"></script>
  10. <body style="background-color: #FFF; overflow: auto;min-width:auto;">
  11. <div id="toolTipLayer" style="position: absolute; z-index: 9999; display: none; visibility: visible; left: 95px; top: 573px;"></div>
  12. <div id="append_parent"></div>
  13. <div id="ajaxwaitid"></div>
  14. <div class="page" style="min-width:auto;box-shadow:none;">
  15. <form class="form-horizontal" id="post_form" action="{:url('Index/ajax_theme_tplfile_edit')}" method="post">
  16. <div class="ncap-form-default">
  17. <dl class="row">
  18. <dt class="tit">模板目录</dt>
  19. <dd class="opt">
  20. {$tpldirpath}
  21. <span class="err"></span>
  22. <p class="notic"></p>
  23. </dd>
  24. </dl>
  25. <dl class="row {if condition="$type != 'welcome'"}none{/if}">
  26. <dt class="tit">
  27. <label for="theme_title"><em>*</em>模板名称</label>
  28. </dt>
  29. <dd class="opt" style="width: auto;">
  30. <input type="text" name="theme_title" placeholder="" id="theme_title" value="{$info.theme_title}" class="input-txt" autocomplete="off">
  31. <span class="err"></span>
  32. <p class="notic"></p>
  33. </dd>
  34. </dl>
  35. <dl class="row">
  36. <dt class="tit">
  37. <label for="url"><em>*</em>文件名称</label>
  38. </dt>
  39. <dd class="opt">
  40. {$type}_<input type="text" name="filename" value="{$info.filename}" id="filename" placeholder="自定义" tabindex="2" onkeyup="this.value=this.value.replace(/[^\w\-]/g,'');" onpaste="this.value=this.value.replace(/[^\w\-]/g,'')" autocomplete="off">.htm
  41. <span class="err"></span>
  42. <p class="notic">只允许字母、数字、下划线、连接符的任意组合</p>
  43. <p class="red" id="txt_filename"></p>
  44. </dd>
  45. </dl>
  46. <dl class="row">
  47. <dt class="tit">
  48. <label for="content">HTML代码</label>
  49. </dt>
  50. <dd class="opt">
  51. <textarea name='content' id="content" style='width:99%;height:500px;background:#ffffff;' tabindex="3">{$content}</textarea>
  52. <span class="err"></span>
  53. <p class="notic"></p>
  54. </dd>
  55. </dl>
  56. <div class="bot">
  57. <input type="hidden" id="type" name="type" value="{$type}" />
  58. <input type="hidden" id="theme_id" name="theme_id" value="{$info['theme_id']}" />
  59. <input type="hidden" id="welcome_tplname" name="welcome_tplname" value="{$info['welcome_tplname']}" />
  60. <a href="JavaScript:void(0);" onclick="checkForm();" class="ncap-btn-big ncap-btn-green" id="submitBtn" tabindex="4">确认提交</a>
  61. <a href="JavaScript:void(0);" onclick="welcome_tplname_del(this);" class="ncap-btn-big ncap-btn-green" style="border: 1px solid #C9C9C9; background-color: #fff;color: #555;" >删除</a>
  62. </div>
  63. </div>
  64. </form>
  65. </div>
  66. <script type="text/javascript">
  67. var editor = '';
  68. $(function(){
  69. editor = CodeMirror.fromTextArea(document.getElementById('content'), {
  70. lineNumbers: true, // 显示行号
  71. lineWrapping: true, // 在行槽中添加行号显示器、折叠器、语法检测器`
  72. autofocus:true, //自动聚焦
  73. mode: 'text/html'
  74. });
  75. editor.setSize('auto','500px');
  76. $('#filename').keyup(function(){
  77. $.ajax({
  78. type: "POST",
  79. url: "{:url('Index/ajax_theme_tplfile_edit', ['nosubmit'=>1,'_ajax'=>1])}",
  80. data: $('#post_form').serialize(),
  81. dataType: 'json',
  82. success: function (res) {
  83. if(res.code == 1){
  84. $('#txt_filename').html('');
  85. } else {
  86. $('#txt_filename').html(res.msg);
  87. }
  88. }
  89. });
  90. });
  91. });
  92. function welcome_tplname_del(obj)
  93. {
  94. layer.confirm('确定删除?', {
  95. shade: layer_shade,
  96. area: ['480px', '190px'],
  97. move: false,
  98. title: '提示',
  99. btnAlign:'r',
  100. closeBtn: 3,
  101. btn: ['确定', '取消'], //按钮
  102. success: function () {
  103. $(".layui-layer-content").css('text-align', 'left');
  104. }
  105. }, function(){
  106. layer_loading('正在处理');
  107. var type = $('#type').val();
  108. var theme_id = $('#theme_id').val();
  109. $.ajax({
  110. type : 'POST',
  111. url : "{:url('Index/ajax_theme_tplfile_del', ['_ajax'=>1])}",
  112. data : {theme_id:theme_id, type:type, _ajax:1},
  113. dataType : 'json',
  114. success : function(res){
  115. if(res.code == 1){
  116. parent.layer.closeAll();
  117. var id = res.data.select_input_id;
  118. if ('login' == type) {
  119. // $('#'+id+'_'+res.data.theme_id, window.parent.document).text(res.data.filename);
  120. } else if ('welcome' == type) {
  121. if ($('#per_'+id+'_'+theme_id, window.parent.document).find('input[name=welcome_tplname]:checked').length == 1) {
  122. $($('#welcome_tplname', window.parent.document).find('input[name=welcome_tplname]').get(0)).attr('checked', true);
  123. }
  124. $('#per_'+id+'_'+theme_id, window.parent.document).remove();
  125. }
  126. parent.layer.msg(res.msg, {icon: 1, time: 1000});
  127. return false;
  128. }else{
  129. layer.closeAll();
  130. showErrorAlert(res.msg);
  131. }
  132. },
  133. error:function(e){
  134. layer.closeAll();
  135. showErrorAlert(e.responseText);
  136. }
  137. })
  138. }, function(index){
  139. layer.close(index);
  140. return false;// 取消
  141. }
  142. );
  143. }
  144. // 判断输入框是否为空
  145. function checkForm(){
  146. var type = $('#type').val();
  147. if ('welcome' == type) {
  148. if($('input[name=theme_title]').val() == ''){
  149. showErrorMsg('模板名称不能为空!');
  150. $('input[name=theme_title]').focus();
  151. return false;
  152. }
  153. }
  154. if($('input[name=filename]').val() == ''){
  155. showErrorMsg('文件名称不能为空!');
  156. $('input[name=filename]').focus();
  157. return false;
  158. }
  159. var content = editor.getValue();
  160. if(content == ''){
  161. showErrorMsg('HTML代码不能为空!');
  162. $('#content').focus();
  163. return false;
  164. }
  165. layer_loading('正在处理');
  166. var theme_title = $('#theme_title').val();
  167. var theme_id = $('#theme_id').val();
  168. var welcome_tplname = $('#welcome_tplname').val();
  169. $.ajax({
  170. type: "POST",
  171. url: "{:url('Index/ajax_theme_tplfile_edit', ['_ajax'=>1])}",
  172. data: {filename:$('#filename').val(), content:content, type:type, theme_title:theme_title, theme_id:theme_id, welcome_tplname:welcome_tplname},
  173. dataType: 'json',
  174. success: function (res) {
  175. if(res.code == 1){
  176. parent.layer.closeAll();
  177. var html = '';
  178. var id = res.data.select_input_id;
  179. if ('login' == type) {
  180. // $('#'+id+'_'+res.data.theme_id, window.parent.document).text(res.data.filename);
  181. } else if ('welcome' == type) {
  182. $('#'+id+'_'+res.data.theme_id, window.parent.document).text(res.data.theme_title);
  183. }
  184. parent.layer.msg(res.msg, {icon: 1, time: 1000});
  185. return false;
  186. }else{
  187. layer.closeAll();
  188. if (res.data.focus) {
  189. $('#'+res.data.focus).focus();
  190. }
  191. layer.msg(res.msg, {icon: 2});
  192. return false;
  193. }
  194. },
  195. error:function(e){
  196. layer.closeAll();
  197. layer.alert(e.responseText, {icon: 2, title:false});
  198. }
  199. });
  200. }
  201. </script>
  202. {include file="public/footer" /}