How to use the @pluginjs/dom.insertBefore 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 / time-table / src / components / month / monthEvent.js View on Github external
addEvent(data) {
    this.length++
    const e = this.createHtml(data)
    const point = query('span', e)
    setStyle('background-color', data.color, point)
    this.events.push(e)

    insertBefore(e, this.$more)
    this.update()

    // this.updateMore()
  }
github pluginjs / pluginjs / modules / font-editor / src / main.js View on Github external
buildDropdown() {
    insertBefore(this.fontFamily.$wrap, this.$Control)
    insertBefore(this.fontWeight.$wrap, this.$Control)
    insertBefore(this.fontSize.$wrap, this.$Control)
    insertBefore(this.lineHeight.$wrap, this.$Control)
    insertBefore(this.textAlign.$wrap, this.$Control)
  }
github pluginjs / pluginjs / modules / nav-to-select / src / main.js View on Github external
this.options.multiple ? 'multiple' : ''
      }/>`
    )
    this.select.innerHTML = this.buildOptions(items, 1)

    wrap(this.wrap, this.select)

    if (this.options.prependTo === null) {
      insertAfter(this.wrap, this.element)
    } else {
      const prependTo =
        typeof this.options.prependTo === 'string'
          ? this.options.prependTo
          : query(this.options.prependTo)

      insertBefore(this.wrap, prependTo)
    }
    this.enter('builded')
  }
github pluginjs / pluginjs / modules / bg-picker / src / main.js View on Github external
this.PREVIEW = new Preview(this)
    this.IMAGE = new Image(this)

    this.value = this.element.value

    this.val(this.value, false)

    this.bind()

    if (this.element.disabled || this.options.disabled) {
      this.disable()
    }

    this.initDropdown(this.options.dropdown)

    insertBefore(this.POSITION.$wrap, this.$control)
    insertBefore(this.REPEAT.$wrap, this.$control)
    insertBefore(this.ATTACHMENT.$wrap, this.$control)
    insertBefore(this.SIZE.$wrap, this.$control)
    insertBefore(this.IMAGE.$wrap, this.$control)

    this.enter('initialized')
    this.trigger(EVENTS.READY)
  }
github pluginjs / pluginjs / modules / tabs / src / responsive.js View on Github external
) {
      return
    }

    const options = this.instance.options

    if (this.mode === 'drop') {
      if (options.navLabelSelector) {
        this.instance.navLabel = query(
          options.navLabelSelector,
          this.instance.element
        )
      } else {
        this.instance.navLabel = parseHTML(options.navLabelTpl)
        addClass(this.instance.classes.NAVLABEL, this.instance.navLabel)
        insertBefore(this.instance.navLabel, this.instance.$nav)
      }

      this.dropToggle(true)
    } else if (this.mode === 'scroll') {
      if (options.navWrapSelector) {
        this.instance.navWrap = query(
          options.navWrapSelector,
          this.instance.element
        )
      } else {
        const navWrap = parseHTML(options.navWrapTpl)
        addClass(this.instance.classes.NAVWRAP, navWrap)
        wrap(navWrap, this.instance.$nav)

        this.instance.navWrap = query(
          `.${this.instance.classes.NAVWRAP}`,
github pluginjs / pluginjs / modules / list / src / main.js View on Github external
sort(oldIndex, newIndex = -1, dom = true) {
    if (oldIndex !== newIndex) {
      const item = this.data[oldIndex]

      if (newIndex <= -1) {
        newIndex = this.data.length - 1
      }

      if (dom) {
        const $item = this.getItem(oldIndex)
        const $new = this.getItem(newIndex)

        if (oldIndex > newIndex) {
          insertBefore($item, $new)
        } else {
          insertAfter($item, $new)
        }
      }

      if (oldIndex > newIndex) {
        this.data.splice(newIndex, 0, item)
        this.data.splice(oldIndex + 1, 1)
      } else {
        this.data.splice(newIndex + 1, 0, item)
        this.data.splice(oldIndex, 1)
      }

      this.trigger(EVENTS.SORT, oldIndex, newIndex, item)
    }
  }
github pluginjs / pluginjs / modules / infinite / src / main.js View on Github external
showLoader() {
    if (!this.options.loader) {
      return
    }
    if (!this.$loader) {
      this.$loader = document.createElement('div')
      addClass(this.classes.LOADER, this.$loader)
      this.LOADER = Loader.of(this.$loader, this.options.loader)

      if (this.options.item && this.options.horizontal) {
        setStyle(this.getItemStyle(), this.$loader)
      }
    }
    insertBefore(this.$loader, this.$last)
    this.LOADER.show()
  }
github pluginjs / pluginjs / modules / paginator / src / components / list.js View on Github external
if (this.hasPrev()) {
        if (this.prev) {
          this.prev.remove()
        }
        this.prev = parseHTML(this.generatePrev())
        insertAfter(this.prev, items[0])
      } else if (this.prev) {
        this.prev.remove()
      }

      if (this.hasNext()) {
        if (this.next) {
          this.next.remove()
        }
        this.next = parseHTML(this.generateNext())
        insertBefore(this.next, items[items.length - 1])
      } else if (this.next) {
        this.next.remove()
      }

      newPages.forEach(page => {
        if (oldPages.indexOf(page) === -1) {
          if (page < oldPages[0]) {
            const pagehtml = itemTemplate({
              classes: this.instance.classes,
              page
            })

            insertBefore(pagehtml, start)
          } else {
            const endEl = parseHTML(
              itemTemplate({
github pluginjs / pluginjs / modules / infinite / src / main.js View on Github external
resolveEnd() {
    this.$end = parseHTML(
      template.compile(this.options.templates.end())({
        classes: this.classes,
        endText: this.translate('endText')
      })
    )
    insertBefore(this.$end, this.$last)
    if (this.options.trigger === 'button') {
      this.$button.remove()
    }
    this.trigger(EVENTS.END)
    this.enter('end')
  }