mirror of https://github.com/ghostfolio/ghostfolio
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.4 KiB
43 lines
1.4 KiB
/*!
|
|
* (C) Ionic http://ionicframework.com - MIT License
|
|
*/
|
|
const hostContext = (selector, el) => {
|
|
return el.closest(selector) !== null;
|
|
};
|
|
/**
|
|
* Create the mode and color classes for the component based on the classes passed in
|
|
*/
|
|
const createColorClasses = (color, cssClassMap) => {
|
|
return typeof color === 'string' && color.length > 0
|
|
? Object.assign({ 'ion-color': true, [`ion-color-${color}`]: true }, cssClassMap) : cssClassMap;
|
|
};
|
|
const getClassList = (classes) => {
|
|
if (classes !== undefined) {
|
|
const array = Array.isArray(classes) ? classes : classes.split(' ');
|
|
return array
|
|
.filter((c) => c != null)
|
|
.map((c) => c.trim())
|
|
.filter((c) => c !== '');
|
|
}
|
|
return [];
|
|
};
|
|
const getClassMap = (classes) => {
|
|
const map = {};
|
|
getClassList(classes).forEach((c) => (map[c] = true));
|
|
return map;
|
|
};
|
|
const SCHEME = /^[a-z][a-z0-9+\-.]*:/;
|
|
const openURL = async (url, ev, direction, animation) => {
|
|
if (url != null && url[0] !== '#' && !SCHEME.test(url)) {
|
|
const router = document.querySelector('ion-router');
|
|
if (router) {
|
|
if (ev != null) {
|
|
ev.preventDefault();
|
|
}
|
|
return router.push(url, direction, animation);
|
|
}
|
|
}
|
|
return false;
|
|
};
|
|
|
|
export { createColorClasses as c, getClassMap as g, hostContext as h, openURL as o };
|
|
|