Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dokuwiki
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
BRIC
dokuwiki
Commits
0b0fbf67
Commit
0b0fbf67
authored
15 years ago
by
Adrian Lang
Browse files
Options
Downloads
Patches
Plain Diff
Make drag inheritable
darcs-hash:20091127112402-e4919-dc8340c03ef2d3b242302dcc228d56539eaf9e28.gz
parent
45d05808
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/scripts/drag.js
+29
-26
29 additions, 26 deletions
lib/scripts/drag.js
with
29 additions
and
26 deletions
lib/scripts/drag.js
+
29
−
26
View file @
0b0fbf67
/**
* Makes a DOM object draggable
*
* This is currently for movable DOM dialogs only. If needed it could be
* extended to execute callbacks on special events...
* If you just want to move objects around, use drag.attach. For full
* customization, drag can be used as a javascript prototype, it is
* inheritance-aware.
*
* @link http://nofunc.org/Drag_Drop/
*/
...
...
@@ -26,33 +27,36 @@ var drag = {
attach
:
function
(
obj
,
handle
)
{
if
(
handle
){
handle
.
dragobject
=
obj
;
addEvent
(
$
(
handle
),
'
mousedown
'
,
drag
.
start
);
}
else
{
addEvent
(
$
(
obj
),
'
mousedown
'
,
drag
.
start
)
;
handle
=
obj
;
}
var
_this
=
this
;
addEvent
(
$
(
handle
),
'
mousedown
'
,
function
(
e
)
{
return
_this
.
start
(
e
);
});
},
/**
* Starts the dragging operation
*/
start
:
function
(
e
){
drag
.
handle
=
e
.
target
;
if
(
drag
.
handle
.
dragobject
){
drag
.
obj
=
drag
.
handle
.
dragobject
;
this
.
handle
=
e
.
target
;
if
(
this
.
handle
.
dragobject
){
this
.
obj
=
this
.
handle
.
dragobject
;
}
else
{
drag
.
obj
=
drag
.
handle
;
this
.
obj
=
this
.
handle
;
}
drag
.
handle
.
className
+=
'
ondrag
'
;
drag
.
obj
.
className
+=
'
ondrag
'
;
this
.
handle
.
className
+=
'
ondrag
'
;
this
.
obj
.
className
+=
'
ondrag
'
;
drag
.
oX
=
parseInt
(
drag
.
obj
.
style
.
left
);
drag
.
oY
=
parseInt
(
drag
.
obj
.
style
.
top
);
drag
.
eX
=
drag
.
evX
(
e
);
drag
.
eY
=
drag
.
evY
(
e
);
this
.
oX
=
parseInt
(
this
.
obj
.
style
.
left
);
this
.
oY
=
parseInt
(
this
.
obj
.
style
.
top
);
this
.
eX
=
drag
.
evX
(
e
);
this
.
eY
=
drag
.
evY
(
e
);
addEvent
(
document
,
'
mousemove
'
,
drag
.
drag
);
addEvent
(
document
,
'
mouseup
'
,
drag
.
stop
);
var
_this
=
this
;
this
.
mousehandlers
=
[
function
(
e
)
{
return
_this
.
drag
(
e
);},
function
(
e
)
{
return
_this
.
stop
(
e
);}];
addEvent
(
document
,
'
mousemove
'
,
this
.
mousehandlers
[
0
]);
addEvent
(
document
,
'
mouseup
'
,
this
.
mousehandlers
[
1
]);
e
.
preventDefault
();
e
.
stopPropagation
();
...
...
@@ -63,21 +67,21 @@ var drag = {
* Ends the dragging operation
*/
stop
:
function
(){
drag
.
handle
.
className
=
drag
.
handle
.
className
.
replace
(
/
?
ondrag/
,
''
);
drag
.
obj
.
className
=
drag
.
obj
.
className
.
replace
(
/
?
ondrag/
,
''
);
removeEvent
(
document
,
'
mousemove
'
,
drag
.
drag
);
removeEvent
(
document
,
'
mouseup
'
,
drag
.
stop
);
drag
.
obj
=
null
;
drag
.
handle
=
null
;
this
.
handle
.
className
=
this
.
handle
.
className
.
replace
(
/
?
ondrag/
,
''
);
this
.
obj
.
className
=
this
.
obj
.
className
.
replace
(
/
?
ondrag/
,
''
);
removeEvent
(
document
,
'
mousemove
'
,
this
.
mousehandlers
[
0
]
);
removeEvent
(
document
,
'
mouseup
'
,
this
.
mousehandlers
[
1
]
);
this
.
obj
=
null
;
this
.
handle
=
null
;
},
/**
* Moves the object during the dragging operation
*/
drag
:
function
(
e
)
{
if
(
drag
.
obj
)
{
drag
.
obj
.
style
.
top
=
(
drag
.
evY
(
e
)
+
drag
.
oY
-
drag
.
eY
+
'
px
'
);
drag
.
obj
.
style
.
left
=
(
drag
.
evX
(
e
)
+
drag
.
oX
-
drag
.
eX
+
'
px
'
);
if
(
this
.
obj
)
{
this
.
obj
.
style
.
top
=
(
this
.
evY
(
e
)
+
this
.
oY
-
this
.
eY
+
'
px
'
);
this
.
obj
.
style
.
left
=
(
this
.
evX
(
e
)
+
this
.
oX
-
this
.
eX
+
'
px
'
);
}
},
...
...
@@ -96,4 +100,3 @@ var drag = {
}
};
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment