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
2e471357
Commit
2e471357
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
publish static version
parent
e1a131c1
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
200 additions
and
143 deletions
+200
-143
dream/platform/static/dream/Input_viewProductionLine.js
dream/platform/static/dream/Input_viewProductionLine.js
+4
-5
dream/platform/static/dream/mixin_promise.js
dream/platform/static/dream/mixin_promise.js
+4
-2
dream/platform/static/jsplumb/index.html
dream/platform/static/jsplumb/index.html
+5
-2
dream/platform/static/jsplumb/jsplumb.js
dream/platform/static/jsplumb/jsplumb.js
+154
-117
dream/platform/static/toolbox/index.html
dream/platform/static/toolbox/index.html
+6
-2
dream/platform/static/toolbox/toolbox.css
dream/platform/static/toolbox/toolbox.css
+1
-1
dream/platform/static/toolbox/toolbox.js
dream/platform/static/toolbox/toolbox.js
+26
-14
No files found.
dream/platform/static/dream/Input_viewProductionLine.js
View file @
2e471357
...
...
@@ -25,13 +25,12 @@
toolbox_gadget
.
render
();
});
}).
declareMethod
(
"
startService
"
,
function
()
{
var
g
=
this
;
return
g
.
getDeclaredGadget
(
"
productionline_graph
"
).
push
(
function
(
graph
)
{
return
graph
.
startService
();
}).
push
(
function
()
{
var
g
=
this
,
graph
;
return
g
.
getDeclaredGadget
(
"
productionline_graph
"
).
push
(
function
(
graph_gadget
)
{
graph
=
graph_gadget
;
return
g
.
getDeclaredGadget
(
"
productionline_toolbox
"
);
}).
push
(
function
(
toolbox
)
{
return
toolbox
.
startService
(
);
return
RSVP
.
all
([
graph
.
startService
(),
toolbox
.
startService
()
]
);
});
});
})(
window
,
rJS
,
RSVP
);
\ No newline at end of file
dream/platform/static/dream/mixin_promise.js
View file @
2e471357
...
...
@@ -2,7 +2,7 @@
/*jslint unparam: true */
(
function
(
window
,
RSVP
,
FileReader
)
{
"
use strict
"
;
window
.
loopEventListener
=
function
(
target
,
type
,
useCapture
,
callback
)
{
window
.
loopEventListener
=
function
(
target
,
type
,
useCapture
,
callback
,
allowDefault
)
{
//////////////////////////
// Infinite event listener (promise is never resolved)
// eventListener is removed when promise is cancelled/rejected
...
...
@@ -22,7 +22,9 @@
function
itsANonResolvableTrap
(
resolve
,
reject
)
{
handle_event_callback
=
function
(
evt
)
{
evt
.
stopPropagation
();
evt
.
preventDefault
();
if
(
allowDefault
!==
true
)
{
evt
.
preventDefault
();
}
cancelResolver
();
callback_promise
=
new
RSVP
.
Queue
().
push
(
function
()
{
return
callback
(
evt
);
...
...
dream/platform/static/jsplumb/index.html
View file @
2e471357
...
...
@@ -11,7 +11,7 @@
<script
src=
"../lib/renderjs.min.js"
></script>
<script
src=
"../lib/jquery.jsplumb.min.js"
></script>
<script
src=
"../lib/handlebars.min.js"
></script>
<script
id=
"node-template"
type=
"text/x-handlebars-template"
>
<
div
class
=
"
window {{class}}
"
id
=
"
{{element_id}}
"
...
...
@@ -20,7 +20,10 @@
<
div
class
=
"
ep
"
><
/div
>
<
/div
>
</script>
<script
src=
"../dream/mixin_gadget.js"
></script>
<script
src=
"../dream/mixin_promise.js"
></script>
<script
src=
"jsplumb.js"
></script>
</head>
<body>
...
...
dream/platform/static/jsplumb/jsplumb.js
View file @
2e471357
...
...
@@ -16,12 +16,13 @@
* You should have received a copy of the GNU Lesser General Public License
* along with DREAM. If not, see <http://www.gnu.org/licenses/>.
* ==========================================================================*/
/*global RSVP, rJS, $, jsPlumb, Handlebars*/
/*global RSVP, rJS, $, jsPlumb, Handlebars, initGadgetMixin,
loopEventListener, DOMParser*/
/*jslint unparam: true */
(
function
(
RSVP
,
rJS
,
$
,
jsPlumb
,
Handlebars
)
{
(
function
(
RSVP
,
rJS
,
$
,
jsPlumb
,
Handlebars
,
initGadgetMixin
,
loopEventListener
,
DOMParser
)
{
"
use strict
"
;
/*jslint nomen: true*/
var
gadget_klass
=
rJS
(
window
),
node_template_source
=
gadget_klass
.
__template_element
.
getElementById
(
"
node-template
"
).
innerHTML
,
node_template
=
Handlebars
.
compile
(
node_template_source
);
var
gadget_klass
=
rJS
(
window
),
node_template_source
=
gadget_klass
.
__template_element
.
getElementById
(
"
node-template
"
).
innerHTML
,
node_template
=
Handlebars
.
compile
(
node_template_source
)
,
domParser
=
new
DOMParser
()
;
function
getNodeId
(
node_container
,
element_id
)
{
var
node_id
;
$
.
each
(
node_container
,
function
(
k
,
v
)
{
...
...
@@ -44,42 +45,42 @@
// }
// return (option.short_id || element_type) + n;
// }
//
function generateElementId(gadget_element) {
//
var n = 1;
// while ($(gadget_element).find('#DreamNode_'
+ n).length > 0) {
//
n += 1;
//
}
// return 'DreamNode_'
+ n;
//
}
function
generateElementId
(
gadget_element
)
{
var
n
=
1
;
while
(
$
(
gadget_element
).
find
(
"
#DreamNode_
"
+
n
).
length
>
0
)
{
n
+=
1
;
}
return
"
DreamNode_
"
+
n
;
}
function
onDataChange
()
{
//$.publish("Dream.Gui.onDataChange", g.private.getData());
return
undefined
;
}
function
convertToAbsolutePosition
(
gadget
,
x
,
y
)
{
var
zoom_level
=
(
gadget
.
pr
ivate
.
preference_container
.
zoom_level
||
1
)
*
1.1111
,
canvas_size_x
=
$
(
gadget
.
private
.
element
).
find
(
"
#main
"
).
width
(),
canvas_size_y
=
$
(
gadget
.
private
.
element
).
find
(
"
#main
"
).
height
(),
size_x
=
$
(
gadget
.
private
.
element
).
find
(
"
.dummy_window
"
).
width
()
*
zoom_level
,
size_y
=
$
(
gadget
.
private
.
element
).
find
(
"
.dummy_window
"
).
height
()
*
zoom_level
,
top
=
Math
.
floor
(
y
*
(
canvas_size_y
-
size_y
))
+
"
px
"
,
left
=
Math
.
floor
(
x
*
(
canvas_size_x
-
size_x
))
+
"
px
"
;
var
zoom_level
=
(
gadget
.
pr
ops
.
preference_container
.
zoom_level
||
1
)
*
1.1111
,
canvas_size_x
=
$
(
gadget
.
props
.
element
).
find
(
"
#main
"
).
width
(),
canvas_size_y
=
$
(
gadget
.
props
.
element
).
find
(
"
#main
"
).
height
(),
size_x
=
$
(
gadget
.
props
.
element
).
find
(
"
.dummy_window
"
).
width
()
*
zoom_level
,
size_y
=
$
(
gadget
.
props
.
element
).
find
(
"
.dummy_window
"
).
height
()
*
zoom_level
,
top
=
Math
.
floor
(
y
*
(
canvas_size_y
-
size_y
))
+
"
px
"
,
left
=
Math
.
floor
(
x
*
(
canvas_size_x
-
size_x
))
+
"
px
"
;
return
[
left
,
top
];
}
function
convertToRelativePosition
(
gadget
,
x
,
y
)
{
var
zoom_level
=
(
gadget
.
pr
ivate
.
preference_container
.
zoom_level
||
1
)
*
1.1111
,
canvas_size_x
=
$
(
gadget
.
private
.
element
).
find
(
"
#main
"
).
width
(),
canvas_size_y
=
$
(
gadget
.
private
.
element
).
find
(
"
#main
"
).
height
(),
size_x
=
$
(
gadget
.
private
.
element
).
find
(
"
.dummy_window
"
).
width
()
*
zoom_level
,
size_y
=
$
(
gadget
.
private
.
element
).
find
(
"
.dummy_window
"
).
height
()
*
zoom_level
,
top
=
Math
.
max
(
Math
.
min
(
y
.
replace
(
"
px
"
,
""
)
/
(
canvas_size_y
-
size_y
),
1
),
0
),
left
=
Math
.
max
(
Math
.
min
(
x
.
replace
(
"
px
"
,
""
)
/
(
canvas_size_x
-
size_x
),
1
),
0
);
var
zoom_level
=
(
gadget
.
pr
ops
.
preference_container
.
zoom_level
||
1
)
*
1.1111
,
canvas_size_x
=
$
(
gadget
.
props
.
element
).
find
(
"
#main
"
).
width
(),
canvas_size_y
=
$
(
gadget
.
props
.
element
).
find
(
"
#main
"
).
height
(),
size_x
=
$
(
gadget
.
props
.
element
).
find
(
"
.dummy_window
"
).
width
()
*
zoom_level
,
size_y
=
$
(
gadget
.
props
.
element
).
find
(
"
.dummy_window
"
).
height
()
*
zoom_level
,
top
=
Math
.
max
(
Math
.
min
(
y
.
replace
(
"
px
"
,
""
)
/
(
canvas_size_y
-
size_y
),
1
),
0
),
left
=
Math
.
max
(
Math
.
min
(
x
.
replace
(
"
px
"
,
""
)
/
(
canvas_size_x
-
size_x
),
1
),
0
);
return
[
left
,
top
];
}
function
updateElementCoordinate
(
gadget
,
node_id
,
coordinate
)
{
var
element_id
=
gadget
.
pr
ivate
.
node_container
[
node_id
].
element_id
,
coordinates
=
gadget
.
private
.
preference_container
.
coordinates
||
{},
element
,
relative_position
;
var
element_id
=
gadget
.
pr
ops
.
node_container
[
node_id
].
element_id
,
coordinates
=
gadget
.
props
.
preference_container
.
coordinates
||
{},
element
,
relative_position
;
if
(
coordinate
===
undefined
)
{
coordinate
=
{};
element
=
$
(
gadget
.
pr
ivate
.
element
).
find
(
"
#
"
+
element_id
);
element
=
$
(
gadget
.
pr
ops
.
element
).
find
(
"
#
"
+
element_id
);
relative_position
=
convertToRelativePosition
(
gadget
,
element
.
css
(
"
left
"
),
element
.
css
(
"
top
"
));
coordinate
.
top
=
relative_position
[
1
];
coordinate
.
left
=
relative_position
[
0
];
}
coordinates
[
node_id
]
=
coordinate
;
gadget
.
pr
ivate
.
preference_container
.
coordinates
=
coordinates
;
gadget
.
pr
ops
.
preference_container
.
coordinates
=
coordinates
;
onDataChange
();
return
coordinate
;
}
function
draggable
(
gadget
)
{
var
jsplumb_instance
=
gadget
.
pr
ivate
.
jsplumb_instance
,
stop
=
function
(
element
)
{
updateElementCoordinate
(
gadget
,
getNodeId
(
gadget
.
pr
ivate
.
node_container
,
element
.
target
.
id
));
var
jsplumb_instance
=
gadget
.
pr
ops
.
jsplumb_instance
,
stop
=
function
(
element
)
{
updateElementCoordinate
(
gadget
,
getNodeId
(
gadget
.
pr
ops
.
node_container
,
element
.
target
.
id
));
};
jsplumb_instance
.
draggable
(
jsplumb_instance
.
getSelector
(
"
.window
"
),
{
containment
:
"
parent
"
,
...
...
@@ -107,7 +108,7 @@
});
}
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
.
importDefaults
({
HoverPaintStyle
:
{
...
...
@@ -142,11 +143,11 @@
// return undefined;
// });
// split in 2 methods ? one for events one for manip
gadget
.
pr
ivate
.
updateConnectionData
=
function
(
connection
,
remove
,
edge_data
)
{
gadget
.
pr
ops
.
updateConnectionData
=
function
(
connection
,
remove
,
edge_data
)
{
if
(
remove
)
{
delete
gadget
.
pr
ivate
.
edge_container
[
connection
.
id
];
delete
gadget
.
pr
ops
.
edge_container
[
connection
.
id
];
}
else
{
gadget
.
pr
ivate
.
edge_container
[
connection
.
id
]
=
[
getNodeId
(
gadget
.
private
.
node_container
,
connection
.
sourceId
),
getNodeId
(
gadget
.
private
.
node_container
,
connection
.
targetId
),
edge_data
||
{}
];
gadget
.
pr
ops
.
edge_container
[
connection
.
id
]
=
[
getNodeId
(
gadget
.
props
.
node_container
,
connection
.
sourceId
),
getNodeId
(
gadget
.
props
.
node_container
,
connection
.
targetId
),
edge_data
||
{}
];
}
onDataChange
();
};
...
...
@@ -154,19 +155,19 @@
// and update the list of connections on screen.
// jsplumb_instance
// .bind("connection", function (info, originalEvent) {
// gadget.pr
ivate
.updateConnectionData(info.connection);
// gadget.pr
ops
.updateConnectionData(info.connection);
// });
// jsplumb_instance
// .bind("connectionDetached", function (info, originalEvent) {
// gadget.pr
ivate
.updateConnectionData(info.connection, true);
// gadget.pr
ops
.updateConnectionData(info.connection, true);
// });
onDataChange
();
draggable
(
gadget
);
}
function
updateNodeStyle
(
gadget
,
element_id
)
{
var
zoom_level
=
(
gadget
.
pr
ivate
.
preference_container
.
zoom_level
||
1
)
*
1.1111
,
element
=
$
(
gadget
.
private
.
element
).
find
(
"
#
"
+
element_id
),
new_value
;
$
.
each
(
gadget
.
pr
ivate
.
style_attr_list
,
function
(
i
,
j
)
{
new_value
=
$
(
gadget
.
pr
ivate
.
element
).
find
(
"
.dummy_window
"
).
css
(
j
).
replace
(
"
px
"
,
""
)
*
zoom_level
+
"
px
"
;
var
zoom_level
=
(
gadget
.
pr
ops
.
preference_container
.
zoom_level
||
1
)
*
1.1111
,
element
=
$
(
gadget
.
props
.
element
).
find
(
"
#
"
+
element_id
),
new_value
;
$
.
each
(
gadget
.
pr
ops
.
style_attr_list
,
function
(
i
,
j
)
{
new_value
=
$
(
gadget
.
pr
ops
.
element
).
find
(
"
.dummy_window
"
).
css
(
j
).
replace
(
"
px
"
,
""
)
*
zoom_level
+
"
px
"
;
element
.
css
(
j
,
new_value
);
});
}
...
...
@@ -179,16 +180,24 @@
};
node_container
[
element
.
id
]
=
element_data
;
}
function
redraw
(
gadget
)
{
var
coordinates
=
gadget
.
private
.
preference_container
.
coordinates
||
{},
absolute_position
,
element
;
$
.
each
(
coordinates
,
function
(
node_id
,
v
)
{
absolute_position
=
convertToAbsolutePosition
(
gadget
,
v
.
left
,
v
.
top
);
element
=
$
(
gadget
.
private
.
element
).
find
(
"
#
"
+
getElementId
(
gadget
.
private
.
node_container
,
node_id
));
element
.
css
(
"
top
"
,
absolute_position
[
1
]);
element
.
css
(
"
left
"
,
absolute_position
[
0
]);
gadget
.
private
.
jsplumb_instance
.
repaint
(
element
);
});
}
// function redraw(gadget) {
// var coordinates = gadget.props.preference_container.coordinates || {},
// absolute_position,
// element;
// $.each(coordinates, function (node_id, v) {
// absolute_position = convertToAbsolutePosition(
// gadget,
// v.left,
// v.top
// );
// element = $(gadget.props.element).find(
// '#' + getElementId(gadget.props.node_container, node_id)
// );
// element.css('top', absolute_position[1]);
// element.css('left', absolute_position[0]);
// gadget.props.jsplumb_instance.repaint(element);
// });
// }
// function positionGraph(gadget) {
// $.ajax(
// '/positionGraph',
...
...
@@ -214,55 +223,55 @@
// );
// }
// function setZoom(gadget, zoom_level) {
// $.each(gadget.pr
ivate
.style_attr_list, function (i, j) {
// var new_value = $(gadget.pr
ivate
.element).find('.dummy_window')
// $.each(gadget.pr
ops
.style_attr_list, function (i, j) {
// var new_value = $(gadget.pr
ops
.element).find('.dummy_window')
// .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) {
// 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;
// setZoom(gadget, zoom_level);
// gadget.pr
ivate
.preference_container.zoom_level = zoom_level;
// gadget.pr
ops
.preference_container.zoom_level = zoom_level;
// onDataChange();
// redraw(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;
// setZoom(gadget, zoom_level);
// gadget.pr
ivate
.preference_container.zoom_level = zoom_level;
// gadget.pr
ops
.preference_container.zoom_level = zoom_level;
// onDataChange();
// redraw(gadget);
// }
// function removeElement(gadget, node_id) {
// var element_id = gadget.pr
ivate
.node_container[node_id].element_id;
// gadget.pr
ivate
.jsplumb_instance.removeAllEndpoints(
// $(gadget.pr
ivate
.element).find("#" + element_id)
// var element_id = gadget.pr
ops
.node_container[node_id].element_id;
// gadget.pr
ops
.jsplumb_instance.removeAllEndpoints(
// $(gadget.pr
ops
.element).find("#" + element_id)
// );
// $(gadget.pr
ivate
.element).find("#" + element_id).remove();
// delete gadget.pr
ivate
.node_container[node_id];
// delete gadget.pr
ivate
.preference_container.coordinates[node_id];
// $.each(gadget.pr
ivate
.edge_container, function (k, v) {
// $(gadget.pr
ops
.element).find("#" + element_id).remove();
// delete gadget.pr
ops
.node_container[node_id];
// delete gadget.pr
ops
.preference_container.coordinates[node_id];
// $.each(gadget.pr
ops
.edge_container, function (k, v) {
// if (node_id === v[0] || node_id === v[1]) {
// delete gadget.pr
ivate
.edge_container[k];
// delete gadget.pr
ops
.edge_container[k];
// }
// });
// onDataChange();
// }
function
updateElementData
(
gadget
,
node_id
,
data
)
{
var
element_id
=
gadget
.
pr
ivate
.
node_container
[
node_id
].
element_id
,
new_id
=
data
.
id
;
var
element_id
=
gadget
.
pr
ops
.
node_container
[
node_id
].
element_id
,
new_id
=
data
.
id
;
if
(
data
.
name
)
{
$
(
gadget
.
pr
ivate
.
element
).
find
(
"
#
"
+
element_id
).
text
(
data
.
name
).
append
(
'
<div class="ep"></div></div>
'
);
gadget
.
pr
ivate
.
node_container
[
node_id
].
name
=
data
.
name
;
$
(
gadget
.
pr
ops
.
element
).
find
(
"
#
"
+
element_id
).
text
(
data
.
name
).
append
(
'
<div class="ep"></div></div>
'
);
gadget
.
pr
ops
.
node_container
[
node_id
].
name
=
data
.
name
;
}
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
)
{
gadget
.
pr
ivate
.
node_container
[
new_id
]
=
gadget
.
private
.
node_container
[
node_id
];
delete
gadget
.
pr
ivate
.
node_container
[
node_id
];
$
.
each
(
gadget
.
pr
ivate
.
edge_container
,
function
(
k
,
v
)
{
gadget
.
pr
ops
.
node_container
[
new_id
]
=
gadget
.
props
.
node_container
[
node_id
];
delete
gadget
.
pr
ops
.
node_container
[
node_id
];
$
.
each
(
gadget
.
pr
ops
.
edge_container
,
function
(
k
,
v
)
{
if
(
v
[
0
]
===
node_id
)
{
v
[
0
]
=
new_id
;
}
...
...
@@ -270,23 +279,23 @@
v
[
1
]
=
new_id
;
}
});
gadget
.
pr
ivate
.
preference_container
.
coordinates
[
new_id
]
=
gadget
.
private
.
preference_container
.
coordinates
[
node_id
];
delete
gadget
.
pr
ivate
.
preference_container
.
coordinates
[
node_id
];
gadget
.
pr
ops
.
preference_container
.
coordinates
[
new_id
]
=
gadget
.
props
.
preference_container
.
coordinates
[
node_id
];
delete
gadget
.
pr
ops
.
preference_container
.
coordinates
[
node_id
];
}
onDataChange
();
}
// 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);
// });
// // delete anything if still remains
// $(gadget.pr
ivate
.element).find("#main").children().remove();
// gadget.pr
ivate
.node_container = {};
// gadget.pr
ivate
.edge_container = {};
// gadget.pr
ivate
.preference_container = {};
// gadget.pr
ivate
.general_container = {};
// gadget.pr
ivate
.initGeneralProperties();
// gadget.pr
ivate
.prepareDialogForGeneralProperties();
// $(gadget.pr
ops
.element).find("#main").children().remove();
// gadget.pr
ops
.node_container = {};
// gadget.pr
ops
.edge_container = {};
// gadget.pr
ops
.preference_container = {};
// gadget.pr
ops
.general_container = {};
// gadget.pr
ops
.initGeneralProperties();
// gadget.pr
ops
.prepareDialogForGeneralProperties();
// }
function
addEdge
(
gadget
,
edge_id
,
edge_data
)
{
var
source_id
=
edge_data
[
0
],
target_id
=
edge_data
[
1
],
data
=
edge_data
[
2
],
overlays
=
[],
connection
;
...
...
@@ -296,9 +305,9 @@
label
:
data
.
title
}
]
];
}
connection
=
gadget
.
pr
ivate
.
jsplumb_instance
.
connect
({
source
:
getElementId
(
gadget
.
pr
ivate
.
node_container
,
source_id
),
target
:
getElementId
(
gadget
.
pr
ivate
.
node_container
,
target_id
),
connection
=
gadget
.
pr
ops
.
jsplumb_instance
.
connect
({
source
:
getElementId
(
gadget
.
pr
ops
.
node_container
,
source_id
),
target
:
getElementId
(
gadget
.
pr
ops
.
node_container
,
target_id
),
Connector
:
[
"
Bezier
"
,
{
curviness
:
75
}
],
...
...
@@ -306,28 +315,31 @@
});
// call again updateConnectionData to set the connection data that
// 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) {
// gadget.pr
ivate
.preference_container = preferences;
// var zoom_level = gadget.pr
ivate
.preference_container.zoom_level || 1.0;
// gadget.pr
ops
.preference_container = preferences;
// var zoom_level = gadget.pr
ops
.preference_container.zoom_level || 1.0;
// setZoom(gadget, zoom_level);
// }
// function setGeneralProperties(gadget, properties) {
// gadget.pr
ivate
.general_container = properties;
// gadget.pr
ops
.general_container = properties;
// onDataChange();
// }
// function updateGeneralProperties(gadget, properties) {
// $.extend(gadget.pr
ivate
.general_container, properties);
// $.extend(gadget.pr
ops
.general_container, properties);
// onDataChange();
// }
function
newElement
(
gadget
,
element
,
option
)
{
element
.
name
=
element
.
name
||
option
.
name
;
addElementToContainer
(
gadget
.
pr
ivate
.
node_container
,
element
);
var
render_element
=
$
(
gadget
.
pr
ivate
.
element
).
find
(
"
#main
"
),
coordinate
=
element
.
coordinate
,
box
,
absolute_position
;
addElementToContainer
(
gadget
.
pr
ops
.
node_container
,
element
);
var
render_element
=
$
(
gadget
.
pr
ops
.
element
).
find
(
"
#main
"
),
coordinate
=
element
.
coordinate
,
box
,
absolute_position
;
if
(
coordinate
!==
undefined
)
{
coordinate
=
updateElementCoordinate
(
gadget
,
element
.
id
,
coordinate
);
}
if
(
element
.
element_id
===
undefined
)
{
element
.
element_id
=
generateElementId
(
gadget
.
props
.
element
);
}
/*jslint nomen: true*/
render_element
.
append
(
node_template
({
"
class
"
:
element
.
_class
.
replace
(
"
.
"
,
"
-
"
),
...
...
@@ -335,7 +347,7 @@
title
:
element
.
name
||
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
(
gadget
,
coordinate
.
left
,
coordinate
.
top
);
box
.
css
(
"
top
"
,
absolute_position
[
1
]);
box
.
css
(
"
left
"
,
absolute_position
[
0
]);
...
...
@@ -343,49 +355,74 @@
draggable
(
gadget
);
onDataChange
();
}
function
waitForDragover
(
gadget
)
{
return
loopEventListener
(
gadget
.
props
.
main
,
"
dragover
"
,
false
,
function
()
{
return
undefined
;
});
}
function
waitForDrop
(
gadget
)
{
var
target
=
gadget
.
props
.
element
.
querySelector
(
"
#main
"
),
callback
;
function
canceller
()
{
if
(
callback
!==
undefined
)
{
target
.
removeEventListener
(
"
drop
"
,
callback
,
false
);
}
}
function
nonResolvableTrap
(
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
]
},
_class
:
element_class
,
name
:
element_class
});
};
target
.
addEventListener
(
"
drop
"
,
callback
,
false
);
}
return
new
RSVP
.
Promise
(
nonResolvableTrap
,
canceller
);
}
initGadgetMixin
(
gadget_klass
);
gadget_klass
.
ready
(
function
(
g
)
{
g
.
private
=
{
node_container
:
{},
edge_container
:
{},
preference_container
:
{},
style_attr_list
:
[
"
width
"
,
"
height
"
,
"
padding-top
"
,
"
line-height
"
]
};
g
.
props
.
node_container
=
{};
g
.
props
.
edge_container
=
{};
g
.
props
.
preference_container
=
{};
g
.
props
.
style_attr_list
=
[
"
width
"
,
"
height
"
,
"
padding-top
"
,
"
line-height
"
];
}).
declareMethod
(
"
render
"
,
function
(
data
)
{
this
.
pr
ivate
.
data
=
JSON
.
parse
(
data
);
this
.
pr
ivate
.
jsplumb_instance
=
jsPlumb
.
getInstance
();
this
.
pr
ops
.
data
=
JSON
.
parse
(
data
);
this
.
pr
ops
.
jsplumb_instance
=
jsPlumb
.
getInstance
();
}).
declareMethod
(
"
getData
"
,
function
()
{
return
JSON
.
stringify
({
nodes
:
this
.
pr
ivate
.
node_container
,
edges
:
this
.
pr
ivate
.
edge_container
,
preference
:
this
.
pr
ivate
.
preference_container
nodes
:
this
.
pr
ops
.
node_container
,
edges
:
this
.
pr
ops
.
edge_container
,
preference
:
this
.
pr
ops
.
preference_container
});
}).
declareMethod
(
"
startService
"
,
function
()
{
var
gadget
=
this
,
preference
=
gadget
.
private
.
data
.
preference
!==
undefined
?
gadget
.
private
.
data
.
preference
:
{},
coordinates
=
preference
.
coordinates
;
return
gadget
.
getElement
().
then
(
function
(
el
)
{
gadget
.
private
.
element
=
el
;
initJsPlumb
(
gadget
);
$
.
each
(
gadget
.
private
.
data
.
nodes
,
function
(
key
,
value
)
{
if
(
coordinates
===
undefined
||
coordinates
[
key
]
===
undefined
)
{
value
.
coordinate
=
{
top
:
0
,
left
:
0
};
}
else
{
value
.
coordinate
=
coordinates
[
key
];
}
value
.
id
=
key
;
newElement
(
gadget
,
value
);
if
(
value
.
data
)
{
// backward compatibility
updateElementData
(
gadget
,
key
,
{
data
:
value
.
data
});
}
});
$
.
each
(
gadget
.
private
.
data
.
edges
,
function
(
key
,
value
)
{
addEdge
(
gadget
,
key
,
value
);
});
redraw
(
gadget
);
var
g
=
this
,
preference
=
g
.
props
.
data
.
preference
!==
undefined
?
g
.
props
.
data
.
preference
:
{},
coordinates
=
preference
.
coordinates
;
g
.
props
.
main
=
g
.
props
.
element
.
querySelector
(
"
#main
"
);
initJsPlumb
(
g
);
$
.
each
(
g
.
props
.
data
.
nodes
,
function
(
key
,
value
)
{
if
(
coordinates
===
undefined
||
coordinates
[
key
]
===
undefined
)
{
value
.
coordinate
=
{
top
:
0
,
left
:
0
};
}
else
{
value
.
coordinate
=
coordinates
[
key
];
}
value
.
id
=
key
;
newElement
(
g
,
value
);
if
(
value
.
data
)
{
// backward compatibility
updateElementData
(
g
,
key
,
{
data
:
value
.
data
});
}
});
$
.
each
(
g
.
props
.
data
.
edges
,
function
(
key
,
value
)
{
addEdge
(
g
,
key
,
value
);
});
return
RSVP
.
all
([
waitForDragover
(
g
),
waitForDrop
(
g
)
]);
});
})(
RSVP
,
rJS
,
$
,
jsPlumb
,
Handlebars
);
\ No newline at end of file
})(
RSVP
,
rJS
,
$
,
jsPlumb
,
Handlebars
,
initGadgetMixin
,
loopEventListener
,
DOMParser
);
\ No newline at end of file
dream/platform/static/toolbox/index.html
View file @
2e471357
...
...
@@ -13,12 +13,16 @@
<script
id=
"tool-template"
type=
"text/x-handlebars-template"
>
<
div
id
=
"
{{key}}
"
class
=
"
tool {{key}}
"
>
class
=
"
tool {{key}}
"
draggable
=
"
true
"
>
{{
name
}}
<
ul
/>
<
/div
>
</script>
<script
src=
"../dream/mixin_gadget.js"
></script>
<script
src=
"../dream/mixin_promise.js"
></script>
<script
src=
"toolbox.js"
></script>
</head>
<body>
...
...
dream/platform/static/toolbox/toolbox.css
View file @
2e471357
.tools
{
border
:
1px
solid
#999
;
margin
:
20px
0
;
border-radius
:
10px
;
padding-bottom
:
20px
}
.tools-container
{
margin-bottom
:
4px
}
.tools
.ui-button
{
margin
:
4px
0
}
.tool
{
border
:
1px
solid
#d3d3d3
;
box-shadow
:
1px
1px
2px
#aaa
;
min-width
:
7em
;
height
:
3em
;
z-index
:
10001
;
color
:
gray
;
font-family
:
serif
;
font-style
:
italic
;
font-size
:
.9em
;
margin
:
.8em
;
display
:
inline-block
;
border-radius
:
5px
;
text-align
:
center
;
padding-top
:
1.3em
}
.Dream-Source
,
.Dream-BatchSource
{
border
:
1px
solid
#bbc
;
background-color
:
#ffe
;
background-image
:
linear-gradient
(
to
bottom
,
#ffe
0
,
#dde
100%
)}
.Dream-Machine
,
.Dream-MachineJobShop
,
.Dream-BatchScrapMachine
,
.Dream-MachineManagedJob
,
.Dream-MouldAssembly
{
border
:
1px
solid
#cbc
;
background-color
:
#fef
;
background-image
:
linear-gradient
(
to
bottom
,
#fef
0
,
#ede
100%
)}
.Dream-Queue
,
.Dream-QueueJobShop
,
.Dream-LineClearance
,
.Dream-QueueManagedJob
,
.Dream-ConditionalBuffer
,
.Dream-OrderDecomposition
,
.Dream-MouldAssemblyBuffer
{
border
:
1px
solid
#bcc
;
background-color
:
#eff
;
background-image
:
linear-gradient
(
to
bottom
,
#eff
0
,
#dee
100%
)}
.Dream-Exit
,
.Dream-ExitJobShop
{
border
:
1px
solid
#ccb
;
background-color
:
#eef
;
background-image
:
linear-gradient
(
to
bottom
,
#eef
0
,
#dde
100%
)}
.Dream-EventGenerator
{
border
:
1px
solid
#cba
;
background-color
:
#fdc
;
background-image
:
linear-gradient
(
to
bottom
,
#fdc
0
,
#ecb
100%
)}
.Dream-BatchDecomposition
,
.Dream-BatchDecompositionStartTime
,
.Dream-BatchReassembly
{
border
:
1px
solid
#bcb
;
background-color
:
#dfd
;
background-image
:
linear-gradient
(
to
bottom
,
#dfd
0
,
#cec
100%
)}
.Dream-Repairman
{
border
:
1px
solid
#cbb
;
background-color
:
#fdd
;
background-image
:
linear-gradient
(
to
bottom
,
#fdd
0
,
#dcc
100%
)}
\ No newline at end of file
.tools
{
border
:
1px
solid
#999
;
margin
:
20px
0
;
border-radius
:
10px
;
padding-bottom
:
20px
}
.tools-container
{
margin-bottom
:
4px
}
.tools
.ui-button
{
margin
:
4px
0
}
.tool
{
border
:
1px
solid
#d3d3d3
;
box-shadow
:
1px
1px
2px
#aaa
;
min-width
:
7em
;
height
:
3em
;
z-index
:
10001
;
color
:
gray
;
font-family
:
serif
;
font-style
:
italic
;
font-size
:
.9em
;
margin
:
.8em
;
display
:
inline-block
;
border-radius
:
5px
;
text-align
:
center
;
padding-top
:
1.3em
;
cursor
:
move
}
.Dream-Source
,
.Dream-BatchSource
{
border
:
1px
solid
#bbc
;
background-color
:
#ffe
;
background-image
:
linear-gradient
(
to
bottom
,
#ffe
0
,
#dde
100%
)}
.Dream-Machine
,
.Dream-MachineJobShop
,
.Dream-BatchScrapMachine
,
.Dream-MachineManagedJob
,
.Dream-MouldAssembly
{
border
:
1px
solid
#cbc
;
background-color
:
#fef
;
background-image
:
linear-gradient
(
to
bottom
,
#fef
0
,
#ede
100%
)}
.Dream-Queue
,
.Dream-QueueJobShop
,
.Dream-LineClearance
,
.Dream-QueueManagedJob
,
.Dream-ConditionalBuffer
,
.Dream-OrderDecomposition
,
.Dream-MouldAssemblyBuffer
{
border
:
1px
solid
#bcc
;
background-color
:
#eff
;
background-image
:
linear-gradient
(
to
bottom
,
#eff
0
,
#dee
100%
)}
.Dream-Exit
,
.Dream-ExitJobShop
{
border
:
1px
solid
#ccb
;
background-color
:
#eef
;
background-image
:
linear-gradient
(
to
bottom
,
#eef
0
,
#dde
100%
)}
.Dream-EventGenerator
{
border
:
1px
solid
#cba
;
background-color
:
#fdc
;
background-image
:
linear-gradient
(
to
bottom
,
#fdc
0
,
#ecb
100%
)}
.Dream-BatchDecomposition
,
.Dream-BatchDecompositionStartTime
,
.Dream-BatchReassembly
{
border
:
1px
solid
#bcb
;
background-color
:
#dfd
;
background-image
:
linear-gradient
(
to
bottom
,
#dfd
0
,
#cec
100%
)}
.Dream-Repairman
{
border
:
1px
solid
#cbb
;
background-color
:
#fdd
;
background-image
:
linear-gradient
(
to
bottom
,
#fdd
0
,
#dcc
100%
)}
\ No newline at end of file
dream/platform/static/toolbox/toolbox.js
View file @
2e471357
/*global window, document, RSVP, rJS, Handlebars*/
(
function
(
window
,
document
,
RSVP
,
rJS
,
Handlebars
)
{
/*global window, document, RSVP, rJS, Handlebars
, initGadgetMixin
*/
(
function
(
window
,
document
,
RSVP
,
rJS
,
Handlebars
,
initGadgetMixin
)
{
"
use strict
"
;
/*jslint nomen: true*/
var
gadget_klass
=
rJS
(
window
),
tool_template_source
=
gadget_klass
.
__template_element
.
getElementById
(
"
tool-template
"
).
innerHTML
,
tool_template
=
Handlebars
.
compile
(
tool_template_source
);
function
waitForDragstart
(
tool
)
{
/*jslint unparam: true*/
var
callback
=
function
(
evt
)
{
evt
.
dataTransfer
.
setData
(
"
text/html
"
,
tool
.
outerHTML
);
};
return
new
RSVP
.
Promise
(
function
(
resolve
,
reject
)
{
tool
.
addEventListener
(
"
dragstart
"
,
callback
,
false
);
},
function
()
{
tool
.
removeEventListener
(
"
dragstart
"
,
callback
,
false
);
});
}
initGadgetMixin
(
gadget_klass
);
gadget_klass
.
declareAcquiredMethod
(
"
getConfigurationDict
"
,
"
getConfigurationDict
"
).
declareMethod
(
"
render
"
,
function
()
{
var
g
=
this
;
return
new
RSVP
.
Queue
().
push
(
function
()
{
return
g
.
getConfigurationDict
();
}).
push
(
function
(
config
)
{
g
.
tools_container
=
document
.
createElement
(
"
div
"
);
g
.
tools_container
.
className
=
"
tools-container
"
;
Object
.
keys
(
config
).
forEach
(
function
(
key
)
{
var
name
=
config
[
key
].
name
||
key
.
split
(
"
-
"
)[
1
];
return
g
.
getConfigurationDict
().
push
(
function
(
config_dict
)
{
var
tools_container
=
document
.
createElement
(
"
div
"
);
tools_container
.
className
=
"
tools-container
"
;
Object
.
keys
(
config_dict
).
forEach
(
function
(
key
)
{
var
name
=
config_dict
[
key
].
name
||
key
.
split
(
"
-
"
)[
1
];
if
(
key
!==
"
Dream-Configuration
"
)
{
g
.
tools_container
.
innerHTML
+=
tool_template
({
tools_container
.
innerHTML
+=
tool_template
({
key
:
key
,
name
:
name
});
}
});
g
.
props
.
element
.
querySelector
(
"
.tools
"
).
appendChild
(
tools_container
);
});
}).
declareMethod
(
"
startService
"
,
function
()
{
var
g
=
this
;
return
g
.
getElement
().
then
(
function
(
element
)
{
element
.
querySelector
(
"
.tools
"
).
appendChild
(
g
.
tools_container
);
var
promiseArray
=
[]
;
[].
forEach
.
call
(
this
.
props
.
element
.
querySelectorAll
(
"
.tool
"
),
function
(
tool
)
{
promiseArray
.
push
(
waitForDragstart
(
tool
)
);
});
return
RSVP
.
all
(
promiseArray
);
});
})(
window
,
document
,
RSVP
,
rJS
,
Handlebars
);
\ No newline at end of file
})(
window
,
document
,
RSVP
,
rJS
,
Handlebars
,
initGadgetMixin
);
\ No newline at end of file
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