Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
dream
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
dream
Commits
135f6f88
Commit
135f6f88
authored
Jun 26, 2014
by
Thibaut Frain
Committed by
Jérome Perrin
Aug 11, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
drag and drop relative callbacks are linked with application promise tree
parent
7a141d97
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
36 deletions
+50
-36
dream/platform/src2/jsplumb/jsplumb.js
dream/platform/src2/jsplumb/jsplumb.js
+32
-29
dream/platform/src2/toolbox/toolbox.js
dream/platform/src2/toolbox/toolbox.js
+18
-7
No files found.
dream/platform/src2/jsplumb/jsplumb.js
View file @
135f6f88
...
...
@@ -528,48 +528,51 @@
}
function
waitForDrop
(
gadget
,
config
)
{
var
target
=
gadget
.
props
.
element
.
querySelector
(
'
#main
'
),
callback
;
var
callback
;
function
canceller
()
{
if
(
callback
!==
undefined
)
{
target
.
removeEventListener
(
'
drop
'
,
callback
,
false
);
gadget
.
props
.
main
.
removeEventListener
(
'
drop
'
,
callback
,
false
);
}
}
function
nonResolvableTrap
(
resolve
,
reject
)
{
/*jslint unparam: true*/
function
itsANonResolvableTrap
(
resolve
,
reject
)
{
callback
=
function
(
evt
)
{
var
element
=
domParser
.
parseFromString
(
evt
.
dataTransfer
.
getData
(
'
text/html
'
),
'
text/html
'
).
querySelector
(
"
.tool
"
),
offset
=
$
(
gadget
.
props
.
main
).
offset
(),
box_top
=
evt
.
clientY
-
offset
.
top
+
"
px
"
,
box_left
=
evt
.
clientX
-
offset
.
left
+
"
px
"
,
element_class
=
element
.
id
.
replace
(
'
-
'
,
'
.
'
),
relative_position
=
convertToRelativePosition
(
gadget
,
box_left
,
box_top
);
newElement
(
gadget
,
{
coordinate
:
{
left
:
relative_position
[
0
],
top
:
relative_position
[
1
]
try
{
var
element
=
domParser
.
parseFromString
(
evt
.
dataTransfer
.
getData
(
'
text/html
'
),
'
text/html
'
).
querySelector
(
"
.tool
"
),
offset
=
$
(
gadget
.
props
.
main
).
offset
(),
box_top
=
evt
.
clientY
-
offset
.
top
+
"
px
"
,
box_left
=
evt
.
clientX
-
offset
.
left
+
"
px
"
,
element_class
=
element
.
id
.
replace
(
'
-
'
,
'
.
'
),
relative_position
=
convertToRelativePosition
(
gadget
,
box_left
,
box_top
);
newElement
(
gadget
,
{
coordinate
:
{
left
:
relative_position
[
0
],
top
:
relative_position
[
1
]
},
"
_class
"
:
element_class
,
"
name
"
:
element_class
},
"
_class
"
:
element_class
,
"
name
"
:
element_class
},
config
);
config
);
}
catch
(
e
)
{
reject
(
e
);
}
};
target
.
addEventListener
(
'
drop
'
,
callback
,
false
);
gadget
.
props
.
main
.
addEventListener
(
'
drop
'
,
callback
,
false
);
}
return
new
RSVP
.
Promise
(
n
onResolvableTrap
,
canceller
);
return
new
RSVP
.
Promise
(
itsAN
onResolvableTrap
,
canceller
);
}
initGadgetMixin
(
gadget_klass
);
...
...
dream/platform/src2/toolbox/toolbox.js
View file @
135f6f88
...
...
@@ -8,16 +8,27 @@
tool_template
=
Handlebars
.
compile
(
tool_template_source
);
function
waitForDragstart
(
tool
)
{
var
callback
;
function
canceller
()
{
if
(
callback
!==
undefined
)
{
tool
.
removeEventListener
(
'
dragstart
'
,
callback
,
false
);
}
}
/*jslint unparam: true*/
var
callback
=
function
(
evt
)
{
evt
.
dataTransfer
.
setData
(
'
text/html
'
,
tool
.
outerHTML
);
};
function
itsANonResolvableTrap
(
resolve
,
reject
)
{
callback
=
function
(
evt
)
{
try
{
evt
.
dataTransfer
.
setData
(
'
text/html
'
,
tool
.
outerHTML
);
}
catch
(
e
)
{
reject
(
e
);
}
};
return
new
RSVP
.
Promise
(
function
(
resolve
,
reject
)
{
tool
.
addEventListener
(
'
dragstart
'
,
callback
,
false
);
},
function
()
{
tool
.
removeEventListener
(
'
dragstart
'
,
callback
,
false
);
});
}
return
new
RSVP
.
Promise
(
itsANonResolvableTrap
,
canceller
);
}
initGadgetMixin
(
gadget_klass
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment