Drag and Drop - DDProxy : Drag Drop « GUI Components « JavaScript DHTML

JavaScript DHTML
1. Ajax Layer
2. Data Type
3. Date Time
4. Development
5. Document
6. Dojo toolkit
7. Event
8. Event onMethod
9. Ext JS
10. Form Control
11. GUI Components
12. HTML
13. Javascript Collections
14. Javascript Objects
15. Javascript Properties
16. jQuery
17. Language Basics
18. Mochkit
19. Mootools
20. Node Operation
21. Object Oriented
22. Page Components
23. Rico
24. Scriptaculous
25. Security
26. SmartClient
27. Style Layout
28. Table
29. Utilities
30. Window Browser
31. YUI Library
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
JavaScript DHTML » GUI Components » Drag Drop 
Drag and Drop - DDProxy


<!doctype html public "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<head>
<title>Yahoo! UI Library - Drag and Drop</title>
<link rel="stylesheet" type="text/css" href="./examples/dragdrop/css/screen.css">
</head>

<body>

<script type="text/javascript" src="./build/yahoo/yahoo.js" ></script>
<script type="text/javascript" src="./build/event/event.js" ></script>
<script type="text/javascript" src="./build/dom/dom.js"></script>
<script type="text/javascript" src="./build/logger/logger.js"></script>

<script type="text/javascript" src="./build/dragdrop/dragdrop-debug.js" ></script>
        <script type="text/javascript" src="./examples/dragdrop/js/DDSwap.js" ></script>

<script type="text/javascript" language="JavaScript">

YAHOO.example.DDApp = function() {
    var dd, dd2, dd3;

    function handleKeypress(e) {
        alert("asdf");
        YAHOO.log("keypress");
        YAHOO.util.Event.stopEvent(e);
        e.cancel = true;
        return false;
    }

    function initPointMode() {

        YAHOO.log("point mode");

        unreg();

        YAHOO.util.DDM.mode = YAHOO.util.DDM.POINT;

        dd = new YAHOO.example.DDSwap("dragDiv1""proxytest");
        // dd.setPadding(10);
        //dd.setXConstraint(0,0);

        dd2 = new YAHOO.example.DDSwap("dragDiv2""proxytest");
        dd2.addInvalidHandleType("input");
        // dd2.setPadding(10, 20, 30, 40);
        // dd2.setXConstraint(0,0);

        // the third DD instance uses its own proxy element
        dd3 = new YAHOO.example.DDSwap("dragDiv3""proxytest",
                    dragElId: "dragDiv4" });
        // dd3.setPadding(10, 40);
        // dd3.setPadding(10, 0, 20, 40);


    }

    function initIntersectMode() {

        YAHOO.log("intersect mode");

        unreg();

        YAHOO.util.DDM.mode = YAHOO.util.DDM.INTERSECT;

        dd = new YAHOO.example.DDSwap_i("dragDiv1");
        //dd.setPadding(10);

        dd2 = new YAHOO.example.DDSwap_i("dragDiv2");
        dd2.addInvalidHandleType("input");
        //dd2.setPadding(10, 20, 30, 40);
        // dd2.setXConstraint(0,0);

        dd3 = new YAHOO.example.DDSwap_i("dragDiv3");
        // dd3.setPadding(10, 40);
        //dd3.setPadding(10, 0, 20, 40);
    }

    function unreg() {
        if (dddd.unreg();
        if (dd2dd2.unreg();
        if (dd3dd3.unreg();
    }

    return {
        init: function() {

            // YAHOO.util.Event.on("testtext", "keydown", handleKeypress);
            initPointMode();
        },

        lock: function() { 
            dd.lock()
            dd2.setXConstraint(100100);
            dd2.setYConstraint(100100);
        },

        unlock: function() { 
            dd.unlock()
        },

        changeMode: function(val) {
            if (val == 1) {
                initIntersectMode();
            else {
                initPointMode();
            }
        },

        unreg: function() {
            dd.unreg();
        }

    };
}();


YAHOO.util.Event.addListener(window, "load", YAHOO.example.DDApp.init);

</script>

<div id="pageTitle">
    <h3>Drag and Drop - DDProxy</h3>
</div>

  
<style type="text/css">

/* logger default styles */
/* font size is controlled here: default 77% */
#yui-log {position:absolute;top:1em;right:1em;font-size:77%;text-align:left;}
/* width is controlled here: default 31em */
.yui-log {background-color:#AAA;border:1px solid black;font-family:monospace;z-index:9000;}
.yui-log p {margin:1px;padding:.1em;}
.yui-log button {font-family:monospace;}
.yui-log .yui-log-hd {padding:.5em;background-color:#575757;color:#FFF;}
/* height is controlled here: default 20em*/
.yui-log .yui-log-bd {width:100%;height:20em;background-color:#FFF;border:1px solid gray;overflow:auto;}
.yui-log .yui-log-ft {margin-top:.5em;margin-bottom:1em;}
.yui-log .yui-log-ft .yui-log-categoryfilters {}
.yui-log .yui-log-ft .yui-log-sourcefilters {width:100%;border-top:1px solid #575757;margin-top:.75em;padding-top:.75em;}
.yui-log .yui-log-btns {position:relative;float:right;bottom:.25em;}
.yui-log .yui-log-filtergrp {margin-right:.5em;}
.yui-log .info {background-color:#A7CC25;/* A7CC25 green */
.yui-log .warn {background-color:#F58516;/* F58516 orange */
.yui-log .error {background-color:#E32F0B;/* E32F0B red */
.yui-log .time {background-color:#A6C9D7;/* A6C9D7 blue */
.yui-log .window {background-color:#F2E886;/* F2E886 tan */


</style>


<img id="ylogo" src="./examples/dragdrop/img/logo.gif" />

<div id="container">
<div id="containerTop">
<div id="header">
<h4>&nbsp;</h4>
</div>
<div id="main">

<div id="rightbar">

<div id="rightBarPad">
<h3>Examples</h3>
<script type="text/javascript">

    YAHOO.example.logApp = function() {
        return {
            init: function() {
                if (YAHOO.widget.Logger) {
                    var reader = new YAHOO.widget.LogReader"logDiv"
                            newestOnTop: true, height: "400px" } );

                    reader._onClickPauseBtn(null, reader);

                }
            }
        };
    } ()

    YAHOO.util.Event.on(window, "load", YAHOO.example.logApp.init);

</script>

</h4>
<div id="logDiv"></div>
</div>


</div>

  <div id="content">
    <form name="dragDropForm" action="javscript:;">
    <div class="newsItem">
      <h3>Proxy</h3>

      <!--
      <a href="javascript:YAHOO.util.DDM._onUnload()">Unload test</a>
      <a href="javascript:YAHOO.example.DDApp.lock()">lock</a>
      <a href="javascript:YAHOO.example.DDApp.unlock()">unlock</a>
      <a href="javascript:YAHOO.example.DDApp.unreg()">Unreg test</a>
      -->
      <p>
        This example builds on
        <a>YAHOO.util.DD</a>.
        Instead of moving the actual html element that was clicked, we have a hidden
        layer, empty aside from a border, absolutely positioned, that we place in the same 
        location of the clicked object.  The onDrag event handler was implemented so
        that the style of the DragDrop elements change when they interact.  The onDragDrop
        event handler was implemented so that the elements swap positions if one is dropped
        on another.
        Mode: 
        <select onchange="YAHOO.example.DDApp.changeMode(this.selectedIndex)">
          <option value="0" selected>Point</point>
          <option value="1">Intersect</point>
        </select>
<!--
        <input name="testtext" id="testtext" type="text" />
-->

      </p>

<strong>The logger is paused for performance reasons.  Click "Resume" to re-enable it.</strong>
    </div>
    </form>
  </div>
    
        <div id="footerContainer">
        <div id="footer">
          <p>&nbsp;</p>
        </div>
      </div>
    </div>
  </div>
</div>

  
<!--
<div id="wrapperDiv" style="position:relative;width:400px;top:200px;height:200px;overflow:auto">
-->

<div id="dragDiv1" class="testSquare" style="background:url(./examples/dragdrop/img/sq1.png) 0 0 no-repeat;background-color:#6D739A;top:270px; left:105px ">DDSwap</div>
<div id="dragDiv2" class="testSquare" style="background:url(./examples/dragdrop/img/sq2.png) 0 0 no-repeat;background-color:#566F4E;top:350px; left:215px">
DDSwap
<!--
<input type="text" name="testinput" />
-->
</div>
<div id="wrapperDiv">
  <div id="dragDiv3" class="testSquare" style="background:url(./examples/dragdrop/img/sq3.png) 0 0 no-repeat;background-color:#7E5B60;top:430px; left:325px">DDSwap</div>
</div>

  <div id="dragDiv4" class="testSquare" style="visibility:hidden;border:0px solid black;height: 141px;width:160px;background-color:#7E5B60;top:630px; left:525px">a custom proxy element</div>
<!--
</div>
-->
</body>
</html>

           
       
yui.zip( 3,714 k)
Related examples in the same category
1. DynAPI Examples - Drag Drop /w Collision Detection
2. Display Drag Icon in drag and drop
3. Drag Over Event: Drag and Drop the file over recycle bins
4. Yahoo! UI Library - Drag and Drop 1
5. Yahoo! UI Library - Drag and Drop 2
6. Yahoo! UI Library - Drag and Drop 3
7. Yahoo! UI Library - Drag and Drop 5
8. Dragged object is on top
9. Yahoo! UI Library - Drag and Drop: Resize
10. Drag and Drop: Multiple groups, targetable affordance
11. Drag and Drop to sort slides
12. Drag and Drop to sort lists
13. Drag inside and outside a range
14. Drag still
15. Crop an image
16. Drag and drop custom window with title bar
17. Dragable float window with scrollable text inside
18. Dragable transparent window
19. Drag within a range 2
20. Dragable sorted list
21. Dragable and sortable toolbar
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.