diff dnd.module @ 4:c2eb995212bf

TONS of fixes in this commit.
author David Eads <eads@chicagotech.org>
date Thu, 19 Feb 2009 12:33:19 -0600
parents 5df0783706f7
children ea5d7834d0dc
line wrap: on
line diff
--- a/dnd.module	Tue Feb 17 15:46:36 2009 -0600
+++ b/dnd.module	Thu Feb 19 12:33:19 2009 -0600
@@ -77,8 +77,8 @@
 function dnd_process_textarea($element, $form_state) {
   if ($element['#dnd-enabled']) {
 
-    drupal_add_js(drupal_get_path('module', 'dnd') .'/js/dnd.js');
-    drupal_add_js(drupal_get_path('module', 'dnd') .'/js/dnd-library.js');
+    drupal_add_js(drupal_get_path('module', 'dnd') .'/js/dnd.js', 'footer');
+    drupal_add_js(drupal_get_path('module', 'dnd') .'/js/dnd-library.js', 'footer');
 
     $settings = array();
 
@@ -126,18 +126,16 @@
   // We must remove some Drupal escaping
   $json = json_decode(str_replace(array('\x3c', '\x3e', '\x26'), array("<", ">", "&"), $request->data), TRUE);
 
-  foreach ($json['library'] as $id=>$item) {
-    $editor_representations[$id] = filter_xss_admin($item['editor']);
-    $library_representations[$id] = filter_xss_admin($item['library']);
+  // Generate an array of editor representations to add
+  foreach ($json['editor_representations'] as $editor_id=>$editor_item) {
+    $editor_representations[$editor_id] = filter_xss_admin($editor_item);
   }
 
+  // Store editor representations in Drupal setting
+  drupal_add_js(array('dndEditorRepresentations' => $editor_representations,), 'setting');
+
   $variables['library_id'] = $settings['library_id'];
-  $variables['header'] = filter_xss_admin($json['header']);
-  $variables['items'] = $library_representations;
-  $variables['footer'] = filter_xss_admin($json['footer']);
-
-  // Store editor representations in Drupal setting
-  drupal_add_js(array(
-    'dndEditorRepresentations' => $editor_representations, 
-  ), 'setting');
+  $variables['header']     = filter_xss_admin($json['header']);
+  $variables['library']    = filter_xss_admin($json['library']);
+  $variables['footer']     = filter_xss_admin($json['footer']);
 }