How to use the @pluginjs/dom.data function in @pluginjs/dom

To help you get started, we’ve selected a few @pluginjs/dom examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pluginjs / pluginjs / modules / wizard / src / main.js View on Github external
ele.addEventListener('click', e => {
    let href
    const target =
      attr('data-target', e.target) ||
      query(
        (href = attr('href', e.target)) && href.replace(/.*(?=#[^\s]+$)/, '')
      )

    const wizard = getData(NAMESPACE, target)

    if (!wizard) {
      return
    }

    const method = data(NAMESPACE, e.target)

    if (/^(back|next|first|finish|reset)$/.test(method)) {
      wizard[method]()
    }

    e.preventDefault()
  })
})
github pluginjs / pluginjs / modules / wizard / src / step.js View on Github external
setLoaderFromData() {
    const loader = getData('loader', this.pane)

    if (loader) {
      if (isFunction(window[loader])) {
        this.loader = window[loader]
      }
    } else {
      const url = getData('loader-url', this.pane)

      if (url) {
        this.loader = {
          url,
          settings: data('settings', this.pane) || {}
        }
      }
    }
  }
github pluginjs / pluginjs / modules / slider / src / main.js View on Github external
index = this.current === 0 ? length - 1 : this.current - 1
          pos = `${offset - 100}%`
          this.cards[i].inactive()
          break
        default:
          index = this.current
          pos = `${offset}%`
          this.cards[i].active()
          break
      }

      const card = this.cards[i].element
      const content = query(`.${this.classes.CONTENT}`, card)

      if (content) {
        const oldIndex = parseInt(data('index', content), 10)

        if (index !== oldIndex) {
          const module = this.modules[oldIndex]

          if (module.type === 'video' && module.isload) {
            this.modules[oldIndex].video.destroy()
          }

          this.cards[i].createModule(this.data[index], index)
          this.cards[i].module.setData({ index }).replace(content)
        }
      } else {
        this.cards[i].createModule(this.data[index], index)
        this.cards[i].module.setData({ index }).appendTo(card)
      }
github pluginjs / pluginjs / modules / wizard / src / step.js View on Github external
setValidatorFromData() {
    const validator = data('validator', this.pane)
    if (validator && isFunction(window[validator])) {
      this.validator = window[validator]
    }
  }
github pluginjs / pluginjs / modules / slider / src / main.js View on Github external
children(this.element).forEach(element => {
      switch (element.tagName.toLowerCase()) {
        case 'img':
          dataArr.push({
            type: 'image',
            src: attr('src', element)
          })
          break
        case 'video':
          dataArr.push({
            type: 'video',
            videoType: data('videoType', element),
            src: data('src', element),
            href: attr('href', element),
            id: data('id', element)
          })
          break
        default:
          if (data('type', element) === 'inline') {
            dataArr.push({
              type: 'inline',
              html: element.innerHTML
            })
          } else {
            dataArr.push({
              type: data('type', element),
              src: data('src', element)
            })
          }
      }
    })
github pluginjs / pluginjs / modules / bg-video / samples / src / sections / html5 / index.js View on Github external
query('.api', root).addEventListener('click', event => {
  const el = event.target
  if (!el.matches('[data-api]')) {
    return
  }
  instance[data('api', el)]()
})
github pluginjs / pluginjs / modules / pop-dialog / src / main.js View on Github external
this.eventName('click'),
      `.${this.classes.BUTTON}`,
      ({ target }) => {
        this.do(
          hasClass(this.classes.BUTTON, target)
            ? data('action', target)
            : compose(
                data('action'),
                closest(`.${this.classes.BUTTON}`)
              )(target)
        )
        return false
      },
      $tip
    )
    data({ buttonEventsBinded: true }, $tip)
  }
github pluginjs / pluginjs / modules / modal / src / main.js View on Github external
event => {
          if (
            !event.target.classList.contains(this.classes.BUTTON) ||
            !data('action', event.target)
          ) {
            return false
          }

          const action = data('action', event.target)

          for (let i = 0; i < this.options.buttons.length; i++) {
            if (action === this.options.buttons[i].action) {
              const button = this.options.buttons[i]
              if (isFunction(button.fn)) {
                button.fn(this.close.bind(this))
              } else {
                this.close()
              }
            }
          }

          return false
        },
        this.$buttons