305 Star 1.5K Fork 291

GVPNotadd/Neditor

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
message.js 2.32 KB
一键复制 编辑 原始数据 按行查看 历史
///import core
///import uicore
;(function() {
var utils = baidu.editor.utils,
domUtils = baidu.editor.dom.domUtils,
UIBase = baidu.editor.ui.UIBase,
Message = (baidu.editor.ui.Message = function(options) {
this.initOptions(options);
this.initMessage();
});
Message.prototype = {
initMessage: function() {
this.initUIBase();
},
getHtmlTpl: function() {
return (
'<div id="##" class="edui-message %%">' +
' <div id="##_closer" class="edui-message-closer">×</div>' +
' <div id="##_body" class="edui-message-body edui-message-type-info">' +
' <iframe style="position:absolute;z-index:-1;left:0;top:0;background-color: transparent;" frameborder="0" width="100%" height="100%" src="about:blank"></iframe>' +
' <div class="edui-shadow"></div>' +
' <div id="##_content" class="edui-message-content">' +
" </div>" +
" </div>" +
"</div>"
);
},
reset: function(opt) {
var me = this;
if (!opt.keepshow) {
clearTimeout(this.timer);
me.timer = setTimeout(function() {
me.hide();
}, opt.timeout || 4000);
}
opt.content !== undefined && me.setContent(opt.content);
opt.type !== undefined && me.setType(opt.type);
me.show();
},
postRender: function() {
var me = this,
closer = this.getDom("closer");
closer &&
domUtils.on(closer, "click", function() {
me.hide();
});
},
setContent: function(content) {
this.getDom("content").innerHTML = content;
},
setType: function(type) {
type = type || "info";
var body = this.getDom("body");
body.className = body.className.replace(
/edui-message-type-[\w-]+/,
"edui-message-type-" + type
);
},
getContent: function() {
return this.getDom("content").innerHTML;
},
getType: function() {
var arr = this.getDom("body").match(/edui-message-type-([\w-]+)/);
return arr ? arr[1] : "";
},
show: function() {
this.getDom().style.display = "block";
},
hide: function() {
var dom = this.getDom();
if (dom) {
dom.style.display = "none";
dom.parentNode && dom.parentNode.removeChild(dom);
}
}
};
utils.inherits(Message, UIBase);
})();
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/notadd/neditor.git
git@gitee.com:notadd/neditor.git
notadd
neditor
Neditor
master

搜索帮助