Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function onTabLoaded(contentEl) {
// Remove theme elements
router.removeThemeElements($newTabEl);
let tabEventTarget = $newTabEl;
if (typeof contentEl !== 'string') tabEventTarget = $(contentEl);
tabEventTarget.trigger('tab:init tab:mounted', tabRoute);
router.emit('tabInit tabMounted', $newTabEl[0], tabRoute);
if ($oldTabEl && router.params.unloadTabContent) {
if (animated) {
onTabsChanged(() => {
router.tabRemove($oldTabEl, $newTabEl, tabRoute);
});
} else {
router.tabRemove($oldTabEl, $newTabEl, tabRoute);
}
}
}
if (!router.params.unloadTabContent) {
$pagesToRemove.each((index, pageEl) => {
const $oldPageEl = $(pageEl);
const $oldNavbarInnerEl = $(app.navbar.getElByPage($oldPageEl));
if (router.params.stackPages && router.initialPages.indexOf($oldPageEl[0]) >= 0) {
$oldPageEl.addClass('stacked');
if (separateNavbar) {
$oldNavbarInnerEl.addClass('stacked');
}
} else {
// Page remove event
router.pageCallback('beforeRemove', $oldPageEl, $oldNavbarInnerEl, 'previous', undefined, {});
router.removePage($oldPageEl);
if (separateNavbar && $oldNavbarInnerEl.length) {
router.removeNavbar($oldNavbarInnerEl);
}
}
});
}
function onFocus() {
const inputEl = this;
if (app.params.input.scrollIntoViewOnFocus) {
if (Device.android) {
$(window).once('resize', () => {
if (document && document.activeElement === inputEl) {
app.input.scrollIntoView(inputEl, app.params.input.scrollIntoViewDuration, app.params.input.scrollIntoViewCentered, app.params.input.scrollIntoViewAlways);
}
});
} else {
app.input.scrollIntoView(inputEl, app.params.input.scrollIntoViewDuration, app.params.input.scrollIntoViewCentered, app.params.input.scrollIntoViewAlways);
}
}
app.input.focus(inputEl);
}
function onBlur() {
function targetNeedsPrevent(el) {
const $el = $(el);
let prevent = true;
if ($el.is('label') || $el.parents('label').length > 0) {
if (Device.android) {
prevent = false;
} else if (Device.ios && $el.is('input')) {
prevent = true;
} else prevent = false;
}
return prevent;
}
if ($el[0].f7Panel) return $el[0].f7Panel;
$el[0].f7Panel = panel;
let { side, effect, resizable } = panel.params;
if (typeof side === 'undefined') side = $el.hasClass('panel-left') ? 'left' : 'right';
if (typeof effect === 'undefined') effect = $el.hasClass('panel-cover') ? 'cover' : 'reveal';
if (typeof resizable === 'undefined') resizable = $el.hasClass('panel-resizable');
let $backdropEl;
if (panel.params.backdrop && panel.params.backdropEl) {
$backdropEl = $(panel.params.backdropEl);
} else if (panel.params.backdrop) {
$backdropEl = app.root.children('.panel-backdrop');
if ($backdropEl.length === 0) {
$backdropEl = $('<div class="panel-backdrop"></div>');
app.root.prepend($backdropEl);
}
}
Utils.extend(panel, {
app,
side,
effect,
resizable,
$el,
el: $el[0],
opened: false,
$backdropEl,
backdropEl: $backdropEl && $backdropEl[0],
});
toggle(el) {
const app = this;
const $el = $(el);
if ($el.length === 0) return;
if ($el.hasClass('accordion-item-opened')) app.accordion.close(el);
else app.accordion.open(el);
},
};
getPageEl(content) {
const router = this;
if (typeof content === 'string') {
router.tempDom.innerHTML = content;
} else {
if ($(content).hasClass('page')) {
return content;
}
router.tempDom.innerHTML = '';
$(router.tempDom).append(content);
}
return router.findElement('.page', router.tempDom);
}
function onSubmitChange(e, fromData) {
const $formEl = $(this);
if (e.type === 'change' && !$formEl.hasClass('form-ajax-submit-onchange')) return;
if (e.type === 'submit') e.preventDefault();
if (e.type === 'change' && fromData === 'fromdata') return;
const method = ($formEl.attr('method') || 'GET').toUpperCase();
const contentType = $formEl.prop('enctype') || $formEl.attr('enctype');
const url = $formEl.attr('action');
if (!url) return;
let data;
if (method === 'POST') {
if (contentType === 'application/x-www-form-urlencoded') {
data = app.form.convertToData($formEl[0]);
} else {
function initSwiper(swiperEl) {
const app = this;
const $swiperEl = $(swiperEl);
if ($swiperEl.length === 0) return;
if ($swiperEl[0].swiper) return;
let initialSlide;
let params = {};
let isTabs;
let isRoutableTabs;
if ($swiperEl.hasClass('tabs-swipeable-wrap')) {
$swiperEl
.addClass('swiper-container')
.children('.tabs')
.addClass('swiper-wrapper')
.children('.tab')
.addClass('swiper-slide');
initialSlide = $swiperEl.children('.tabs').children('.tab-active').index();
isTabs = true;
isRoutableTabs = $swiperEl.find('.tabs-routable').length > 0;
function initSwipers(swiperEl) {
const app = this;
const $swiperEl = $(swiperEl);
if ($swiperEl.length === 0) return;
if ($swiperEl[0].swiper) return;
let initialSlide;
let params = {};
let isTabs;
let isRoutableTabs;
if ($swiperEl.hasClass('tabs-swipeable-wrap')) {
$swiperEl
.addClass('swiper-container')
.children('.tabs')
.addClass('swiper-wrapper')
.children('.tab')
.addClass('swiper-slide');
initialSlide = $swiperEl.children('.tabs').children('.tab-active').index();
isTabs = true;
isRoutableTabs = $swiperEl.find('.tabs-routable').length > 0;