How to use the @pluginjs/dom.setData 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 / lightbox / src / components / footer / thumbnails.js View on Github external
init() {
    this.thumbs = this.instance.getElement('thumbnails')
    this.inner = this.thumbs.children[0]
    this.elements = {}

    const length = this.instance.length
    for (let i = 1; i <= length; i++) {
      const item = this.instance.items[i]
      const itemHtml = this.instance.getElement('thumb')
      const image = itemHtml.children[0]
      // image.dataset.index = i
      setData('index', i, image)
      setStyle('background-image', `url(${item.thumbHref})`, image)
      append(itemHtml, this.inner)
      this.elements[i] = itemHtml
    }
    this.index = this.instance.activeIndex

    this.bind()
    this.goTo(this.instance.activeIndex)
  }
github pluginjs / pluginjs / modules / pattern-picker / src / main.js View on Github external
setPlugins() {
    this.$selected = this.$selecting
 
    if (!this.$selected) {
      return
    }

    const info = JSON.parse(JSON.stringify(getData('info', this.$selecting)))
    setData('info', info, this.$fillImg)

    if (info['background-color']) {
      this.bgColor = info['background-color']
    } else {
      info['background-color'] = this.options.bgColor
    }

    this.BGCOLOR.val(this.options.format(info, 'background-color'))
    this.FORECOLOR.val(this.options.format(info, 'color'))
    this.OPACITY.val(`${this.options.format(info, 'opacity')}%`)

    // set preview

    this.setInfo(this.$fillImg)
  }
github pluginjs / pluginjs / modules / pattern-picker / src / main.js View on Github external
setInfo(img) {
    const imgData = getData('info', img)
    setStyle(
      {
        backgroundColor: imgData['background-color'],

        // make '#' to '%23', fixed svg data image not working on FireFox.
        backgroundImage: imgData['background-image'].replace(/\#+/g, '%23')/* eslint-disable-line */

      },
      img
    )

    setData('info', imgData, img)
  }
github pluginjs / pluginjs / modules / tooltip / src / main.js View on Github external
toggle(event) {
    if (event) {
      const target = event.currentTarget
      let context = getData(this.plugin, target)

      if (!context) {
        context = this.constructor
          .getInstances()
          .find(plugin => plugin.element === this.element)
        setData(this.plugin, context, target)
      }

      context._activeTrigger.click = !context._activeTrigger.click

      if (context.isWithActiveTrigger()) {
        context._enter(null, context)
      } else {
        context._leave(null, context)
      }
    } else {
      if (hasClass(this.classes.SHOW, this.getTip())) {
        this._leave(null, this)
        return
      }

      this._enter(null, this)
github pluginjs / pluginjs / modules / tooltip / src / main.js View on Github external
const popperInstance = popperData.instance
    this.$tip = popperInstance.popper
    const lastPlacement = getData('lastPlacement', this.$tip)

    if (lastPlacement !== popperData.placement) {
      if (lastPlacement) {
        removeClass(
          this.getClass(this.classes.PLACEMENT, 'placement', lastPlacement),
          this.$tip
        )
      }

      this.addPlacementClass(popperData.placement)
    }

    setData('lastPlacement', popperData.placement, this.$tip)
  }
github pluginjs / pluginjs / modules / pattern-picker / src / main.js View on Github external
update(data, trigger = true) {
    if (this.is('save')) {
      if (data) {
        setData('info', data, this.$fillImg)
        this.setInfo(this.$fillImg)
      } else {
        this.data = getData('info', this.$fillImg)
      }

      this.module = 'custom'
      this.actived = true
      this.element.value = this.val()
      addClass(this.classes.SHOW, this.$wrap)

      if (trigger) {
        this.trigger(EVENTS.CHANGE, this.data)
        triggerNative(this.element, 'change')
      }
    } else if (!this.$selected) {
      this.clear()
github pluginjs / pluginjs / modules / toggle-list / src / constant.js View on Github external
WRAP: `{namespace} ${instance.classes.TOGGLE}`
          },
          size: 'small',
          checked: item.checked,
          clickable: true,
          dragable: false,
          onChange(checked) {
            const index = instance.getIndex($item)
            if (checked) {
              instance.check(index)
            } else {
              instance.uncheck(index)
            }
          }
        })
        setData('toggle', api, $item)
      }
    }
github pluginjs / pluginjs / modules / bg-picker / src / repeat.js View on Github external
this.values.forEach((value, key) => {
      setData('repeat', value, this.$items[key])
    })
github pluginjs / pluginjs / modules / gradient-selector / src / main.js View on Github external
update(data, trigger = true) {
    if (this.is('save')) {
      if (data) {
        setData('info', data, this.$fillImg)
        this.setInfo(this.$fillImg)
      } else {
        this.data = getData('info', this.$fillImg)
      }
      this.module = 'gradient'
      this.actived = true
      this.element.value = this.val()
      addClass(this.classes.SHOW, this.$wrap)

      if (trigger) {
        this.trigger(EVENTS.CHANGE, this.data)
        triggerNative(this.element, 'change')
      }
    } else if (!this.$selected) {
      this.clear()
    } else {
github pluginjs / pluginjs / modules / gradient-selector / src / main.js View on Github external
clear() {
    setData('info', '', this.$fillImg)
    setStyle(
      {
        backgroundImage: 'none'
      },
      this.$fillImg
    )

    this.GRADIENTPICKER.clear()

    this.$selecting = null
    this.$selected = null
    this.actived = false
    this.module = this.options.module

    this.element.value = ''