/adei/ui

To get this branch, use:
bzr branch http://darksoft.org/webbzr/adei/ui

« back to all changes in this revision

Viewing changes to includes/dhtmlx.orig/ext/dhtmlxtree_dragin.js

  • Committer: Suren A. Chilingaryan
  • Date: 2008-10-30 01:27:40 UTC
  • mto: This revision was merged to the branch mainline in revision 116.
  • Revision ID: csa@dside.dyndns.org-20081030012740-svt0yigxj5uzwxyj
Few steps on source tree integration in javascript frontend

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//v.2.0 build 81009
 
2
 
 
3
/*
 
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
 
7
*/
 
8
/**
 
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
 
12
*     @type: public
 
13
*     @topic: 0
 
14
*/
 
15
dhtmlXTreeObject.prototype.makeDraggable=function(obj,func){
 
16
        if (typeof(obj)!="object")
 
17
                obj=document.getElementById(obj);
 
18
 
 
19
    dragger=new dhtmlDragAndDropObject();
 
20
        dropper=new dhx_dragSomethingInTree();
 
21
 
 
22
    dragger.addDraggableItem(obj,dropper);
 
23
    obj.dragLanding=null;
 
24
    obj.ondragstart=dropper._preventNsDrag;
 
25
    obj.onselectstart=new Function("return false;");
 
26
 
 
27
    obj.parentObject=new Object;
 
28
    obj.parentObject.img=obj;
 
29
    obj.parentObject.treeNod=dropper;
 
30
        dropper._customDrop=func;
 
31
}
 
32
dhtmlXTreeObject.prototype.makeDragable=dhtmlXTreeObject.prototype.makeDraggable;
 
33
/**
 
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
 
36
*     @type: public
 
37
*     @topic: 0
 
38
*/
 
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);
 
44
}
 
45
 
 
46
function dhx_dragSomethingInTree(){
 
47
        this.lWin=window;
 
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;
 
54
        return dragSpan;
 
55
    };
 
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; }
 
61
        return false;
 
62
    }
 
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);
 
68
 
 
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);
 
73
     }
 
74
}
 
75
//(c)dhtmlx ltd. www.dhtmlx.com
 
 
b'\\ No newline at end of file'