$ -> # 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 +scrivito_tag+. # # For example: # scrivito_tag(:div, @obj, :my_attribute, data: { placeholder: 'My custom placeholder text.' }) addPlaceholder = -> cmsFields = $('[data-scrivito-field-type]') .not('[data-scrivito-field-type$=enum]:not([data-values])') 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()