annotate src/examples/dropzones.html @ 12:66e427a8d046

set draggable=false
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 15 May 2023 18:37:41 -0600
parents 4d699321068f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6
4d699321068f add dropzones
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1 <!doctype html>
4d699321068f add dropzones
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
2 <html>
4d699321068f add dropzones
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
3 <head>
4d699321068f add dropzones
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
4 <meta name="viewport" content="width=device-width, initial-scale=1">
4d699321068f add dropzones
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
5 <style>
4d699321068f add dropzones
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
6 @import "/site.css";
4d699321068f add dropzones
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
7 @import "/dad.css";
4d699321068f add dropzones
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
8
4d699321068f add dropzones
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
9 [drag] {
4d699321068f add dropzones
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
10 display: inline-block;
4d699321068f add dropzones
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
11 background-color: LightGreen;
4d699321068f add dropzones
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
12 padding: 8px;
4d699321068f add dropzones
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
13 }
4d699321068f add dropzones
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
14 [dropzone] {
4d699321068f add dropzones
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
15 background-color: LightBlue;
4d699321068f add dropzones
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
16 padding: 8px;
4d699321068f add dropzones
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
17 }
4d699321068f add dropzones
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
18 [dropzone][in] {
4d699321068f add dropzones
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
19 border: 1px solid;
4d699321068f add dropzones
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
20 }
4d699321068f add dropzones
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
21 </style>
4d699321068f add dropzones
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
22 <script src="/dad.js"></script>
4d699321068f add dropzones
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
23 <script>
4d699321068f add dropzones
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
24 dad.onEnter = function(event) {
4d699321068f add dropzones
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
25 event.dropzone.setAttribute('in','');
4d699321068f add dropzones
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
26 };
4d699321068f add dropzones
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
27
4d699321068f add dropzones
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
28 dad.onLeave = function(event) {
4d699321068f add dropzones
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
29 event.dropzone.removeAttribute('in');
4d699321068f add dropzones
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
30 };
4d699321068f add dropzones
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
31
4d699321068f add dropzones
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
32 dad.onDrop = function(event) {
4d699321068f add dropzones
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
33 if( event.dropzone )
4d699321068f add dropzones
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
34 event.dropzone.appendChild(event.original);
4d699321068f add dropzones
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
35 };
4d699321068f add dropzones
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
36
4d699321068f add dropzones
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
37 function init() {
4d699321068f add dropzones
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
38 let drag = document.querySelector('[drag]');
4d699321068f add dropzones
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
39 dad.setDraggable(drag);
4d699321068f add dropzones
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
40 let dropzones = document.querySelectorAll('[dropzone]');
4d699321068f add dropzones
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
41 for( let i=0; i<dropzones.length; i++ ) {
4d699321068f add dropzones
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
42 let dropzone = dropzones[i];
4d699321068f add dropzones
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
43 dad.setDropzone(dropzone);
4d699321068f add dropzones
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
44 }
4d699321068f add dropzones
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
45 }
4d699321068f add dropzones
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
46 </script>
4d699321068f add dropzones
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
47 </head>
4d699321068f add dropzones
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
48 <body>
4d699321068f add dropzones
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
49 <h1>Dropzones</h1>
4d699321068f add dropzones
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
50 <p dropzone>dropzone 1 <span drag>drag me</span></p>
4d699321068f add dropzones
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
51 <p dropzone>dropzone 2 </p>
4d699321068f add dropzones
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
52 <p dropzone>dropzone 3 </p>
4d699321068f add dropzones
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
53 <p>bottom</p>
4d699321068f add dropzones
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
54 </body>
4d699321068f add dropzones
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
55 <script> init(); </script>
4d699321068f add dropzones
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
56 </html>