Skip to content

Commit cd1517f

Browse files
committed
将文档模版移动到 imi 主项目中维护
# Conflicts: # .gitattributes # .gitignore
1 parent 4e53f6c commit cd1517f

File tree

161 files changed

+15812
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

161 files changed

+15812
-0
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@
77
/tests export-ignore
88
/doc export-ignore
99
/website export-ignore
10+
/mddoc export-ignore
1011
/src/Components export-ignore

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ composer.lock
55
*.log
66
.session
77
/.idea
8+
.php_cs.cache
9+
/mddoc/vendor
10+
*.lock
811
/.vscode
912
*.cache
1013
/src/Components/*/vendor

mddoc/composer.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"require": {
3+
"yurunsoft/mddoc": "^1.1"
4+
}
5+
}

mddoc/template/html/article.php

Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
7+
<?php
8+
$pageTitle = $currentCatalog['title'] . ' - imi 框架开发手册文档';
9+
?>
10+
<title><?= $pageTitle ?></title>
11+
<!-- jQuery-->
12+
<script src="<?=$this->path('statics/plugin/jquery/jquery-1.12.0.min.js')?>"></script>
13+
<!-- layui -->
14+
<link rel="stylesheet" href="<?=$this->path('statics/plugin/layui/css/layui.css')?>" />
15+
<script src="<?=$this->path('statics/plugin/layui/layui.all.js')?>"></script>
16+
<!-- zTree -->
17+
<link rel="stylesheet" href="<?=$this->path('statics/plugin/zTree/css/zTreeStyle/zTreeStyle.css')?>" />
18+
<script src="<?=$this->path('statics/plugin/zTree/js/jquery.ztree.core.js')?>"></script>
19+
<!-- SyntaxHighlighter -->
20+
<script src="<?=$this->path('statics/plugin/SyntaxHighlighter/shCore.js')?>" type="text/javascript"></script>
21+
<link rel="stylesheet" type="text/css" href="<?=$this->path('statics/plugin/SyntaxHighlighter/shCoreDefault.css')?>"/>
22+
<!-- 自定义 -->
23+
<link rel="stylesheet" href="<?=$this->path('statics/css/style.css')?>" />
24+
<script src="<?=$this->path('statics/js/home.js')?>"></script>
25+
<link rel="stylesheet" href="<?=$this->path('statics/css/docView.css')?>" />
26+
<script src="<?=$this->path('statics/js/docView.js')?>"></script>
27+
</head>
28+
<body>
29+
<!-- top-begin -->
30+
<div id="navbar">
31+
<ul class="layui-nav" lay-filter="">
32+
<div class="navRight">
33+
<li class="layui-nav-item" lay-unselect>
34+
<a id="btn-about" href="javascript:;">关于</a>
35+
</li>
36+
</div>
37+
</ul>
38+
<div class="nav-menu">
39+
<a href="<?=$this->path('')?>" class="logo"><?=$this->config['name']?></a>
40+
<a href="javascript:;" id="navMenuLeft"><i class="layui-icon">&#xe658;</i></a>
41+
<a href="javascript:;" id="navMenuRight"><i class="layui-icon">&#xe61a;</i></a>
42+
</div>
43+
<div class="clear"></div>
44+
</div>
45+
<script>
46+
function openMenuLeft()
47+
{
48+
$('#leftbar').addClass('show-item');
49+
$('#navMenuLeft').addClass('active');
50+
}
51+
function closeMenuLeft()
52+
{
53+
$('#leftbar').removeClass('show-item');
54+
$('#navMenuLeft').removeClass('active');
55+
}
56+
$('#navMenuLeft').click(function(){
57+
var isShow = $('#leftbar').hasClass('show-item');
58+
if(isShow)
59+
{
60+
closeMenuLeft();
61+
}
62+
else
63+
{
64+
closeMenuRight();
65+
openMenuLeft();
66+
}
67+
});
68+
function openMenuRight()
69+
{
70+
$('#navbar > .layui-nav').addClass('show-item')
71+
$('#navMenuRight').addClass('active').find('i').html('&#xe619;');
72+
}
73+
function closeMenuRight()
74+
{
75+
$('#navbar > .layui-nav').removeClass('show-item')
76+
$('#navMenuRight').removeClass('active').find('i').html('&#xe61a;');
77+
}
78+
$('#navMenuRight').click(function(){
79+
var isShow = $('#navbar > .layui-nav').hasClass('show-item');
80+
if(isShow)
81+
{
82+
closeMenuRight();
83+
}
84+
else
85+
{
86+
closeMenuLeft();
87+
openMenuRight();
88+
}
89+
});
90+
</script>
91+
<!-- top-end -->
92+
93+
<!-- left-begin -->
94+
<div id="leftbar" class="layui-nav-side">
95+
<div class="layui-tab layui-tab-brief" style="margin-top:0">
96+
<ul class="layui-tab-title">
97+
<li class="layui-this"><i class="layui-icon">&#xe705;</i> 目录</li>
98+
<li><i class="layui-icon">&#xe615;</i> 搜索</li>
99+
</ul>
100+
<div class="layui-tab-content" style="padding:0;overflow-y: auto;position: relative;padding-top: 12px;box-sizing: border-box;">
101+
<div class="layui-tab-item layui-show">
102+
<ul id="treeDirectory" class="ztree showIcon"></ul>
103+
</div>
104+
<div class="layui-tab-item">
105+
<div class="searchBox">
106+
<div id="searchForm">
107+
<div class="inputBox">
108+
<input type="text" id="search-keyword" name="keyword" placeholder="搜索关键词" class="layui-input"/>
109+
<i class="layui-icon input-icon">&#xe615;</i>
110+
</div>
111+
</div>
112+
<ul id="treeSearch" class="ztree">
113+
</ul>
114+
<div class="searchResultNone">
115+
<i class="layui-icon">&#xe615;</i>
116+
<p>未搜索到结果</p>
117+
</div>
118+
</div>
119+
</div>
120+
</div>
121+
<div class="copyright noScroll">mddoc</div>
122+
</div>
123+
</div>
124+
<script id="searchListTemplate" type="text/html">
125+
{{# layui.each(d, function(index, item){ }}
126+
<li>
127+
<a href="{{ item.url }}"><span>{{ item.title }}</span></a>
128+
</li>
129+
{{# }) }}
130+
</script>
131+
<!-- left-end -->
132+
133+
<div id="body">
134+
<div id="content_body" name="content_body" style="width:100%;height:100%;border:none;overflow: auto;">
135+
<div id="article-content" class="markdown-body">
136+
<script>
137+
function parseCatalogItem(item)
138+
{
139+
item.url = new Array(<?=substr_count($currentCatalog['url'], '/')?> + 1).join('../') + item.url;
140+
return item;
141+
}
142+
document.title = '<?= $pageTitle ?>';
143+
var currentCatalog = parseCatalogItem(<?=json_encode($currentCatalog)?>);
144+
var catalogList = <?=json_encode($data['catalogList'])?>;
145+
for(var i = 0; i < catalogList.length; ++i)
146+
{
147+
if(void 0 !== catalogList[i].url)
148+
{
149+
catalogList[i] = parseCatalogItem(catalogList[i]);
150+
}
151+
}
152+
initTree(catalogList);
153+
</script>
154+
<?=$articleContent?>
155+
</div>
156+
</div>
157+
</div>
158+
159+
<script>
160+
$(function(){
161+
var leftBarTimeout = null;
162+
$('#leftbar').hover(function(e){
163+
if(null !== leftBarTimeout)
164+
{
165+
clearTimeout(leftBarTimeout);
166+
leftBarTimeout = null;
167+
}
168+
if(e.type === 'mouseenter')
169+
{
170+
$('.left-show-hide').fadeIn(250);
171+
}
172+
else if($('#leftbar').css('left') == '0px')
173+
{
174+
$('.left-show-hide').fadeOut(500);
175+
}
176+
});
177+
});
178+
function showLeftbar()
179+
{
180+
$('#leftbar').css('left', 0);
181+
$('#body').css('padding-left','');
182+
$('.left-show-hide > i.layui-icon').html('&#xe603;');
183+
}
184+
function hideLeftbar()
185+
{
186+
$('#leftbar').css('left', '-240px');
187+
$('#body').css('padding-left',0);
188+
$('.left-show-hide > i.layui-icon').html('&#xe602;');
189+
$('.left-show-hide').fadeIn(250);
190+
}
191+
$('.left-show-hide').click(function(){
192+
if($('#leftbar').css('left') == '0px')
193+
{
194+
hideLeftbar();
195+
}
196+
else
197+
{
198+
showLeftbar();
199+
}
200+
})
201+
</script>
202+
<script src="<?=$this->path('statics/js/mddoc-search.js')?>"></script>
203+
<script src="https://s13.cnzz.com/z_stat.php?id=1273991018&web_id=1273991018" language="JavaScript"></script>
204+
</body>
205+
</html>

mddoc/template/html/search.php

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
var originSearchDatas = <?=json_encode($searchDatas)?>;
2+
var searchDatas = [];
3+
function initSearchDatas()
4+
{
5+
searchDatas = JSON.parse(JSON.stringify(originSearchDatas));
6+
for(var i = 0; i < searchDatas.length; ++i)
7+
{
8+
if(void 0 !== searchDatas[i].url)
9+
{
10+
searchDatas[i] = parseCatalogItem(searchDatas[i]);
11+
}
12+
}
13+
doSearch($('#search-keyword').val());
14+
}
15+
16+
String.prototype.indexOf2 = function(f){
17+
var rt = this.match(eval('/' + f + '/i'));
18+
return (rt == null) ? -1 : rt.index;
19+
}
20+
21+
function switchSearchNode(a)
22+
{
23+
if ('pushState' in history)
24+
{
25+
getChapter(a.attr('href'));
26+
history.pushState('', '', a.attr('href'));
27+
$('#treeSearch a').removeClass('curSelectedNode');
28+
a.addClass('curSelectedNode');
29+
}
30+
else
31+
{
32+
location = treeNode.url;
33+
}
34+
}
35+
36+
function searchArticle(keyword)
37+
{
38+
var keywords = keyword.split(' ');
39+
var tSearchDatas = searchDatas;
40+
var result = [];
41+
keywords.forEach(function(kw){
42+
if('' === kw)
43+
{
44+
return;
45+
}
46+
result = [];
47+
tSearchDatas.forEach(function(item, index){
48+
if(item.content.indexOf2(kw) > -1 || item.title.indexOf2(kw) > -1)
49+
{
50+
result.push(item);
51+
}
52+
});
53+
tSearchDatas = result;
54+
});
55+
return result;
56+
}
57+
58+
var searchTimer = null;
59+
function parseSearch()
60+
{
61+
$('#search-keyword').on('input', function(){
62+
if(null != searchTimer)
63+
{
64+
clearTimeout(searchTimer);
65+
searchTimer = null;
66+
}
67+
var inputKeyword = $(this);
68+
searchTimer = setTimeout(function(){
69+
doSearch(inputKeyword.val());
70+
searchTimer = null;
71+
}, 200);
72+
return false;
73+
});
74+
}
75+
76+
function doSearch(keyword)
77+
{
78+
var result = searchArticle(keyword);
79+
if(result.length > 0)
80+
{
81+
$('.searchResultNone').hide();
82+
}
83+
else
84+
{
85+
$('.searchResultNone').show();
86+
}
87+
var index = -1;
88+
$('#treeSearch a').each(function(i, item){
89+
++index;
90+
if($(item).hasClass('curSelectedNode'))
91+
{
92+
return false;
93+
}
94+
});
95+
layui.laytpl($('#searchListTemplate').html()).render(result, function(html){
96+
$('#treeSearch').html(html);
97+
if(index >= 0)
98+
{
99+
var node = $('#treeSearch a').get(index);
100+
if(null !== node)
101+
{
102+
$(node).addClass('curSelectedNode');
103+
}
104+
}
105+
});
106+
}
107+
108+
$(function(){
109+
110+
$('body').on('click', '#treeSearch a', function(e){
111+
switchSearchNode($(this));
112+
return false;
113+
});
114+
115+
parseSearch();
116+
117+
})

0 commit comments

Comments
 (0)