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
4e3e4799
Commit
4e3e4799
authored
Nov 19, 2013
by
Kazuhiko Shiozaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
store node positions in relative value (0 to 1).
parent
65b11f73
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
24 deletions
+44
-24
dream/platform/static/src/dream_launcher.js
dream/platform/static/src/dream_launcher.js
+2
-2
dream/platform/static/src/jsonPlumb.js
dream/platform/static/src/jsonPlumb.js
+42
-22
No files found.
dream/platform/static/src/dream_launcher.js
View file @
4e3e4799
...
...
@@ -216,8 +216,8 @@
stop
:
function
(
tool
)
{
var
box_top
,
box_left
,
_class
;
var
offset
=
$
(
"
[id=render]
"
).
offset
();
box_top
=
tool
.
clientY
-
offset
.
top
+
"
px
"
;
box_left
=
tool
.
clientX
-
offset
.
left
+
"
px
"
;
box_top
=
(
tool
.
clientY
-
offset
.
top
)
/
$
(
'
#main
'
).
height
()
;
box_left
=
(
tool
.
clientX
-
offset
.
left
)
/
$
(
'
#main
'
).
width
()
;
id_container
[
tool
.
target
.
id
]
=
(
id_container
[
tool
.
target
.
id
]
||
0
)
+
1
;
_class
=
tool
.
target
.
id
.
replace
(
'
-
'
,
'
.
'
);
// XXX - vs .
...
...
dream/platform/static/src/jsonPlumb.js
View file @
4e3e4799
...
...
@@ -112,8 +112,10 @@
if
(
coordinate
===
undefined
)
{
coordinate
=
{};
element
=
$
(
"
#
"
+
element_id
);
coordinate
.
top
=
element
.
css
(
"
top
"
);
coordinate
.
left
=
element
.
css
(
"
left
"
);
var
relative_position
=
priv
.
convertToRelativePosition
(
element
.
css
(
'
left
'
),
element
.
css
(
'
top
'
));
coordinate
.
top
=
relative_position
[
1
];
coordinate
.
left
=
relative_position
[
0
];
}
coordinates
[
element_id
]
=
coordinate
;
priv
.
preference_container
[
'
coordinates
'
]
=
coordinates
;
...
...
@@ -127,6 +129,26 @@
element
.
css
(
node_style
);
};
priv
.
convertToAbsolutePosition
=
function
(
x
,
y
)
{
var
canvas_size_x
=
$
(
'
#main
'
).
width
();
var
canvas_size_y
=
$
(
'
#main
'
).
height
();
var
size_x
=
$
(
'
.window
'
).
width
();
var
size_y
=
$
(
'
.window
'
).
height
();
var
top
=
Math
.
floor
(
y
*
(
canvas_size_y
-
size_y
))
+
"
px
"
;
var
left
=
Math
.
floor
(
x
*
(
canvas_size_x
-
size_x
))
+
"
px
"
;
return
[
left
,
top
];
};
priv
.
convertToRelativePosition
=
function
(
x
,
y
)
{
var
canvas_size_x
=
$
(
'
#main
'
).
width
();
var
canvas_size_y
=
$
(
'
#main
'
).
height
();
var
size_x
=
$
(
'
.window
'
).
width
();
var
size_y
=
$
(
'
.window
'
).
height
();
var
top
=
y
.
replace
(
'
px
'
,
''
)
/
(
pos
.
top
*
(
canvas_size_y
-
size_y
));
var
left
=
x
/
(
pos
.
left
*
(
canvas_size_x
-
size_x
));
return
[
left
,
top
];
};
priv
.
saveNodeStyle
=
function
(
style_dict
)
{
var
node_style
=
priv
.
preference_container
[
'
node_style
'
]
||
{};
$
.
each
(
style_dict
,
function
(
k
,
v
)
{
...
...
@@ -170,19 +192,15 @@
contentType
:
'
application/json
'
,
type
:
'
POST
'
,
success
:
function
(
data
,
textStatus
,
jqXHR
)
{
var
canvas_size_x
=
$
(
'
#main
'
).
width
();
var
canvas_size_y
=
$
(
'
#main
'
).
height
();
var
size_x
=
$
(
'
.window
'
).
width
();
var
size_y
=
$
(
'
.window
'
).
height
();
$
.
each
(
data
,
function
(
node
,
pos
)
{
var
top
=
Math
.
floor
(
pos
.
top
*
(
canvas_size_y
-
size_y
))
+
"
px
"
;
var
left
=
Math
.
floor
(
pos
.
left
*
(
canvas_size_x
-
size_x
))
+
"
px
"
;
var
absolute_position
=
priv
.
convertToAbsolutePosition
(
pos
.
left
,
pos
.
top
)
;
priv
.
updateElementCoordinate
(
node
,
{
top
:
top
,
left
:
left
top
:
pos
.
top
,
left
:
pos
.
left
});
$
(
'
#
'
+
node
).
css
(
'
top
'
,
top
);
$
(
'
#
'
+
node
).
css
(
'
left
'
,
left
);
$
(
'
#
'
+
node
).
css
(
'
top
'
,
absolute_position
[
1
]
);
$
(
'
#
'
+
node
).
css
(
'
left
'
,
absolute_position
[
0
]
);
});
jsPlumb
.
repaintEverything
();
}
...
...
@@ -296,8 +314,10 @@
render_element
.
append
(
'
<div class="window
'
+
element
.
_class
.
replace
(
'
.
'
,
'
-
'
)
+
'
" id="
'
+
element
.
id
+
'
">
'
+
element
.
id
+
'
</div>
'
);
box
=
$
(
"
#
"
+
element
.
id
);
box
.
css
(
"
top
"
,
coordinate
.
top
);
box
.
css
(
"
left
"
,
coordinate
.
left
);
var
absolute_position
=
priv
.
convertToAbsolutePosition
(
coordinate
.
left
,
coordinate
.
top
);
box
.
css
(
"
top
"
,
absolute_position
[
1
]);
box
.
css
(
"
left
"
,
absolute_position
[
0
]);
priv
.
updateNodeStyle
(
element
.
id
);
// Initial DEMO code : make all the window divs draggable
...
...
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