JavaScript DHTML/Ajax Layer/Drag Action

Материал из Web эксперт
Перейти к: навигация, поиск

Drag ending action

   <source lang="html4strict">

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head>

 <title>script.aculo.us Drag and drop functional test file</title>
 <meta http-equiv="content-type" content="text/html; charset=utf-8" />
 <script src="./scriptaculous-js-1.6.4src/prototype.js" type="text/javascript"></script>
 <script src="./scriptaculous-js-1.6.4src/scriptaculous.js" type="text/javascript"></script>
 <script src="./scriptaculous-js-1.6.4src/unittest.js" type="text/javascript"></script>
 <style type="text/css" media="screen">
   #thelist li { background: green; margin:5px; padding: 30px; }
   #thelist2 li { background: #ffb; margin:2px; padding: 2px; }
 </style>

</head> <body>

script.aculo.us Drag and drop functional test file

Draggables/Droppables

 drag here
<input type="checkbox" id="shouldrevert1"/> Revert?
 drag here
<input type="checkbox" id="shouldrevert2"/> Revert? I"ve onStart, onDrag and onEnd events!
 This box overrides the default endeffect
 This box overrides the default starteffect
 This box overrides the default end- and starteffects
accepts first box
accepts second box

<script type="text/javascript" language="javascript" charset="utf-8">

 new Draggable("revertbox1",{scroll:window,handle:"handle1",revert:function(element){return ($("shouldrevert1").checked)}});
 new Draggable("revertbox2",{
   handle:"handle2",
   revert:function(element){return ($("shouldrevert2").checked)},
   onStart:function(){$("revertbox2").setStyle({backgroundColor:"#bfb"})},
   onDrag:function(){$("event-info").update("drag!")},
   onEnd:function(){alert("end!")}
 });
 
 Droppables.add("droptarget1",{accept:["box1","otherstuff"],onDrop:function(){alert("drop!")}});
 Droppables.add("droptarget2",{accept:"box",onDrop:function(){alert("drop!")}});
 
 
 new Draggable("specialbox",{
   endeffect:function(){
     new Effect.Highlight("specialbox",{queue:"end"});
   }
 });
 new Draggable("specialbox2",{
   starteffect:function(){
     new Effect.Highlight("specialbox2",{queue:"end"});
   }
 });
 new Draggable("specialbox3",{
   starteffect:function(){
     new Effect.Highlight("specialbox3",{queue:"end"});
   },
   endeffect:function(){
     new Effect.Highlight("specialbox3",{queue:"end"});
   }
 });

</script>

</body> </html>

      </source>
   
  

<A href="http://www.wbex.ru/Code/JavaScriptDownload/scriptaculous-js-1.6.4.zip">scriptaculous-js-1.6.4.zip( 139 k)</a>


Revert to orignal position after dragging

   <source lang="html4strict">

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head>

 <title>script.aculo.us Drag and drop functional test file</title>
 <meta http-equiv="content-type" content="text/html; charset=utf-8" />
 <script src="./scriptaculous-js-1.6.4src/prototype.js" type="text/javascript"></script>
 <script src="./scriptaculous-js-1.6.4src/scriptaculous.js" type="text/javascript"></script>
 <script src="./scriptaculous-js-1.6.4src/unittest.js" type="text/javascript"></script>
 <style type="text/css" media="screen">
   #thelist li { background: green; margin:5px; padding: 30px; }
   #thelist2 li { background: #ffb; margin:2px; padding: 2px; }
 </style>

</head> <body>

script.aculo.us Drag and drop functional test file

Draggables/Droppables

 drag here
<input type="checkbox" id="shouldrevert1"/> Revert?
 drag here
<input type="checkbox" id="shouldrevert2"/> Revert? I"ve onStart, onDrag and onEnd events!
 This box overrides the default endeffect
 This box overrides the default starteffect
 This box overrides the default end- and starteffects
accepts first box
accepts second box

<script type="text/javascript" language="javascript" charset="utf-8">

 new Draggable("revertbox1",{scroll:window,handle:"handle1",revert:function(element){return ($("shouldrevert1").checked)}});
 new Draggable("revertbox2",{
   handle:"handle2",
   revert:function(element){return ($("shouldrevert2").checked)},
   onStart:function(){$("revertbox2").setStyle({backgroundColor:"#bfb"})},
   onDrag:function(){$("event-info").update("drag!")},
   onEnd:function(){alert("end!")}
 });
 
 Droppables.add("droptarget1",{accept:["box1","otherstuff"],onDrop:function(){alert("drop!")}});
 Droppables.add("droptarget2",{accept:"box",onDrop:function(){alert("drop!")}});
 
 
 new Draggable("specialbox",{
   endeffect:function(){
     new Effect.Highlight("specialbox",{queue:"end"});
   }
 });
 new Draggable("specialbox2",{
   starteffect:function(){
     new Effect.Highlight("specialbox2",{queue:"end"});
   }
 });
 new Draggable("specialbox3",{
   starteffect:function(){
     new Effect.Highlight("specialbox3",{queue:"end"});
   },
   endeffect:function(){
     new Effect.Highlight("specialbox3",{queue:"end"});
   }
 });

</script>

</body> </html>

      </source>
   
  

<A href="http://www.wbex.ru/Code/JavaScriptDownload/scriptaculous-js-1.6.4.zip">scriptaculous-js-1.6.4.zip( 139 k)</a>