How to use the @pluginjs/dom.attr 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 / color-picker / src / main2.js View on Github external
constructor(element, options = {}) {
    super(NAMESPACE, element)
    // options
    this.initOptions(DEFAULTS, options)
    if (options.module) {
      this.options.module = options.module
    }
    this.firstClassName = this.element.className
    this.setupI18n()
    // class
    this.initClasses(CLASSES)
    compose(
      attr({ placeholder: this.options.placeholder }),
      addClass(this.classes.NAMESPACE, 'pj-input')
    )(this.element)
    // init global vars
    this.$body = query('body')

    this.module = this.options.module[0]
    this.contrast = true
    this.history = true

    this.data = DATA
    this.color = null
    this.oldColor = null
    this.solidModule = this.options.solidModule

    this.info = {
      collection: '',
github pluginjs / pluginjs / modules / initializer / samples / src / sections / custom / index.js View on Github external
(element, options) => {
    new Flip({
      ...options,
      node: element,
      from: attr('data-from', element),
      to: attr('data-to', element)
    })
  },
  {
github pluginjs / pluginjs / modules / auto-complete / src / main.js View on Github external
initialize() {
    this.data = []
    this.items = []

    attr(
      {
        autocomplete: 'off',
        spellcheck: 'false'
      },
      this.element
    )

    if (this.options.placeholder) {
      this.element.placeholder = this.options.placeholder
    }

    addClass(this.classes.INPUT, this.element)

    this.$trigger = wrap(
      templateEngine.render(this.options.templates.trigger.call(this), {
        classes: this.classes
github pluginjs / pluginjs / modules / lazyload / src / main.js View on Github external
attr('src', this.src, this.element)
      attr('srcset', this.srcset, this.element)
    } else if (this.element.tagName === 'PICTURE') {
      queryAll('source', this.element).forEach(source => {
        const src = getData('src', source)
        const srcset = getData('srcset', source)
        attr('src', src, source)
        attr('srcset', srcset, source)
      })
      const img = query('img', this.element)
      const src = getData('src', img)
      const srcset = getData('srcset', img)

      attr('src', src, img)
      attr('srcset', srcset, img)
    } else {
      setStyle('backgroundImage', `url(${this.src})`, this.element)
    }

    this.trigger(EVENTS.LOAD)
    loader.load()
  }
github pluginjs / pluginjs / modules / wizard / src / main.js View on Github external
get(index) {
    if (isString(index) && index.substring(0, 1) === '#') {
      const id = index.substring(1)
      for (const i in this.steps) {
        if (attr('id', this.steps[i].pane) === id) {
          return this.steps[i]
        }
      }
    }

    if (index < this.length() && this.steps[index]) {
      return this.steps[index]
    }

    return null
  }
github pluginjs / pluginjs / modules / lazyload / src / main.js View on Github external
this.trigger(EVENTS.LOADED)
      this.destroy()
    })

    if (this.element.tagName === 'IMG') {
      if (parent(this.element).tagName === 'PICTURE') {
        queryAll('source', parent(this.element)).forEach(source => {
          const src = getData('src', source)
          const srcset = getData('srcset', source)
          attr('src', src, source)
          attr('srcset', srcset, source)
        })
      }

      attr('src', this.src, this.element)
      attr('srcset', this.srcset, this.element)
    } else if (this.element.tagName === 'PICTURE') {
      queryAll('source', this.element).forEach(source => {
        const src = getData('src', source)
        const srcset = getData('srcset', source)
        attr('src', src, source)
        attr('srcset', srcset, source)
      })
      const img = query('img', this.element)
      const src = getData('src', img)
      const srcset = getData('srcset', img)

      attr('src', src, img)
      attr('srcset', srcset, img)
    } else {
      setStyle('backgroundImage', `url(${this.src})`, this.element)
    }
github pluginjs / pluginjs / modules / lazyload / src / main.js View on Github external
addClass(this.classes.LOADED, this.element)
      this.trigger(EVENTS.LOADED)
      this.destroy()
    })

    if (this.element.tagName === 'IMG') {
      if (parent(this.element).tagName === 'PICTURE') {
        queryAll('source', parent(this.element)).forEach(source => {
          const src = getData('src', source)
          const srcset = getData('srcset', source)
          attr('src', src, source)
          attr('srcset', srcset, source)
        })
      }

      attr('src', this.src, this.element)
      attr('srcset', this.srcset, this.element)
    } else if (this.element.tagName === 'PICTURE') {
      queryAll('source', this.element).forEach(source => {
        const src = getData('src', source)
        const srcset = getData('srcset', source)
        attr('src', src, source)
        attr('srcset', srcset, source)
      })
      const img = query('img', this.element)
      const src = getData('src', img)
      const srcset = getData('srcset', img)

      attr('src', src, img)
      attr('srcset', srcset, img)
    } else {
      setStyle('backgroundImage', `url(${this.src})`, this.element)
github pluginjs / pluginjs / modules / scroll-spy / src / main.js View on Github external
this.menuItems.forEach(item => {
      let activeElement
      if (this.options.cloestActive) {
        activeElement = item.closest(this.options.cloestActive)
      } else {
        activeElement = item.parentNode
      }

      removeClass(activeClass, activeElement)

      if (attr(this.options.hrefFrom, item) === `#${id}`) {
        addClass(activeClass, activeElement)
        this.activeElement = activeElement
        this.activeTarget = query(`#${id}`)
        this.trigger(EVENTS.CHANGE, `#${id}`)
      }
    })
  }
github pluginjs / pluginjs / modules / swipe / src / main.js View on Github external
`.${this.classes.ITEM}.${
            this.classes.CLONED
          }[data-swipe-item-index="${attr(
            'data-swipe-item-index',
            nextItem
          )}"]`,
          this.$inner
        ).forEach(children => {
          addClass(this.classes.CLONEDNEXT, children)
        })
      }
      if (hasClass(this.classes.CLONED, prevItem)) {
        children(
          `.${this.classes.ITEM}:not(.${
            this.classes.CLONED
          })[data-swipe-item-index="${attr(
            'data-swipe-item-index',
            prevItem
          )}"]`,
          this.$inner
        ).forEach(children => {
          addClass(this.classes.CLONEDPREV, children)
        })
      } else {
        children(
          `.${this.classes.ITEM}.${
            this.classes.CLONED
          }[data-swipe-item-index="${attr(
            'data-swipe-item-index',
            prevItem
          )}"]`,
          this.$inner
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)
            })
          }
      }