mirror of
https://github.com/fluxscape/fluxscape.git
synced 2026-01-12 07:12:54 +01:00
Co-Authored-By: Eric Tuvesson <eric.tuvesson@gmail.com> Co-Authored-By: mikaeltellhed <2311083+mikaeltellhed@users.noreply.github.com> Co-Authored-By: kotte <14197736+mrtamagotchi@users.noreply.github.com> Co-Authored-By: Anders Larsson <64838990+anders-topp@users.noreply.github.com> Co-Authored-By: Johan <4934465+joolsus@users.noreply.github.com> Co-Authored-By: Tore Knudsen <18231882+torekndsn@users.noreply.github.com> Co-Authored-By: victoratndl <99176179+victoratndl@users.noreply.github.com>
49 lines
1.4 KiB
JavaScript
49 lines
1.4 KiB
JavaScript
const { RouterHandler } = require('../nodes/navigation/router-handler');
|
|
const NoodlRuntime = require('@noodl/runtime');
|
|
|
|
const navigation = {
|
|
async showPopup(componentPath, params) {
|
|
return new Promise((resolve) => {
|
|
navigation._noodlRuntime.context.showPopup(componentPath, params, {
|
|
onClosePopup: (action, results) => {
|
|
resolve({
|
|
action: action.replace('closeAction-', ''),
|
|
parameters: results
|
|
});
|
|
}
|
|
});
|
|
});
|
|
},
|
|
|
|
navigate(routerName, targetPageName, params) {
|
|
RouterHandler.instance.navigate(routerName, {
|
|
target: targetPageName,
|
|
params: params
|
|
});
|
|
},
|
|
|
|
navigateToPath(path, options) {
|
|
let hashPath, urlPath;
|
|
var navigationPathType = NoodlRuntime.instance.getProjectSettings()['navigationPathType'];
|
|
if (navigationPathType === undefined || navigationPathType === 'hash') hashPath = path;
|
|
else urlPath = path;
|
|
|
|
var query = [];
|
|
if (options && options.query !== undefined) {
|
|
for (let key in options.query) {
|
|
query.push(key + '=' + options.query[key]);
|
|
}
|
|
}
|
|
|
|
var compiledUrl =
|
|
(urlPath !== undefined ? urlPath : '') +
|
|
(query.length >= 1 ? '?' + query.join('&') : '') +
|
|
(hashPath !== undefined ? '#' + hashPath : '');
|
|
|
|
window.history.pushState({}, '', compiledUrl);
|
|
dispatchEvent(new PopStateEvent('popstate', {}));
|
|
}
|
|
};
|
|
|
|
module.exports = navigation;
|