|
本帖最后由 xingcj 于 2016-8-5 08:00 编辑
在\function\editor目录中增加fixtoolbar.js文件,内容如下:
KindEditor.plugin('fixtoolbar', function (K) {
var self = this;
if (!self.fixToolBar) {
return;
}
function init() {
var toolbar = K('.ke-toolbar');
var originY = toolbar.pos().y;
K(window).bind('scroll', function () {
if (toolbar.css('position') == 'fixed') {
if(document.body.scrollTop - originY < 0){
toolbar.css('position', 'static');
toolbar.css('top', 'auto');
}
} else {
if (toolbar.pos().y - document.body.scrollTop < 0) {
toolbar.css('position', 'fixed');
toolbar.css('top', 0);
}
}
});
}
if (self.isCreated) {
init();
} else {
self.afterCreate(init);
}
});
编辑 \client\manage\templates\ourphp_editor.html ,增加红色字体内容
<link rel="stylesheet" href="../../function/editor/themes/default/default.css" />
<script charset="utf-8" src="../../function/editor/kindeditor.js"></script>
<script charset="utf-8" src="../../function/editor/fixtoolbar.js"></script>
<script charset="utf-8" src="../../function/editor/lang/zh_CN.js"></script>
<script>
KindEditor.ready(function(K) {
K.create('textarea[id="container"]', {
allowFileManager : true,
autoHeightMode : true,
fixToolBar:true,
afterCreate : function() {
this.loadPlugin('autoheight');
}
});
});
</script>
此时后台编辑器的工具栏就可以固定浮动了。
|
|