From 86d229bd5b56835dc3d42ddd20b5c834fa5eb24b Mon Sep 17 00:00:00 2001 From: neyric Date: Mon, 13 Jul 2009 16:27:11 +0200 Subject: [PATCH] Adding InOutContainer --- css/WireIt.css | 16 +++++++- examples/WiringEditor/demo.js | 14 ++++++- examples/WiringEditor/index.html | 6 +++ index.html | 3 +- js/InOutContainer.js | 68 ++++++++++++++++++++++++++++++++ 5 files changed, 104 insertions(+), 3 deletions(-) create mode 100644 js/InOutContainer.js diff --git a/css/WireIt.css b/css/WireIt.css index e2b79cb4..b9d77212 100644 --- a/css/WireIt.css +++ b/css/WireIt.css @@ -80,7 +80,8 @@ div.WireIt-Container-ddhandle { font-size: 10pt; } div.WireIt-Container-ddhandle span { - margin-right: 32px; + /*margin-right: 32px;*/ + text-align:center; } img.WireIt-Container-icon { @@ -137,6 +138,19 @@ div.WireIt-ImageContainer div.WireIt-Container-closebutton { div.WireIt-ImageContainer:hover div.WireIt-Container-closebutton { display: block; } + +/** + * InOutContainer + */ + +div.WireIt-InOutContainer { + width: 150px; +} + +div.WireIt-InOutContainer div.body { + padding: 5px 10px; + font-size: 10pt; +} /** * Layers diff --git a/examples/WiringEditor/demo.js b/examples/WiringEditor/demo.js index 328b749c..04311836 100644 --- a/examples/WiringEditor/demo.js +++ b/examples/WiringEditor/demo.js @@ -109,7 +109,19 @@ var demoLanguage = { {"name": "FOLLOWUPS", "direction": [0,1], "offsetPosition": {"left": 100, "bottom": -15}} ] } - } + }, + + + { + "name": "InOut test", + "container": { + "xtype":"WireIt.InOutContainer", + "icon": "http://dev.tarpipe.com/img/tumblr.png", + "inputs": ["text1", "text2", "option1"], + "outputs": ["result", "error"] + } + } + ] }; \ No newline at end of file diff --git a/examples/WiringEditor/index.html b/examples/WiringEditor/index.html index 1c4dba1b..f5421037 100644 --- a/examples/WiringEditor/index.html +++ b/examples/WiringEditor/index.html @@ -21,6 +21,11 @@ div.WireIt-Container { width: 350px; /* Prevent the modules from scratching on the right */ } + +div.WireIt-InOutContainer { + width: 150px; +} + div.WireIt-InputExTerminal { float: left; width: 21px; @@ -92,6 +97,7 @@ + diff --git a/index.html b/index.html index 362c97e6..24b4b347 100644 --- a/index.html +++ b/index.html @@ -145,7 +145,8 @@

Clone from GitHub: git clone git://github.com/neyric/wireit.git

-

If you wish to support this project, Donate at PayPal !

+

If you wish to support this project, Donate at PayPal !
+ Donations will be used for WireIt development and promotion.

diff --git a/js/InOutContainer.js b/js/InOutContainer.js new file mode 100644 index 00000000..b34f750b --- /dev/null +++ b/js/InOutContainer.js @@ -0,0 +1,68 @@ +/** + * Container with left inputs and right outputs + * @class InOutContainer + * @extends WireIt.Container + * @constructor + * @param {Object} options + * @param {WireIt.Layer} layer + */ +WireIt.InOutContainer = function(options, layer) { + WireIt.InOutContainer.superclass.constructor.call(this, options, layer); +}; + +YAHOO.lang.extend(WireIt.InOutContainer, WireIt.Container, { + + /** + * @method setOptions + * @param {Object} options the options object + */ + setOptions: function(options) { + WireIt.InOutContainer.superclass.setOptions.call(this, options); + + this.options.xtype = "WireIt.InOutContainer"; + + this.options.className = options.className || "WireIt-Container WireIt-InOutContainer"; + + // Overwrite default value for options: + this.options.resizable = (typeof options.resizable == "undefined") ? false : options.resizable; + + this.options.inputs = options.inputs || []; + this.options.outputs = options.outputs || []; + + }, + + render: function() { + WireIt.InOutContainer.superclass.render.call(this); + + for(var i = 0 ; i < this.options.inputs.length ; i++) { + var input = this.options.inputs[i]; + this.options.terminals.push({ + "name": input, + "direction": [-1,0], + "offsetPosition": {"left": -14, "top": 3+30*(i+1) }, + "ddConfig": { + "type": "input", + "allowedTypes": ["output"] + }, + "alwaysSrc": true + }); + this.bodyEl.appendChild(WireIt.cn('div', null, {lineHeight: "30px"}, input)); + } + + for(i = 0 ; i < this.options.outputs.length ; i++) { + var output = this.options.outputs[i]; + this.options.terminals.push({ + "name": output, + "direction": [1,0], + "offsetPosition": {"right": -14, "top": 3+30*(i+1+this.options.inputs.length) }, + "ddConfig": { + "type": "output", + "allowedTypes": ["input"] + } + }); + this.bodyEl.appendChild(WireIt.cn('div', null, {lineHeight: "30px", textAlign: "right"}, output)); + } + + } + +}); \ No newline at end of file