Added tests for jQuery.

This commit is contained in:
Uwe Oestermeier 2019-07-16 10:04:25 +02:00
parent 09b50d3b81
commit 1f5df65c48
3 changed files with 33 additions and 25 deletions

24
dist/iwmlib.js vendored
View File

@ -9328,7 +9328,9 @@
}
//jquery hyphenate below
$('.column').not('.overview').children('p').hyphenate('de');
if (typeof($) != 'undefined') {
$('.column').not('.overview').children('p').hyphenate('de');
}
//logging
if (src) {
@ -9764,7 +9766,7 @@
let linkRects = links.map(link => {
let rect = link.getBoundingClientRect();
let topLeft = Points.fromPageToNode(indexbox, rect);
let center = Points.fromPageToNode(indexbox, {x: rect.x + rect.width/2, y: rect.y + rect.height/2});
let center = Points.fromPageToNode(indexbox, { x: rect.x + rect.width / 2, y: rect.y + rect.height / 2 });
return { x: topLeft.x, y: topLeft.y, width: rect.width, height: rect.height, center, link }
});
@ -9820,8 +9822,10 @@
this._setPopupSource(popup, source);
context.popup = popup;
//jquery hyphenate below
console.log('hyphenated popup:', $('span').hyphenate('de'));
if (typeof($) != 'undefined') {
//jquery hyphenate below
console.log('hyphenated popup:', $('span').hyphenate('de'));
}
}
static _unsetPopup(context) {
@ -9944,10 +9948,6 @@
zoomable: 0.5
};
/** Make the class available in the global namespace */
window.Card = Card;
/**
* Extends the card with scatter functionality.
*
@ -10053,13 +10053,16 @@
*/
static loadAndCreateScatterCard(scatterContainer, item, {
basePath = "../",
modules = null,
modules = [],
onClose = null
} = {}) {
console.log(basePath);
return new Promise((resolve, reject) => {
this.loadHTML(basePath + "/" + item + "/index.html")
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
@ -10205,6 +10208,7 @@
window.CardWrapper = CardWrapper;
window.Card = Card;
window.ScatterCard = ScatterCard;
window.Highlight = Highlight$1;
window.Theme = Theme;

View File

@ -21,7 +21,7 @@ import UITest from './uitest.js'
import CardWrapper from './card/wrapper.js'
import Highlight from './card/highlight.js'
import Card from './card/card.js'
import {Card, ScatterCard} from './card/card.js'
import Theme from './card/theme.js'
/* Needed to ensure that rollup.js includes class definitions and the classes
@ -90,5 +90,6 @@ window.randomFloat = randomFloat
window.CardWrapper = CardWrapper
window.Card = Card
window.ScatterCard = ScatterCard
window.Highlight = Highlight
window.Theme = Theme

View File

@ -29,7 +29,7 @@ const enableNearestNeighborTaps = false
*
* The class is used as a namespace and should never called with new.
*/
export default class Card {
export class Card {
static setup(context, modules = []) {
console.log("Setup Card...", modules)
@ -1253,7 +1253,9 @@ export default class Card {
}
//jquery hyphenate below
$('.column').not('.overview').children('p').hyphenate('de')
if (typeof($) != 'undefined') {
$('.column').not('.overview').children('p').hyphenate('de')
}
//logging
if (src) {
@ -1699,7 +1701,7 @@ export default class Card {
let linkRects = links.map(link => {
let rect = link.getBoundingClientRect()
let topLeft = Points.fromPageToNode(indexbox, rect)
let center = Points.fromPageToNode(indexbox, {x: rect.x + rect.width/2, y: rect.y + rect.height/2})
let center = Points.fromPageToNode(indexbox, { x: rect.x + rect.width / 2, y: rect.y + rect.height / 2 })
return { x: topLeft.x, y: topLeft.y, width: rect.width, height: rect.height, center, link }
})
@ -1755,8 +1757,10 @@ export default class Card {
this._setPopupSource(popup, source)
context.popup = popup
//jquery hyphenate below
console.log('hyphenated popup:', $('span').hyphenate('de'))
if (typeof($) != 'undefined') {
//jquery hyphenate below
console.log('hyphenated popup:', $('span').hyphenate('de'))
}
}
static _unsetPopup(context) {
@ -1879,16 +1883,12 @@ Card.animation = {
zoomable: 0.5
}
/** Make the class available in the global namespace */
window.Card = Card
/**
* Extends the card with scatter functionality.
*
* @class ScatterCard
*/
class ScatterCard extends Card {
export class ScatterCard extends Card {
/**
@ -1988,13 +1988,16 @@ class ScatterCard extends Card {
*/
static loadAndCreateScatterCard(scatterContainer, item, {
basePath = "../",
modules = null,
modules = [],
onClose = null
} = {}) {
console.log(basePath)
return new Promise((resolve, reject) => {
this.loadHTML(basePath + "/" + item + "/index.html")
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