-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDragDrop.html
More file actions
340 lines (272 loc) · 7.23 KB
/
Copy pathDragDrop.html
File metadata and controls
340 lines (272 loc) · 7.23 KB
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
<!DOCTYPE html>
<html lang="en">
<head>
<title> Creating a Pizza </title>
<meta name="generator" content="BBEdit 7.0.3" />
<link rel="Stylesheet" href="../../includes/style.css" type="text/css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script>
<style type="text/css">
p{font-size:1em;}
.caption{font-size:.8em;
font-weight:bold;}
img{border:solid 1px #000000;}
td{vertical-align:top;}
#draggable { width: 24px; height: 24px; background: red; }
#helper { width: 24px; height: 24px; background: yellow; }
/* Main content area */
#gameContent {
margin: 10px;
font-family: Georgia, serif;
line-height: 1.1em;
color: #333;
margin: 5px 5px;
text-align: center;
}
#cardPile {
margin: 0 auto;
background: #fff;
}
#cardSlots {
margin: 10px auto 0 auto;
background: #99cc33;
}
#cardSlots, #cardPile {
width: 910px;
height: 300px;
padding: 12px;
border: 2px solid #333;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
border-radius: 10px;
-moz-box-shadow: 0 0 .3em rgba(0, 0, 0, .8);
-webkit-box-shadow: 0 0 .3em rgba(0, 0, 0, .8);
box-shadow: 0 0 .3em rgba(0, 0, 0, .8);
}
/* Individual cards and slots */
#cardSlots div, #cardPile div {
float: left;
position: relative;
width: 170px;
height: 170px;
padding: 40px;
padding-bottom: 0;
border: 2px solid #333;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
border-radius: 10px;
margin: 5px 5px 5px 5px;
background: #fff;
background-size: contain;
}
#cardSlots div:first-child, #cardPile div:first-child {
margin-left: 0;
}
#cardSlots div.hovered {
background: #aaa;
}
#cardSlots div {
border-style: dashed;
}
#cardPile div {
color: #fff;
font-size: .8em;
text-shadow: 0 2px 2px #000;
background-size: 170px 170px;
}
#cardPile div.ui-draggable-dragging {
-moz-box-shadow: 0 0 .5em rgba(0, 0, 0, .8);
-webkit-box-shadow: 0 0 .5em rgba(0, 0, 0, .8);
box-shadow: 0 0 .5em rgba(0, 0, 0, .8);
}
/* Individually coloured cards */
/* "You did it!" message */
#successMessage {
position: absolute;
left: 480px;
top: 500px;
width: 0;
height: 0;
z-index: 100;
background: #ccc;
border: 2px solid #333;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
border-radius: 10px;
-moz-box-shadow: .3em .3em .5em rgba(0, 0, 0, .8);
-webkit-box-shadow: .3em .3em .5em rgba(0, 0, 0, .8);
box-shadow: .3em .3em .5em rgba(0, 0, 0, .8);
padding: 20px;
}
</style>
<script type="text/javascript">
//<!--
title="Creating A Pizza";
subject="Level Easy";
var list=new Array("part1");
// Usage:
function showAnswer(id){
if(document.getElementById(id).style.display=="none"){
document.getElementById(id).style.display="";
}else{
document.getElementById(id).style.display="none";
}
}
function hideAll(){
for(i=0;i<list.length;i++){
document.getElementById(list[i]).style.display="none";
}
}
$(function(){
$("#answers").hide("fast");
$("#answersToggle").click(function(){
$("#answers").toggle("slow");
});
$("#answer1").hide("fast");
$("#answer2").hide("fast");
$("#answer1Toggle").click(function(){
$("#answer1").toggle("slow");
$("#answer2").hide("fast");
});
$("#answer2Toggle").click(function(){
$("#answer2").toggle("slow");
$("#answer1").hide("fast");
});
});
$( init );
function init() {
$('#makeMeDraggable').draggable();
$('#draggable').draggable( {
cursor: 'move',
containment: 'document',
helper: helper
} );
}
function helper( event ) {
return '<div id="helper" style="font-size:.6em;">drag!</div>';
}
var correctCards = 0;
$( gameInit );
function gameInit() {
// Hide the success message
$('#successMessage').hide();
$('#successMessage').css( {
left: '580px',
top: '750px',
width: 0,
height: 0
} );
$('#message').hide();
$('#message').css( {
left: '580px',
top: '750px',
width: 0,
height: 0
} );
// Reset the game
correctCards = 0;
$('#cardPile').html( '' );
$('#cardSlots').html( '' );
var numOfCards=3 ;
// Create the pile of shuffled cards
var numbers = [ 1, 2, 3];
var img = ['../Hackathon/Images/ep1.png', '../Hackathon/Images/ep2.png','../Hackathon/Images/ep3.png'];
numbers.sort( function() { return Math.random() - .5 } );
for ( var i=0; i<img.length; i++ ) {
$('<div><img src=' + img[numbers[i]-1] + '></div>').data( 'number', numbers[i] ).attr( 'id', 'card'+numbers[i] ).appendTo( '#cardPile' ).draggable( {
containment: '#gameContent',
stack: '#cardPile div',
cursor: 'move',
revert: true,
start:hideMessage
} );
}
// Create the card slots
var words = [ 'Step One', 'Step Two', 'Step Three'];
for ( var i=1; i<=words.length; i++ ) {
$('<div>' + words[i-1] + '</div>').data( 'number', i ).appendTo( '#cardSlots' ).droppable( {
accept: '#cardPile div',
hoverClass: 'hovered',
drop: handleCardDrop
} );
}
}
function handleCardDrop( event, ui ) {
var slotNumber = $(this).data( 'number' );
var cardNumber = ui.draggable.data( 'number' );
// If the card was dropped to the correct slot,
// change the card colour, position it directly
// on top of the slot, and prevent it being dragged
// again
if ( slotNumber == cardNumber ) {
animateMessage();
ui.draggable.addClass( 'correct' );
ui.draggable.draggable( 'disable' );
$(this).droppable( 'disable' );
ui.draggable.position( { of: $(this), my: 'left top', at: 'left top' } );
ui.draggable.draggable( 'option', 'revert', false );
correctCards++;
}
// If all the cards have been placed correctly then display a message
// and reset the cards for another go
if ( correctCards == 3 ) {
$('#successMessage').show();
$('#successMessage').animate( {
left: '450px',
top: '540px',
width: '300px',
height: '150px',
opacity: 1
} );
}
}
function hideMessage(){
$('#message').animate(
{
left: '220px',
top: '700px',
width: '600px',
height: '100px',
opacity: 0
});
}
function animateMessage(){
$('#message').animate(
{
left: '220px',
top: '700px',
width: '600px',
height: '100px',
opacity: 1
});
}
//-->
</script>
</head>
<body class="thrColFixHdr">
<!-- begin address -->
<div id="container">
<!-- begin #maincontent -->
<div id="mainContent">
<!--Game-->
<div id="part1" style="display:block;">
<h2>Procedural - Interactive Lesson</h2>
<br />
<br /><h3>Drag and Drop</h3>
Follow the steps learned earlier and put in order the steps to create a pizza
<br /><br />
<div style="height:50px;"></div>
<div id="gameContent">
<div id="cardPile"> </div>
<div id="cardSlots"> </div>
<div id="message"></div>
<div id="successMessage">
<span style="font-weight:bold;font-size:2em;">You did it!</span><br />
<button onclick="gameInit()">Play Again</button>
<button onclick="gameInit()">Go </button>
</div>
</div>
<div class="sectionBreak"></div>
<!-- end #container --></div>
</body>
</html>