Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if ("universal" !== 'desktop') {
if (
(view && router.params.iosSwipeBack && app.theme === 'ios')
|| (view && router.params.mdSwipeBack && app.theme === 'md')
) {
SwipeBack(router);
}
}
// Dynamic not separated navbbar
if (router.dynamicNavbar && !router.separateNavbar) {
router.$el.addClass('router-dynamic-navbar-inside');
}
let initUrl = router.params.url;
let documentUrl = document.location.href.split(document.location.origin)[1];
let historyRestored;
const { pushState, pushStateOnLoad, pushStateSeparator, pushStateAnimateOnLoad } = router.params;
let { pushStateRoot } = router.params;
if (window.cordova && pushState && !pushStateSeparator && !pushStateRoot && document.location.pathname.indexOf('index.html')) {
// eslint-disable-next-line
console.warn('Framework7: wrong or not complete pushState configuration, trying to guess pushStateRoot');
pushStateRoot = document.location.pathname.split('index.html')[0];
}
if (!pushState || !pushStateOnLoad) {
if (!initUrl) {
initUrl = documentUrl;
}
if (document.location.search && initUrl.indexOf('?') < 0) {
initUrl += document.location.search;
}
init() {
const router = this;
const { app, view } = router;
// Init Swipeback
if (
(view && router.params.iosSwipeBack && app.theme === 'ios')
|| (view && router.params.mdSwipeBack && app.theme === 'md')
|| (view && router.params.auroraSwipeBack && app.theme === 'aurora')
) {
SwipeBack(router);
}
let initUrl = router.params.url;
let documentUrl = document.location.href.split(document.location.origin)[1];
let historyRestored;
const { pushState, pushStateOnLoad, pushStateSeparator, pushStateAnimateOnLoad } = router.params;
let { pushStateRoot } = router.params;
if (window.cordova && pushState && !pushStateSeparator && !pushStateRoot && document.location.pathname.indexOf('index.html')) {
// eslint-disable-next-line
console.warn('Framework7: wrong or not complete pushState configuration, trying to guess pushStateRoot');
pushStateRoot = document.location.pathname.split('index.html')[0];
}
if (!pushState || !pushStateOnLoad) {
if (!initUrl) {
initUrl = documentUrl;
}
if (document.location.search && initUrl.indexOf('?') < 0) {
initUrl += document.location.search;
}
if (document.location.hash && initUrl.indexOf('#') < 0) {
init() {
const router = this;
const { app, view } = router;
// Init Swipeback
if (
(view && router.params.iosSwipeBack && app.theme === 'ios')
|| (view && router.params.mdSwipeBack && app.theme === 'md')
|| (view && router.params.auroraSwipeBack && app.theme === 'aurora')
) {
SwipeBack(router);
}
let initUrl = router.params.url;
let documentUrl = document.location.href.split(document.location.origin)[1];
let historyRestored;
const { pushState, pushStateOnLoad, pushStateSeparator, pushStateAnimateOnLoad } = router.params;
let { pushStateRoot } = router.params;
if (window.cordova && pushState && !pushStateSeparator && !pushStateRoot && document.location.pathname.indexOf('index.html')) {
// eslint-disable-next-line
console.warn('Framework7: wrong or not complete pushState configuration, trying to guess pushStateRoot');
pushStateRoot = document.location.pathname.split('index.html')[0];
}
if (!pushState || !pushStateOnLoad) {
if (!initUrl) {
initUrl = documentUrl;
}
if (document.location.search && initUrl.indexOf('?') < 0) {
initUrl += document.location.search;
}
if (document.location.hash && initUrl.indexOf('#') < 0) {
const { pushState, pushStateOnLoad, pushStateSeparator, pushStateAnimateOnLoad } = router.params;
let { pushStateRoot } = router.params;
if (window.cordova && pushState && !pushStateSeparator && !pushStateRoot && document.location.pathname.indexOf('index.html')) {
// eslint-disable-next-line
console.warn('Framework7: wrong or not complete pushState configuration, trying to guess pushStateRoot');
pushStateRoot = document.location.pathname.split('index.html')[0];
}
if (!pushState || !pushStateOnLoad) {
if (!initUrl) {
initUrl = documentUrl;
}
if (document.location.search && initUrl.indexOf('?') < 0) {
initUrl += document.location.search;
}
if (document.location.hash && initUrl.indexOf('#') < 0) {
initUrl += document.location.hash;
}
} else {
if (pushStateRoot && documentUrl.indexOf(pushStateRoot) >= 0) {
documentUrl = documentUrl.split(pushStateRoot)[1];
if (documentUrl === '') documentUrl = '/';
}
if (pushStateSeparator.length > 0 && documentUrl.indexOf(pushStateSeparator) >= 0) {
initUrl = documentUrl.split(pushStateSeparator)[1];
} else {
initUrl = documentUrl;
}
router.restoreHistory();
if (router.history.indexOf(initUrl) >= 0) {
router.history = router.history.slice(0, router.history.indexOf(initUrl) + 1);
} else if (router.params.url === initUrl) {
router.history = [initUrl];
) {
SwipeBack(router);
}
}
// Dynamic not separated navbbar
if (router.dynamicNavbar && !router.separateNavbar) {
router.$el.addClass('router-dynamic-navbar-inside');
}
let initUrl = router.params.url;
let documentUrl = document.location.href.split(document.location.origin)[1];
let historyRestored;
const { pushState, pushStateOnLoad, pushStateSeparator, pushStateAnimateOnLoad } = router.params;
let { pushStateRoot } = router.params;
if (window.cordova && pushState && !pushStateSeparator && !pushStateRoot && document.location.pathname.indexOf('index.html')) {
// eslint-disable-next-line
console.warn('Framework7: wrong or not complete pushState configuration, trying to guess pushStateRoot');
pushStateRoot = document.location.pathname.split('index.html')[0];
}
if (!pushState || !pushStateOnLoad) {
if (!initUrl) {
initUrl = documentUrl;
}
if (document.location.search && initUrl.indexOf('?') < 0) {
initUrl += document.location.search;
}
if (document.location.hash && initUrl.indexOf('#') < 0) {
initUrl += document.location.hash;
}
} else {
setHash() {
const swiper = this;
if (!swiper.hashNavigation.initialized || !swiper.params.hashNavigation.enabled) return;
if (swiper.params.hashNavigation.replaceState && window.history && window.history.replaceState) {
window.history.replaceState(null, null, (`#${swiper.slides.eq(swiper.activeIndex).attr('data-hash')}` || ''));
} else {
const slide = swiper.slides.eq(swiper.activeIndex);
const hash = slide.attr('data-hash') || slide.attr('data-history');
document.location.hash = hash || '';
}
},
init() {
init() {
const swiper = this;
if (!swiper.params.hashNavigation.enabled || (swiper.params.history && swiper.params.history.enabled)) return;
swiper.hashNavigation.initialized = true;
const hash = document.location.hash.replace('#', '');
if (hash) {
const speed = 0;
for (let i = 0, length = swiper.slides.length; i < length; i += 1) {
const slide = swiper.slides.eq(i);
const slideHash = slide.attr('data-hash') || slide.attr('data-history');
if (slideHash === hash && !slide.hasClass(swiper.params.slideDuplicateClass)) {
const index = slide.index();
swiper.slideTo(index, speed, swiper.params.runCallbacksOnInit, true);
}
}
}
if (swiper.params.hashNavigation.watchState) {
$(window).on('hashchange', swiper.hashNavigation.onHashCange);
}
},
destroy() {
setHash() {
const swiper = this;
if (!swiper.hashNavigation.initialized || !swiper.params.hashNavigation.enabled) return;
if (swiper.params.hashNavigation.replaceState && window.history && window.history.replaceState) {
window.history.replaceState(null, null, (`#${swiper.slides.eq(swiper.activeIndex).attr('data-hash')}` || ''));
} else {
const slide = swiper.slides.eq(swiper.activeIndex);
const hash = slide.attr('data-hash') || slide.attr('data-history');
document.location.hash = hash || '';
}
},
init() {
onHashCange() {
const swiper = this;
const newHash = document.location.hash.replace('#', '');
const activeSlideHash = swiper.slides.eq(swiper.activeIndex).attr('data-hash');
if (newHash !== activeSlideHash) {
const newIndex = swiper.$wrapperEl.children(`.${swiper.params.slideClass}[data-hash="${newHash}"]`).index();
if (typeof newIndex === 'undefined') return;
swiper.slideTo(newIndex);
}
},
setHash() {