How to use navigateUrl method in storybook-root

Best JavaScript code snippet using storybook-root

back.js

Source:back.js Github

copy

Full Screen

1"use strict";2exports.__esModule = true;3exports.back = back;4var _ssrWindow = require("ssr-window");5var _dom = _interopRequireDefault(require("../../shared/dom7"));6var _utils = require("../../shared/utils");7var _getDevice = require("../../shared/get-device");8var _history = _interopRequireDefault(require("../../shared/history"));9var _redirect = _interopRequireDefault(require("./redirect"));10var _processRouteQueue = _interopRequireDefault(require("./process-route-queue"));11var _appRouterCheck = _interopRequireDefault(require("./app-router-check"));12var _asyncComponent = _interopRequireDefault(require("./async-component"));13function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }14function backward(router, el, backwardOptions) {15 var device = (0, _getDevice.getDevice)();16 var document = (0, _ssrWindow.getDocument)();17 var $el = (0, _dom.default)(el);18 var app = router.app;19 var view = router.view;20 var options = (0, _utils.extend)({21 animate: router.params.animate,22 browserHistory: true,23 replaceState: false24 }, backwardOptions);25 var masterDetailEnabled = router.params.masterDetailBreakpoint > 0;26 var isMaster = masterDetailEnabled && options.route && options.route.route && (options.route.route.master === true || typeof options.route.route.master === 'function' && options.route.route.master(app, router));27 var masterPageEl;28 var masterPageRemoved;29 var dynamicNavbar = router.dynamicNavbar;30 var $newPage = $el;31 var $oldPage = router.$el.children('.page-current');32 var initialPreload = $oldPage.length === 0 && options.preload;33 var currentIsMaster = masterDetailEnabled && $oldPage.hasClass('page-master');34 if ($newPage.length) {35 // Remove theme elements36 router.removeThemeElements($newPage);37 }38 var $navbarsEl;39 var $newNavbarEl;40 var $oldNavbarEl;41 if (dynamicNavbar) {42 $newNavbarEl = $newPage.children('.navbar');43 $navbarsEl = router.$navbarsEl;44 if ($newNavbarEl.length === 0 && $newPage[0] && $newPage[0].f7Page) {45 // Try from pageData46 $newNavbarEl = $newPage[0].f7Page.$navbarEl;47 }48 $oldNavbarEl = $navbarsEl.find('.navbar-current');49 }50 router.allowPageChange = false;51 if ($newPage.length === 0 || $oldPage.length === 0 && !options.preload) {52 router.allowPageChange = true;53 return router;54 } // Remove theme elements55 router.removeThemeElements($newPage); // Save Keep Alive Cache56 if (options.route && options.route.route && options.route.route.keepAlive && !options.route.route.keepAliveData) {57 options.route.route.keepAliveData = {58 pageEl: $el[0]59 };60 } // Pages In View61 var isDetail;62 var isDetailRoot;63 if (masterDetailEnabled) {64 var $pagesInView = router.$el.children('.page:not(.stacked)').filter(function (pageInView) {65 return pageInView !== $newPage[0];66 }); // Find Detail' master page67 for (var i = 0; i < $pagesInView.length; i += 1) {68 if (!masterPageEl && $pagesInView[i].classList.contains('page-master')) {69 masterPageEl = $pagesInView[i];70 continue; // eslint-disable-line71 }72 }73 isDetail = !isMaster && masterPageEl && router.history.indexOf(options.route.url) > router.history.indexOf(masterPageEl.f7Page.route.url);74 if (!isDetail && !isMaster && masterPageEl && masterPageEl.f7Page && options.route.route.masterRoute) {75 isDetail = options.route.route.masterRoute.path === masterPageEl.f7Page.route.route.path;76 }77 }78 if (isDetail && masterPageEl && masterPageEl.f7Page) {79 isDetailRoot = router.history.indexOf(options.route.url) - router.history.indexOf(masterPageEl.f7Page.route.url) === 1;80 } // New Page81 $newPage.addClass("page-" + (initialPreload ? 'current' : 'previous') + (isMaster ? ' page-master' : '') + (isDetail ? ' page-master-detail' : '') + (isDetailRoot ? ' page-master-detail-root' : '')).removeClass('stacked').removeAttr('aria-hidden').trigger('page:unstack').trigger('page:position', {82 position: initialPreload ? 'current' : 'previous'83 });84 router.emit('pageUnstack', $newPage[0]);85 router.emit('pagePosition', $newPage[0], initialPreload ? 'current' : 'previous');86 if (isMaster || isDetail) {87 $newPage.trigger('page:role', {88 role: isMaster ? 'master' : 'detail',89 root: !!isDetailRoot90 });91 router.emit('pageRole', $newPage[0], {92 role: isMaster ? 'master' : 'detail',93 detailRoot: !!isDetailRoot94 });95 }96 if (dynamicNavbar && $newNavbarEl.length > 0) {97 $newNavbarEl.addClass("navbar-" + (initialPreload ? 'current' : 'previous') + (isMaster ? ' navbar-master' : '') + (isDetail ? ' navbar-master-detail' : '') + (isDetailRoot ? ' navbar-master-detail-root' : '')).removeClass('stacked').removeAttr('aria-hidden');98 $newNavbarEl.trigger('navbar:position', {99 position: initialPreload ? 'current' : 'previous'100 });101 router.emit('navbarPosition', $newNavbarEl[0], initialPreload ? 'current' : 'previous');102 if (isMaster || isDetailRoot) {103 router.emit('navbarRole', $newNavbarEl[0], {104 role: isMaster ? 'master' : 'detail',105 detailRoot: !!isDetailRoot106 });107 }108 } // Remove previous page in case of "forced"109 var backIndex;110 if (options.force) {111 if ($oldPage.prev('.page-previous:not(.stacked)').length > 0 || $oldPage.prev('.page-previous').length === 0) {112 if (router.history.indexOf(options.route.url) >= 0) {113 backIndex = router.history.length - router.history.indexOf(options.route.url) - 1;114 router.history = router.history.slice(0, router.history.indexOf(options.route.url) + 2);115 view.history = router.history;116 } else if (router.history[[router.history.length - 2]]) {117 router.history[router.history.length - 2] = options.route.url;118 } else {119 router.history.unshift(router.url);120 }121 if (backIndex && router.params.stackPages) {122 $oldPage.prevAll('.page-previous').each(function (pageToRemove) {123 var $pageToRemove = (0, _dom.default)(pageToRemove);124 var $navbarToRemove;125 if (dynamicNavbar) {126 // $navbarToRemove = $oldNavbarEl.prevAll('.navbar-previous').eq(index);127 $navbarToRemove = (0, _dom.default)(app.navbar.getElByPage($pageToRemove));128 }129 if ($pageToRemove[0] !== $newPage[0] && $pageToRemove.index() > $newPage.index()) {130 if (router.initialPages.indexOf($pageToRemove[0]) >= 0) {131 $pageToRemove.addClass('stacked');132 $pageToRemove.trigger('page:stack');133 router.emit('pageStack', $pageToRemove[0]);134 if (dynamicNavbar) {135 $navbarToRemove.addClass('stacked');136 }137 } else {138 router.pageCallback('beforeRemove', $pageToRemove, $navbarToRemove, 'previous', undefined, options);139 if ($pageToRemove[0] === masterPageEl) {140 masterPageRemoved = true;141 }142 router.removePage($pageToRemove);143 if (dynamicNavbar && $navbarToRemove.length > 0) {144 router.removeNavbar($navbarToRemove);145 }146 }147 }148 });149 } else {150 var $pageToRemove = $oldPage.prev('.page-previous:not(.stacked)');151 var $navbarToRemove;152 if (dynamicNavbar) {153 // $navbarToRemove = $oldNavbarEl.prev('.navbar-inner:not(.stacked)');154 $navbarToRemove = (0, _dom.default)(app.navbar.getElByPage($pageToRemove));155 }156 if (router.params.stackPages && router.initialPages.indexOf($pageToRemove[0]) >= 0) {157 $pageToRemove.addClass('stacked');158 $pageToRemove.trigger('page:stack');159 router.emit('pageStack', $pageToRemove[0]);160 $navbarToRemove.addClass('stacked');161 } else if ($pageToRemove.length > 0) {162 router.pageCallback('beforeRemove', $pageToRemove, $navbarToRemove, 'previous', undefined, options);163 if ($pageToRemove[0] === masterPageEl) {164 masterPageRemoved = true;165 }166 router.removePage($pageToRemove);167 if (dynamicNavbar && $navbarToRemove.length) {168 router.removeNavbar($navbarToRemove);169 }170 }171 }172 }173 } // Insert new page174 var newPageInDom = $newPage.parents(document).length > 0;175 var f7Component = $newPage[0].f7Component;176 function insertPage() {177 if (initialPreload) {178 if (!newPageInDom && f7Component) {179 f7Component.mount(function (componentEl) {180 router.$el.append(componentEl);181 });182 } else {183 router.$el.append($newPage);184 }185 }186 if ($newPage.next($oldPage).length === 0) {187 if (!newPageInDom && f7Component) {188 f7Component.mount(function (componentEl) {189 (0, _dom.default)(componentEl).insertBefore($oldPage);190 });191 } else {192 $newPage.insertBefore($oldPage);193 }194 }195 if (dynamicNavbar && $newNavbarEl.length) {196 if ($newNavbarEl.find('.title-large').length) {197 $newNavbarEl.addClass('navbar-large');198 }199 $newNavbarEl.insertBefore($oldNavbarEl);200 if ($oldNavbarEl.length > 0) {201 $newNavbarEl.insertBefore($oldNavbarEl);202 } else {203 if (!router.$navbarsEl.parents(document).length) {204 router.$el.prepend(router.$navbarsEl);205 }206 $navbarsEl.append($newNavbarEl);207 }208 }209 if (!newPageInDom) {210 router.pageCallback('mounted', $newPage, $newNavbarEl, 'previous', 'current', options, $oldPage);211 } else if (options.route && options.route.route && options.route.route.keepAlive && !$newPage[0].f7PageMounted) {212 $newPage[0].f7PageMounted = true;213 router.pageCallback('mounted', $newPage, $newNavbarEl, 'previous', 'current', options, $oldPage);214 }215 }216 if (options.preload) {217 // Insert Page218 insertPage(); // Tab route219 if (options.route.route.tab) {220 router.tabLoad(options.route.route.tab, (0, _utils.extend)({}, options, {221 history: false,222 browserHistory: false,223 preload: true224 }));225 }226 if (isMaster) {227 $newPage.removeClass('page-master-stacked').trigger('page:masterunstack');228 router.emit('pageMasterUnstack', $newPage[0]);229 if (dynamicNavbar) {230 (0, _dom.default)(app.navbar.getElByPage($newPage)).removeClass('navbar-master-stacked');231 router.emit('navbarMasterUnstack', app.navbar.getElByPage($newPage));232 }233 } // Page init and before init events234 router.pageCallback('init', $newPage, $newNavbarEl, 'previous', 'current', options, $oldPage);235 if (initialPreload) {236 router.pageCallback('beforeIn', $newPage, $newNavbarEl, 'current', undefined, options);237 router.pageCallback('afterIn', $newPage, $newNavbarEl, 'current', undefined, options);238 }239 var $previousPages = $newPage.prevAll('.page-previous:not(.stacked):not(.page-master)');240 if ($previousPages.length > 0) {241 $previousPages.each(function (pageToRemove) {242 var $pageToRemove = (0, _dom.default)(pageToRemove);243 var $navbarToRemove;244 if (dynamicNavbar) {245 // $navbarToRemove = $newNavbarEl.prevAll('.navbar-previous:not(.stacked)').eq(index);246 $navbarToRemove = (0, _dom.default)(app.navbar.getElByPage($pageToRemove));247 }248 if (router.params.stackPages && router.initialPages.indexOf(pageToRemove) >= 0) {249 $pageToRemove.addClass('stacked');250 $pageToRemove.trigger('page:stack');251 router.emit('pageStack', $pageToRemove[0]);252 if (dynamicNavbar) {253 $navbarToRemove.addClass('stacked');254 }255 } else {256 router.pageCallback('beforeRemove', $pageToRemove, $navbarToRemove, 'previous', undefined);257 router.removePage($pageToRemove);258 if (dynamicNavbar && $navbarToRemove.length) {259 router.removeNavbar($navbarToRemove);260 }261 }262 });263 }264 router.allowPageChange = true;265 return router;266 } // History State267 if (!(device.ie || device.edge || device.firefox && !device.ios)) {268 if (router.params.browserHistory && options.browserHistory) {269 if (options.replaceState) {270 var browserHistoryRoot = router.params.browserHistoryRoot || '';271 _history.default.replace(view.id, {272 url: options.route.url273 }, browserHistoryRoot + router.params.browserHistorySeparator + options.route.url);274 } else if (backIndex) {275 _history.default.go(-backIndex);276 } else {277 _history.default.back();278 }279 }280 } // Update History281 if (options.replaceState) {282 router.history[router.history.length - 1] = options.route.url;283 } else {284 if (router.history.length === 1) {285 router.history.unshift(router.url);286 }287 router.history.pop();288 }289 router.saveHistory(); // Current Page & Navbar290 router.currentPageEl = $newPage[0];291 if (dynamicNavbar && $newNavbarEl.length) {292 router.currentNavbarEl = $newNavbarEl[0];293 } else {294 delete router.currentNavbarEl;295 } // Current Route296 router.currentRoute = options.route; // History State297 if (device.ie || device.edge || device.firefox && !device.ios) {298 if (router.params.browserHistory && options.browserHistory) {299 if (options.replaceState) {300 var _browserHistoryRoot = router.params.browserHistoryRoot || '';301 _history.default.replace(view.id, {302 url: options.route.url303 }, _browserHistoryRoot + router.params.browserHistorySeparator + options.route.url);304 } else if (backIndex) {305 _history.default.go(-backIndex);306 } else {307 _history.default.back();308 }309 }310 } // Insert Page311 insertPage(); // Load Tab312 if (options.route.route.tab) {313 router.tabLoad(options.route.route.tab, (0, _utils.extend)({}, options, {314 history: false,315 browserHistory: false316 }));317 } // Check master detail318 if (masterDetailEnabled && (currentIsMaster || masterPageRemoved)) {319 view.checkMasterDetailBreakpoint(false);320 } // Page init and before init events321 router.pageCallback('init', $newPage, $newNavbarEl, 'previous', 'current', options, $oldPage); // Before animation callback322 router.pageCallback('beforeOut', $oldPage, $oldNavbarEl, 'current', 'next', options);323 router.pageCallback('beforeIn', $newPage, $newNavbarEl, 'previous', 'current', options); // Animation324 function afterAnimation() {325 // Set classes326 router.setPagePosition($newPage, 'current', false);327 router.setPagePosition($oldPage, 'next', true);328 if (dynamicNavbar) {329 router.setNavbarPosition($newNavbarEl, 'current', false);330 router.setNavbarPosition($oldNavbarEl, 'next', true);331 } // After animation event332 router.pageCallback('afterOut', $oldPage, $oldNavbarEl, 'current', 'next', options);333 router.pageCallback('afterIn', $newPage, $newNavbarEl, 'previous', 'current', options); // Remove Old Page334 if (router.params.stackPages && router.initialPages.indexOf($oldPage[0]) >= 0) {335 $oldPage.addClass('stacked');336 $oldPage.trigger('page:stack');337 router.emit('pageStack', $oldPage[0]);338 if (dynamicNavbar) {339 $oldNavbarEl.addClass('stacked');340 }341 } else {342 router.pageCallback('beforeRemove', $oldPage, $oldNavbarEl, 'next', undefined, options);343 router.removePage($oldPage);344 if (dynamicNavbar && $oldNavbarEl.length) {345 router.removeNavbar($oldNavbarEl);346 }347 }348 router.allowPageChange = true;349 router.emit('routeChanged', router.currentRoute, router.previousRoute, router); // Preload previous page350 var preloadPreviousPage = router.params.preloadPreviousPage || router.params[app.theme + "SwipeBack"];351 if (preloadPreviousPage && router.history[router.history.length - 2] && !isMaster) {352 router.back(router.history[router.history.length - 2], {353 preload: true354 });355 }356 if (router.params.browserHistory) {357 _history.default.clearRouterQueue();358 }359 }360 function setPositionClasses() {361 router.setPagePosition($oldPage, 'current');362 router.setPagePosition($newPage, 'previous', false);363 if (dynamicNavbar) {364 router.setNavbarPosition($oldNavbarEl, 'current');365 router.setNavbarPosition($newNavbarEl, 'previous', false);366 }367 }368 if (options.animate && !(currentIsMaster && app.width >= router.params.masterDetailBreakpoint)) {369 var transition = router.params.transition;370 if ($oldPage[0] && $oldPage[0].f7PageTransition) {371 transition = $oldPage[0].f7PageTransition;372 delete $oldPage[0].f7PageTransition;373 }374 if (options.transition) transition = options.transition;375 if (!transition && router.previousRoute && router.previousRoute.route) {376 transition = router.previousRoute.route.transition;377 }378 if (!transition && router.previousRoute && router.previousRoute.route && router.previousRoute.route.options) {379 transition = router.previousRoute.route.options.transition;380 }381 setPositionClasses();382 router.animate($oldPage, $newPage, $oldNavbarEl, $newNavbarEl, 'backward', transition, function () {383 afterAnimation();384 });385 } else {386 afterAnimation();387 }388 return router;389}390function loadBack(router, backParams, backOptions, ignorePageChange) {391 if (!router.allowPageChange && !ignorePageChange) return router;392 var params = backParams;393 var options = backOptions;394 var url = params.url,395 content = params.content,396 el = params.el,397 pageName = params.pageName,398 component = params.component,399 componentUrl = params.componentUrl;400 if (options.route.url && router.url === options.route.url && !(options.reloadCurrent || options.reloadPrevious) && !router.params.allowDuplicateUrls) {401 return false;402 }403 if (!options.route && url) {404 options.route = router.parseRouteUrl(url);405 } // Component Callbacks406 function resolve(pageEl, newOptions) {407 return backward(router, pageEl, (0, _utils.extend)(options, newOptions));408 }409 function reject() {410 router.allowPageChange = true;411 return router;412 }413 if (url || componentUrl || component) {414 router.allowPageChange = false;415 } // Proceed416 if (content) {417 backward(router, router.getPageEl(content), options);418 } else if (el) {419 // Load page from specified HTMLElement or by page name in pages container420 backward(router, router.getPageEl(el), options);421 } else if (pageName) {422 // Load page by page name in pages container423 backward(router, router.$el.children(".page[data-name=\"" + pageName + "\"]").eq(0), options);424 } else if (component || componentUrl) {425 // Load from component (F7/Vue/React/...)426 try {427 router.pageComponentLoader({428 routerEl: router.el,429 component: component,430 componentUrl: componentUrl,431 options: options,432 resolve: resolve,433 reject: reject434 });435 } catch (err) {436 router.allowPageChange = true;437 throw err;438 }439 } else if (url) {440 // Load using XHR441 if (router.xhrAbortController) {442 router.xhrAbortController.abort();443 router.xhrAbortController = false;444 }445 router.xhrRequest(url, options).then(function (pageContent) {446 backward(router, router.getPageEl(pageContent), options);447 }).catch(function () {448 router.allowPageChange = true;449 });450 }451 return router;452}453function back() {454 var router = this;455 var device = (0, _getDevice.getDevice)();456 if (router.swipeBackActive) return router;457 var navigateUrl;458 var navigateOptions;459 var route;460 if (typeof (arguments.length <= 0 ? undefined : arguments[0]) === 'object') {461 navigateOptions = (arguments.length <= 0 ? undefined : arguments[0]) || {};462 } else {463 navigateUrl = arguments.length <= 0 ? undefined : arguments[0];464 navigateOptions = (arguments.length <= 1 ? undefined : arguments[1]) || {};465 }466 var _navigateOptions = navigateOptions,467 name = _navigateOptions.name,468 params = _navigateOptions.params,469 query = _navigateOptions.query;470 if (name) {471 navigateUrl = router.generateUrl({472 name: name,473 params: params,474 query: query475 });476 if (navigateUrl) {477 return router.back(navigateUrl, (0, _utils.extend)({}, navigateOptions, {478 name: null,479 params: null,480 query: null481 }));482 }483 return router;484 }485 var app = router.app;486 (0, _appRouterCheck.default)(router, 'back');487 var currentRouteIsModal = router.currentRoute.modal;488 var modalType;489 if (!currentRouteIsModal) {490 'popup popover sheet loginScreen actions customModal panel'.split(' ').forEach(function (modalLoadProp) {491 if (router.currentRoute.route[modalLoadProp]) {492 currentRouteIsModal = true;493 modalType = modalLoadProp;494 }495 });496 }497 if (currentRouteIsModal && !navigateOptions.preload) {498 var modalToClose = router.currentRoute.modal || router.currentRoute.route.modalInstance || app[modalType].get();499 var previousUrl = router.history[router.history.length - 2];500 var previousRoute; // check if previous route is modal too501 if (modalToClose && modalToClose.$el) {502 var prevOpenedModals = modalToClose.$el.prevAll('.modal-in');503 if (prevOpenedModals.length && prevOpenedModals[0].f7Modal) {504 var modalEl = prevOpenedModals[0]; // check if current router not inside of the modalEl505 if (!router.$el.parents(modalEl).length) {506 previousRoute = modalEl.f7Modal.route;507 }508 }509 }510 if (!previousRoute) {511 previousRoute = router.findMatchingRoute(previousUrl);512 }513 if (!previousRoute && previousUrl) {514 previousRoute = {515 url: previousUrl,516 path: previousUrl.split('?')[0],517 query: (0, _utils.parseUrlQuery)(previousUrl),518 route: {519 path: previousUrl.split('?')[0],520 url: previousUrl521 }522 };523 }524 if (!navigateUrl || navigateUrl.replace(/[# ]/g, '').trim().length === 0) {525 if (!previousRoute || !modalToClose) {526 return router;527 }528 }529 var forceOtherUrl = navigateOptions.force && previousRoute && navigateUrl;530 if (previousRoute && modalToClose) {531 var isBrokenBrowserHistory = device.ie || device.edge || device.firefox && !device.ios;532 var needHistoryBack = router.params.browserHistory && navigateOptions.browserHistory !== false;533 var currentRouteWithoutBrowserHistory = router.currentRoute && router.currentRoute.route && router.currentRoute.route.options && router.currentRoute.route.options.browserHistory === false;534 if (needHistoryBack && !isBrokenBrowserHistory && !currentRouteWithoutBrowserHistory) {535 _history.default.back();536 }537 router.currentRoute = previousRoute;538 router.history.pop();539 router.saveHistory();540 if (needHistoryBack && isBrokenBrowserHistory && !currentRouteWithoutBrowserHistory) {541 _history.default.back();542 }543 router.modalRemove(modalToClose);544 if (forceOtherUrl) {545 router.navigate(navigateUrl, {546 reloadCurrent: true547 });548 }549 } else if (modalToClose) {550 router.modalRemove(modalToClose);551 if (navigateUrl) {552 router.navigate(navigateUrl, {553 reloadCurrent: true554 });555 }556 }557 return router;558 }559 var $previousPage = router.$el.children('.page-current').prevAll('.page-previous:not(.page-master)').eq(0);560 var skipMaster;561 if (router.params.masterDetailBreakpoint > 0) {562 var classes = [];563 router.$el.children('.page').each(function (pageEl) {564 classes.push(pageEl.className);565 });566 var $previousMaster = router.$el.children('.page-current').prevAll('.page-master').eq(0);567 if ($previousMaster.length) {568 var expectedPreviousPageUrl = router.history[router.history.length - 2];569 var expectedPreviousPageRoute = router.findMatchingRoute(expectedPreviousPageUrl);570 if (expectedPreviousPageRoute && $previousMaster[0].f7Page && expectedPreviousPageRoute.route === $previousMaster[0].f7Page.route.route) {571 $previousPage = $previousMaster;572 if (!navigateOptions.preload) {573 skipMaster = app.width >= router.params.masterDetailBreakpoint;574 }575 }576 }577 }578 if (!navigateOptions.force && $previousPage.length && !skipMaster) {579 if (router.params.browserHistory && $previousPage[0].f7Page && router.history[router.history.length - 2] !== $previousPage[0].f7Page.route.url) {580 router.back(router.history[router.history.length - 2], (0, _utils.extend)(navigateOptions, {581 force: true582 }));583 return router;584 }585 var previousPageRoute = $previousPage[0].f7Page.route;586 _processRouteQueue.default.call(router, previousPageRoute, router.currentRoute, function () {587 loadBack(router, {588 el: $previousPage589 }, (0, _utils.extend)(navigateOptions, {590 route: previousPageRoute591 }));592 }, function () {}, 'backward');593 return router;594 } // Navigate URL595 if (navigateUrl === '#') {596 navigateUrl = undefined;597 }598 if (navigateUrl && navigateUrl[0] !== '/' && navigateUrl.indexOf('#') !== 0) {599 navigateUrl = ((router.path || '/') + navigateUrl).replace('//', '/');600 }601 if (!navigateUrl && router.history.length > 1) {602 navigateUrl = router.history[router.history.length - 2];603 }604 if (skipMaster && !navigateOptions.force && router.history[router.history.length - 3]) {605 return router.back(router.history[router.history.length - 3], (0, _utils.extend)({}, navigateOptions || {}, {606 force: true,607 animate: false608 }));609 }610 if (skipMaster && !navigateOptions.force) {611 return router;612 } // Find route to load613 route = router.findMatchingRoute(navigateUrl);614 if (!route) {615 if (navigateUrl) {616 route = {617 url: navigateUrl,618 path: navigateUrl.split('?')[0],619 query: (0, _utils.parseUrlQuery)(navigateUrl),620 route: {621 path: navigateUrl.split('?')[0],622 url: navigateUrl623 }624 };625 }626 }627 if (!route) {628 return router;629 }630 if (route.route.redirect) {631 return _redirect.default.call(router, 'backward', route, navigateOptions);632 }633 var options = {};634 if (route.route.options) {635 (0, _utils.extend)(options, route.route.options, navigateOptions);636 } else {637 (0, _utils.extend)(options, navigateOptions);638 }639 options.route = route;640 var backForceLoaded;641 if (options.force && router.params.stackPages) {642 router.$el.children('.page-previous.stacked').each(function (pageEl) {643 if (pageEl.f7Page && pageEl.f7Page.route && pageEl.f7Page.route.url === route.url) {644 backForceLoaded = true;645 loadBack(router, {646 el: pageEl647 }, options);648 }649 });650 if (backForceLoaded) {651 return router;652 }653 }654 function resolve() {655 var routerLoaded = false;656 if (route.route.keepAlive && route.route.keepAliveData) {657 loadBack(router, {658 el: route.route.keepAliveData.pageEl659 }, options);660 routerLoaded = true;661 }662 'url content component pageName el componentUrl'.split(' ').forEach(function (pageLoadProp) {663 if (route.route[pageLoadProp] && !routerLoaded) {664 var _loadBack;665 routerLoaded = true;666 loadBack(router, (_loadBack = {}, _loadBack[pageLoadProp] = route.route[pageLoadProp], _loadBack), options);667 }668 });669 if (routerLoaded) return; // Async670 function asyncResolve(resolveParams, resolveOptions) {671 router.allowPageChange = false;672 loadBack(router, resolveParams, (0, _utils.extend)(options, resolveOptions), true);673 }674 function asyncReject() {675 router.allowPageChange = true;676 }677 if (route.route.async) {678 router.allowPageChange = false;679 route.route.async.call(router, {680 router: router,681 to: route,682 from: router.currentRoute,683 resolve: asyncResolve,684 reject: asyncReject,685 direction: 'backward',686 app: app687 });688 }689 if (route.route.asyncComponent) {690 (0, _asyncComponent.default)(router, route.route.asyncComponent, asyncResolve, asyncReject);691 }692 }693 function reject() {694 router.allowPageChange = true;695 }696 if (options.preload) {697 resolve();698 } else {699 _processRouteQueue.default.call(router, route, router.currentRoute, function () {700 if (route.route.modules) {701 app.loadModules(Array.isArray(route.route.modules) ? route.route.modules : [route.route.modules]).then(function () {702 resolve();703 }).catch(function () {704 reject();705 });706 } else {707 resolve();708 }709 }, function () {710 reject();711 }, 'backward');712 } // Return Router713 return router;...

Full Screen

Full Screen

config.js

Source:config.js Github

copy

Full Screen

1const contentModuleFunc = [2 {3 name: '行业',4 icon: 'icon-industry-copy',5 navigateUrl: '/dataset/concept'6 },7 {8 name: '个股',9 icon: 'icon-stock-copy',10 navigateUrl: '/dataset/stocks'11 },12 {13 name: '指数',14 icon: 'icon-zhishu-copy',15 navigateUrl: '/dataset/concept'16 },17 {18 name: '宏观',19 icon: 'icon-juece-copy',20 navigateUrl: '/dataset/concept'21 },22 {23 name: '热门板块',24 icon: 'icon-hot',25 navigateUrl: '/dataset/concept'26 },27 {28 name: '自选',29 icon: 'icon-stock-in',30 navigateUrl: '/dataset/concept'31 },32 {33 name: '我的资产',34 icon: 'icon-pocket-color',35 navigateUrl: '/dataset/concept'36 },37 {38 name: '盈利预测',39 icon: 'icon-profit-predict',40 navigateUrl: '/dataset/concept'41 },42 {43 name: '机构调研',44 icon: 'icon-investigate',45 navigateUrl: '/dataset/investigate'46 },47 {48 name: '机构评级',49 icon: 'icon-grade',50 navigateUrl: '/dataset/institute-grade'51 },52 {53 name: '决策',54 icon: 'icon-juece-color',55 navigateUrl: '/dataset/concept'56 },57 {58 name: '数据中心',59 icon: 'icon-database',60 navigateUrl: '/dataset/concept'61 },62 {63 name: '期货',64 icon: 'icon-qihuo',65 navigateUrl: '/dataset/concept'66 }67]68export default {69 contentModuleFunc...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1import { storiesOf, html } from '@open-wc/demoing-storybook';2const navigateUrl = async (url) => {3 const root = document.querySelector('storybook-root');4 await root.navigateUrl(url);5};6storiesOf('Button', module)7 .add('with text', () => html`8 <button @click=${() => navigateUrl('/demo/other-page')}>Go to other page</button>9 `);10import { storiesOf, html } from '@open-wc/demoing-storybook';11const navigateUrl = async (url) => {12 const root = document.querySelector('storybook-root');13 await root.navigateUrl(url);14};15storiesOf('Other page', module)16 .add('with text', () => html`17 <button @click=${() => navigateUrl('/demo/button')}>Go to button page</button>18 `);19import { storiesOf, html } from '@open-wc/demoing-storybook';20const navigateUrl = async (url) => {21 const root = document.querySelector('storybook-root');22 await root.navigateUrl(url);23};24storiesOf('Other page', module)25 .add('with text', () => html`26 <button @click=${() => navigateUrl('/demo/button')}>Go to button page</button>27 `);28import { storiesOf, html } from '@open-wc/demoing-storybook';29const navigateUrl = async (url) => {30 const root = document.querySelector('storybook-root');31 await root.navigateUrl(url);32};33storiesOf('Other page', module)34 .add('with text', () => html`35 <button @click=${() => navigateUrl('/demo/button')}>Go to button page</button>36 `);37import { storiesOf, html } from '@open-wc/demoing-storybook';38const navigateUrl = async (url) => {39 const root = document.querySelector('storybook-root');40 await root.navigateUrl(url);41};42storiesOf('Other page', module)

Full Screen

Using AI Code Generation

copy

Full Screen

1var storybookRoot = document.querySelector('storybook-root');2storybookRoot.navigateUrl('/?path=/story/button--primary');3var storybookRouter = document.querySelector('storybook-router');4storybookRouter.navigate('/?path=/story/button--primary');5var storybookRouter = document.querySelector('storybook-router');6storybookRouter.navigateUrl('/?path=/story/button--primary');

Full Screen

Using AI Code Generation

copy

Full Screen

1import { navigateUrl } from 'storybook-root';2navigateUrl('/my-url');3import { navigateUrl } from 'storybook-root';4navigateUrl('/my-url');5import { navigateUrl } from 'storybook-root';6navigateUrl('/my-url');

Full Screen

Using AI Code Generation

copy

Full Screen

1import { navigateUrl } from 'storybook-root';2navigateUrl('/some/path');3export function navigateUrl(url) {4}5I’m not sure if I understand correctly, but I guess you’re suggesting to create a new file (storybook-root.js) and add the navigateUrl function in it. Am I right?6I’m not sure if I understand correctly, but I guess you’re suggesting to create a new file (storybook-root.js) and add the navigateUrl function in it. Am I right?7I’m not sure if I understand correctly, but I guess you’re suggesting to create a new file (storybook-root.js) and add the navigateUrl function in it. Am I right?

Full Screen

Using AI Code Generation

copy

Full Screen

1import { LitElement, html } from 'lit-element';2import { navigateUrl } from '@storybook/addon-links';3class StorybookRoot extends LitElement {4 static get properties() {5 return {6 url: { type: String },7 };8 }9 constructor() {10 super();11 this.url = '';12 }13 connectedCallback() {14 super.connectedCallback();15 this.url = window.location.href;16 }17 firstUpdated() {18 navigateUrl(this.url);19 }20 render() {21 return html` `;22 }23}24customElements.define('storybook-root', StorybookRoot);25import { document } from 'global';26import { addons, types } from '@storybook/addons';27import { EVENTS } from './constants';28const navigateUrl = url => {29 const event = new CustomEvent(EVENTS.NAVIGATE_URL, { detail: url });30 document.dispatchEvent(event);31};32export { navigateUrl };33import { document } from 'global';34import { addons, types } from '@storybook/addons';35import { EVENTS } from './constants';36const navigateUrl = url => {37 const event = new CustomEvent(EVENTS.NAVIGATE_URL, { detail: url });38 document.dispatchEvent(event);39};40export { navigateUrl };

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run storybook-root automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful