Improve multi-document handling

This commit is contained in:
David Evans 2020-04-12 17:29:07 +01:00
parent d278b4d0e1
commit 1136325f5b
6 changed files with 21 additions and 14 deletions

View File

@ -80,8 +80,9 @@
<p class="loadmsg">Loading&hellip;</p> <p class="loadmsg">Loading&hellip;</p>
<noscript><p class="noscript">This tool requires Javascript!</p></noscript> <noscript><p class="noscript">This tool requires Javascript!</p></noscript>
<nav> <nav>
<a href="#" data-touch="Files">My Diagrams</a>
<a href="library.htm" target="_blank" data-touch="API">Library</a> <a href="library.htm" target="_blank" data-touch="API">Library</a>
<a href="https://github.com/davidje13/SequenceDiagram" target="_blank" data-touch="Git">GitHub</a> <a href="https://github.com/davidje13/SequenceDiagram" target="_blank" data-touch="">GitHub</a>
</nav> </nav>
</div> </div>

View File

@ -1816,9 +1816,12 @@
const libPane = this.buildLibPane(); const libPane = this.buildLibPane();
const viewPane = this.buildViewPane(); const viewPane = this.buildViewPane();
const links = this.links.map((link) => this.dom.el('a') const links = this.links.map((link) => {
.attrs({'href': link.href, 'target': '_blank'}) const label = this.touchUI ? link.touchLabel : link.label;
.text(this.touchUI ? link.touchLabel : link.label)); return label && this.dom.el('a')
.attrs({'href': link.href, 'target': link.target || ''})
.text(label);
}).filter((x) => x);
if(this.touchUI) { if(this.touchUI) {
this.buildOptionsDownloads(); this.buildOptionsDownloads();
@ -2237,13 +2240,13 @@
const dom = new DOMWrapper(window.document); const dom = new DOMWrapper(window.document);
const container = dom.el('div').setClass('pick-document') const container = dom.el('div').setClass('pick-document')
.add(dom.el('h1').text('Available documents on this computer:')) .add(dom.el('h1').text('Diagrams on this device:'))
.add(dom.el('p').text('(right-click to delete)')) .add(dom.el('p').text('(right-click to delete)'))
.attach(document.body); .attach(document.body);
function remove(slot) { function remove(slot) {
// eslint-disable-next-line no-alert // eslint-disable-next-line no-alert
if(window.confirm('Delete this document?')) { if(window.confirm('Delete this diagram?')) {
slotStorage.remove(slot); slotStorage.remove(slot);
window.location.reload(); window.location.reload();
} }
@ -2261,7 +2264,6 @@
.attr('href', `#${slot}`) .attr('href', `#${slot}`)
.setClass('pick-document-item') .setClass('pick-document-item')
.add(holdInner) .add(holdInner)
.fastClick()
.on('click', (e) => { .on('click', (e) => {
e.preventDefault(); e.preventDefault();
resolve(slot); resolve(slot);
@ -2404,6 +2406,7 @@
links.push({ links.push({
href: element.getAttribute('href'), href: element.getAttribute('href'),
label: element.textContent, label: element.textContent,
target: element.getAttribute('target'),
touchLabel: element.dataset.touch, touchLabel: element.dataset.touch,
}); });
} }

File diff suppressed because one or more lines are too long

View File

@ -73,6 +73,7 @@ window.addEventListener('load', () => {
links.push({ links.push({
href: element.getAttribute('href'), href: element.getAttribute('href'),
label: element.textContent, label: element.textContent,
target: element.getAttribute('target'),
touchLabel: element.dataset.touch, touchLabel: element.dataset.touch,
}); });
} }

View File

@ -488,9 +488,12 @@ export default class Interface {
const libPane = this.buildLibPane(); const libPane = this.buildLibPane();
const viewPane = this.buildViewPane(); const viewPane = this.buildViewPane();
const links = this.links.map((link) => this.dom.el('a') const links = this.links.map((link) => {
.attrs({'href': link.href, 'target': '_blank'}) const label = this.touchUI ? link.touchLabel : link.label;
.text(this.touchUI ? link.touchLabel : link.label)); return label && this.dom.el('a')
.attrs({'href': link.href, 'target': link.target || ''})
.text(label);
}).filter((x) => x);
if(this.touchUI) { if(this.touchUI) {
this.buildOptionsDownloads(); this.buildOptionsDownloads();

View File

@ -14,13 +14,13 @@ export default (hashNav, slotStorage) => {
const dom = new DOMWrapper(window.document); const dom = new DOMWrapper(window.document);
const container = dom.el('div').setClass('pick-document') const container = dom.el('div').setClass('pick-document')
.add(dom.el('h1').text('Available documents on this computer:')) .add(dom.el('h1').text('Diagrams on this device:'))
.add(dom.el('p').text('(right-click to delete)')) .add(dom.el('p').text('(right-click to delete)'))
.attach(document.body); .attach(document.body);
function remove(slot) { function remove(slot) {
// eslint-disable-next-line no-alert // eslint-disable-next-line no-alert
if(window.confirm('Delete this document?')) { if(window.confirm('Delete this diagram?')) {
slotStorage.remove(slot); slotStorage.remove(slot);
window.location.reload(); window.location.reload();
} }
@ -38,7 +38,6 @@ export default (hashNav, slotStorage) => {
.attr('href', `#${slot}`) .attr('href', `#${slot}`)
.setClass('pick-document-item') .setClass('pick-document-item')
.add(holdInner) .add(holdInner)
.fastClick()
.on('click', (e) => { .on('click', (e) => {
e.preventDefault(); e.preventDefault();
resolve(slot); resolve(slot);