forked from mirror/MrDoc
99 lines
4.0 KiB
HTML
99 lines
4.0 KiB
HTML
{% extends 'app_doc/editor/create_base.html' %}
|
|
{% load static %}
|
|
{% load i18n %}
|
|
{% block title %}新建文档模板{% endblock %}
|
|
|
|
{% block head_toolbar %}
|
|
<a class="btn pull-left" aria-label="" href="{% url 'create_doc' %}?pid={{project.id}}" target="_blank">
|
|
<i class="fa fa-plus-square"></i> <span class="layui-hide-xs">新建模板</span>
|
|
</a>
|
|
<a class="btn pull-left" aria-label="" href="{% url 'manage_doctemp' %}?pid={{project.id}}" target="_blank">
|
|
<i class="fa fa-cubes"></i> <span class="layui-hide-xs">管理模板</span>
|
|
</a>
|
|
<a class="btn pull-left" aria-label="" href="{% url 'manage_project' %}" target="_blank">
|
|
<i class="fa fa-cubes"></i> <span class="layui-hide-xs">管理文集</span>
|
|
</a>
|
|
{% endblock %}
|
|
|
|
{% block left_opera %}
|
|
<div class="layui-form" style="padding: 10px;">
|
|
<div class="layui-row">
|
|
<div class="layui-col-md12" style="margin-bottom: 10px;">
|
|
<label class="doc-form-label">
|
|
<button class="layui-btn layui-btn-normal layui-btn-fluid" onclick="createDocTemp()">
|
|
<i class="fa fa-save"></i> 保存模板
|
|
</button>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
<div class="layui-col-md12" style="margin-bottom: 10px;">
|
|
<label class="doc-form-label">
|
|
<button class="layui-btn layui-btn-primary layui-btn-fluid" id="doc-cache-btn">
|
|
<i class="fa fa-save"></i> 本地缓存
|
|
</button>
|
|
</label>
|
|
</div>
|
|
<!-- 已有模板 -->
|
|
<div class="layui-row">
|
|
<div class="layui-card">
|
|
<div class="layui-card-header">现有模板</div>
|
|
<div class="layui-card-body">
|
|
{% for temp in doctemps %}
|
|
<li><a href="{% url 'modify_doctemp' temp.id %}" target="_blank" title="点击查看修改《{{temp.name}}》的内容"><i class="fa fa-file"></i> {{temp.name}}</a></li>
|
|
{% endfor %}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endblock %}
|
|
|
|
|
|
{% block content %}
|
|
<div class="create-doc-form">
|
|
<div class="layui-form" style="padding-bottom:10px;">
|
|
<div class="layui-input-block" style="margin-left:0px;">
|
|
<input type="text" name="doc-name" id="doctemp-name" required lay-verify="required" placeholder="请输入模板标题" autocomplete="off" class="layui-input">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div id="editor-md">
|
|
<textarea style="display:none;"></textarea>
|
|
</div>
|
|
{% endblock %}
|
|
|
|
{% block custom_script %}
|
|
<script>
|
|
//保存文档模板
|
|
createDocTemp = function(){
|
|
$('button.layui-btn').attr("disabled",true);
|
|
$('button.layui-btn').addClass('layui-btn-disabled');
|
|
layer.load(1);
|
|
if(editor_mode == 1){
|
|
var content = editor.getMarkdown()
|
|
}else if(editor_mode == 2){
|
|
var content = editor.getValue()
|
|
}
|
|
var data = {
|
|
'name':$("#doctemp-name").val(),
|
|
'content':content,
|
|
}
|
|
$.post("{% url 'create_doctemp' %}",data,function(r){
|
|
if(r.status){
|
|
//创建成功
|
|
layer.closeAll("loading");
|
|
window.localStorage.removeItem('mrdoc_doc_cache') // 清空文档缓存
|
|
layer.msg('保存成功',function(){
|
|
md_changed = false;
|
|
window.location.href = '/modify_doctemp/' + r.data + '/';
|
|
});
|
|
}else{
|
|
//创建失败
|
|
layer.closeAll("loading");
|
|
layer.msg('保存失败');
|
|
$('button.layui-btn').attr("disabled",false);
|
|
$('button.layui-btn').removeClass('layui-btn-disabled');
|
|
}
|
|
});
|
|
};
|
|
</script>
|
|
{% endblock %} |