Author: yradtsevich
Date: 2009-11-02 07:21:07 -0500 (Mon, 02 Nov 2009)
New Revision: 18383
Added:
workspace/yradtsevich/mock/DnD/DndJsPrototype/.project
workspace/yradtsevich/mock/DnD/DndJsPrototype/.settings/
workspace/yradtsevich/mock/DnD/DndJsPrototype/.settings/.jsdtscope
workspace/yradtsevich/mock/DnD/DndJsPrototype/.settings/org.eclipse.wst.common.component
workspace/yradtsevich/mock/DnD/DndJsPrototype/.settings/org.eclipse.wst.common.project.facet.core.xml
workspace/yradtsevich/mock/DnD/DndJsPrototype/.settings/org.eclipse.wst.jsdt.ui.superType.container
workspace/yradtsevich/mock/DnD/DndJsPrototype/.settings/org.eclipse.wst.jsdt.ui.superType.name
workspace/yradtsevich/mock/DnD/DndJsPrototype/WebContent/
workspace/yradtsevich/mock/DnD/DndJsPrototype/WebContent/dragIcon.gif
workspace/yradtsevich/mock/DnD/DndJsPrototype/WebContent/index.html
workspace/yradtsevich/mock/DnD/DndJsPrototype/WebContent/script.js
Log:
JavaScript prototype for Drag&Drop in VPE
(
https://jira.jboss.org/jira/browse/JBIDE-5042 ). initial Commit
Added: workspace/yradtsevich/mock/DnD/DndJsPrototype/.project
===================================================================
--- workspace/yradtsevich/mock/DnD/DndJsPrototype/.project (rev
0)
+++ workspace/yradtsevich/mock/DnD/DndJsPrototype/.project 2009-11-02 12:21:07 UTC (rev
18383)
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>DndJsPrototype</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.wst.common.project.facet.core.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.wst.validation.validationbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
+ <nature>org.eclipse.wst.jsdt.core.jsNature</nature>
+ <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
+ </natures>
+</projectDescription>
Added: workspace/yradtsevich/mock/DnD/DndJsPrototype/.settings/.jsdtscope
===================================================================
--- workspace/yradtsevich/mock/DnD/DndJsPrototype/.settings/.jsdtscope
(rev 0)
+++ workspace/yradtsevich/mock/DnD/DndJsPrototype/.settings/.jsdtscope 2009-11-02 12:21:07
UTC (rev 18383)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con"
path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con"
path="org.eclipse.wst.jsdt.launching.WebProject">
+ <attributes>
+ <attribute name="hide" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con"
path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/>
+ <classpathentry kind="output" path=""/>
+</classpath>
Added:
workspace/yradtsevich/mock/DnD/DndJsPrototype/.settings/org.eclipse.wst.common.component
===================================================================
---
workspace/yradtsevich/mock/DnD/DndJsPrototype/.settings/org.eclipse.wst.common.component
(rev 0)
+++
workspace/yradtsevich/mock/DnD/DndJsPrototype/.settings/org.eclipse.wst.common.component 2009-11-02
12:21:07 UTC (rev 18383)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project-modules id="moduleCoreId" project-version="1.5.0">
+ <wb-module deploy-name="DndJsPrototype">
+ <wb-resource deploy-path="/"
source-path="/WebContent"/>
+ <property name="context-root" value="DndJsPrototype"/>
+ </wb-module>
+</project-modules>
Added:
workspace/yradtsevich/mock/DnD/DndJsPrototype/.settings/org.eclipse.wst.common.project.facet.core.xml
===================================================================
---
workspace/yradtsevich/mock/DnD/DndJsPrototype/.settings/org.eclipse.wst.common.project.facet.core.xml
(rev 0)
+++
workspace/yradtsevich/mock/DnD/DndJsPrototype/.settings/org.eclipse.wst.common.project.facet.core.xml 2009-11-02
12:21:07 UTC (rev 18383)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faceted-project>
+ <fixed facet="wst.web"/>
+ <installed facet="wst.jsdt.web" version="1.0"/>
+ <installed facet="wst.web" version="1.0"/>
+</faceted-project>
Added:
workspace/yradtsevich/mock/DnD/DndJsPrototype/.settings/org.eclipse.wst.jsdt.ui.superType.container
===================================================================
---
workspace/yradtsevich/mock/DnD/DndJsPrototype/.settings/org.eclipse.wst.jsdt.ui.superType.container
(rev 0)
+++
workspace/yradtsevich/mock/DnD/DndJsPrototype/.settings/org.eclipse.wst.jsdt.ui.superType.container 2009-11-02
12:21:07 UTC (rev 18383)
@@ -0,0 +1 @@
+org.eclipse.wst.jsdt.launching.baseBrowserLibrary
\ No newline at end of file
Added:
workspace/yradtsevich/mock/DnD/DndJsPrototype/.settings/org.eclipse.wst.jsdt.ui.superType.name
===================================================================
---
workspace/yradtsevich/mock/DnD/DndJsPrototype/.settings/org.eclipse.wst.jsdt.ui.superType.name
(rev 0)
+++
workspace/yradtsevich/mock/DnD/DndJsPrototype/.settings/org.eclipse.wst.jsdt.ui.superType.name 2009-11-02
12:21:07 UTC (rev 18383)
@@ -0,0 +1 @@
+Window
\ No newline at end of file
Added: workspace/yradtsevich/mock/DnD/DndJsPrototype/WebContent/dragIcon.gif
===================================================================
(Binary files differ)
Property changes on:
workspace/yradtsevich/mock/DnD/DndJsPrototype/WebContent/dragIcon.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: workspace/yradtsevich/mock/DnD/DndJsPrototype/WebContent/index.html
===================================================================
--- workspace/yradtsevich/mock/DnD/DndJsPrototype/WebContent/index.html
(rev 0)
+++ workspace/yradtsevich/mock/DnD/DndJsPrototype/WebContent/index.html 2009-11-02
12:21:07 UTC (rev 18383)
@@ -0,0 +1,61 @@
+<html>
+<head>
+<script type="text/javascript" src="script.js"></script>
+<style type="text/css">
+table
+{
+ border-color: black;
+ border-width: 1px;
+ border-style: solid;
+}
+
+td
+{
+ border-color: blasck;
+ border-width: 1px 1px 1px 1px;
+ border-style: solid;
+ margin: 0;
+ padding: 0px;
+ background-color: yellow;
+}
+</style>
+</head>
+<body style="margin-left: 25px; margin-top: 25px;">
+ <img id="dragIcon" src="dragIcon.gif" style="display:none;
position: absolute; cursor: move"/>
+ <button id="draggableButton">DRAG ME!</button>
+ <button>Non-draggable</button>
+ <P/>
+ <table>
+ <tr id="graggableRow">
+ <td>Draggable row</td>
+ <td id="graggableRow">DRAG ME!</td>
+ </tr>
+ <tr>
+ <td>row2</td>
+ <td>non-draggable</td>
+ </tr>
+ <tr>
+ <td>row3</td>
+ <td>non-draggable</td>
+ </tr>
+ </table>
+ <P/>
+ <table id="draggableTable">
+ <tr>
+ <th colspan="2">Draggable Table</th>
+ </tr>
+ <tr>
+ <td>row1</td>
+ <td rowspan="3">DRAG ME!</td>
+ </tr>
+ <tr>
+ <td>row2</td>
+ </tr>
+ <tr>
+ <td>row3</td>
+ </tr>
+ </table>
+ <P/>
+ <input id="draggableInputText" type="text" value="DRAG
ME!">
+</body>
+</html>
Added: workspace/yradtsevich/mock/DnD/DndJsPrototype/WebContent/script.js
===================================================================
--- workspace/yradtsevich/mock/DnD/DndJsPrototype/WebContent/script.js
(rev 0)
+++ workspace/yradtsevich/mock/DnD/DndJsPrototype/WebContent/script.js 2009-11-02 12:21:07
UTC (rev 18383)
@@ -0,0 +1,106 @@
+document.onmousemove = mouseMove;
+document.onmouseup = mouseUp;
+window.onload = function() {
+ makeDraggable($("draggableButton"));
+ makeDraggable($("graggableRow"));
+ makeDraggable($("draggableTable"));
+ makeDraggable($("draggableDiv"));
+ makeDraggable($("draggableInputText"));
+
+ dragIcon = $("dragIcon");
+ dragIcon.onmousedown = function(ev) {
+ mouseOffset = getMouseOffset(dragTarget, ev);
+ dragObject = dragTarget;
+ dragObject.style.opacity = 0.4;
+ return false;
+ };
+};
+
+var dragIcon = null;
+var dragTarget = null;
+var dragObject = null;
+var mouseOffset = null;
+
+function $(id) {
+ return document.getElementById(id);
+}
+
+function mouseCoords(ev) {
+ if (ev.pageX || ev.pageY) {
+ return {
+ x : ev.pageX,
+ y : ev.pageY
+ };
+ }
+ return {
+ x : ev.clientX + document.body.scrollLeft - document.body.clientLeft,
+ y : ev.clientY + document.body.scrollTop - document.body.clientTop
+ };
+}
+
+function getMouseOffset(target, ev) {
+ ev = ev || window.event;
+
+ var docPos = getPosition(target);
+ var mousePos = mouseCoords(ev);
+ return {
+ x : mousePos.x - docPos.x,
+ y : mousePos.y - docPos.y
+ };
+}
+
+function getPosition(e) {
+ var left = 0;
+ var top = 0;
+
+ while (e.offsetParent) {
+ left += e.offsetLeft;
+ top += e.offsetTop;
+ e = e.offsetParent;
+ }
+
+ left += e.offsetLeft;
+ top += e.offsetTop;
+
+ return {
+ x : left,
+ y : top
+ };
+}
+
+function mouseMove(ev) {
+ ev = ev || window.event;
+ var mousePos = mouseCoords(ev);
+
+ if (dragObject) {
+ dragObject.style.position = 'absolute';
+ dragObject.style.top = mousePos.y - mouseOffset.y;
+ dragObject.style.left = mousePos.x - mouseOffset.x;
+
+ drawDragIcon(dragObject);
+ return false;
+ }
+}
+function mouseUp() {
+ if (dragObject) {
+ dragObject.style.opacity = 1.0;
+ dragObject = null;
+ }
+}
+
+function makeDraggable(item) {
+ if (!item)
+ return;
+ item.onmousedown = function(ev) {
+ dragTarget = this;
+ drawDragIcon(dragTarget);
+ return true;
+ };
+}
+
+function drawDragIcon(draggable) {
+ docPos = getPosition(draggable);
+ dragIcon.style.top = docPos.y - 19;
+ dragIcon.style.left = docPos.x - 19;
+ dragIcon.style.display = "";
+}