代码拉取完成,页面将自动刷新
;(function() {
var browser = baidu.editor.browser,
domUtils = baidu.editor.dom.domUtils,
uiUtils = baidu.editor.ui.uiUtils;
var TPL_STATEFUL =
'onmousedown="$$.Stateful_onMouseDown(event, this);"' +
' onmouseup="$$.Stateful_onMouseUp(event, this);"' +
(browser.ie
? ' onmouseenter="$$.Stateful_onMouseEnter(event, this);"' +
' onmouseleave="$$.Stateful_onMouseLeave(event, this);"'
: ' onmouseover="$$.Stateful_onMouseOver(event, this);"' +
' onmouseout="$$.Stateful_onMouseOut(event, this);"');
baidu.editor.ui.Stateful = {
alwalysHoverable: false,
target: null, //目标元素和this指向dom不一样
Stateful_init: function() {
this._Stateful_dGetHtmlTpl = this.getHtmlTpl;
this.getHtmlTpl = this.Stateful_getHtmlTpl;
},
Stateful_getHtmlTpl: function() {
var tpl = this._Stateful_dGetHtmlTpl();
// 使用function避免$转义
return tpl.replace(/stateful/g, function() {
return TPL_STATEFUL;
});
},
Stateful_onMouseEnter: function(evt, el) {
this.target = el;
if (!this.isDisabled() || this.alwalysHoverable) {
this.addState("hover");
this.fireEvent("over");
}
},
Stateful_onMouseLeave: function(evt, el) {
if (!this.isDisabled() || this.alwalysHoverable) {
this.removeState("hover");
this.removeState("active");
this.fireEvent("out");
}
},
Stateful_onMouseOver: function(evt, el) {
var rel = evt.relatedTarget;
if (!uiUtils.contains(el, rel) && el !== rel) {
this.Stateful_onMouseEnter(evt, el);
}
},
Stateful_onMouseOut: function(evt, el) {
var rel = evt.relatedTarget;
if (!uiUtils.contains(el, rel) && el !== rel) {
this.Stateful_onMouseLeave(evt, el);
}
},
Stateful_onMouseDown: function(evt, el) {
if (!this.isDisabled()) {
this.addState("active");
}
},
Stateful_onMouseUp: function(evt, el) {
if (!this.isDisabled()) {
this.removeState("active");
}
},
Stateful_postRender: function() {
if (this.disabled && !this.hasState("disabled")) {
this.addState("disabled");
}
},
hasState: function(state) {
return domUtils.hasClass(this.getStateDom(), "edui-state-" + state);
},
addState: function(state) {
if (!this.hasState(state)) {
this.getStateDom().className += " edui-state-" + state;
}
},
removeState: function(state) {
if (this.hasState(state)) {
domUtils.removeClasses(this.getStateDom(), ["edui-state-" + state]);
}
},
getStateDom: function() {
return this.getDom("state");
},
isChecked: function() {
return this.hasState("checked");
},
setChecked: function(checked) {
if (!this.isDisabled() && checked) {
this.addState("checked");
} else {
this.removeState("checked");
}
},
isDisabled: function() {
return this.hasState("disabled");
},
setDisabled: function(disabled) {
if (disabled) {
this.removeState("hover");
this.removeState("checked");
this.removeState("active");
this.addState("disabled");
} else {
this.removeState("disabled");
}
}
};
})();
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。