Mercurial > defr > drupal > scald > dnd
comparison 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 |
comparison
equal
deleted
inserted
replaced
13:d0e7287c7a55 | 14:ef7ad7b5baa4 |
---|---|
167 var target = this; | 167 var target = this; |
168 var selector = 'img[src='+ element.src +']'; | 168 var selector = 'img[src='+ element.src +']'; |
169 | 169 |
170 // Watch the iframe for changes | 170 // Watch the iframe for changes |
171 var t = setInterval(function() { | 171 var t = setInterval(function() { |
172 var match = $(selector, $(target).contents()); | 172 $('img', $(target).contents()).each(function() { |
173 if (match.length > 0) { | 173 if (opt.idSelector(this) == representation_id) { |
174 var drop = opt.preprocessDrop(target, match); // Must return a jquery object | 174 var drop = opt.preprocessDrop(target, $(this)); // Must return a jquery object |
175 var representation = opt.renderRepresentation(target, drop, representation_id); | 175 var representation = opt.renderRepresentation(target, drop, representation_id); |
176 | 176 if (representation) { |
177 if (representation) { | 177 if (opt.dropWrapper) { |
178 if (opt.dropWrapper) { | 178 drop.wrap(opt.dropWrapper); |
179 drop.wrap(opt.dropWrapper); | 179 } |
180 if (opt.insertBefore) { | |
181 drop.before(opt.insertBefore); | |
182 } | |
183 if (opt.insertAfter) { | |
184 drop.after(opt.insertAfter); | |
185 } | |
186 drop.replaceWith(representation); | |
187 opt.postprocessDrop(target, drop, element); | |
180 } | 188 } |
181 if (opt.insertBefore) { | |
182 drop.before(opt.insertBefore); | |
183 } | |
184 if (opt.insertAfter) { | |
185 drop.after(opt.insertAfter); | |
186 } | |
187 drop.replaceWith(representation); | |
188 opt.postprocessDrop(target, drop, element); | |
189 } | 189 } |
190 } | 190 }); |
191 }, opt.interval); | 191 }, opt.interval); |
192 // @TODO track the timer with $.data() so we can clear it? | 192 // @TODO track the timer with $.data() so we can clear it? |
193 } else if ($(this).is('textarea')) { | 193 } else if ($(this).is('textarea')) { |
194 //console.log('@TODO handle textareas via.... regexp?'); | 194 //console.log('@TODO handle textareas via.... regexp?'); |
195 } | 195 } |