-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
39e6a08
commit 74d9f57
Showing
4 changed files
with
81 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -105,3 +105,7 @@ ul, | |
visibility: visible; | ||
opacity: 1; | ||
} | ||
|
||
.tormenta20-import-export-button { | ||
margin-left: 15px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { createElement, enhanceElement } from '../common/helpers'; | ||
|
||
/** | ||
* Create a new ImportExportSheet object. | ||
* | ||
* @class | ||
*/ | ||
export class ImportExportSheet { | ||
/** | ||
* @constructs | ||
* @param {Object} props | ||
* @param {EnhancedHTMLElement} props.iframe | ||
* @param {Object} props.character | ||
*/ | ||
constructor({ iframe, character }) { | ||
/** @type {EnhancedHTMLElement} */ | ||
this.iframe = iframe; | ||
/** @type {Object} */ | ||
this.character = character; | ||
this._dialogHeader = null; | ||
} | ||
|
||
/** @type {EnhancedHTMLElement|null} */ | ||
get dialogHeader() { | ||
if (this._dialogHeader === null) { | ||
const characterId = this.character.get('id'); | ||
const selector = `iframe[name="iframe_${characterId}"]`; | ||
const rawIframe = document.querySelector(selector); | ||
const header = rawIframe | ||
.closest('div.ui-dialog') | ||
.querySelector('div.ui-dialog-titlebar'); | ||
this._dialogHeader = enhanceElement(header); | ||
} | ||
return this._dialogHeader; | ||
} | ||
|
||
addImportButton() { | ||
const span = this.dialogHeader.getElement('span.ui-dialog-title'); | ||
const importButton = createElement('button', { | ||
id: 't20-import-button', | ||
classes: 'btn tormenta20-import-export-button', | ||
innerHTML: 'Importar', | ||
}); | ||
importButton.addEventObserver('click', () => { | ||
console.log('import'); | ||
}); | ||
span.insertBefore(importButton, span.childNodes[2]); | ||
} | ||
|
||
addExportButton() { | ||
const span = this.dialogHeader.getElement('span.ui-dialog-title'); | ||
const exportButton = createElement('button', { | ||
id: 't20-export-button', | ||
classes: 'btn tormenta20-import-export-button', | ||
innerHTML: 'Exportar', | ||
}); | ||
exportButton.addEventObserver('click', () => { | ||
console.log('export'); | ||
}); | ||
span.insertBefore(exportButton, span.childNodes[3]); | ||
} | ||
|
||
/** Load the sheet import/export capabilities. */ | ||
load() { | ||
this.addImportButton(); | ||
this.addExportButton(); | ||
} | ||
} |