in progress
parent
8fcaa37396
commit
9f9ec73daa
|
@ -97,9 +97,7 @@ template.innerHTML = `
|
|||
<div class="menu-item">menu 1</div>
|
||||
<div class="menu-item">menu 2 est un peu plus long</div>
|
||||
<div class="menu-item">menu 3</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
`;
|
||||
|
@ -118,15 +116,16 @@ export class ExplorerButton extends HTMLElement {
|
|||
// locate the component
|
||||
this.$button = this._shadowRoot.querySelector('.menu-button');
|
||||
this.$overall = this._shadowRoot.querySelector('.overall');
|
||||
this.$img = this._shadowRoot.querySelector('img');
|
||||
this.$img = this._shadowRoot.querySelector('.menu-button img');
|
||||
this.$menu = this._shadowRoot.querySelector('.menu');
|
||||
this.files = [];
|
||||
}
|
||||
/**
|
||||
* @function observedAttributes
|
||||
* @returns {any} observed
|
||||
*/
|
||||
static get observedAttributes () {
|
||||
return ['title', 'pressed', 'disabled'];
|
||||
return ['title', 'pressed', 'disabled', 'lib'];
|
||||
}
|
||||
/**
|
||||
* @function attributeChangedCallback
|
||||
|
@ -158,6 +157,29 @@ export class ExplorerButton extends HTMLElement {
|
|||
this.$div.classList.remove('disabled');
|
||||
}
|
||||
break;
|
||||
case 'lib':
|
||||
{
|
||||
// read the json containing the list of library files.
|
||||
const request = new XMLHttpRequest();
|
||||
request.open('GET', newValue, true);
|
||||
request.addEventListener('load', (resp) => {
|
||||
if (resp.target.status >= 200 && resp.target.status < 400) {
|
||||
const json = JSON.parse(resp.target.response);
|
||||
const {lib} = json;
|
||||
// eslint-disable-next-line no-unsanitized/property
|
||||
this.$menu.innerHTML = lib.map((menu) => (
|
||||
`<div class="menu-item">${menu}</div>`
|
||||
)).join('');
|
||||
} else {
|
||||
console.error(`could not read file:${newValue}`);
|
||||
}
|
||||
});
|
||||
request.addEventListener('error', (error) => {
|
||||
console.log(error);
|
||||
});
|
||||
request.send();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(`unknown attribute: ${name}`);
|
||||
|
@ -229,6 +251,7 @@ export class ExplorerButton extends HTMLElement {
|
|||
console.log(ev);
|
||||
switch (ev.target.nodeName) {
|
||||
case 'SE-EXPLORERBUTTON':
|
||||
|
||||
this.$menu.classList.add('open');
|
||||
break;
|
||||
case 'SE-BUTTON':
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"lib": [
|
||||
"basic",
|
||||
"animal",
|
||||
"game"
|
||||
]
|
||||
}
|
|
@ -400,7 +400,7 @@
|
|||
<se-button id="tool_fhellipse" title="Free-Hand Rectangle" src="./images/fh_ellipse.svg"></se-button>
|
||||
</se-flyingbutton>
|
||||
<se-button id="tool_path" title="Path Tool" src="./images/path.svg" shortcut="P"></se-button>
|
||||
<se-explorerbutton id="tool_shapelib_show" title="Shape library" src="./images/shapelib.svg"></se-explorerbutton>
|
||||
<se-explorerbutton id="tool_shapelib_show" title="Shape library" lib="./extensions/ext-shapes/shapelib/shapelib.json"></se-explorerbutton>
|
||||
<se-button id="tool_text" title="Text Tool" src="./images/text.svg" shortcut="T"></se-button>
|
||||
<se-button id="tool_image" title="Image Tool" src="./images/image.svg"></se-button>
|
||||
<se-button id="tool_zoom" title="Zoom Tool" src="./images/zoom.svg" shortcut="Z"></se-button>
|
||||
|
|
Loading…
Reference in New Issue