Commit 2e471357 authored by Thibaut Frain's avatar Thibaut Frain Committed by Jérome Perrin

publish static version

parent e1a131c1
...@@ -25,13 +25,12 @@ ...@@ -25,13 +25,12 @@
toolbox_gadget.render(); toolbox_gadget.render();
}); });
}).declareMethod("startService", function() { }).declareMethod("startService", function() {
var g = this; var g = this, graph;
return g.getDeclaredGadget("productionline_graph").push(function(graph) { return g.getDeclaredGadget("productionline_graph").push(function(graph_gadget) {
return graph.startService(); graph = graph_gadget;
}).push(function() {
return g.getDeclaredGadget("productionline_toolbox"); return g.getDeclaredGadget("productionline_toolbox");
}).push(function(toolbox) { }).push(function(toolbox) {
return toolbox.startService(); return RSVP.all([ graph.startService(), toolbox.startService() ]);
}); });
}); });
})(window, rJS, RSVP); })(window, rJS, RSVP);
\ No newline at end of file
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/*jslint unparam: true */ /*jslint unparam: true */
(function(window, RSVP, FileReader) { (function(window, RSVP, FileReader) {
"use strict"; "use strict";
window.loopEventListener = function(target, type, useCapture, callback) { window.loopEventListener = function(target, type, useCapture, callback, allowDefault) {
////////////////////////// //////////////////////////
// Infinite event listener (promise is never resolved) // Infinite event listener (promise is never resolved)
// eventListener is removed when promise is cancelled/rejected // eventListener is removed when promise is cancelled/rejected
...@@ -22,7 +22,9 @@ ...@@ -22,7 +22,9 @@
function itsANonResolvableTrap(resolve, reject) { function itsANonResolvableTrap(resolve, reject) {
handle_event_callback = function(evt) { handle_event_callback = function(evt) {
evt.stopPropagation(); evt.stopPropagation();
evt.preventDefault(); if (allowDefault !== true) {
evt.preventDefault();
}
cancelResolver(); cancelResolver();
callback_promise = new RSVP.Queue().push(function() { callback_promise = new RSVP.Queue().push(function() {
return callback(evt); return callback(evt);
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
<script src="../lib/renderjs.min.js"></script> <script src="../lib/renderjs.min.js"></script>
<script src="../lib/jquery.jsplumb.min.js"></script> <script src="../lib/jquery.jsplumb.min.js"></script>
<script src="../lib/handlebars.min.js"></script> <script src="../lib/handlebars.min.js"></script>
<script id="node-template" type="text/x-handlebars-template"> <script id="node-template" type="text/x-handlebars-template">
<div class="window {{class}}" <div class="window {{class}}"
id="{{element_id}}" id="{{element_id}}"
...@@ -20,7 +20,10 @@ ...@@ -20,7 +20,10 @@
<div class="ep"></div> <div class="ep"></div>
</div> </div>
</script> </script>
<script src="../dream/mixin_gadget.js"></script>
<script src="../dream/mixin_promise.js"></script>
<script src="jsplumb.js"></script> <script src="jsplumb.js"></script>
</head> </head>
<body> <body>
......
This diff is collapsed.
...@@ -13,12 +13,16 @@ ...@@ -13,12 +13,16 @@
<script id="tool-template" type="text/x-handlebars-template"> <script id="tool-template" type="text/x-handlebars-template">
<div id="{{key}}" <div id="{{key}}"
class="tool {{key}}"> class="tool {{key}}"
draggable="true">
{{name}} {{name}}
<ul/> <ul/>
</div> </div>
</script> </script>
<script src="../dream/mixin_gadget.js"></script>
<script src="../dream/mixin_promise.js"></script>
<script src="toolbox.js"></script> <script src="toolbox.js"></script>
</head> </head>
<body> <body>
......
.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%)} .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 \ No newline at end of file
/*global window, document, RSVP, rJS, Handlebars*/ /*global window, document, RSVP, rJS, Handlebars, initGadgetMixin*/
(function(window, document, RSVP, rJS, Handlebars) { (function(window, document, RSVP, rJS, Handlebars, initGadgetMixin) {
"use strict"; "use strict";
/*jslint nomen: true*/ /*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); 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() { gadget_klass.declareAcquiredMethod("getConfigurationDict", "getConfigurationDict").declareMethod("render", function() {
var g = this; var g = this;
return new RSVP.Queue().push(function() { return g.getConfigurationDict().push(function(config_dict) {
return g.getConfigurationDict(); var tools_container = document.createElement("div");
}).push(function(config) { tools_container.className = "tools-container";
g.tools_container = document.createElement("div"); Object.keys(config_dict).forEach(function(key) {
g.tools_container.className = "tools-container"; var name = config_dict[key].name || key.split("-")[1];
Object.keys(config).forEach(function(key) {
var name = config[key].name || key.split("-")[1];
if (key !== "Dream-Configuration") { if (key !== "Dream-Configuration") {
g.tools_container.innerHTML += tool_template({ tools_container.innerHTML += tool_template({
key: key, key: key,
name: name name: name
}); });
} }
}); });
g.props.element.querySelector(".tools").appendChild(tools_container);
}); });
}).declareMethod("startService", function() { }).declareMethod("startService", function() {
var g = this; var promiseArray = [];
return g.getElement().then(function(element) { [].forEach.call(this.props.element.querySelectorAll(".tool"), function(tool) {
element.querySelector(".tools").appendChild(g.tools_container); promiseArray.push(waitForDragstart(tool));
}); });
return RSVP.all(promiseArray);
}); });
})(window, document, RSVP, rJS, Handlebars); })(window, document, RSVP, rJS, Handlebars, initGadgetMixin);
\ No newline at end of file \ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment