feat: Update drag page and other small things
- Add parameter to NewDiv class - Add instance with content to drag page - Drag page now also uses frame template - Use macro for footer in explorer
This commit is contained in:
parent
e572f64259
commit
1ddba29d9c
5 changed files with 40 additions and 29 deletions
|
|
@ -1,17 +1,18 @@
|
||||||
// Creates a div element which is draggable
|
// Creates a div element which is draggable
|
||||||
class NewDiv {
|
class NewDiv {
|
||||||
constructor(x, y, width, height, backgroundColor) {
|
constructor(x, y, width, height, backgroundColor, content) {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
this.width = width;
|
this.width = width;
|
||||||
this.height = height;
|
this.height = height;
|
||||||
this.backgroundColor = backgroundColor;
|
this.backgroundColor = backgroundColor;
|
||||||
this.element = null;
|
this.element = null;
|
||||||
|
this.content = content;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the div element
|
// Create the div element
|
||||||
createDiv() {
|
createDiv() {
|
||||||
this.element = document.createElement('div');
|
this.element = this._content;
|
||||||
this.element.style.position = 'absolute';
|
this.element.style.position = 'absolute';
|
||||||
this.element.style.left = `${this.x}px`;
|
this.element.style.left = `${this.x}px`;
|
||||||
this.element.style.top = `${this.y}px`;
|
this.element.style.top = `${this.y}px`;
|
||||||
|
|
@ -93,6 +94,19 @@ class NewDiv {
|
||||||
loadData();
|
loadData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME: this.element wird von appendToFrame() verwendet
|
||||||
|
get content() {
|
||||||
|
return this._content = this.content;
|
||||||
|
}
|
||||||
|
|
||||||
|
set content(value) {
|
||||||
|
if (!value) {
|
||||||
|
value = document.createElement('div');
|
||||||
|
}
|
||||||
|
|
||||||
|
this._content = value;
|
||||||
|
}
|
||||||
|
|
||||||
// Append the div to the space
|
// Append the div to the space
|
||||||
appendToFrame(space) {
|
appendToFrame(space) {
|
||||||
this.element.id = `newDiv${space.children.length}`;
|
this.element.id = `newDiv${space.children.length}`;
|
||||||
|
|
|
||||||
|
|
@ -5,25 +5,22 @@ tags:
|
||||||
---
|
---
|
||||||
{% set pageId = page.fileSlug %}
|
{% set pageId = page.fileSlug %}
|
||||||
|
|
||||||
{% extends "hippie/_app.njk" %}
|
{% extends "hippie/_app_frame.njk" %}
|
||||||
|
|
||||||
{% block title %}{{ title }}
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block links %}
|
|
||||||
{{ super() }}
|
|
||||||
<link href="{{ pageBase }}css/ui.css" media="all" rel="stylesheet"/>
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block head %}
|
|
||||||
{{ super() }}
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block body %}
|
{% block body %}
|
||||||
<header class="io pos_fix pin_top pin_right pin_left">
|
<header class="io pos_fix pin_top pin_right pin_left">
|
||||||
<button data-action="add">Add</button>
|
<button data-action="add">Add</button>
|
||||||
</header>
|
</header>
|
||||||
<div id="space"></div>
|
<div id="space"></div>
|
||||||
|
<div>
|
||||||
|
<div id="test">
|
||||||
|
<div class="body_frame">
|
||||||
|
{{ io.frameHeader('title-bar') }}
|
||||||
|
<main></main>
|
||||||
|
{{ io.frameFooter('mode-bar') }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{%- block script %}
|
{%- block script %}
|
||||||
|
|
@ -32,6 +29,7 @@ tags:
|
||||||
// Get the space element
|
// Get the space element
|
||||||
const space = document.getElementById('space');
|
const space = document.getElementById('space');
|
||||||
const add = document.querySelector('[data-action=add]');
|
const add = document.querySelector('[data-action=add]');
|
||||||
|
const test = document.getElementById('test');
|
||||||
|
|
||||||
// Add event listener to the add space button
|
// Add event listener to the add space button
|
||||||
add.addEventListener('click', () => {
|
add.addEventListener('click', () => {
|
||||||
|
|
@ -41,8 +39,12 @@ tags:
|
||||||
});
|
});
|
||||||
|
|
||||||
// Create a new NewDiv instance
|
// Create a new NewDiv instance
|
||||||
const newDiv = new NewDiv(100, 100, 800, 600, '#000');
|
const newDiv = new NewDiv(100, 100, 200, 200, '#000');
|
||||||
newDiv.createDiv();
|
newDiv.createDiv();
|
||||||
newDiv.appendToFrame(space);
|
newDiv.appendToFrame(space);
|
||||||
|
|
||||||
|
const explorer = new NewDiv(256, 128, 800, 600, '#fff', test);
|
||||||
|
explorer.createDiv();
|
||||||
|
explorer.appendToFrame(space);
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
@ -152,14 +152,5 @@ tags:
|
||||||
</footer>
|
</footer>
|
||||||
</section>
|
</section>
|
||||||
</main>
|
</main>
|
||||||
<footer class="io">
|
{{ io.frameFooter('mode-bar') }}
|
||||||
<nav>
|
|
||||||
<button>mode</button>
|
|
||||||
<span>mode-bar</span>
|
|
||||||
</nav>
|
|
||||||
<nav>
|
|
||||||
<div class="spacer a"></div>
|
|
||||||
<button>action</button>
|
|
||||||
</nav>
|
|
||||||
</footer>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
@ -1,4 +1,8 @@
|
||||||
#space {
|
#space {
|
||||||
position: relative;
|
position: relative;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
|
||||||
|
.body_frame {
|
||||||
|
background-color: white;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -27,9 +27,9 @@
|
||||||
|
|
||||||
flex: 1;
|
flex: 1;
|
||||||
|
|
||||||
aside {
|
// aside {
|
||||||
// background-color: rgba(255, 255, 255, .1);
|
// background-color: rgba(255, 255, 255, .1);
|
||||||
}
|
// }
|
||||||
|
|
||||||
section {
|
section {
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue