Sha256: 60dd48dbdb89a74d8cb679be49e30869a1c620785bc45206870f116a0ac846a5

Contents?: true

Size: 1.09 KB

Versions: 20

Compression:

Stored size: 1.09 KB

Contents

$.extend decko,
  editorContentFunctionMap: {}
  editorInitFunctionMap: {
    '.date-editor': -> @datepicker { dateFormat: 'yy-mm-dd' }
    'textarea': -> $(this).autosize()
    '.file-upload': -> decko.upload_file(this)
    '.etherpad-textarea': ->
      $(this).closest('form')
      .find('.edit-submit-button')
      .attr('class', 'etherpad-submit-button')
  }

  addEditor: (selector, init, get_content) ->
    decko.editorContentFunctionMap[selector] = get_content
    decko.editorInitFunctionMap[selector] = init

jQuery.fn.extend {
  setContentFieldsFromMap: (map) ->
    map = decko.editorContentFunctionMap unless map?
    this_form = $(this)
    $.each map, (selector, fn) ->
      this_form.setContentFields(selector, fn)
  setContentFields: (selector, fn) ->
    $.each @find(selector), ->
      $(this).setContentField(fn)
  setContentField: (fn) ->
    field = @closest('.card-editor').find('.d0-card-content')
    init_val = field.val() # tinymce-jquery overrides val();
    # that's why we're not using it.
    new_val = fn.call this
    field.val new_val
    field.change() if init_val != new_val
}

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
card-1.94.1 mod/machines/lib/javascript/decko_editor.js.coffee
card-1.94.0 mod/machines/lib/javascript/decko_editor.js.coffee
card-1.93.13 mod/machines/lib/javascript/decko_editor.js.coffee
card-1.93.12 mod/machines/lib/javascript/decko_editor.js.coffee
card-1.93.11 mod/machines/lib/javascript/decko_editor.js.coffee
card-1.93.10 mod/machines/lib/javascript/decko_editor.js.coffee
card-1.93.9 mod/machines/lib/javascript/decko_editor.js.coffee
card-1.93.8 mod/machines/lib/javascript/decko_editor.js.coffee
card-1.93.7 mod/machines/lib/javascript/decko_editor.js.coffee
card-1.93.6 mod/machines/lib/javascript/decko_editor.js.coffee
card-1.93.5 mod/machines/lib/javascript/decko_editor.js.coffee
card-1.93.4 mod/machines/lib/javascript/decko_editor.js.coffee
card-1.93.3 mod/machines/lib/javascript/decko_editor.js.coffee
card-1.93.2 mod/machines/lib/javascript/decko_editor.js.coffee
card-1.93.1 mod/machines/lib/javascript/decko_editor.js.coffee
card-1.93.0 mod/machines/lib/javascript/decko_editor.js.coffee
card-1.92.2 mod/machines/lib/javascript/decko_editor.js.coffee
card-1.92.1 mod/machines/lib/javascript/decko_editor.js.coffee
card-1.92 mod/machines/lib/javascript/decko_editor.js.coffee
card-1.91 mod/machines/lib/javascript/decko_editor.js.coffee