|
|
|
|
@ -17,18 +17,29 @@ export class Header extends HTMLElement {
|
|
|
|
|
|
|
|
|
|
textEn = {
|
|
|
|
|
download: 'Download',
|
|
|
|
|
rename: 'Rename',
|
|
|
|
|
rename: 'Move/Rename',
|
|
|
|
|
delete: 'Delete',
|
|
|
|
|
confirmDelete: f => (
|
|
|
|
|
`Are you sure you want to delete ${f}?`
|
|
|
|
|
),
|
|
|
|
|
cancel: 'Cancel',
|
|
|
|
|
alreadyExists: 'There is already a page with that name.',
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
textEs = {
|
|
|
|
|
download: 'Descargar',
|
|
|
|
|
rename: 'Renombrar',
|
|
|
|
|
rename: 'Mover/Renombrar',
|
|
|
|
|
delete: 'Borrar',
|
|
|
|
|
confirmDelete: f => (
|
|
|
|
|
`¿Desea borrar ${f}?`
|
|
|
|
|
),
|
|
|
|
|
cancel: 'Cancelar',
|
|
|
|
|
alreadyExists: 'Ya existe una página con ese nombre.',
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
|
super()
|
|
|
|
|
this.language = navigator.language
|
|
|
|
|
this.editing = false
|
|
|
|
|
this.attachShadow({mode: 'open'})
|
|
|
|
|
this.addButton(this.icons.menu, 'nav', () => {
|
|
|
|
|
@ -48,7 +59,8 @@ export class Header extends HTMLElement {
|
|
|
|
|
})
|
|
|
|
|
this.addMenu()
|
|
|
|
|
this.addPageMenu()
|
|
|
|
|
//this.addDialogPanel()
|
|
|
|
|
this.dialogWrap = document.createElement('div')
|
|
|
|
|
this.shadowRoot.appendChild(this.dialogWrap)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
connectedCallback() {
|
|
|
|
|
@ -100,9 +112,6 @@ export class Header extends HTMLElement {
|
|
|
|
|
left: 0;
|
|
|
|
|
opacity: 15%;
|
|
|
|
|
}
|
|
|
|
|
div.overlay.open.dialog {
|
|
|
|
|
opacity: 50%;
|
|
|
|
|
}
|
|
|
|
|
button.page {
|
|
|
|
|
position: relative;
|
|
|
|
|
}
|
|
|
|
|
@ -134,6 +143,10 @@ export class Header extends HTMLElement {
|
|
|
|
|
div.page-menu.open {
|
|
|
|
|
display: block;
|
|
|
|
|
}
|
|
|
|
|
m-dialog::part(footer) {
|
|
|
|
|
padding-top: 15px;
|
|
|
|
|
text-align: right;
|
|
|
|
|
}
|
|
|
|
|
`
|
|
|
|
|
this.shadowRoot.append(style)
|
|
|
|
|
}
|
|
|
|
|
@ -174,7 +187,7 @@ export class Header extends HTMLElement {
|
|
|
|
|
|
|
|
|
|
addPageMenu() {
|
|
|
|
|
this.pageMenu = document.createElement('m-page-menu')
|
|
|
|
|
this.pageMenu.add('download', () => {
|
|
|
|
|
this.pageMenu.add(this.text.download, () => {
|
|
|
|
|
const text = localStorage.getItem(this.path)
|
|
|
|
|
const sp = this.path.split('/')
|
|
|
|
|
const filename = sp[sp.length - 1]
|
|
|
|
|
@ -190,14 +203,63 @@ export class Header extends HTMLElement {
|
|
|
|
|
el.click()
|
|
|
|
|
this.shadowRoot.removeChild(el)
|
|
|
|
|
})
|
|
|
|
|
/*this.pageMenu.add('rename', () => {
|
|
|
|
|
this.pageMenu.add(this.text.rename, () => {
|
|
|
|
|
const dialog = document.createElement('m-dialog')
|
|
|
|
|
dialog.title = this.text.rename
|
|
|
|
|
this.showDialog(dialog)
|
|
|
|
|
this.dialogWrap.replaceChildren(dialog)
|
|
|
|
|
const input = document.createElement('input')
|
|
|
|
|
input.style.width = '85%'
|
|
|
|
|
dialog.bodyEl.appendChild(input)
|
|
|
|
|
const cancelBtn = document.createElement('button')
|
|
|
|
|
cancelBtn.innerText = this.text.cancel
|
|
|
|
|
cancelBtn.addEventListener('click', () => {
|
|
|
|
|
dialog.close()
|
|
|
|
|
})
|
|
|
|
|
const confirmBtn = document.createElement('button')
|
|
|
|
|
confirmBtn.innerText = this.text.rename
|
|
|
|
|
confirmBtn.style.marginLeft = '3px'
|
|
|
|
|
confirmBtn.addEventListener('click', () => {
|
|
|
|
|
const newPath = input.value
|
|
|
|
|
if (newPath !== this.path) {
|
|
|
|
|
localStorage.setItem(
|
|
|
|
|
newPath,
|
|
|
|
|
localStorage.getItem(this.path)
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
localStorage.removeItem(this.path)
|
|
|
|
|
window.location.hash = newPath
|
|
|
|
|
dialog.close()
|
|
|
|
|
})
|
|
|
|
|
dialog.footerEl.replaceChildren(
|
|
|
|
|
cancelBtn, confirmBtn
|
|
|
|
|
)
|
|
|
|
|
dialog.open()
|
|
|
|
|
})
|
|
|
|
|
this.pageMenu.add(this.text.delete, () => {
|
|
|
|
|
const dialog = document.createElement('m-dialog')
|
|
|
|
|
this.dialogWrap.replaceChildren(dialog)
|
|
|
|
|
const p = document.createElement('p')
|
|
|
|
|
p.innerText = this.text.confirmDelete(
|
|
|
|
|
JSON.stringify(this.path)
|
|
|
|
|
)
|
|
|
|
|
dialog.bodyEl.appendChild(p)
|
|
|
|
|
const cancelBtn = document.createElement('button')
|
|
|
|
|
cancelBtn.innerText = this.text.cancel
|
|
|
|
|
cancelBtn.addEventListener('click', () => {
|
|
|
|
|
dialog.close()
|
|
|
|
|
})
|
|
|
|
|
const confirmBtn = document.createElement('button')
|
|
|
|
|
confirmBtn.innerText = this.text.delete
|
|
|
|
|
confirmBtn.style.marginLeft = '3px'
|
|
|
|
|
confirmBtn.addEventListener('click', () => {
|
|
|
|
|
localStorage.removeItem(this.path)
|
|
|
|
|
window.location.hash = '/'
|
|
|
|
|
dialog.close()
|
|
|
|
|
})
|
|
|
|
|
dialog.footerEl.replaceChildren(
|
|
|
|
|
cancelBtn, confirmBtn
|
|
|
|
|
)
|
|
|
|
|
dialog.open()
|
|
|
|
|
})
|
|
|
|
|
this.pageMenu.add('delete', () => {
|
|
|
|
|
|
|
|
|
|
})*/
|
|
|
|
|
this.pageMenu.addEventListener('close-menu', () => {
|
|
|
|
|
this.close()
|
|
|
|
|
})
|
|
|
|
|
@ -208,18 +270,6 @@ export class Header extends HTMLElement {
|
|
|
|
|
this.shadowRoot.appendChild(this.pageMenuPanel)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
addDialogPanel() {
|
|
|
|
|
this.dialogPanel = document.createElement('div')
|
|
|
|
|
this.dialogPanel.classList.add('dialog-panel')
|
|
|
|
|
this.shadowRoot.appendChild(this.dialogPanel)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
showDialog(dialog) {
|
|
|
|
|
this.overlay.classList.add('open', 'dialog')
|
|
|
|
|
this.dialogPanel.replaceChildren(dialog)
|
|
|
|
|
this.dialogPanel.classList.add('open')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
close() {
|
|
|
|
|
this.overlay.classList.add('closing')
|
|
|
|
|
this.overlay.classList.remove('open')
|
|
|
|
|
|