mirror of
https://github.com/esiur/iui.git
synced 2025-12-14 02:20:25 +00:00
initial commit
This commit is contained in:
60
src/Router/Target.js
Normal file
60
src/Router/Target.js
Normal file
@@ -0,0 +1,60 @@
|
||||
import IUIElement from "../Core/IUIElement.js";
|
||||
import { IUI } from "../Core/IUI.js";
|
||||
import Route from "./Route.js";
|
||||
|
||||
export default IUI.module(class Target extends IUIElement {
|
||||
constructor(properties) {
|
||||
super(IUI.extend(properties, { cssClass: 'target' }));
|
||||
|
||||
this._register("show");
|
||||
this._register("hide");
|
||||
|
||||
}
|
||||
|
||||
setLoading(value)
|
||||
{
|
||||
if (value)
|
||||
this.classList.add(this.cssClass + "-loading");
|
||||
else
|
||||
this.classList.remove(this.cssClass + "-loading");
|
||||
}
|
||||
|
||||
create() {
|
||||
|
||||
}
|
||||
|
||||
show(route, previous) {
|
||||
|
||||
let previousTarget = previous?.target;
|
||||
|
||||
route.target = this;
|
||||
|
||||
for (var i = 0; i < this.children.length; i++)
|
||||
if (this.children[i] instanceof Route && this.children[i] != route) {
|
||||
this.children[i].set(false);
|
||||
}
|
||||
|
||||
//if (previous != null && previous != route && previous.target == this) {
|
||||
// previous.set(false);
|
||||
//}
|
||||
//else
|
||||
if (previousTarget != null && previousTarget != this) {
|
||||
previousTarget.hide(this.active);
|
||||
}
|
||||
|
||||
|
||||
if (route.parentElement != this)
|
||||
this.appendChild(route);
|
||||
|
||||
this._emit("show", { route, previous});
|
||||
}
|
||||
|
||||
hide(route) {
|
||||
for (var i = 0; i < this.children.length; i++)
|
||||
if (this.children[i] instanceof Route) {
|
||||
this.children[i].set(false);
|
||||
}
|
||||
|
||||
this._emit("hide", { route });
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user