Sha256: 6908735562e374436758bad87a4307ef91c4e0fe66164f853160549a6f3b9ce9

Contents?: true

Size: 779 Bytes

Versions: 11

Compression:

Stored size: 779 Bytes

Contents

scrivito.on 'content', (content) ->
  return unless scrivito.in_editable_view()
  setup = (sel) -> scrivito.editors._file_dropzone $(content).find(sel), save
  setup 'img[data-scrivito-field-type=linklist]:not([data-editor])'
  setup 'img[data-scrivito-field-type=reference]:not([data-editor])'
  setup '[data-editor~=image_drop]'

save = (field, file) ->
  createImage(file).then (obj) ->
    type = field.attr('data-scrivito-field-type')
    value = switch
      when type is 'reference' then obj.id
      when type is 'linklist'  then [{obj_id: obj.id}]
      else $.error 'Field type must be "reference" or "linklist"'
    field.scrivito('save', value).then -> field.scrivito('reload')

createImage = (blob) ->
  _obj_class = 'Image'
  scrivito.create_obj {blob, _obj_class}

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
scrivito_editors-0.70.2 app/assets/javascripts/scrivito_editors/image_drop_editor.js.coffee
scrivito_editors-0.71.2 app/assets/javascripts/scrivito_editors/image_drop_editor.js.coffee
scrivito_editors-0.71.1 app/assets/javascripts/scrivito_editors/image_drop_editor.js.coffee
scrivito_editors-0.70.1 app/assets/javascripts/scrivito_editors/image_drop_editor.js.coffee
scrivito_editors-0.71.0 app/assets/javascripts/scrivito_editors/image_drop_editor.js.coffee
scrivito_editors-0.71.0.rc2 app/assets/javascripts/scrivito_editors/image_drop_editor.js.coffee
scrivito_editors-0.71.0.rc1 app/assets/javascripts/scrivito_editors/image_drop_editor.js.coffee
scrivito_editors-0.70.0 app/assets/javascripts/scrivito_editors/image_drop_editor.js.coffee
scrivito_editors-0.70.0.rc3 app/assets/javascripts/scrivito_editors/image_drop_editor.js.coffee
scrivito_editors-0.70.0.rc2 app/assets/javascripts/scrivito_editors/image_drop_editor.js.coffee
scrivito_editors-0.70.0.rc1 app/assets/javascripts/scrivito_editors/image_drop_editor.js.coffee