1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168
| <!doctype html>
<html lang="fr">
<head>
<meta charset="utf-8">
<meta name="Author" content="Daniel Hagnoul">
<title>Forum jQuery</title>
<link href='http://fonts.googleapis.com/css?family=Sofia|Ubuntu:400|Kreon'>
<link rel="stylesheet" href="http://danielhagnoul.developpez.com/styles/dvjhRemBase.css">
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.23/themes/overcast/jquery-ui.css">
<link rel="stylesheet" href="http://danielhagnoul.developpez.com/lib/jPicker/css/jPicker.dvjh-1.1.6.min.css">
<style>
/* TEST */
.draggable { width: 150px; height: 150px; background-color : black; color : white; border :solid; }
.trash { width: 150px; height: 120px; background-color: #617673; border :red solid; }
#left { float : left; }
#right { float:left; }
.joueur_survole { width: 153px; height: 153px; background-color :#54BFB1; margin : -10px 3px 0 0; }
</style>
</head>
<body>
<h1>Forum jQuery</h1>
<h2><a href="http://www.developpez.net/forums/newreply.php?do=newreply&noquote=1&p=6883375">Lien</a></h2>
<section class="conteneur">
<div id="drag"> <!-- Div drag -->
<div id="left"> <!-- Block gauche -->
<table>
<colgroup><col width="100"/></colgroup>
<tbody>
<tr><td></td></tr>
<tr><td><div class="draggable">Messi</div></td></tr>
<tr><td><div class="draggable">test</div></td></tr>
<tr><td></td></tr>
<tr><td></td></tr>
<tr><td></td></tr>
<tr><td></td></tr>
<tr><td></td></tr>
<tr><td></td></tr>
</tbody>
</table>
</div> <!-- Fin block gauche -->
<div id="right"> <!-- Block droit -->
<div class="trash"> </div>
<table>
<tbody>
<tr>
<td><div id="joueur_1"></div></td>
<td><div id="joueur_2"></div></td>
</tr>
</tbody>
</table>
<br>
<table>
<colgroup><col width="100"/><col width="100"/><col width="100"/><col width="100"/></colgroup>
<tbody>
<tr>
<td><div id="joueur_3"></div></td>
<td><div id="joueur_4"></div></td>
<td><div id="joueur_5"></div></td>
<td><div id="joueur_6"></div></td>
</tr>
</tbody>
</table>
<br>
<table>
<colgroup><col width="100"/><col width="100"/><col width="100"/><col width="100"/></colgroup>
<tbody>
<tr>
<td><div id="joueur_7"></div></td>
<td><div id="joueur_8"></div></td>
<td><div id="joueur_9"></div></td>
<td><div id="joueur_10"></div></td>
</tr>
</tbody>
</table>
<br>
<table>
<colgroup><col width="100"/></colgroup>
<tbody>
<tr>
<td><div id="joueur_11"></div></td>
</tr>
</tbody>
</table>
</div> <!-- Fin block droit -->
</div> <!-- Fin div drag -->
<div style="clear:both;"> </div>
</section>
<footer itemscope itemtype="http://danielhagnoul.developpez.com/">
<time datetime="2012-09-11T21:52:12.224+02:00" pubdate>2012-09-11T21:52:12.224+02:00</time>
<span itemprop="name">Daniel Hagnoul</span>
<a href="http://www.developpez.net/forums/u285162/danielhagnoul/" itemprop="url">@danielhagnoul</a>
<a href="http://danielhagnoul.developpez.com/" itemprop="url">Mon cahier dexercices</a>
<a href="http://javascript.developpez.com/faq/jquery/" itemprop="url">FAQ</a>
<a href="http://javascript.developpez.com/cours/?page=frameworks#jquery" itemprop="url">Tutoriels</a>
</footer>
<script src="http://danielhagnoul.developpez.com/lib/raphael-min.js"></script>
<script src="http://code.jquery.com/jquery-1.8.1.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.23/i18n/jquery-ui-i18n.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.23/jquery-ui.min.js"></script>
<script src="http://danielhagnoul.developpez.com/lib/jPicker/jpicker-1.1.6.min.js"></script>
<script charset="utf-8" src="http://danielhagnoul.developpez.com/lib/dvjh/base.js"></script>
<script>
"use strict";
$(function(){
$( ".draggable" ).draggable({
scope : "dragNdrop",
revert : "invalid",
snap : ".droppable",
snapMode : "inner",
snapTolerance : 100
});
$( "[id^='joueur_']" )
.append( '<div class="droppable" style="width:150px; height:150px; border:solid"></div>' )
.droppable({
scope : "dragNdrop",
hoverClass : "joueur_survole",
drop : function( event, ui ){
/*
Il me reste plus qu'à faire en sorte qu'une div drop
ne puisse accueillir qu'une seule div draggable.
*/
// bloque le droppable et le draggable
// mais on ne peut plus changer d'avis !
// http://jqueryui.com/demos/droppable/#method-disable
$( this ).droppable( "disable" );
// $.get( "js/deleteNews.php", { boite: this.id } );
}
});
$( ".trash" ).droppable({
scope : "dragNdrop",
drop: function( event, ui ){
var idSup = $( ui.draggable ).text();
$( this )
.removeClass( "hover" )
.addClass( "deleted" );
//On supprime la ligne dans la base de donnée
// $.get( "js/deleteNews.php", { idSup : idSup } );
$( this ).text( " Joueur supprimé : " + idSup );
// On supprime lélément de la page,
// le setTimeout est un fixe pour IE
//(http://dev.jqueryui.com/ticket/4088)
setTimeout( function(){
ui.draggable.remove();
}, 1 );
}
});
});
$(window).load(function(){
});
</script>
</body>
</html> |
Partager