4
Copyright DHTMLX LTD. http://www.dhtmlx.com
5
You allowed to use this component or parts of it under GPL terms
6
To use it on other terms or get Professional edition of the component please contact us at sales@dhtmlx.com
9
* @desc: adds drag-n-drop capabilities (with possibility to drop into dhtmlxTree) to HTML object.
10
* @param: obj - HTML object, or HTML object ID
11
* @param: func - custom drag processor function, optional
15
dhtmlXTreeObject.prototype.makeDraggable=function(obj,func){
16
if (typeof(obj)!="object")
17
obj=document.getElementById(obj);
19
dragger=new dhtmlDragAndDropObject();
20
dropper=new dhx_dragSomethingInTree();
22
dragger.addDraggableItem(obj,dropper);
24
obj.ondragstart=dropper._preventNsDrag;
25
obj.onselectstart=new Function("return false;");
27
obj.parentObject=new Object;
28
obj.parentObject.img=obj;
29
obj.parentObject.treeNod=dropper;
30
dropper._customDrop=func;
32
dhtmlXTreeObject.prototype.makeDragable=dhtmlXTreeObject.prototype.makeDraggable;
34
* @desc: adds drag-n-drop capabilities (with possibility to drop into dhtmlxTree) to all HTML items with dragInDhtmlXTree attribute
35
* @param: func - custom drag processor function, optional
39
dhtmlXTreeObject.prototype.makeAllDraggable=function(func){
40
var z=document.getElementsByTagName("div");
41
for (var i=0; i<z.length; i++)
42
if (z[i].getAttribute("dragInDhtmlXTree"))
43
this.makeDragable(z[i],func);
46
function dhx_dragSomethingInTree(){
48
//this function creates a HTML object which will be used while drag-n-drop
49
this._createDragNode=function(node){
50
var dragSpan=document.createElement('div');
51
dragSpan.style.position="absolute";
52
dragSpan.innerHTML=node.innerHTML;
53
dragSpan.style.zIndex=12;
56
//this function necessary for correct browser support
57
//doesn't change anything in it
58
this._preventNsDrag=function(e){
59
(e||window.event).cancelBubble=true;
60
if ((e)&&(e.preventDefault)) { e.preventDefault(); return false; }
63
//this function contains a reaction on drop operation
64
//the tree don't know what to do with custom item
65
//so you must define this reaction
66
this._nonTrivialNode=function(tree,item,bitem,source){
67
if (this._customDrop) return this._customDrop(tree,source.img.id,item.id,bitem?bitem.id:null);
69
var image=(source.img.getAttribute("image")||"");
70
var id=source.img.id||"new";
71
var text=(source.img.getAttribute("text")||(_isIE?source.img.innerText:source.img.textContent));
72
tree[bitem?"insertNewNext":"insertNewItem"](bitem?bitem.id:item.id,id,text,"",image,image,image);
75
//(c)dhtmlx ltd. www.dhtmlx.com
b'\\ No newline at end of file'