Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
initContainer() {
this.container = closest(`.${this.classes.CONTAINER}`, this.element)
if (!this.container) {
if (this.options.container) {
addClass(
this.classes.CONTAINER,
closest(this.options.container, this.element)
)
} else {
wrap(`<div class="${this.classes.CONTAINER}"></div>`, this.element)
}
this.container = parentWith(
hasClass(this.classes.CONTAINER),
this.element
)
}
this.containerOptions = this.container.dataset
? parseDataOptions(this.container.dataset)
: {}
if (this.containerOptions.height) {
initContainer() {
this.container = closest(`.${this.classes.CONTAINER}`, this.element)
if (!this.container) {
if (this.options.container) {
addClass(
this.classes.CONTAINER,
closest(this.options.container, this.element)
)
} else {
wrap(`<div class="${this.classes.CONTAINER}"></div>`, this.element)
}
this.container = parentWith(
hasClass(this.classes.CONTAINER),
this.element
)
}
img => {
if (this.options.loader) {
loader.hide()
}
addClass(this.classes.LOADED, closest(`.${this.classes.THUMB}`, img))
}
)
this.dropdown.on('tap', e => {
if (this.instance.is('disabled')) {
return
}
const { target } = e
const aTag = target.tagName === 'A' ? target : closest('A', target)
const liTag = target.tagName === 'LI' ? target : closest('LI', target)
if (aTag) {
this.switch()
} else if (liTag) {
this.labelActive(children(parent(liTag)).indexOf(liTag))
}
})
}
initViewport() {
if (!this.options.anchor) {
this.viewElement = this.element
} else {
this.viewElement = closest(this.options.anchor, this.element)
? closest(this.options.anchor, this.element)
: query(this.options.anchor)
}
if (!this.viewElement) {
throw new Error('Can not find anchor element')
}
this.viewport = Viewport.of(this.viewElement, {
container: this.container,
offset: this.options.offset,
threshold: this.options.threshold
})
}
click(e) {
const $target = e.target
if (
!this.$inputIcon.contains($target) &&
!this.$picker.contains($target) &&
!this.$element.contains($target) &&
this.options.alwaysShow === false
) {
this.hide()
} else if (
!this.$element.contains($target) &&
this.$picker.contains($target)
) {
const privateTarget = closest('div', $target)
const privateTargetSpan = closest('span', $target)
const queryParent = curry((selector, target) =>
closest(selector, target)
)
const queryContent = queryParent(`.${this.classes.CONTENT}`)
const indexOfParentElement = targetParent =>
children(parent(targetParent)).indexOf(targetParent)
const queryContentAndIndexOfParentElement = compose(
indexOfParentElement,
queryContent
)
if (queryParent(`.${this.classes.HEADER}`, privateTarget)) {
const i = queryContentAndIndexOfParentElement(privateTarget)
switch (privateTarget.className) {
case this.classes.CAPTION:
this.changeView('caption', i)
onChange: value => {
this.data.source = value
if (value === 'Local File') {
showElement(closest(`.${this.classes.FIELD}`, this.$localUrl))
hideElement(closest(`.${this.classes.FIELD}`, this.$videoUrl))
} else {
hideElement(closest(`.${this.classes.FIELD}`, this.$localUrl))
showElement(closest(`.${this.classes.FIELD}`, this.$videoUrl))
}
if (this.$videoPoster) {
setStyle('backgroundImage', null, this.$videoPoster)
}
removeClass(this.classes.POSTERSELECTED, this.$poster)
if (this.videoApi) {
if (query('.pj-video', this.$wrap)) {
this.removeVideo()
}
}
}
})
({ target }) => {
if (hasClass(this.classes.ACTION, target)) {
return
}
const $item = hasClass(this.classes.ITEM, target)
? target
: closest(`.${this.classes.ITEM}`, target)
const index = this.getIndex($item)
this.trigger(EVENTS.CLICKITEM, index, this.data[index])
},
this.$list