|
0
|
1 |
|
|
|
2 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> |
|
|
3 |
<html> |
|
|
4 |
<head> |
|
|
5 |
<meta http-equiv="content-type" content="text/html; charset=utf-8"> |
|
|
6 |
<title>Using the Drag Shim</title> |
|
|
7 |
|
|
|
8 |
<style type="text/css"> |
|
|
9 |
/*margin and padding on body element |
|
|
10 |
can introduce errors in determining |
|
|
11 |
element position and are not recommended; |
|
|
12 |
we turn them off as a foundation for YUI |
|
|
13 |
CSS treatments. */ |
|
|
14 |
body { |
|
|
15 |
margin:0; |
|
|
16 |
padding:0; |
|
|
17 |
} |
|
|
18 |
</style> |
|
|
19 |
|
|
|
20 |
<link type="text/css" rel="stylesheet" href="../../build/cssfonts/fonts-min.css" /> |
|
|
21 |
<script type="text/javascript" src="../../build/yui/yui-min.js"></script> |
|
|
22 |
|
|
|
23 |
<!--there is no custom header content for this example--> |
|
|
24 |
|
|
|
25 |
</head> |
|
|
26 |
|
|
|
27 |
<body class=" yui-skin-sam"> |
|
|
28 |
|
|
|
29 |
<h1>Using the Drag Shim</h1> |
|
|
30 |
|
|
|
31 |
<div class="exampleIntro"> |
|
|
32 |
<p>This example shows the use of the drag shim when dragging nodes over other troublesome nodes.</p> |
|
|
33 |
|
|
|
34 |
</div> |
|
|
35 |
|
|
|
36 |
<!--BEGIN SOURCE CODE FOR EXAMPLE =============================== --> |
|
|
37 |
|
|
|
38 |
<style> |
|
|
39 |
#demo { |
|
|
40 |
height: 100px; |
|
|
41 |
width: 100px; |
|
|
42 |
border: 1px solid black; |
|
|
43 |
cursor: move; |
|
|
44 |
float: right; |
|
|
45 |
} |
|
|
46 |
#ifrm { |
|
|
47 |
width: 400px; |
|
|
48 |
height: 300px; |
|
|
49 |
} |
|
|
50 |
</style> |
|
|
51 |
<p>Try dragging the proxy element over the iframe below, in most browsers this will not happen. Now click the <code>Shim off</code> button and drag again. Now you can drag over the iframe.</p> |
|
|
52 |
<p>You can see the shim by clicking the <code>Debug Off</code> button.</p> |
|
|
53 |
<p><button id="shim" value="off">Shim Off</button> <button id="debugShim" value="off" disabled>Debug Off</button></p> |
|
|
54 |
<div id="demo">Drag Me</div> |
|
|
55 |
<iframe id="ifrm" src="assets/blank.htm"></iframe> |
|
|
56 |
|
|
|
57 |
<script> |
|
|
58 |
|
|
|
59 |
YUI({base:"../../build/", timeout: 10000}).use('dd-ddm', 'dd-drag', 'dd-proxy', function(Y) { |
|
|
60 |
//Toggling the buttons |
|
|
61 |
Y.Node.get('#shim').on('click', function(e) { |
|
|
62 |
var value = e.target.get('value'); |
|
|
63 |
if (value == 'off' || value == 'Shim Off') { |
|
|
64 |
dd.set('useShim', true); |
|
|
65 |
e.target.set('value', 'on'); |
|
|
66 |
e.target.set('innerHTML', 'Shim On'); |
|
|
67 |
Y.Node.get('#debugShim').set('disabled', false); |
|
|
68 |
} else { |
|
|
69 |
dd.set('useShim', false); |
|
|
70 |
e.target.set('value', 'off'); |
|
|
71 |
e.target.set('innerHTML', 'Shim Off'); |
|
|
72 |
Y.Node.get('#debugShim').set('disabled', true); |
|
|
73 |
} |
|
|
74 |
}); |
|
|
75 |
|
|
|
76 |
Y.Node.get('#debugShim').on('click', function(e) { |
|
|
77 |
var value = e.target.get('value'); |
|
|
78 |
if (value == 'off' || value == 'Debug Off') { |
|
|
79 |
Y.DD.DDM._debugShim = true; |
|
|
80 |
e.target.set('value', 'on'); |
|
|
81 |
e.target.set('innerHTML', 'Debug On'); |
|
|
82 |
} else { |
|
|
83 |
Y.DD.DDM._debugShim = false; |
|
|
84 |
e.target.set('value', 'off'); |
|
|
85 |
e.target.set('innerHTML', 'Debug Off'); |
|
|
86 |
} |
|
|
87 |
}); |
|
|
88 |
|
|
|
89 |
var dd = new Y.DD.Drag({ |
|
|
90 |
//Selector of the node to make draggable |
|
|
91 |
node: '#demo', |
|
|
92 |
useShim: false |
|
|
93 |
}).plug(Y.Plugin.DDProxy, { |
|
|
94 |
offsetNode: false, |
|
|
95 |
resizeFrame: false |
|
|
96 |
}); |
|
|
97 |
dd.on('drag:start', function() { |
|
|
98 |
this.get('dragNode').setStyles({ |
|
|
99 |
height: '20px', |
|
|
100 |
width: '100px', |
|
|
101 |
backgroundColor: 'blue', |
|
|
102 |
color: '#fff' |
|
|
103 |
}); |
|
|
104 |
this.get('dragNode').set('innerHTML', 'Custom Proxy'); |
|
|
105 |
this.deltaXY = [this.deltaXY[0] - 20, this.deltaXY[1] - 20]; |
|
|
106 |
}); |
|
|
107 |
}); |
|
|
108 |
</script> |
|
|
109 |
|
|
|
110 |
<!--END SOURCE CODE FOR EXAMPLE =============================== --> |
|
|
111 |
|
|
|
112 |
</body> |
|
|
113 |
</html> |