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.
36 lines
918 B
36 lines
918 B
/**
|
|
* Created by chenyihong on 14/12/4.
|
|
*/
|
|
|
|
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);
|
|
}
|
|
|
|
});
|