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
613ea05a
Commit
613ea05a
authored
Jun 24, 2014
by
Thibaut Frain
Committed by
Jérome Perrin
Aug 11, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use mixin_gadget.js in jsplumb
parent
4801018c
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
112 additions
and
115 deletions
+112
-115
dream/platform/src2/jsplumb/index.html
dream/platform/src2/jsplumb/index.html
+1
-0
dream/platform/src2/jsplumb/jsplumb.js
dream/platform/src2/jsplumb/jsplumb.js
+110
-115
dream/platform/src2/toolbox/index.html
dream/platform/src2/toolbox/index.html
+1
-0
No files found.
dream/platform/src2/jsplumb/index.html
View file @
613ea05a
...
@@ -21,6 +21,7 @@
...
@@ -21,6 +21,7 @@
<
/div
>
<
/div
>
</script>
</script>
<script
src=
"../dream/mixin_gadget.js"
></script>
<script
src=
"jsplumb.js"
></script>
<script
src=
"jsplumb.js"
></script>
</head>
</head>
<body>
<body>
...
...
dream/platform/src2/jsplumb/jsplumb.js
View file @
613ea05a
...
@@ -17,9 +17,9 @@
...
@@ -17,9 +17,9 @@
* along with DREAM. If not, see <http://www.gnu.org/licenses/>.
* along with DREAM. If not, see <http://www.gnu.org/licenses/>.
* ==========================================================================*/
* ==========================================================================*/
/*global RSVP, rJS, $, jsPlumb, Handlebars*/
/*global RSVP, rJS, $, jsPlumb, Handlebars
, DOMParser, initGadgetMixin
*/
/*jslint unparam: true */
/*jslint unparam: true */
(
function
(
RSVP
,
rJS
,
$
,
jsPlumb
,
Handlebars
)
{
(
function
(
RSVP
,
rJS
,
$
,
jsPlumb
,
Handlebars
,
initGadgetMixin
)
{
"
use strict
"
;
"
use strict
"
;
/*jslint nomen: true*/
/*jslint nomen: true*/
...
@@ -67,13 +67,13 @@
...
@@ -67,13 +67,13 @@
}
}
function
convertToAbsolutePosition
(
gadget
,
x
,
y
)
{
function
convertToAbsolutePosition
(
gadget
,
x
,
y
)
{
var
zoom_level
=
(
gadget
.
pr
ivate
.
preference_container
.
zoom_level
||
1.0
)
*
var
zoom_level
=
(
gadget
.
pr
ops
.
preference_container
.
zoom_level
||
1.0
)
*
1.1111
,
1.1111
,
canvas_size_x
=
$
(
gadget
.
pr
ivate
.
element
).
find
(
'
#main
'
).
width
(),
canvas_size_x
=
$
(
gadget
.
pr
ops
.
element
).
find
(
'
#main
'
).
width
(),
canvas_size_y
=
$
(
gadget
.
pr
ivate
.
element
).
find
(
'
#main
'
).
height
(),
canvas_size_y
=
$
(
gadget
.
pr
ops
.
element
).
find
(
'
#main
'
).
height
(),
size_x
=
$
(
gadget
.
pr
ivate
.
element
).
find
(
'
.dummy_window
'
).
width
()
*
size_x
=
$
(
gadget
.
pr
ops
.
element
).
find
(
'
.dummy_window
'
).
width
()
*
zoom_level
,
zoom_level
,
size_y
=
$
(
gadget
.
pr
ivate
.
element
).
find
(
'
.dummy_window
'
).
height
()
*
size_y
=
$
(
gadget
.
pr
ops
.
element
).
find
(
'
.dummy_window
'
).
height
()
*
zoom_level
,
zoom_level
,
top
=
Math
.
floor
(
y
*
(
canvas_size_y
-
size_y
))
+
"
px
"
,
top
=
Math
.
floor
(
y
*
(
canvas_size_y
-
size_y
))
+
"
px
"
,
left
=
Math
.
floor
(
x
*
(
canvas_size_x
-
size_x
))
+
"
px
"
;
left
=
Math
.
floor
(
x
*
(
canvas_size_x
-
size_x
))
+
"
px
"
;
...
@@ -81,13 +81,13 @@
...
@@ -81,13 +81,13 @@
}
}
function
convertToRelativePosition
(
gadget
,
x
,
y
)
{
function
convertToRelativePosition
(
gadget
,
x
,
y
)
{
var
zoom_level
=
(
gadget
.
pr
ivate
.
preference_container
.
zoom_level
||
1.0
)
*
var
zoom_level
=
(
gadget
.
pr
ops
.
preference_container
.
zoom_level
||
1.0
)
*
1.1111
,
1.1111
,
canvas_size_x
=
$
(
gadget
.
pr
ivate
.
element
).
find
(
'
#main
'
).
width
(),
canvas_size_x
=
$
(
gadget
.
pr
ops
.
element
).
find
(
'
#main
'
).
width
(),
canvas_size_y
=
$
(
gadget
.
pr
ivate
.
element
).
find
(
'
#main
'
).
height
(),
canvas_size_y
=
$
(
gadget
.
pr
ops
.
element
).
find
(
'
#main
'
).
height
(),
size_x
=
$
(
gadget
.
pr
ivate
.
element
).
find
(
'
.dummy_window
'
).
width
()
*
size_x
=
$
(
gadget
.
pr
ops
.
element
).
find
(
'
.dummy_window
'
).
width
()
*
zoom_level
,
zoom_level
,
size_y
=
$
(
gadget
.
pr
ivate
.
element
).
find
(
'
.dummy_window
'
).
height
()
*
size_y
=
$
(
gadget
.
pr
ops
.
element
).
find
(
'
.dummy_window
'
).
height
()
*
zoom_level
,
zoom_level
,
top
=
Math
.
max
(
Math
.
min
(
y
.
replace
(
'
px
'
,
''
)
/
top
=
Math
.
max
(
Math
.
min
(
y
.
replace
(
'
px
'
,
''
)
/
(
canvas_size_y
-
size_y
),
1
),
0
),
(
canvas_size_y
-
size_y
),
1
),
0
),
...
@@ -97,13 +97,13 @@
...
@@ -97,13 +97,13 @@
}
}
function
updateElementCoordinate
(
gadget
,
node_id
,
coordinate
)
{
function
updateElementCoordinate
(
gadget
,
node_id
,
coordinate
)
{
var
element_id
=
gadget
.
pr
ivate
.
node_container
[
node_id
].
element_id
,
var
element_id
=
gadget
.
pr
ops
.
node_container
[
node_id
].
element_id
,
coordinates
=
gadget
.
pr
ivate
.
preference_container
.
coordinates
||
{},
coordinates
=
gadget
.
pr
ops
.
preference_container
.
coordinates
||
{},
element
,
element
,
relative_position
;
relative_position
;
if
(
coordinate
===
undefined
)
{
if
(
coordinate
===
undefined
)
{
coordinate
=
{};
coordinate
=
{};
element
=
$
(
gadget
.
pr
ivate
.
element
).
find
(
"
#
"
+
element_id
);
element
=
$
(
gadget
.
pr
ops
.
element
).
find
(
"
#
"
+
element_id
);
relative_position
=
convertToRelativePosition
(
relative_position
=
convertToRelativePosition
(
gadget
,
gadget
,
element
.
css
(
'
left
'
),
element
.
css
(
'
left
'
),
...
@@ -113,16 +113,16 @@
...
@@ -113,16 +113,16 @@
coordinate
.
left
=
relative_position
[
0
];
coordinate
.
left
=
relative_position
[
0
];
}
}
coordinates
[
node_id
]
=
coordinate
;
coordinates
[
node_id
]
=
coordinate
;
gadget
.
pr
ivate
.
preference_container
.
coordinates
=
coordinates
;
gadget
.
pr
ops
.
preference_container
.
coordinates
=
coordinates
;
onDataChange
();
onDataChange
();
return
coordinate
;
return
coordinate
;
}
}
function
draggable
(
gadget
)
{
function
draggable
(
gadget
)
{
var
jsplumb_instance
=
gadget
.
pr
ivate
.
jsplumb_instance
,
var
jsplumb_instance
=
gadget
.
pr
ops
.
jsplumb_instance
,
stop
=
function
(
element
)
{
stop
=
function
(
element
)
{
updateElementCoordinate
(
gadget
,
getNodeId
(
updateElementCoordinate
(
gadget
,
getNodeId
(
gadget
.
pr
ivate
.
node_container
,
gadget
.
pr
ops
.
node_container
,
element
.
target
.
id
element
.
target
.
id
));
));
};
};
...
@@ -159,7 +159,7 @@
...
@@ -159,7 +159,7 @@
}
}
function
initJsPlumb
(
gadget
)
{
function
initJsPlumb
(
gadget
)
{
var
jsplumb_instance
=
gadget
.
pr
ivate
.
jsplumb_instance
;
var
jsplumb_instance
=
gadget
.
pr
ops
.
jsplumb_instance
;
jsplumb_instance
.
setRenderMode
(
jsplumb_instance
.
SVG
);
jsplumb_instance
.
setRenderMode
(
jsplumb_instance
.
SVG
);
jsplumb_instance
.
importDefaults
({
jsplumb_instance
.
importDefaults
({
...
@@ -201,14 +201,14 @@
...
@@ -201,14 +201,14 @@
// return undefined;
// return undefined;
// });
// });
// split in 2 methods ? one for events one for manip
// split in 2 methods ? one for events one for manip
gadget
.
pr
ivate
.
updateConnectionData
gadget
.
pr
ops
.
updateConnectionData
=
function
(
connection
,
remove
,
edge_data
)
{
=
function
(
connection
,
remove
,
edge_data
)
{
if
(
remove
)
{
if
(
remove
)
{
delete
gadget
.
pr
ivate
.
edge_container
[
connection
.
id
];
delete
gadget
.
pr
ops
.
edge_container
[
connection
.
id
];
}
else
{
}
else
{
gadget
.
pr
ivate
.
edge_container
[
connection
.
id
]
=
[
gadget
.
pr
ops
.
edge_container
[
connection
.
id
]
=
[
getNodeId
(
gadget
.
pr
ivate
.
node_container
,
connection
.
sourceId
),
getNodeId
(
gadget
.
pr
ops
.
node_container
,
connection
.
sourceId
),
getNodeId
(
gadget
.
pr
ivate
.
node_container
,
connection
.
targetId
),
getNodeId
(
gadget
.
pr
ops
.
node_container
,
connection
.
targetId
),
edge_data
||
{}
edge_data
||
{}
];
];
}
}
...
@@ -219,23 +219,23 @@
...
@@ -219,23 +219,23 @@
// and update the list of connections on screen.
// and update the list of connections on screen.
// jsplumb_instance
// jsplumb_instance
// .bind("connection", function (info, originalEvent) {
// .bind("connection", function (info, originalEvent) {
// gadget.pr
ivate
.updateConnectionData(info.connection);
// gadget.pr
ops
.updateConnectionData(info.connection);
// });
// });
// jsplumb_instance
// jsplumb_instance
// .bind("connectionDetached", function (info, originalEvent) {
// .bind("connectionDetached", function (info, originalEvent) {
// gadget.pr
ivate
.updateConnectionData(info.connection, true);
// gadget.pr
ops
.updateConnectionData(info.connection, true);
// });
// });
onDataChange
();
onDataChange
();
draggable
(
gadget
);
draggable
(
gadget
);
}
}
function
updateNodeStyle
(
gadget
,
element_id
)
{
function
updateNodeStyle
(
gadget
,
element_id
)
{
var
zoom_level
=
(
gadget
.
pr
ivate
.
preference_container
.
zoom_level
||
1.0
)
*
var
zoom_level
=
(
gadget
.
pr
ops
.
preference_container
.
zoom_level
||
1.0
)
*
1.1111
,
1.1111
,
element
=
$
(
gadget
.
pr
ivate
.
element
).
find
(
"
#
"
+
element_id
),
element
=
$
(
gadget
.
pr
ops
.
element
).
find
(
"
#
"
+
element_id
),
new_value
;
new_value
;
$
.
each
(
gadget
.
pr
ivate
.
style_attr_list
,
function
(
i
,
j
)
{
$
.
each
(
gadget
.
pr
ops
.
style_attr_list
,
function
(
i
,
j
)
{
new_value
=
$
(
gadget
.
pr
ivate
.
element
).
find
(
'
.dummy_window
'
).
css
(
j
)
new_value
=
$
(
gadget
.
pr
ops
.
element
).
find
(
'
.dummy_window
'
).
css
(
j
)
.
replace
(
'
px
'
,
''
)
*
zoom_level
+
'
px
'
;
.
replace
(
'
px
'
,
''
)
*
zoom_level
+
'
px
'
;
element
.
css
(
j
,
new_value
);
element
.
css
(
j
,
new_value
);
});
});
...
@@ -296,63 +296,63 @@
...
@@ -296,63 +296,63 @@
// }
// }
// function setZoom(gadget, zoom_level) {
// function setZoom(gadget, zoom_level) {
// $.each(gadget.pr
ivate
.style_attr_list, function (i, j) {
// $.each(gadget.pr
ops
.style_attr_list, function (i, j) {
// var new_value = $(gadget.pr
ivate
.element).find('.dummy_window')
// var new_value = $(gadget.pr
ops
.element).find('.dummy_window')
// .css(j).replace('px', '') * zoom_level + 'px';
// .css(j).replace('px', '') * zoom_level + 'px';
// $(gadget.pr
ivate
.element).find('.window').css(j, new_value);
// $(gadget.pr
ops
.element).find('.window').css(j, new_value);
// });
// });
// }
// }
// function zoom_in(gadget) {
// function zoom_in(gadget) {
// var zoom_level = (gadget.pr
ivate
.preference_container.zoom_level || 1.0) *
// var zoom_level = (gadget.pr
ops
.preference_container.zoom_level || 1.0) *
// 1.1111;
// 1.1111;
// setZoom(gadget, zoom_level);
// setZoom(gadget, zoom_level);
// gadget.pr
ivate
.preference_container.zoom_level = zoom_level;
// gadget.pr
ops
.preference_container.zoom_level = zoom_level;
// onDataChange();
// onDataChange();
// redraw(gadget);
// redraw(gadget);
// }
// }
// function zoom_out(gadget) {
// function zoom_out(gadget) {
// var zoom_level = (gadget.pr
ivate
.preference_container.zoom_level || 1.0) *
// var zoom_level = (gadget.pr
ops
.preference_container.zoom_level || 1.0) *
// 0.9;
// 0.9;
// setZoom(gadget, zoom_level);
// setZoom(gadget, zoom_level);
// gadget.pr
ivate
.preference_container.zoom_level = zoom_level;
// gadget.pr
ops
.preference_container.zoom_level = zoom_level;
// onDataChange();
// onDataChange();
// redraw(gadget);
// redraw(gadget);
// }
// }
// function removeElement(gadget, node_id) {
// function removeElement(gadget, node_id) {
// var element_id = gadget.pr
ivate
.node_container[node_id].element_id;
// var element_id = gadget.pr
ops
.node_container[node_id].element_id;
// gadget.pr
ivate
.jsplumb_instance.removeAllEndpoints(
// gadget.pr
ops
.jsplumb_instance.removeAllEndpoints(
// $(gadget.pr
ivate
.element).find("#" + element_id)
// $(gadget.pr
ops
.element).find("#" + element_id)
// );
// );
// $(gadget.pr
ivate
.element).find("#" + element_id).remove();
// $(gadget.pr
ops
.element).find("#" + element_id).remove();
// delete gadget.pr
ivate
.node_container[node_id];
// delete gadget.pr
ops
.node_container[node_id];
// delete gadget.pr
ivate
.preference_container.coordinates[node_id];
// delete gadget.pr
ops
.preference_container.coordinates[node_id];
// $.each(gadget.pr
ivate
.edge_container, function (k, v) {
// $.each(gadget.pr
ops
.edge_container, function (k, v) {
// if (node_id === v[0] || node_id === v[1]) {
// if (node_id === v[0] || node_id === v[1]) {
// delete gadget.pr
ivate
.edge_container[k];
// delete gadget.pr
ops
.edge_container[k];
// }
// }
// });
// });
// onDataChange();
// onDataChange();
// }
// }
function
updateElementData
(
gadget
,
node_id
,
data
)
{
function
updateElementData
(
gadget
,
node_id
,
data
)
{
var
element_id
=
gadget
.
pr
ivate
.
node_container
[
node_id
].
element_id
,
var
element_id
=
gadget
.
pr
ops
.
node_container
[
node_id
].
element_id
,
new_id
=
data
.
id
;
new_id
=
data
.
id
;
if
(
data
.
name
)
{
if
(
data
.
name
)
{
$
(
gadget
.
pr
ivate
.
element
).
find
(
"
#
"
+
element_id
).
text
(
data
.
name
)
$
(
gadget
.
pr
ops
.
element
).
find
(
"
#
"
+
element_id
).
text
(
data
.
name
)
.
append
(
'
<div class="ep"></div></div>
'
);
.
append
(
'
<div class="ep"></div></div>
'
);
gadget
.
pr
ivate
.
node_container
[
node_id
].
name
=
data
.
name
;
gadget
.
pr
ops
.
node_container
[
node_id
].
name
=
data
.
name
;
}
}
delete
data
.
id
;
delete
data
.
id
;
$
.
extend
(
gadget
.
pr
ivate
.
node_container
[
node_id
],
data
.
data
);
$
.
extend
(
gadget
.
pr
ops
.
node_container
[
node_id
],
data
.
data
);
if
(
new_id
&&
new_id
!==
node_id
)
{
if
(
new_id
&&
new_id
!==
node_id
)
{
gadget
.
pr
ivate
.
node_container
[
new_id
]
gadget
.
pr
ops
.
node_container
[
new_id
]
=
gadget
.
pr
ivate
.
node_container
[
node_id
];
=
gadget
.
pr
ops
.
node_container
[
node_id
];
delete
gadget
.
pr
ivate
.
node_container
[
node_id
];
delete
gadget
.
pr
ops
.
node_container
[
node_id
];
$
.
each
(
gadget
.
pr
ivate
.
edge_container
,
function
(
k
,
v
)
{
$
.
each
(
gadget
.
pr
ops
.
edge_container
,
function
(
k
,
v
)
{
if
(
v
[
0
]
===
node_id
)
{
if
(
v
[
0
]
===
node_id
)
{
v
[
0
]
=
new_id
;
v
[
0
]
=
new_id
;
}
}
...
@@ -360,25 +360,25 @@
...
@@ -360,25 +360,25 @@
v
[
1
]
=
new_id
;
v
[
1
]
=
new_id
;
}
}
});
});
gadget
.
pr
ivate
.
preference_container
.
coordinates
[
new_id
]
gadget
.
pr
ops
.
preference_container
.
coordinates
[
new_id
]
=
gadget
.
pr
ivate
.
preference_container
.
coordinates
[
node_id
];
=
gadget
.
pr
ops
.
preference_container
.
coordinates
[
node_id
];
delete
gadget
.
pr
ivate
.
preference_container
.
coordinates
[
node_id
];
delete
gadget
.
pr
ops
.
preference_container
.
coordinates
[
node_id
];
}
}
onDataChange
();
onDataChange
();
}
}
// function clearAll(gadget) {
// function clearAll(gadget) {
// $.each(gadget.pr
ivate
.node_container, function (node_id) {
// $.each(gadget.pr
ops
.node_container, function (node_id) {
// removeElement(gadget, node_id);
// removeElement(gadget, node_id);
// });
// });
// // delete anything if still remains
// // delete anything if still remains
// $(gadget.pr
ivate
.element).find("#main").children().remove();
// $(gadget.pr
ops
.element).find("#main").children().remove();
// gadget.pr
ivate
.node_container = {};
// gadget.pr
ops
.node_container = {};
// gadget.pr
ivate
.edge_container = {};
// gadget.pr
ops
.edge_container = {};
// gadget.pr
ivate
.preference_container = {};
// gadget.pr
ops
.preference_container = {};
// gadget.pr
ivate
.general_container = {};
// gadget.pr
ops
.general_container = {};
// gadget.pr
ivate
.initGeneralProperties();
// gadget.pr
ops
.initGeneralProperties();
// gadget.pr
ivate
.prepareDialogForGeneralProperties();
// gadget.pr
ops
.prepareDialogForGeneralProperties();
// }
// }
function
addEdge
(
gadget
,
edge_id
,
edge_data
)
{
function
addEdge
(
gadget
,
edge_id
,
edge_data
)
{
...
@@ -393,37 +393,37 @@
...
@@ -393,37 +393,37 @@
label
:
data
.
title
label
:
data
.
title
}]];
}]];
}
}
connection
=
gadget
.
pr
ivate
.
jsplumb_instance
.
connect
({
connection
=
gadget
.
pr
ops
.
jsplumb_instance
.
connect
({
source
:
getElementId
(
gadget
.
pr
ivate
.
node_container
,
source_id
),
source
:
getElementId
(
gadget
.
pr
ops
.
node_container
,
source_id
),
target
:
getElementId
(
gadget
.
pr
ivate
.
node_container
,
target_id
),
target
:
getElementId
(
gadget
.
pr
ops
.
node_container
,
target_id
),
Connector
:
[
"
Bezier
"
,
{
curviness
:
75
}
],
Connector
:
[
"
Bezier
"
,
{
curviness
:
75
}
],
overlays
:
overlays
overlays
:
overlays
});
});
// call again updateConnectionData to set the connection data that
// call again updateConnectionData to set the connection data that
// was not passed to the connection hook
// was not passed to the connection hook
gadget
.
pr
ivate
.
updateConnectionData
(
connection
,
0
,
data
);
gadget
.
pr
ops
.
updateConnectionData
(
connection
,
0
,
data
);
}
}
// function setPreferences(gadget, preferences) {
// function setPreferences(gadget, preferences) {
// gadget.pr
ivate
.preference_container = preferences;
// gadget.pr
ops
.preference_container = preferences;
// var zoom_level = gadget.pr
ivate
.preference_container.zoom_level || 1.0;
// var zoom_level = gadget.pr
ops
.preference_container.zoom_level || 1.0;
// setZoom(gadget, zoom_level);
// setZoom(gadget, zoom_level);
// }
// }
// function setGeneralProperties(gadget, properties) {
// function setGeneralProperties(gadget, properties) {
// gadget.pr
ivate
.general_container = properties;
// gadget.pr
ops
.general_container = properties;
// onDataChange();
// onDataChange();
// }
// }
// function updateGeneralProperties(gadget, properties) {
// function updateGeneralProperties(gadget, properties) {
// $.extend(gadget.pr
ivate
.general_container, properties);
// $.extend(gadget.pr
ops
.general_container, properties);
// onDataChange();
// onDataChange();
// }
// }
function
newElement
(
gadget
,
element
,
option
)
{
function
newElement
(
gadget
,
element
,
option
)
{
element
.
name
=
element
.
name
||
option
.
name
;
element
.
name
=
element
.
name
||
option
.
name
;
addElementToContainer
(
gadget
.
pr
ivate
.
node_container
,
element
);
addElementToContainer
(
gadget
.
pr
ops
.
node_container
,
element
);
var
render_element
=
$
(
gadget
.
pr
ivate
.
element
).
find
(
"
#main
"
),
var
render_element
=
$
(
gadget
.
pr
ops
.
element
).
find
(
"
#main
"
),
coordinate
=
element
.
coordinate
,
coordinate
=
element
.
coordinate
,
box
,
box
,
absolute_position
;
absolute_position
;
...
@@ -441,7 +441,7 @@
...
@@ -441,7 +441,7 @@
"
title
"
:
element
.
name
||
element
.
id
,
"
title
"
:
element
.
name
||
element
.
id
,
"
id
"
:
element
.
id
"
id
"
:
element
.
id
}));
}));
box
=
$
(
gadget
.
pr
ivate
.
element
).
find
(
"
#
"
+
element
.
element_id
);
box
=
$
(
gadget
.
pr
ops
.
element
).
find
(
"
#
"
+
element
.
element_id
);
absolute_position
=
convertToAbsolutePosition
(
absolute_position
=
convertToAbsolutePosition
(
gadget
,
gadget
,
coordinate
.
left
,
coordinate
.
left
,
...
@@ -456,37 +456,39 @@
...
@@ -456,37 +456,39 @@
gadget_klass
gadget_klass
.
ready
(
function
(
g
)
{
.
ready
(
function
(
g
)
{
g
.
private
=
{
g
.
props
.
node_container
=
{};
node_container
:
{},
g
.
props
.
edge_container
=
{};
edge_container
:
{},
g
.
props
.
preference_container
=
{};
preference_container
:
{},
g
.
props
.
style_attr_list
=
[
style_attr_list
:
[
'
width
'
,
'
height
'
,
'
padding-top
'
,
'
line-height
'
]
'
width
'
,
};
'
height
'
,
'
padding-top
'
,
'
line-height
'
];
})
})
.
declareMethod
(
'
render
'
,
function
(
data
)
{
.
declareMethod
(
'
render
'
,
function
(
data
)
{
this
.
pr
ivate
.
data
=
JSON
.
parse
(
data
);
this
.
pr
ops
.
data
=
JSON
.
parse
(
data
);
this
.
pr
ivate
.
jsplumb_instance
=
jsPlumb
.
getInstance
();
this
.
pr
ops
.
jsplumb_instance
=
jsPlumb
.
getInstance
();
})
})
.
declareMethod
(
'
getData
'
,
function
()
{
.
declareMethod
(
'
getData
'
,
function
()
{
return
JSON
.
stringify
({
return
JSON
.
stringify
({
"
nodes
"
:
this
.
pr
ivate
.
node_container
,
"
nodes
"
:
this
.
pr
ops
.
node_container
,
"
edges
"
:
this
.
pr
ivate
.
edge_container
,
"
edges
"
:
this
.
pr
ops
.
edge_container
,
"
preference
"
:
this
.
pr
ivate
.
preference_container
"
preference
"
:
this
.
pr
ops
.
preference_container
});
});
})
})
.
declareMethod
(
'
startService
'
,
function
()
{
.
declareMethod
(
'
startService
'
,
function
()
{
var
g
adget
=
this
,
var
g
=
this
,
preference
=
g
adget
.
private
.
data
.
preference
!==
undefined
?
preference
=
g
.
props
.
data
.
preference
!==
undefined
?
g
adget
.
private
.
data
.
preference
:
{},
g
.
props
.
data
.
preference
:
{},
coordinates
=
preference
.
coordinates
;
coordinates
=
preference
.
coordinates
;
return
gadget
.
getElement
()
.
then
(
function
(
el
)
{
g
.
props
.
main
=
g
.
props
.
element
.
querySelector
(
'
#main
'
);
gadget
.
private
.
element
=
el
;
initJsPlumb
(
g
);
initJsPlumb
(
gadget
);
$
.
each
(
g
.
props
.
data
.
nodes
,
function
(
key
,
value
)
{
$
.
each
(
gadget
.
private
.
data
.
nodes
,
function
(
key
,
value
)
{
if
(
coordinates
===
undefined
||
coordinates
[
key
]
===
undefined
)
{
if
(
coordinates
===
undefined
||
coordinates
[
key
]
===
undefined
)
{
value
.
coordinate
=
{
value
.
coordinate
=
{
'
top
'
:
0.0
,
'
top
'
:
0.0
,
...
@@ -496,17 +498,10 @@
...
@@ -496,17 +498,10 @@
value
.
coordinate
=
coordinates
[
key
];
value
.
coordinate
=
coordinates
[
key
];
}
}
value
.
id
=
key
;
value
.
id
=
key
;
newElement
(
gadget
,
value
);
newElement
(
g
,
value
);
if
(
value
.
data
)
{
// backward compatibility
if
(
value
.
data
)
{
// backward compatibility
updateElementData
(
gadget
,
key
,
{
updateElementData
(
g
,
key
,
{
data
:
value
.
data
data
:
value
.
data
});
});
}
});
$
.
each
(
gadget
.
private
.
data
.
edges
,
function
(
key
,
value
)
{
addEdge
(
gadget
,
key
,
value
);
});
redraw
(
gadget
);
});
});
});
}(
RSVP
,
rJS
,
$
,
jsPlumb
,
Handlebars
));
}(
RSVP
,
rJS
,
$
,
jsPlumb
,
Handlebars
,
DOMParser
,
initGadgetMixin
));
dream/platform/src2/toolbox/index.html
View file @
613ea05a
...
@@ -19,6 +19,7 @@
...
@@ -19,6 +19,7 @@
<
/div
>
<
/div
>
</script>
</script>
<script
src=
"../dream/mixin_gadget.js"
></script>
<script
src=
"toolbox.js"
></script>
<script
src=
"toolbox.js"
></script>
</head>
</head>
<body>
<body>
...
...
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