How to use the vc-cake.env function in vc-cake

To help you get started, we’ve selected a few vc-cake 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 VisualComposer / builder / public / sources / attributes / attachimage / filterItem.js View on Github external
getPublicImage (filename) {
    let { metaAssetsPath } = this.props
    if (!filename) {
      return ''
    }
    const isDynamic = env('VCV_JS_FT_DYNAMIC_FIELDS')
    if (isDynamic && filename.match(blockRegexp)) {
      let blockInfo = filename.split(blockRegexp)
      let blockAtts = JSON.parse(blockInfo[ 4 ])
      filename = getDynamicFieldsData({
        blockAtts: blockAtts
      })

      return filename
    }
    return filename.match('^(https?:)?\\/\\/?') ? filename : metaAssetsPath + filename
  }
github VisualComposer / builder / public / sources / attributes / dynamicField / dynamicAttribute.js View on Github external
constructor (props) {
    super(props)
    this.handleDynamicFieldOpen = this.handleDynamicFieldOpen.bind(this)
    this.handleDynamicFieldClose = this.handleDynamicFieldClose.bind(this)
    this.handleDynamicFieldChange = this.handleDynamicFieldChange.bind(this)
    this.onLoadPostFields = this.onLoadPostFields.bind(this)
    this.open = this.open.bind(this)
    this.hide = this.hide.bind(this)

    const isDynamic = env('VCV_JS_FT_DYNAMIC_FIELDS') && this.props.options && this.props.options.dynamicField
    let state = {
      isDynamic: isDynamic,
      dynamicFieldOpened: false,
      isWindowOpen: false,
      blockInfo: false
    }

    if (isDynamic) {
      let newState = this.getStateFromValue(this.props.value)
      state = { ...state, ...newState }
      if (state.blockInfo && state.blockInfo.blockAtts && state.blockInfo.blockAtts.sourceId) {
        window.setTimeout(() => {
          settingsStorage.trigger('loadDynamicPost', state.blockInfo.blockAtts.sourceId, this.onLoadPostFields, (error) => {
            console.warn('Error loading dynamic post info', error)
            this.onLoadPostFields(state.blockInfo.blockAtts.sourceId, {}, {})
          }, true)
github VisualComposer / builder / public / sources / attributes / dynamicAttribute.js View on Github external
constructor (props) {
    super(props)

    this.handleChangeSourceId = this.handleChangeSourceId.bind(this)
    this.handleDynamicFieldOpen = this.handleDynamicFieldOpen.bind(this)
    this.handleDynamicFieldClose = this.handleDynamicFieldClose.bind(this)
    this.handleDynamicFieldChange = this.handleDynamicFieldChange.bind(this)
    this.handleAutocompleteToggle = this.handleAutocompleteToggle.bind(this)
    this.onLoadPostFields = this.onLoadPostFields.bind(this)

    const isDynamic = env('VCV_JS_FT_DYNAMIC_FIELDS') && this.props.options && this.props.options.dynamicField && !(this.props.editFormOptions && this.props.editFormOptions.nestedAttr)
    let state = {
      isDynamic: isDynamic,
      dynamicFieldOpened: false
    }

    if (isDynamic) {
      let newState = this.getStateFromValue(this.props.value)
      window.setTimeout(() => {
        settingsStorage.trigger('loadDynamicPost', state.sourceId, this.onLoadPostFields, function (error) {
          console.warn('Error loading dynamic post info', error)
          this.onLoadPostFields(this.state.sourceId, {}, {})
        })
      }, 1)
      state = { ...state, ...newState }
    }
    this.state = state
github VisualComposer / builder / public / components / panels / addTemplate / addTemplatePanel.js View on Github external
getTemplateControlProps (template) {
    template = Object.assign({}, template)
    if (
      (env('VCV_FT_TEMPLATE_DATA_ASYNC') && this.state.showLoading === template.id) ||
      (this.state.removing && template.id === this.state.showSpinner)
    ) {
      template.spinner = true
    }
    return {
      key: 'vcv-element-control-' + template.id,
      applyTemplate: this.handleApplyTemplate,
      removeTemplate: this.handleRemoveTemplate,
      ...template
    }
  }
github VisualComposer / builder / public / editor / services / cook / lib / element-attribute.js View on Github external
getValue (settings, data, key, ignoreGetter = false) {
    if ((env('EXISTING_ELEMENT_ATTR_FIX') && settings.access === 'protected') || (typeof data[ key ] === 'undefined' && typeof settings.value !== 'undefined')) {
      data[ key ] = settings.value
    }
    return this.getter && ignoreGetter !== true ? this.getter(data, key, settings) : this.getRawValue(data, key)
  }

vc-cake

Modular approach for javascript based projects from WPBakery

ISC
Latest version published 12 months ago

Package Health Score

56 / 100
Full package analysis