Skip to content

Commit

Permalink
增加一键(Ctrl+b)打印或导出pdf功能
Browse files Browse the repository at this point in the history
  • Loading branch information
JoneXiong committed Jan 15, 2018
1 parent af0dd79 commit a9031e4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
8 changes: 7 additions & 1 deletion static/css/styles.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
@import url(bootstrap.css);
@import url(bootstrap-responsive.css);
@import url(customize.css);
@import url(customize.css);

@media print{
.entry {
width: 870px;
}
}
18 changes: 18 additions & 0 deletions templates/entry.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
<script src="/static/editormd/lib/flowchart.min.js"></script>
<script src="/static/editormd/lib/jquery.flowchart.min.js"></script>
<script src="/static/editormd/editormd.js"></script>
<script src="/static/editormd/lib/jQuery.print.js"></script>
<script type="text/javascript">
$(function() {
editormd.markdownToHTML("entry-content", {
Expand All @@ -56,6 +57,23 @@
// 默认不解析
lineNumbers: false,
}).find(".CodeMirror-gutters").css("border-right", "none");

$(window).keydown(function(e) {
if (e.ctrlKey && e.keyCode == 66) {
$('.entry').print({
globalStyles: true,
//是否包含父文档的样式
mediaPrint: true,
//是否包含media='print'的链接标签。会被globalStyles选项覆盖
noPrintSelector: ".span3,.span2",
//不想打印的元素的jQuery选择器
iframe: true,
//是否使用一个iframe来替代打印表单的弹出窗口
prepend: false //是否将用户更新的表单输入框内容作为打印内容(通过迭代每一个表单元素来实现)
})
}
});

})
</script>
<script src="{{ config.static_url }}/js/admin.js"></script>
Expand Down

0 comments on commit a9031e4

Please sign in to comment.