You are here

function dnd_process_textarea in Scald: Media Management made easy 6

Settings array: What should it take, if anything? Probably a source * maybe editor specific configuration shit?

  • source for library json/ajax shit
  • target selector
  • item selector

perhaps like so:

global => droppable targets library source for textarea

tinymce/othereditor => target selector logic configuration options callback should be smart about attachment and detachment

2 string references to 'dnd_process_textarea'
dnd_elements in dnd/dnd.module
Implementation of hook_elements().
mee_elements in mee/mee.module
Implementation of FAPI hook_elements().

File

dnd/dnd.module, line 72

Code

function dnd_process_textarea($element, $edit, $form_state, $form) {
  if (isset($element['#dnd-enabled']) && $element['#dnd-enabled']) {
    dnd_add_library();
    $settings = array(
      'library_id' => $element['#id'] . DND_ID_SUFFIX,
      'url' => dnd_get_library(),
    );

    // We take a string or an object or an array
    if (is_object($element['#dnd-settings'])) {
      $settings = (array) $element['#dnd-settings'] + $settings;
    }
    else {
      if (is_array($element['#dnd-settings'])) {
        $settings = $element['#dnd-settings'] + $settings;
      }
    }
    drupal_add_js(array(
      'dndDropAreas' => array(
        $element['#id'] => $settings,
      ),
    ), 'setting');
  }
  return $element;
}