Sha256: 661eb2f4078fd2af0e0139d70294c61b21db89360b012f0ea4b00666e3fb7b4d

Contents?: true

Size: 793 Bytes

Versions: 4

Compression:

Stored size: 793 Bytes

Contents

$ ->
  # Display a placeholder for empty CMS attributes. The placeholder can be overwritten by
  # defining a +data-placeholder+ HTML attribute on the DOM element generated by +cms_tag+.
  #
  # For example:
  #   cms_tag(:div, @obj, :my_attribute, data: { placeholder: 'My custom placeholder text.' })
  addPlaceholder = ->
    cmsFields = $('[data-scrivito-field-type]')

    cmsFields.each ->
      cmsField = $(@)
      fieldName = cmsField.attr('data-scrivito-field-name')
      defaultPlaceholder = 'Click to edit the "' + fieldName + '" attribute ...'
      placeholder = cmsField.attr('data-placeholder') || defaultPlaceholder

      cmsField.attr('data-placeholder', placeholder)

  scrivito.on 'new_content', ->
    addPlaceholder()

  scrivito.on 'editing', ->
    addPlaceholder()

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
scrivito_editors-0.0.11 app/assets/javascripts/scrivito_editors/placeholder.js.coffee
scrivito_editors-0.0.10 app/assets/javascripts/scrivito_editors/placeholder.js.coffee
scrivito_editors-0.0.9 app/assets/javascripts/scrivito_editors/placeholder.js.coffee
scrivito_editors-0.0.8 app/assets/javascripts/scrivito_editors/placeholder.js.coffee