Sha256: 25068cff5c058996c3760926cf7f8b3fc6d3ee6e291b928f546f3ffe4f1bcab4

Contents?: true

Size: 1.08 KB

Versions: 13

Compression:

Stored size: 1.08 KB

Contents

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

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

jQuery.fn.extend {
  setContentFieldsFromMap: (map) ->
    map = wagn.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('.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

13 entries across 13 versions & 1 rubygems

Version Path
card-1.21.0 mod/machines/lib/javascript/wagn_editor.js.coffee
card-1.20.4 mod/machines/lib/javascript/wagn_editor.js.coffee
card-1.20.3 mod/machines/lib/javascript/wagn_editor.js.coffee
card-1.20.2 mod/machines/lib/javascript/wagn_editor.js.coffee
card-1.20.1 mod/machines/lib/javascript/wagn_editor.js.coffee
card-1.20.0 mod/machines/lib/javascript/wagn_editor.js.coffee
card-1.19.6 mod/machines/lib/javascript/wagn_editor.js.coffee
card-1.19.5 mod/machines/lib/javascript/wagn_editor.js.coffee
card-1.19.4 mod/machines/lib/javascript/wagn_editor.js.coffee
card-1.19.3 mod/machines/lib/javascript/wagn_editor.js.coffee
card-1.19.2 mod/machines/lib/javascript/wagn_editor.js.coffee
card-1.19.1 mod/machines/lib/javascript/wagn_editor.js.coffee
card-1.19.0 mod/machines/lib/javascript/wagn_editor.js.coffee