]> source.dussan.org Git - jquery-ui.git/commitdiff
Sortable: Copy the src of the original item when creating a placeholder from an image...
authorScott González <scott.gonzalez@gmail.com>
Thu, 7 Mar 2013 17:55:00 +0000 (12:55 -0500)
committerScott González <scott.gonzalez@gmail.com>
Thu, 7 Mar 2013 17:55:00 +0000 (12:55 -0500)
tests/unit/sortable/sortable.html
tests/unit/sortable/sortable_options.js
ui/jquery.ui.sortable.js

index 6e326a8657c994f8ca20405180a606da06d39ec2..5e21a49da59bb4de38b29ac7c71a2076a55d56a8 100644 (file)
        </tbody>
 </table>
 
+<div id="sortable-images">
+       <img src="../images/jqueryui_32x32.png">
+       <img src="../images/jqueryui_32x32.png">
+       <img src="../images/jqueryui_32x32.png">
+       <img src="../images/jqueryui_32x32.png">
+</div>
+
 </div>
 </body>
 </html>
index fe50be002d7801a60e3f87dab6a137593688dca8..caba0a7770d1dec657a447891164e34657eb5df9 100644 (file)
@@ -5,10 +5,6 @@
 
 module("sortable: options");
 
-// this is here to make JSHint pass "unused", and we don't want to
-// remove the parameter for when we finally implement
-$.noop();
-
 /*
 test("{ appendTo: 'parent' }, default", function() {
        ok(false, "missing test - untested code is broken code.");
@@ -186,6 +182,23 @@ test("{ placeholder: false }, default", function() {
        ok(false, "missing test - untested code is broken code.");
 });
 */
+
+test( "{ placeholder: false } img", function() {
+       expect( 3 );
+
+       var element = $( "#sortable-images" ).sortable({
+               start: function( event, ui ) {
+                       equal( ui.placeholder.attr( "src" ), "../images/jqueryui_32x32.png", "placeholder img has correct src" );
+                       equal( ui.placeholder.height(), 32, "placeholder has correct height" );
+                       equal( ui.placeholder.width(), 32, "placeholder has correct width" );
+               }
+       });
+
+       element.find( "img" ).eq( 0 ).simulate( "drag", {
+               dy: 1
+       });
+});
+
 test( "{ placeholder: String }", function() {
        expect( 1 );
 
index f095ce9c505dd996a0d6206c579021d34b9db22d..93c6cccc5fb7b15cb91091c06332cd604e560bf3 100644 (file)
@@ -762,6 +762,8 @@ $.widget("ui.sortable", $.ui.mouse, {
                                                // width of the table (browsers are smart enough to
                                                // handle this properly)
                                                element.append( "<td colspan='99'>&#160;</td>" );
+                                       } else if ( nodeName === "img" ) {
+                                               element.attr( "src", that.currentItem.attr( "src" ) );
                                        }
 
                                        if ( !className ) {