Açıklama Yok
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.

ajax_newtpl.htm 5.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. {include file="public/layout" /}
  2. <link rel="stylesheet" type="text/css" href="__SKIN__/js/codemirror/codemirror.css">
  3. <script type="text/javascript" src="__SKIN__/js/codemirror/codemirror.js"></script>
  4. <script type="text/javascript" src="__SKIN__/js/codemirror/mode/xml/xml.js"></script>
  5. <script type="text/javascript" src="__SKIN__/js/codemirror/mode/javascript/javascript.js"></script>
  6. <script type="text/javascript" src="__SKIN__/js/codemirror/mode/css/css.js"></script>
  7. <script type="text/javascript" src="__SKIN__/js/codemirror/mode/php/php.js"></script>
  8. <script type="text/javascript" src="__SKIN__/js/codemirror/mode/clike/clike.js"></script>
  9. <script type="text/javascript" src="__SKIN__/js/codemirror/mode/htmlmixed/htmlmixed.js"></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('Archives/ajax_newtpl')}" method="post">
  16. <div class="ncap-form-default">
  17. <dl class="row">
  18. <dt class="tit">模板目录</dt>
  19. <dd class="opt">
  20. /template/{$tpl_theme}<select name="tpldir" id="tpldir" tabindex="1">
  21. {volist name="tpldirList" id="vo"}
  22. <option value="{$vo}">{$vo}</option>
  23. {/volist}
  24. </select>
  25. <span class="err"></span>
  26. <p class="notic"></p>
  27. </dd>
  28. </dl>
  29. <dl class="row">
  30. <dt class="tit">
  31. <label for="url">文件名称</label>
  32. </dt>
  33. <dd class="opt">
  34. {$type}_{$nid}<font id="font_filename"></font><input type="text" name="filename" value="" id="filename" placeholder="自定义" tabindex="2">.htm
  35. <span class="err"></span>
  36. <p class="notic">只允许字母、数字、下划线、连接符的任意组合</p>
  37. <p class="red" id="txt_filename"></p>
  38. </dd>
  39. </dl>
  40. <dl class="row">
  41. <dt class="tit">
  42. <label for="content">HTML代码</label>
  43. </dt>
  44. <dd class="opt">
  45. <textarea name='content' id="content" style='width:99%;height:500px;background:#ffffff;' tabindex="3">{$content|default=''}</textarea>
  46. <span class="err"></span>
  47. <p class="notic"></p>
  48. </dd>
  49. </dl>
  50. <div class="bot">
  51. <input type="hidden" name="type" id="type" value="{$type}" />
  52. <input type="hidden" name="nid" id="nid" value="{$nid}" />
  53. <a href="JavaScript:void(0);" onclick="checkForm();" class="ncap-btn-big ncap-btn-green" id="submitBtn" tabindex="4">确认提交</a>
  54. </div>
  55. </div>
  56. </form>
  57. </div>
  58. <script type="text/javascript">
  59. var editor = '';
  60. $(function(){
  61. editor = CodeMirror.fromTextArea(document.getElementById('content'), {
  62. lineNumbers: true, // 显示行号
  63. lineWrapping: true, // 在行槽中添加行号显示器、折叠器、语法检测器`
  64. autofocus:true, //自动聚焦
  65. mode: 'text/html'
  66. });
  67. editor.setSize('auto','500px');
  68. $('#filename').keyup(function(){
  69. var filename = $(this).val();
  70. if (filename) {
  71. $('#font_filename').html('_');
  72. } else {
  73. $('#font_filename').html('');
  74. }
  75. $.ajax({
  76. type: "POST",
  77. url: "{:url('Archives/ajax_newtpl', ['nosubmit'=>1,'_ajax'=>1])}",
  78. data: $('#post_form').serialize(),
  79. dataType: 'json',
  80. success: function (res) {
  81. if(res.code == 1){
  82. $('#txt_filename').html('');
  83. } else {
  84. $('#txt_filename').html(res.msg);
  85. }
  86. }
  87. });
  88. });
  89. });
  90. // 判断输入框是否为空
  91. function checkForm(){
  92. if($.trim($('#tpldir').val()) == ''){
  93. showErrorMsg('模板目录不能为空!');
  94. $('#tpldir').focus();
  95. return false;
  96. }
  97. layer_loading('正在处理');
  98. $.ajax({
  99. type: "POST",
  100. url: "{:url('Archives/ajax_newtpl', ['_ajax'=>1])}",
  101. data: {tpldir:$('#tpldir').val(), filename:$('#filename').val(), content:editor.getValue(), type:$('#type').val(), nid:$('#nid').val()},
  102. dataType: 'json',
  103. success: function (res) {
  104. if(res.code == 1){
  105. parent.layer.closeAll();
  106. if ('lists' == res.data.type) {
  107. var id = 'templist';
  108. } else {
  109. var id = 'tempview';
  110. }
  111. $('#'+id, window.parent.document).append('<option value="'+res.data.filename+'" selected="true">'+res.data.filename+'</option>');
  112. parent.layer.msg(res.msg, {icon: 1, time: 1000});
  113. return false;
  114. }else{
  115. layer.closeAll();
  116. if (res.data.focus) {
  117. $('#'+res.data.focus).focus();
  118. }
  119. layer.msg(res.msg, {icon: 2});
  120. return false;
  121. }
  122. },
  123. error:function(e){
  124. layer.closeAll();
  125. layer.alert(e.responseText, {icon: 2, title:false});
  126. }
  127. });
  128. }
  129. </script>
  130. {include file="public/footer" /}