You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.3 KiB
Plaintext
51 lines
1.3 KiB
Plaintext
9 years ago
|
app
|
||
8 years ago
|
window(each="{windowItem in windows}", router="{parent.router}", window-title="{windowItem.title}", width=640, height=480, x="{windowItem.x}", y="{windowItem.y}", z=0, resizable="true", url="{windowItem.url}")
|
||
9 years ago
|
|
||
|
script.
|
||
8 years ago
|
const stateRouter = require("../../lib/frontend/riot-state-router");
|
||
9 years ago
|
|
||
8 years ago
|
this.mixin(require("../../lib/frontend/riot-on-child"));
|
||
9 years ago
|
this.mixin(require("riot-query").mixin);
|
||
|
|
||
|
this.windows = [
|
||
|
{ title: "test one", x: 10, y: 10, url: "/" },
|
||
|
{ title: "test two", x: 200, y: 200, url: "/" },
|
||
|
{ title: "", x: 390, y: 390, url: "/nodes/create" }
|
||
|
]
|
||
|
|
||
|
let currentZIndex = 0;
|
||
|
|
||
|
let router = stateRouter();
|
||
|
|
||
|
router.get("/", (req, res) => {
|
||
|
res.render("sample", {
|
||
|
text: "Hello World!"
|
||
|
});
|
||
|
});
|
||
|
|
||
|
router.get("/nodes/create", (req, res) => {
|
||
|
res.render("node-create");
|
||
|
});
|
||
|
|
||
|
this.router = router;
|
||
|
|
||
|
this.onChild("create:window", (window) => {
|
||
|
window.on("focused", () => {
|
||
|
this.query("window").filter((otherWindow) => {
|
||
|
return otherWindow !== window;
|
||
|
}).forEach((otherWindow) => {
|
||
|
otherWindow.defocus();
|
||
|
});
|
||
|
|
||
|
window.setZIndex(currentZIndex++);
|
||
|
});
|
||
|
|
||
|
window.on("requestClose", () => {
|
||
|
window.reportClose();
|
||
|
this.windows = this.windows.filter((windowItem) => windowItem !== window._item);
|
||
|
this.update();
|
||
|
});
|
||
|
|
||
|
window.focus();
|
||
8 years ago
|
});
|