diff js/dnd.js @ 14:ef7ad7b5baa4

Slightly changed matching mechanism to handle Firefox's crazy desire to make dropped src attributes relative.
author David Eads <eads@chicagotech.org>
date Fri, 27 Feb 2009 12:30:42 -0600
parents a5b2b9fa2a1a
children 7a5f74482ee3
line wrap: on
line diff
--- a/js/dnd.js	Fri Feb 27 11:51:28 2009 -0600
+++ b/js/dnd.js	Fri Feb 27 12:30:42 2009 -0600
@@ -169,25 +169,25 @@
 
             // Watch the iframe for changes
             var t = setInterval(function() {              
-              var match = $(selector, $(target).contents());
-              if (match.length > 0) {
-                var drop = opt.preprocessDrop(target, match); // Must return a jquery object
-                var representation = opt.renderRepresentation(target, drop, representation_id);
-    
-                if (representation) {
-                  if (opt.dropWrapper) {
-                    drop.wrap(opt.dropWrapper);
+              $('img', $(target).contents()).each(function() {
+                if (opt.idSelector(this) == representation_id) {
+                  var drop = opt.preprocessDrop(target, $(this)); // Must return a jquery object
+                  var representation = opt.renderRepresentation(target, drop, representation_id);
+                  if (representation) {
+                    if (opt.dropWrapper) {
+                      drop.wrap(opt.dropWrapper);
+                    }
+                    if (opt.insertBefore) {
+                      drop.before(opt.insertBefore);
+                    }
+                    if (opt.insertAfter) {
+                      drop.after(opt.insertAfter);
+                    }
+                    drop.replaceWith(representation);
+                    opt.postprocessDrop(target, drop, element);
                   }
-                  if (opt.insertBefore) {
-                    drop.before(opt.insertBefore);
-                  }
-                  if (opt.insertAfter) {
-                    drop.after(opt.insertAfter);
-                  }
-                  drop.replaceWith(representation);
-                  opt.postprocessDrop(target, drop, element);
                 }
-              }
+              });
             }, opt.interval);
             // @TODO track the timer with $.data() so we can clear it?
           } else if ($(this).is('textarea')) {