How to use the @pluginjs/decorator.optionable function in @pluginjs/decorator

To help you get started, we’ve selected a few @pluginjs/decorator 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 / popover / src / main.js View on Github external
import {
  classes as CLASSES,
  defaults as DEFAULTS,
  dependencies as DEPENDENCIES,
  events as EVENTS,
  methods as METHODS,
  namespace as NAMESPACE
} from './constant'
import Tooltip from '@pluginjs/tooltip'

/* Credit to bootstrap popover http://getbootstrap.com MIT */
@themeable()
@styleable(CLASSES)
@eventable(EVENTS)
@stateable()
@optionable(DEFAULTS, true)
@register(NAMESPACE, {
  methods: METHODS,
  dependencies: DEPENDENCIES
})
class Popover extends Tooltip {
  constructor(element, options = {}) {
    super(element, options)
  }

  createTip() {
    let arrow = ''
    let close = ''

    if (this.options.close) {
      close = templateEngine.render(this.options.templates.close.call(this), {
        classes: this.classes
github pluginjs / pluginjs / modules / infinite / src / main.js View on Github external
import { addClass, removeClass } from '@pluginjs/classes'
import { query, append, insertBefore, detach, parseHTML } from '@pluginjs/dom'
import { isNumber, isString, isFunction } from '@pluginjs/is'
import { getStyle, setStyle } from '@pluginjs/styled'
import History from './history'
import { intersectionObserverPolyfill } from '@pluginjs/polyfills'
// import 'whatwg-fetch'

intersectionObserverPolyfill()

@translateable(TRANSLATIONS)
@themeable()
@styleable(CLASSES)
@eventable(EVENTS)
@stateable()
@optionable(DEFAULTS, true)
@register(NAMESPACE, {
  methods: METHODS,
  dependencies: DEPENDENCIES
})
class Infinite extends Component {
  constructor(element, options = {}) {
    super(element)

    this.setupOptions(options)
    this.setupI18n()
    this.setupClasses()
    this.setupStates()
    this.initialize()
  }

  initialize() {
github pluginjs / pluginjs / modules / bg-video / src / main.js View on Github external
stateable,
  styleable,
  optionable
} from '@pluginjs/decorator'
import {
  classes as CLASSES,
  defaults as DEFAULTS,
  dependencies as DEPENDENCIES,
  events as EVENTS,
  methods as METHODS,
  namespace as NAMESPACE
} from './constant'

@styleable(CLASSES)
@eventable(EVENTS)
@optionable(DEFAULTS, true)
@stateable()
@register(NAMESPACE, {
  methods: METHODS,
  dependencies: DEPENDENCIES
})
class BgVideo extends Video {
  constructor(element, options = {}) {
    super(element, options)
  }

  initVideo() {
    this.$video = parseHTML(`<div class="${this.classes.NAMESPACE}"></div>`)

    if (this.options.theme) {
      addClass(this.getThemeClass(), this.$video)
    }
github pluginjs / pluginjs / modules / adapt-text / src / main.js View on Github external
import { compose } from '@pluginjs/utils'
import { setStyle, getStyle, getWidth } from '@pluginjs/styled'
import { parent } from '@pluginjs/dom'
import { bindEvent, removeEvent } from '@pluginjs/events'
import { eventable, register, stateable, optionable } from '@pluginjs/decorator'
import {
  defaults as DEFAULTS,
  events as EVENTS,
  methods as METHODS,
  namespace as NAMESPACE
} from './constant'
import anime from 'animejs'

@eventable(EVENTS)
@stateable()
@optionable(DEFAULTS, true)
@register(NAMESPACE, {
  methods: METHODS
})
class AdaptText extends Component {
  constructor(element, options = {}) {
    super(element)
    this.setupOptions(options)

    const display = getStyle('display', this.element)
    this.inline = display === 'inline' || Boolean(display === 'inline-block')
    this.width = this.getWidth()

    this.setupStates()
    this.initialize()
  }
github pluginjs / pluginjs / modules / rate / src / main.js View on Github external
themeable,
  optionable
} from '@pluginjs/decorator'
import {
  classes as CLASSES,
  defaults as DEFAULTS,
  events as EVENTS,
  methods as METHODS,
  namespace as NAMESPACE
} from './constant'

@themeable()
@styleable(CLASSES)
@eventable(EVENTS)
@stateable()
@optionable(DEFAULTS, true)
@register(NAMESPACE, {
  methods: METHODS
})
class Rate extends Component {
  constructor(element, options = {}) {
    super(element)
    this.setupOptions(options)
    this.setupClasses()

    if (this.options.theme) {
      addClass(this.getThemeClass, this.element)
    }

    this.setupStates()
    this.initialize()
  }
github pluginjs / pluginjs / modules / thumbnails / src / main.js View on Github external
dependencies as DEPENDENCIES,
  events as EVENTS,
  methods as METHODS,
  namespace as NAMESPACE
} from './constant'

import Swipeable from '@pluginjs/swipeable'
import ImageLoader from '@pluginjs/image-loader'
import Loader from '@pluginjs/loader'
import Breakpoints from '@pluginjs/breakpoints'

@themeable()
@styleable(CLASSES)
@eventable(EVENTS)
@stateable()
@optionable(DEFAULTS, true)
@register(NAMESPACE, {
  methods: METHODS,
  dependencies: DEPENDENCIES
})
class Thumbnails extends Component {
  constructor(element, options = {}) {
    super(element)

    this.setupOptions(options)

    this.distance = 0
    this.pos = 0
    this.current = null
    this.dif = null

    this.setupClasses()
github pluginjs / pluginjs / modules / loader / src / main.js View on Github external
themeable,
  optionable
} from '@pluginjs/decorator'
import {
  classes as CLASSES,
  defaults as DEFAULTS,
  events as EVENTS,
  methods as METHODS,
  namespace as NAMESPACE
} from './constant'

@themeable()
@styleable(CLASSES)
@eventable(EVENTS)
@stateable()
@optionable(DEFAULTS, true)
@register(NAMESPACE, {
  methods: METHODS
})
class Loader extends Component {
  constructor(element, options = {}) {
    super(element)

    this.setupOptions(options)
    this.setupClasses()
    this.setupStates()
    this.initialize()
  }

  initialize() {
    this.$mask = appendTo(
      `<div class="${this.classes.MASK}"></div>`,
github pluginjs / pluginjs / modules / zoom / src / main.js View on Github external
namespace as NAMESPACE
} from './constant'
import ImageLoader from '@pluginjs/image-loader'
import { bindEvent, removeEvent, bindEventOnce } from '@pluginjs/events'
import { isFunction, isString, isObject } from '@pluginjs/is'
import { addClass, removeClass } from '@pluginjs/classes'
import { setStyle } from '@pluginjs/styled'
import Pj from '@pluginjs/factory'
import Keyboard from './keyboard'
import Overlay from './overlay'

@themeable()
@styleable(CLASSES)
@eventable(EVENTS)
@stateable()
@optionable(DEFAULTS, true)
@register(NAMESPACE, {
  methods: METHODS,
  dependencies: DEPENDENCIES
})
class Zoom extends Component {
  constructor(element, options = {}) {
    super(element)

    this.setupOptions(options)
    this.setupClasses()
    this.setupStates()

    this.image = {}
    ;['src', 'sizes', 'srcset'].forEach(prop => {
      if (this.element[prop]) {
        this.image[prop] = this.element[prop]
github pluginjs / pluginjs / modules / countdown / src / main.js View on Github external
namespace as NAMESPACE,
  KEY_MAP
} from './constant'

import Times from './times'
import simple from './modes/simple'
import Progress from './modes/progress'
import Flip from './modes/flip'

const MODES = {}

@themeable()
@styleable(CLASSES)
@eventable(EVENTS)
@stateable()
@optionable(DEFAULTS, true)
@register(NAMESPACE, {
  methods: METHODS
})
class CountDown extends Component {
  _interval = {
    createTimer: time => {
      this.timer = () => {
        this.update()
      }
      return window.setInterval(this.timer, time)
    },
    removeTimer: () => {
      window.clearInterval(this.timer())
    }
  }
github pluginjs / pluginjs / modules / select / src / main.js View on Github external
import Loading from './loading'
import { removeEvent } from '@pluginjs/events'
import { addClass, removeClass } from '@pluginjs/classes'
import Dropdown from '@pluginjs/dropdown'
import { insertAfter, appendTo, html, parseHTML } from '@pluginjs/dom'
import { deepClone, triggerNative } from '@pluginjs/utils'

const isInput = el => el.tagName === 'INPUT'
const isSelect = el => el.tagName === 'SELECT'

@translateable(TRANSLATIONS)
@themeable()
@styleable(CLASSES)
@eventable(EVENTS)
@stateable()
@optionable(DEFAULTS, true)
@register(NAMESPACE, {
  methods: METHODS,
  dependencies: DEPENDENCIES
})
class Select extends Component {
  constructor(element, options = {}) {
    super(element)

    this.setupOptions(options)
    this.setupClasses()
    this.setupStates()
    this.setupI18n()
    this.initialize()
  }

  initialize() {

@pluginjs/decorator

A flexible modern decorator js plugin.

GPL-3.0
Latest version published 2 years ago

Package Health Score

46 / 100
Full package analysis