JavaScript Tutorial/Dojo toolkit/Drag Drop — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Текущая версия на 08:24, 26 мая 2010
Содержание
Create a movable tag through code
<html>
<head>
<link rel="StyleSheet" type="text/css"
href="js/dojo/dijit/themes/tundra/tundra.css">
<script type="text/javascript">
var djConfig = {
baseScriptUri : "js/dojo/",
parseOnLoad : true
};
</script>
<script type="text/javascript" src="js/dojo/dojo/dojo.js"></script>
<script>
dojo.require("dojo.dnd.Moveable");
dojo.require("dojo.parser");
dojo.addOnLoad(function( ) {
var e = document.createElement("div");
e.innerHTML="asdf";
dojo.addClass(e, "moveable");
dojo.body( ).appendChild(e);
var m = new dojo.dnd.Moveable(e);
});
</script>
</head>
<body class="tundra">
</body>
</html>
dojo drag and drop reorder
<html>
<head>
<link rel="StyleSheet" type="text/css"
href="js/dojo/dijit/themes/tundra/tundra.css">
<script type="text/javascript">
var djConfig = {
baseScriptUri : "js/dojo/",
parseOnLoad : true
};
</script>
<script type="text/javascript" src="js/dojo/dojo/dojo.js"></script>
<script>
dojo.require("dojo.dnd.source");
dojo.require("dojo.parser");
</script>
</head>
<body class="tundra">
<table border="1" cellpadding="0" cellspacing="0">
<tr>
<td valign="top">
<div dojoType="dojo.dnd.Source" jsId="sourceData" class="source">
<div class="dojoDndItem" dndType="vinod">
<div>1</div>
</div>
<div class="dojoDndItem" dndType="suman">
<div>2</div>
</div>
<div class="dojoDndItem" dndType="deepak">
<div><img src="1.jpg" /></div>
</div>
</div>
</td>
</tr>
</table>
</body>
</html>
Drop to target
<html>
<head>
<link rel="StyleSheet" type="text/css"
href="js/dojo/dijit/themes/tundra/tundra.css">
<script type="text/javascript">
var djConfig = {
baseScriptUri : "js/dojo/",
parseOnLoad : true
};
</script>
<script type="text/javascript" src="js/dojo/dojo/dojo.js"></script>
<script>
dojo.require("dojo.dnd.Source");
dojo.require("dojo.parser");
</script>
</head>
<body class="tundra">
<div dojoType="dojo.dnd.Source" class="container">
<div class="dojoDndItem">foo</div>
<div class="dojoDndItem">bar</div>
<div class="dojoDndItem">baz</div>
<div class="dojoDndItem">quux</div>
</div>
<div dojoType="dojo.dnd.Target" class="container">Drop here</div>
</body>
</html>
Make any tag moveable
<html>
<head>
<link rel="StyleSheet" type="text/css"
href="js/dojo/dijit/themes/tundra/tundra.css">
<script type="text/javascript">
var djConfig = {
baseScriptUri : "js/dojo/",
parseOnLoad : true
};
</script>
<script type="text/javascript" src="js/dojo/dojo/dojo.js"></script>
<script>
dojo.require("dojo.dnd.Moveable");
dojo.require("dojo.parser");
</script>
</head>
<body class="tundra">
<div class="moveable" dojoType="dojo.dnd.Moveable" >asdf</div>
</body>
</html>
Make text field moveable
<html>
<head>
<link rel="StyleSheet" type="text/css"
href="js/dojo/dijit/themes/tundra/tundra.css">
<script type="text/javascript">
var djConfig = {
baseScriptUri : "js/dojo/",
parseOnLoad : true
};
</script>
<script type="text/javascript" src="js/dojo/dojo/dojo.js"></script>
<script>
dojo.require("dojo.dnd.Moveable");
dojo.require("dojo.parser");
</script>
</head>
<body class="tundra">
<div dojoType="dojo.dnd.Moveable" >
<div class="noteHandle"></div>
<textarea class="note">Type some text here</textarea>
</div>
</body>
</html>
Reorder DIV tag
<html>
<head>
<link rel="StyleSheet" type="text/css"
href="js/dojo/dijit/themes/tundra/tundra.css">
<script type="text/javascript">
var djConfig = {
baseScriptUri : "js/dojo/",
parseOnLoad : true
};
</script>
<script type="text/javascript" src="js/dojo/dojo/dojo.js"></script>
<script>
dojo.require("dojo.dnd.Source");
dojo.require("dojo.parser");
</script>
</head>
<body class="tundra">
<div dojoType="dojo.dnd.Source" class="container">
<div class="dojoDndItem">foo</div>
<div class="dojoDndItem">bar</div>
<div class="dojoDndItem">baz</div>
<div class="dojoDndItem">quux</div>
</div>
</body>
</html>