|
@ -1,3 +1,13 @@ |
|
|
|
|
|
export const modal = content => { |
|
|
|
|
|
const wrapper = document.createElement('a') |
|
|
|
|
|
wrapper.href = '/' |
|
|
|
|
|
wrapper.className = 'fullview' |
|
|
|
|
|
const fullview = document.createElement('div') |
|
|
|
|
|
fullview.innerHTML = content |
|
|
|
|
|
wrapper.appendChild(fullview) |
|
|
|
|
|
return wrapper |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
export class Display { |
|
|
export class Display { |
|
|
constructor(baseUrl, dispatch, target) { |
|
|
constructor(baseUrl, dispatch, target) { |
|
|
this.baseUrl = baseUrl |
|
|
this.baseUrl = baseUrl |
|
@ -9,13 +19,6 @@ export class Display { |
|
|
} |
|
|
} |
|
|
return target |
|
|
return target |
|
|
} |
|
|
} |
|
|
target.addEventListener('click', e => { |
|
|
|
|
|
let target = findA(e.target) |
|
|
|
|
|
if (!target) return |
|
|
|
|
|
window.history.pushState(null, "", target.href) |
|
|
|
|
|
dispatch(target.getAttribute('href')) |
|
|
|
|
|
e.preventDefault() |
|
|
|
|
|
}) |
|
|
|
|
|
target.addEventListener('dragstart', e => { |
|
|
target.addEventListener('dragstart', e => { |
|
|
let target = findA(e.target) |
|
|
let target = findA(e.target) |
|
|
if (!target || !target.draggable) return |
|
|
if (!target || !target.draggable) return |
|
@ -135,16 +138,12 @@ export class Display { |
|
|
|
|
|
|
|
|
target.appendChild(field) |
|
|
target.appendChild(field) |
|
|
if (state.show !== null) { |
|
|
if (state.show !== null) { |
|
|
const wrapper = document.createElement('a') |
|
|
|
|
|
wrapper.href = '/' |
|
|
|
|
|
wrapper.className = 'fullview' |
|
|
|
|
|
const fullview = document.createElement('div') |
|
|
|
|
|
const data = state.items[state.show] |
|
|
const data = state.items[state.show] |
|
|
const name = data.name |
|
|
const name = data.name |
|
|
const desc = data.desc |
|
|
const desc = data.desc |
|
|
const img = '/img/' + data.img |
|
|
const img = '/img/' + data.img |
|
|
const text = (data.text || []).map(v => '<p>' + v + '</p>').join('') |
|
|
const text = (data.text || []).map(v => '<p>' + v + '</p>').join('') |
|
|
fullview.innerHTML = `
|
|
|
|
|
|
|
|
|
const wrapper = modal(`
|
|
|
<header> |
|
|
<header> |
|
|
<img src=${img} /> |
|
|
<img src=${img} /> |
|
|
<h1>${name}</h1> |
|
|
<h1>${name}</h1> |
|
@ -152,8 +151,7 @@ export class Display { |
|
|
</header> |
|
|
</header> |
|
|
<div class=fulltext>${text} |
|
|
<div class=fulltext>${text} |
|
|
<blockquote>${data.quote || ''}</blockquote></div> |
|
|
<blockquote>${data.quote || ''}</blockquote></div> |
|
|
`
|
|
|
|
|
|
wrapper.appendChild(fullview) |
|
|
|
|
|
|
|
|
`)
|
|
|
target.appendChild(wrapper) |
|
|
target.appendChild(wrapper) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|