Sha256: 33f2c9c150452b349a8ff98079bde90bb549cf2fbed005f53d2ad1cef735994f

Contents?: true

Size: 776 Bytes

Versions: 4

Compression:

Stored size: 776 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 'content', ->
    if scrivito.in_editable_view()
      addPlaceholder()

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
scrivito_editors-0.0.15 app/assets/javascripts/scrivito_editors/placeholder.js.coffee
scrivito_editors-0.0.14 app/assets/javascripts/scrivito_editors/placeholder.js.coffee
scrivito_editors-0.0.13 app/assets/javascripts/scrivito_editors/placeholder.js.coffee
scrivito_editors-0.0.12 app/assets/javascripts/scrivito_editors/placeholder.js.coffee