Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const swiper = this;
const { rtlTranslate: rtl } = swiper;
let e = event;
if (e.originalEvent) e = e.originalEvent; // jquery fix
const kc = e.keyCode || e.charCode;
// Directions locks
if (!swiper.allowSlideNext && ((swiper.isHorizontal() && kc === 39) || (swiper.isVertical() && kc === 40))) {
return false;
}
if (!swiper.allowSlidePrev && ((swiper.isHorizontal() && kc === 37) || (swiper.isVertical() && kc === 38))) {
return false;
}
if (e.shiftKey || e.altKey || e.ctrlKey || e.metaKey) {
return undefined;
}
if (document.activeElement && document.activeElement.nodeName && (document.activeElement.nodeName.toLowerCase() === 'input' || document.activeElement.nodeName.toLowerCase() === 'textarea')) {
return undefined;
}
if (swiper.params.keyboard.onlyInViewport && (kc === 37 || kc === 39 || kc === 38 || kc === 40)) {
let inView = false;
// Check that swiper should be inside of visible area of window
if (swiper.$el.parents(`.${swiper.params.slideClass}`).length > 0 && swiper.$el.parents(`.${swiper.params.slideActiveClass}`).length === 0) {
return undefined;
}
const windowWidth = window.innerWidth;
const windowHeight = window.innerHeight;
const swiperOffset = swiper.$el.offset();
if (rtl) swiperOffset.left -= swiper.$el[0].scrollLeft;
const swiperCoord = [
[swiperOffset.left, swiperOffset.top],
[swiperOffset.left + swiper.width, swiperOffset.top],
[swiperOffset.left, swiperOffset.top + swiper.height],
function androidNeedsBlur(el) {
const noBlur = ('button input textarea select').split(' ');
if (document.activeElement && el !== document.activeElement && document.activeElement !== document.body) {
if (noBlur.indexOf(el.nodeName.toLowerCase()) >= 0) {
return false;
}
return true;
}
return false;
}
function targetNeedsFastClick(el) {
isScrolling: undefined,
startMoving: undefined,
});
touches.startX = startX;
touches.startY = startY;
data.touchStartTime = Utils.now();
swiper.allowClick = true;
swiper.updateSize();
swiper.swipeDirection = undefined;
if (params.threshold > 0) data.allowThresholdMove = false;
if (e.type !== 'touchstart') {
let preventDefault = true;
if ($targetEl.is(data.formElements)) preventDefault = false;
if (
document.activeElement
&& $(document.activeElement).is(data.formElements)
&& document.activeElement !== $targetEl[0]
) {
document.activeElement.blur();
}
const shouldPreventDefault = preventDefault && swiper.allowTouchMove && params.touchStartPreventDefault;
if (params.touchStartForcePreventDefault || shouldPreventDefault) {
e.preventDefault();
}
}
swiper.emit('touchStart', e);
}
sb.$pageEl.find('.page-content').addClass('with-searchbar-expandable-enabled');
}
if (app.theme === 'md' && sb.$el.parents('.navbar').length) {
sb.$el.parents('.navbar').addClass('with-searchbar-expandable-enabled');
} else {
sb.$el.parents('.navbar').addClass('with-searchbar-expandable-enabled');
sb.$el.parents('.navbar-large').addClass('navbar-large-collapsed');
}
}
if (sb.$hideOnEnableEl) sb.$hideOnEnableEl.addClass('hidden-by-searchbar');
sb.$el.trigger('searchbar:enable');
sb.emit('local::enable searchbarEnable', sb);
}
let needsFocus = false;
if (setFocus === true) {
if (document.activeElement !== sb.inputEl) {
needsFocus = true;
}
}
const isIos = app.device.ios && app.theme === 'ios';
if (isIos) {
if (sb.expandable) {
if (needsFocus) sb.$inputEl.focus();
enable();
} else {
if (needsFocus) sb.$inputEl.focus();
if (setFocus && (setFocus.type === 'focus' || setFocus === true)) {
Utils.nextTick(() => {
enable();
}, 400);
} else {
enable();
if (
(pageY < touches.startY && swiper.translate <= swiper.maxTranslate())
|| (pageY > touches.startY && swiper.translate >= swiper.minTranslate())
) {
data.isTouched = false;
data.isMoved = false;
return;
}
} else if (
(pageX < touches.startX && swiper.translate <= swiper.maxTranslate())
|| (pageX > touches.startX && swiper.translate >= swiper.minTranslate())
) {
return;
}
}
if (data.isTouchEvent && document.activeElement) {
if (e.target === document.activeElement && $(e.target).is(data.formElements)) {
data.isMoved = true;
swiper.allowClick = false;
return;
}
}
if (data.allowTouchCallbacks) {
swiper.emit('touchMove', e);
}
if (e.targetTouches && e.targetTouches.length > 1) return;
touches.currentX = pageX;
touches.currentY = pageY;
const diffX = touches.currentX - touches.startX;
const diffY = touches.currentY - touches.startY;
onBlur() {
const self = this;
if (self.params.placeholder && self.$contentEl.html() === '') {
self.insertPlaceholder();
}
if (self.params.mode === 'popover') {
const selection = window.getSelection();
const selectionIsInContent = $(selection.anchorNode).parents(self.contentEl).length || selection.anchorNode === self.contentEl;
const inPopover = document.activeElement && self.popover && $(document.activeElement).closest(self.popover.$el).length;
if (!inPopover && !selectionIsInContent) {
self.closePopover();
}
}
if (self.params.mode === 'keyboard-toolbar') {
const selection = window.getSelection();
const selectionIsInContent = $(selection.anchorNode).parents(self.contentEl).length || selection.anchorNode === self.contentEl;
if (!selectionIsInContent) {
self.closeKeyboardToolbar();
}
}
self.$el.trigger('texteditor:blur');
self.emit('local::blur textEditorBlur', self);
}
buttons.forEach((button, index) => {
if (button.keyCodes && button.keyCodes.indexOf(keyCode) >= 0) {
if (document.activeElement) document.activeElement.blur();
if (button.onClick) button.onClick(dialog, e);
if (dialog.params.onClick) dialog.params.onClick(dialog, index);
if (button.close !== false) dialog.close();
}
});
}
$(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 {