eads@1: 'Drag and Drop Library', eads@1: 'page callback' => 'dnd_admin', eads@1: 'description' => 'Configure drag-and-drop enabled textareas.', eads@1: 'access arguments' => array('administer dnd'), eads@1: 'file' => 'dnd.admin.inc', eads@1: ); eads@1: return $items; eads@1: } eads@1: eads@1: /** eads@1: * Implementation of hook_perm(). eads@1: */ eads@1: function dnd_perm() { eads@1: return array('administer dnd'); eads@1: } eads@2: eads@2: /** eads@2: * Implementation of hook_theme(). eads@2: */ eads@2: function dnd_theme() { eads@2: return array( eads@31: 'dnd_library_wrapper' => array('arguments' => array('settings' => NULL, 'element' => NULL)), eads@2: ); eads@2: } eads@2: eads@2: eads@2: /** eads@2: * Implementation of hook_elements(). eads@2: * eads@2: * Overload textareas. eads@2: */ eads@2: function dnd_elements() { eads@2: $type = array(); eads@2: $type['textarea'] = array( eads@2: '#dnd-enabled' => FALSE, eads@2: '#dnd-settings' => NULL, eads@2: '#process' => array('form_expand_ahah', 'dnd_process_textarea'), eads@2: ); eads@2: return $type; eads@2: } eads@2: eads@2: /** eads@2: * Settings array: eads@21: * What should it take, if anything? Probably a source * maybe editor specific configuration shit? eads@2: * eads@2: * - source for library json/ajax shit eads@2: * - target selector eads@2: * - item selector eads@2: * eads@2: * perhaps like so: eads@2: * eads@2: * global => eads@2: * droppable targets eads@2: * library source for textarea eads@2: * eads@2: * tinymce/othereditor => eads@2: * target selector logic eads@2: * configuration options eads@2: * callback should be smart about attachment and detachment eads@2: */ eads@21: function dnd_process_textarea($element, $edit, $form_state, $form) { eads@2: if ($element['#dnd-enabled']) { eads@2: eads@2: $settings = array(); eads@2: eads@18: // We take a string or an object or an array eads@2: if (is_string($element['#dnd-settings'])) { eads@2: // @TODO load settings eads@2: } eads@2: else if (is_object($element['#dnd-settings'])) { eads@2: $settings = (array) $element['#dnd-settings']; eads@2: } eads@2: else if (is_array($element['#dnd-settings'])) { eads@2: $settings = $element['#dnd-settings']; eads@2: } eads@2: eads@2: $settings = array('library_id' => $element['#id'] . DND_ID_SUFFIX) + $settings; eads@2: eads@30: // BeautyTips eads@30: drupal_add_js(drupal_get_path('module', 'dnd') .'/js/bt/other_libs/excanvas_0002/excanvas-compressed.js'); eads@30: drupal_add_js(drupal_get_path('module', 'dnd') .'/js/bt/other_libs/jquery.hoverIntent.minified.js'); eads@30: drupal_add_js(drupal_get_path('module', 'dnd') .'/js/bt/jquery.bt.js'); eads@7: eads@30: // Dependencies eads@30: drupal_add_js(drupal_get_path('module', 'dnd') .'/js/jquery.url.packed.js'); eads@30: drupal_add_js(drupal_get_path('module', 'dnd') .'/js/jquery.fieldselection.js'); eads@30: drupal_add_js('misc/jquery.form.js'); eads@28: eads@30: // Drag and drop eads@30: drupal_add_js(drupal_get_path('module', 'dnd') .'/js/jquery.draganddrop.js'); eads@30: drupal_add_js(drupal_get_path('module', 'dnd') .'/js/dnd-library.js'); eads@28: eads@2: drupal_add_js(array( eads@2: 'dndEnabledLibraries' => array($element['#id'] => $settings), eads@2: ), 'setting'); eads@2: eads@31: // Generate franck@34: $element['#prefix'] .= '