|
|
|
@@ -2,20 +2,17 @@ |
|
|
|
* @Author: Liquid |
|
|
|
* @Date: 2021-03-02 13:38:48 |
|
|
|
*/ |
|
|
|
|
|
|
|
import { DomUtil } from '../utils' |
|
|
|
import State from '../state/State' |
|
|
|
import Widget from './Widget' |
|
|
|
|
|
|
|
class LoadlingModule extends Widget { |
|
|
|
class LoadingMask extends Widget { |
|
|
|
constructor() { |
|
|
|
super() |
|
|
|
this._wrapper = DomUtil.create( |
|
|
|
'div', |
|
|
|
'loading-container' |
|
|
|
) |
|
|
|
this.type = Widget.getWidgetType('loadlingMask') |
|
|
|
this._wrapper = DomUtil.create('div', 'dc-loading-container') |
|
|
|
this.type = Widget.getWidgetType('loading_mask') |
|
|
|
this._state = State.INITIALIZED |
|
|
|
this.addLoading() |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
@@ -23,51 +20,33 @@ class LoadlingModule extends Widget { |
|
|
|
* @private |
|
|
|
*/ |
|
|
|
_installHook() { |
|
|
|
Object.defineProperty(this._viewer, 'loadlingMask', { |
|
|
|
Object.defineProperty(this._viewer, 'loadingMask', { |
|
|
|
value: this, |
|
|
|
writable: false |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
set enable(enable) { |
|
|
|
if (this._enable === enable) { |
|
|
|
return this |
|
|
|
} |
|
|
|
enable ? this.show() : this.hide() |
|
|
|
this._enable = enable |
|
|
|
this._state = this._enable ? State.ENABLED : State.DISABLED |
|
|
|
this._enableHook && this._enableHook() |
|
|
|
return this |
|
|
|
} |
|
|
|
|
|
|
|
_enableHook() { |
|
|
|
!this._wrapper.parentNode && |
|
|
|
this._viewer && |
|
|
|
this._viewer.dcContainer.appendChild(this._wrapper) |
|
|
|
} |
|
|
|
|
|
|
|
addLoading() { |
|
|
|
let htmlStr = ` |
|
|
|
<div class="loading"> |
|
|
|
/** |
|
|
|
* |
|
|
|
* @private |
|
|
|
*/ |
|
|
|
_mountContent() { |
|
|
|
let el = DomUtil.parseDom( |
|
|
|
` |
|
|
|
<span></span> |
|
|
|
<span></span> |
|
|
|
<span></span> |
|
|
|
<span></span> |
|
|
|
<span></span> |
|
|
|
</div> |
|
|
|
`; |
|
|
|
this._wrapper.innerHTML = htmlStr |
|
|
|
} |
|
|
|
|
|
|
|
show() { |
|
|
|
this._wrapper.style.visibility = 'visible' |
|
|
|
} |
|
|
|
|
|
|
|
hide() { |
|
|
|
this._wrapper.style.visibility = 'hidden' |
|
|
|
`, |
|
|
|
true, |
|
|
|
'loading' |
|
|
|
) |
|
|
|
this._wrapper.appendChild(el) |
|
|
|
this._ready = true |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
Widget.registerType('loadlingMask') |
|
|
|
Widget.registerType('loading_mask') |
|
|
|
|
|
|
|
export default LoadlingModule |
|
|
|
export default LoadingMask |