Subversion Repositories Applications.papyrus

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1265 jp_milcent 1
/** $Id: domTT_drag.js,v 1.1 2007-03-16 12:39:35 jp_milcent Exp $ */
2
// {{{ license
3
 
4
/*
5
 * Copyright 2002-2005 Dan Allen, Mojavelinux.com (dan.allen@mojavelinux.com)
6
 *
7
 * Licensed under the Apache License, Version 2.0 (the "License");
8
 * you may not use this file except in compliance with the License.
9
 * You may obtain a copy of the License at
10
 *
11
 *      http://www.apache.org/licenses/LICENSE-2.0
12
 *
13
 * Unless required by applicable law or agreed to in writing, software
14
 * distributed under the License is distributed on an "AS IS" BASIS,
15
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
 * See the License for the specific language governing permissions and
17
 * limitations under the License.
18
 */
19
 
20
// }}}
21
// {{{ globals (DO NOT EDIT)
22
 
23
var domTT_dragEnabled = true;
24
var domTT_currentDragTarget;
25
var domTT_dragMouseDown;
26
var domTT_dragOffsetLeft;
27
var domTT_dragOffsetTop;
28
 
29
// }}}
30
// {{{ domTT_dragStart()
31
 
32
function domTT_dragStart(in_this, in_event)
33
{
34
	if (typeof(in_event) == 'undefined') { in_event = window.event; }
35
 
36
	var eventButton = in_event[domLib_eventButton];
37
	if (eventButton != 1 && !domLib_isKHTML)
38
	{
39
		return;
40
	}
41
 
42
	domTT_currentDragTarget = in_this;
43
	in_this.style.cursor = 'move';
44
 
45
	// upgrade our z-index
46
	in_this.style.zIndex = ++domLib_zIndex;
47
 
48
	var eventPosition = domLib_getEventPosition(in_event);
49
 
50
	var targetPosition = domLib_getOffsets(in_this);
51
	domTT_dragOffsetLeft = eventPosition.get('x') - targetPosition.get('left');
52
	domTT_dragOffsetTop = eventPosition.get('y') - targetPosition.get('top');
53
	domTT_dragMouseDown = true;
54
}
55
 
56
// }}}
57
// {{{ domTT_dragUpdate()
58
 
59
function domTT_dragUpdate(in_event)
60
{
61
	if (domTT_dragMouseDown)
62
	{
63
		if (domLib_isGecko)
64
		{
65
			window.getSelection().removeAllRanges()
66
		}
67
 
68
		if (domTT_useGlobalMousePosition && domTT_mousePosition != null)
69
		{
70
			var eventPosition = domTT_mousePosition;
71
		}
72
		else
73
		{
74
			if (typeof(in_event) == 'undefined') { in_event = window.event; }
75
			var eventPosition = domLib_getEventPosition(in_event);
76
		}
77
 
78
		domTT_currentDragTarget.style.left = (eventPosition.get('x') - domTT_dragOffsetLeft) + 'px';
79
		domTT_currentDragTarget.style.top = (eventPosition.get('y') - domTT_dragOffsetTop) + 'px';
80
 
81
		// update the collision detection
82
		domLib_detectCollisions(domTT_currentDragTarget);
83
	}
84
}
85
 
86
// }}}
87
// {{{ domTT_dragStop()
88
 
89
function domTT_dragStop()
90
{
91
	if (domTT_dragMouseDown) {
92
		domTT_dragMouseDown = false;
93
		domTT_currentDragTarget.style.cursor = 'default';
94
		domTT_currentDragTarget = null;
95
		if (domLib_isGecko)
96
		{
97
			window.getSelection().removeAllRanges()
98
		}
99
	}
100
}
101
 
102
// }}}