Prettified all files.
This commit is contained in:
+31
-39
@@ -6,8 +6,6 @@ import Card from './card.js'
|
||||
* @class ScatterCard
|
||||
*/
|
||||
export default class ScatterCard extends Card {
|
||||
|
||||
|
||||
/**
|
||||
* TODO: Find a more suitable name.
|
||||
* Adjusts the HTML to work in the new context.
|
||||
@@ -19,32 +17,27 @@ export default class ScatterCard extends Card {
|
||||
* @param {*} [opts={}]
|
||||
* @memberof Card
|
||||
*/
|
||||
static setup(context, htmlString, {
|
||||
basePath = "./",
|
||||
modules = []
|
||||
} = {}) {
|
||||
context.classList.add("info-card")
|
||||
static setup(context, htmlString, { basePath = './', modules = [] } = {}) {
|
||||
context.classList.add('info-card')
|
||||
|
||||
this.relativePath = basePath
|
||||
htmlString = this._adjustRelativeLinks(htmlString)
|
||||
|
||||
let parser = new DOMParser()
|
||||
let html = parser.parseFromString(htmlString, "text/html")
|
||||
let html = parser.parseFromString(htmlString, 'text/html')
|
||||
|
||||
/**
|
||||
* Conflicts with the FindTarget method of the Abstract scatter.
|
||||
*/
|
||||
this._replaceAttributes(html, "onclick", this._replaceCallback)
|
||||
this._replaceAttributes(html, 'onclick', this._replaceCallback)
|
||||
|
||||
|
||||
let content = html.querySelector(".mainview")
|
||||
let content = html.querySelector('.mainview')
|
||||
context.appendChild(content)
|
||||
|
||||
super.setup(context, modules)
|
||||
return context
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Appends a close listener to the scatter element.
|
||||
*
|
||||
@@ -59,7 +52,6 @@ export default class ScatterCard extends Card {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a scatter for the card and applies the card to it,
|
||||
*
|
||||
@@ -71,11 +63,12 @@ export default class ScatterCard extends Card {
|
||||
* @returns
|
||||
* @memberof Card
|
||||
*/
|
||||
static createCardScatter(html, scatterContainer, {
|
||||
basePath = "./",
|
||||
modules = []
|
||||
} = {}) {
|
||||
let element = document.createElement("div")
|
||||
static createCardScatter(
|
||||
html,
|
||||
scatterContainer,
|
||||
{ basePath = './', modules = [] } = {}
|
||||
) {
|
||||
let element = document.createElement('div')
|
||||
|
||||
scatterContainer.element.appendChild(element)
|
||||
new DOMScatter(element, scatterContainer, {
|
||||
@@ -90,8 +83,6 @@ export default class ScatterCard extends Card {
|
||||
return element
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*Utility function to create a fully functional card scatter.
|
||||
*
|
||||
@@ -103,24 +94,27 @@ export default class ScatterCard extends Card {
|
||||
* @returns
|
||||
* @memberof CardScatter
|
||||
*/
|
||||
static loadAndCreateScatterCard(scatterContainer, item, {
|
||||
basePath = "../",
|
||||
modules = [],
|
||||
onClose = null
|
||||
} = {}) {
|
||||
static loadAndCreateScatterCard(
|
||||
scatterContainer,
|
||||
item,
|
||||
{ basePath = '../', modules = [], onClose = null } = {}
|
||||
) {
|
||||
console.log(basePath)
|
||||
return new Promise((resolve, reject) => {
|
||||
let url = basePath + "/" + item + "/index.html"
|
||||
console.log("Loading", url)
|
||||
let url = basePath + '/' + item + '/index.html'
|
||||
console.log('Loading', url)
|
||||
this.loadHTML(url)
|
||||
.then(html => {
|
||||
console.log("Received", html)
|
||||
let element = this.createCardScatter(html, scatterContainer, {
|
||||
basePath,
|
||||
modules
|
||||
})
|
||||
if (onClose)
|
||||
this.addOnCloseListener(element, onClose)
|
||||
console.log('Received', html)
|
||||
let element = this.createCardScatter(
|
||||
html,
|
||||
scatterContainer,
|
||||
{
|
||||
basePath,
|
||||
modules
|
||||
}
|
||||
)
|
||||
if (onClose) this.addOnCloseListener(element, onClose)
|
||||
resolve(element)
|
||||
})
|
||||
.catch(e => reject(e))
|
||||
@@ -134,14 +128,12 @@ export default class ScatterCard extends Card {
|
||||
static _getLanguage(context) {
|
||||
return context.language
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ScatterCard.selectedLanguage = 0
|
||||
ScatterCard.languages = ["Deutsch", "English"]
|
||||
ScatterCard.languages = ['Deutsch', 'English']
|
||||
ScatterCard.languageTags = {
|
||||
Deutsch: "de",
|
||||
English: "en"
|
||||
Deutsch: 'de',
|
||||
English: 'en'
|
||||
}
|
||||
ScatterCard.scatterContainer = null
|
||||
|
||||
|
||||
Reference in New Issue
Block a user