diff js/dnd-library.js @ 15:7a5f74482ee3

More cross browser work, garbage collection for timers, etc.
author David Eads <eads@chicagotech.org>
date Mon, 02 Mar 2009 23:22:37 -0600
parents 99ba5941779c
children bb68dc3ad56f
line wrap: on
line diff
--- a/js/dnd-library.js	Fri Feb 27 12:30:42 2009 -0600
+++ b/js/dnd-library.js	Mon Mar 02 23:22:37 2009 -0600
@@ -25,6 +25,7 @@
           Drupal.settings.dndEditorRepresentations[editor_id] = data.editor_representations[editor_id];
         }
         var params = Drupal.wysiwyg.instances[editor];
+        $('#' + editor).trigger('wysiwygDetach', params);
         $('#' + editor).trigger('wysiwygAttach', params);
       });
       return false;
@@ -49,7 +50,10 @@
 }
 
 Drupal.behaviors.dndLibrary.detach_library = function(e, data) {
-  //console.log('detach');
+  for (t in $(document).data('dnd_timers')) {
+    clearInterval(t);
+  }
+  $(document).removeData('dnd_timers');
 }
 
 
@@ -76,6 +80,13 @@
   settings = $.extend({
     targets: $('#'+ data.field +'-wrapper iframe'),
     insertAfter: '<p><span id="__caret">_</span></p>',
+
+    // Back out markup to render in place after parent container
+    preprocessDrop: function(target, drop) {
+      drop.id = 'DND-TMP-' + $.data(drop);
+      // Do some native tiny manipulations
+      return drop;
+    },
     postprocessDrop: function(target, drop, element) {
       // Get our special span, select it, delete it, and hope the caret
       // resets correctly.