# HG changeset patch # User David Eads # Date 1235759442 21600 # Node ID ef7ad7b5baa41a7df508700c9badfd520727b3c2 # Parent d0e7287c7a55be0b7890095bc3553a0b857001c5 Slightly changed matching mechanism to handle Firefox's crazy desire to make dropped src attributes relative. diff -r d0e7287c7a55 -r ef7ad7b5baa4 dnd_test/dnd_test.module --- a/dnd_test/dnd_test.module Fri Feb 27 11:51:28 2009 -0600 +++ b/dnd_test/dnd_test.module Fri Feb 27 12:30:42 2009 -0600 @@ -26,10 +26,6 @@ * This demonstrates how to attach Drag and Drop to a given textarea. */ function dnd_test_form_alter(&$form, &$form_state) { - - //global $_SERVER; - //dpm($_SERVER); - if ($form['#id'] == 'node-form' && $form['type']['#value'] == 'page') { drupal_add_css(drupal_get_path('module', 'dnd_test') .'/dnd_test.css'); $form['body_field']['body']['#dnd-enabled'] = TRUE; @@ -92,7 +88,7 @@ /** * Theme wrapper that spins out multiple library representations for a given - ;[''''* editor representation. This is because we want to demonstrate how to allow + * editor representation. This is because we want to demonstrate how to allow * for multiple versions (i.e. different sizes) of a single item */ function dnd_editor_items($i) { @@ -122,12 +118,12 @@ } //$variables['image'] = theme('image', drupal_get_path('module', 'dnd_test') .'/img/item-'. $img .'-thumb.jpg'); - $variables['image'] = ''; + $variables['image'] = ''; $variables['title'] = t('Lorem Ipsum @count', array('@count' => $i)); $variables['date'] = 'Feb 18 2009'; $variables['author'] = 'David Eads'; foreach(array(t('S'), t('M'), t('L')) as $size) { - $sizes[] = ''; + $sizes[] = ''; } $variables['sizes'] = ''; } diff -r d0e7287c7a55 -r ef7ad7b5baa4 js/dnd.js --- 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')) {