Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Re-indent

  • Loading branch information...
commit 29a6f6931f0a7c76253bb0bf9dce5701d10fa824 1 parent a3c58b7
@neyric authored
Showing with 2,064 additions and 2,152 deletions.
  1. +2 −2 VERSION.txt
  2. +1 −1  sandbox/grouping/js/Group.js
  3. +1 −1  sandbox/grouping/js/Grouper.js
  4. +1 −1  sandbox/grouping/js/RubberBand.js
  5. +1 −1  sandbox/wireit-layout/wireit-layout.js
  6. +156 −144 src/arrow-wire/arrow-wire.js
  7. +90 −189 src/bezier-wire/bezier-wire.js
  8. +168 −169 src/bidirectional-arrow-wire/bidirectional-arrow-wire.js
  9. +177 −177 src/container-base/container-base.js
  10. +16 −16 src/container/container.js
  11. +113 −113 src/form-container/form-container.js
  12. +73 −73 src/image-container/image-container.js
  13. +78 −78 src/inout-container/inout-container.js
  14. +27 −27 src/inputex-wirable-fields/inputex-wirable-fields.js
  15. +25 −25 src/inputex-wirable/inputex-wirable.js
  16. +25 −25 src/layer/layer.js
  17. +118 −118 src/loader.js
  18. +58 −58 src/straight-wire/straight-wire.js
  19. +65 −65 src/terminal-base/terminal-base.js
  20. +42 −42 src/terminal-ddgroups/terminal-ddgroups.js
  21. +173 −173 src/terminal-dragedit/terminal-dragedit.js
  22. +16 −16 src/terminal-input/terminal-input.js
  23. +15 −15 src/terminal-output/terminal-output.js
  24. +30 −30 src/terminal-scissors/terminal-scissors.js
  25. +52 −52 src/textarea-container/textarea-container.js
  26. +24 −24 src/widget-icons/widget-icons.js
  27. +91 −91 src/wire-base/wire-base.js
  28. +322 −322 src/wireit-app/wireit-app.js
  29. +104 −104 src/wires-delegate/wires-delegate.js
View
4 VERSION.txt
@@ -2,9 +2,9 @@
To get the latest version, please visit http://neyric.github.com/wireit
---------------------------------------------------------------------------
-Version 3.0.0pr1
+Version 3.0.0pr2
Changeset:
- * Complete rewrite of WireIt using YUI 3.5.1
+ * Complete rewrite of WireIt using YUI 3.6.0
View
2  sandbox/grouping/js/Group.js
@@ -2,7 +2,7 @@
/**
* Handles a Group
- * @class Y.Group
+ * @class Group
*/
Y.Group = function(grouper, layer, serialisedGroup) {
View
2  sandbox/grouping/js/Grouper.js
@@ -1,7 +1,7 @@
(function() {
/**
- * @class Y.Grouper
+ * @class Grouper
*/
Y.Grouper = function (layer, baseConfigFunction) {
View
2  sandbox/grouping/js/RubberBand.js
@@ -2,7 +2,7 @@
/**
* A CanvasElement widget to hand-draw a selection
- * @class Y.RubberBand
+ * @class RubberBand
* @extends CanvasElement
*/
Y.RubberBand = function(grouper) {
View
2  sandbox/wireit-layout/wireit-layout.js
@@ -98,7 +98,7 @@ Y.Layout = {};
/**
* Spring Layout (TODO: use different eges k)
- * @class Y.Layout.Spring
+ * @class Layout.Spring
* @constructor
*/
Y.Layout.Spring = function(layer) {
View
300 src/arrow-wire/arrow-wire.js
@@ -3,158 +3,170 @@
*/
YUI.add('arrow-wire', function(Y) {
-
+/**
+ * Extend CanvasWire to draw an arrow wire
+ * @class ArrowWire
+ * @extends WireBase
+ * @constructor
+ * @param {Object} cfg the configuration for the ArrowWire attributes
+ */
Y.ArrowWire = function(cfg) {
- Y.ArrowWire.superclass.constructor.apply(this, arguments);
+ Y.ArrowWire.superclass.constructor.apply(this, arguments);
};
- Y.ArrowWire.NAME = "arrowwire";
- Y.extend(Y.ArrowWire, Y.WireBase, {
-
- /**
- * @method initializer
- */
- initializer: function() {
- Y.ArrowWire.superclass.initializer.apply(this, arguments);
- if(this.get('src') && this.get('src').get)
- this.set('srcDir', this.get('src').get('dir') );
- if(this.get('tgt') && this.get('tgt').get)
- this.set('tgtDir', this.get('src').get('dir') );
- },
-
- /**
- * @method bindUI
- */
- bindUI: function() {
- Y.ArrowWire.superclass.bindUI.call(this);
-
- //this.after("bezierTangentNormChange", this._afterChangeRedraw, this);
-
- this.on('srcChange', function(e) {
- this.set('srcDir', e.newVal.get('dir') );
- }, this);
-
- this.on('tgtChange', function(e) {
- this.set('tgtDir', e.newVal.get('dir') );
- }, this);
-
- },
- _draw: function() {
-
- var d = 7; // arrow width/2
- var redim = d+3; //we have to make the canvas a little bigger because of arrows
- var margin=[4+redim,4+redim];
-
- var src = this.get('src').getXY();
- var tgt = this.get('tgt').getXY();
-
- var distance=Math.sqrt(Math.pow(src[0]-tgt[0],2)+Math.pow(src[1]-tgt[1],2));
- this.moveTo((src[0]+6), (src[1]+6));
- this.lineTo((tgt[0]+6), (tgt[1]+6));
-
- console.log(this);
- /* start drawing arrows */
-
- var t1 = src;
- var t2 = tgt;
-
- var z = [0,0]; //point on the wire with constant distance (dlug) from terminal2
- var dlug = 20; //arrow length
- var t = (distance == 0) ? 0 : 1-(dlug/distance);
- z[0] = Math.abs( t1[0] + t*(t2[0]-t1[0]) );
- z[1] = Math.abs( t1[1] + t*(t2[1]-t1[1]) );
-
- //line which connects the terminals: y=ax+b
- var W = t1[0] - t2[0];
- var Wa = t1[1] - t2[1];
- var Wb = t1[0]*t2[1] - t1[1]*t2[0];
- if (W !== 0) {
- a = Wa/W;
- b = Wb/W;
- }
- else {
- a = 0;
- }
- //line perpendicular to the main line: y = aProst*x + b
- if (a == 0) {
- aProst = 0;
- }
- else {
- aProst = -1/a;
- }
- bProst = z[1] - aProst*z[0]; //point z lays on this line
- //we have to calculate coordinates of 2 points, which lay on perpendicular line and have the same distance (d) from point z
- var A = 1 + Math.pow(aProst,2);
- var B = 2*aProst*bProst - 2*z[0] - 2*z[1]*aProst;
- var C = -2*z[1]*bProst + Math.pow(z[0],2) + Math.pow(z[1],2) - Math.pow(d,2) + Math.pow(bProst,2);
- var delta = Math.pow(B,2) - 4*A*C;
- if (delta < 0) { return; }
-
- var x1 = (-B + Math.sqrt(delta)) / (2*A);
- var x2 = (-B - Math.sqrt(delta)) / (2*A);
- var y1 = aProst*x1 + bProst;
- var y2 = aProst*x2 + bProst;
-
- if(t1[1] == t2[1]) {
- var o = (t1[0] > t2[0]) ? 1 : -1;
- x1 = t2[0]+o*dlug;
- x2 = x1;
- y1 -= d;
- y2 += d;
- }
+Y.ArrowWire.NAME = "arrowwire";
- //triangle fill
- //this.fillStyle = this.options.color;
- //this.beginPath();
- /*this.moveTo(t2[0],t2[1]);
- this.lineTo(x1,y1);
- this.lineTo(x2,y2);*/
- //this.fill();
+Y.extend(Y.ArrowWire, Y.WireBase, {
+
+ /**
+ * @method initializer
+ */
+ initializer: function() {
+ Y.ArrowWire.superclass.initializer.apply(this, arguments);
+ if(this.get('src') && this.get('src').get)
+ this.set('srcDir', this.get('src').get('dir') );
+ if(this.get('tgt') && this.get('tgt').get)
+ this.set('tgtDir', this.get('src').get('dir') );
+ },
+
+ /**
+ * @method bindUI
+ */
+ bindUI: function() {
+ Y.ArrowWire.superclass.bindUI.call(this);
+
+ //this.after("bezierTangentNormChange", this._afterChangeRedraw, this);
+
+ this.on('srcChange', function(e) {
+ this.set('srcDir', e.newVal.get('dir') );
+ }, this);
+
+ this.on('tgtChange', function(e) {
+ this.set('tgtDir', e.newVal.get('dir') );
+ }, this);
+
+ },
+
+ /**
+ * @method _draw
+ * @private
+ */
+ _draw: function() {
+
+ var d = 7; // arrow width/2
+ var redim = d+3; //we have to make the canvas a little bigger because of arrows
+ var margin=[4+redim,4+redim];
+
+ var src = this.get('src').getXY();
+ var tgt = this.get('tgt').getXY();
+
+ var distance=Math.sqrt(Math.pow(src[0]-tgt[0],2)+Math.pow(src[1]-tgt[1],2));
+ this.moveTo((src[0]+6), (src[1]+6));
+ this.lineTo((tgt[0]+6), (tgt[1]+6));
+
+ // start drawing arrows
+ var t1 = src;
+ var t2 = tgt;
+
+ var z = [0,0]; //point on the wire with constant distance (dlug) from terminal2
+ var dlug = 20; //arrow length
+ var t = (distance === 0) ? 0 : 1-(dlug/distance);
+ z[0] = Math.abs( t1[0] + t*(t2[0]-t1[0]) );
+ z[1] = Math.abs( t1[1] + t*(t2[1]-t1[1]) );
+
+ //line which connects the terminals: y=ax+b
+ var W = t1[0] - t2[0];
+ var Wa = t1[1] - t2[1];
+ var Wb = t1[0]*t2[1] - t1[1]*t2[0];
+ if (W !== 0) {
+ a = Wa/W;
+ b = Wb/W;
+ }
+ else {
+ a = 0;
+ }
+ //line perpendicular to the main line: y = aProst*x + b
+ if (a === 0) {
+ aProst = 0;
+ }
+ else {
+ aProst = -1/a;
+ }
+ bProst = z[1] - aProst*z[0]; //point z lays on this line
+
+ //we have to calculate coordinates of 2 points, which lay on perpendicular line and have the same distance (d) from point z
+ var A = 1 + Math.pow(aProst,2);
+ var B = 2*aProst*bProst - 2*z[0] - 2*z[1]*aProst;
+ var C = -2*z[1]*bProst + Math.pow(z[0],2) + Math.pow(z[1],2) - Math.pow(d,2) + Math.pow(bProst,2);
+ var delta = Math.pow(B,2) - 4*A*C;
+ if (delta < 0) { return; }
+
+ var x1 = (-B + Math.sqrt(delta)) / (2*A);
+ var x2 = (-B - Math.sqrt(delta)) / (2*A);
+ var y1 = aProst*x1 + bProst;
+ var y2 = aProst*x2 + bProst;
+
+ if(t1[1] == t2[1]) {
+ var o = (t1[0] > t2[0]) ? 1 : -1;
+ x1 = t2[0]+o*dlug;
+ x2 = x1;
+ y1 -= d;
+ y2 += d;
+ }
-
- //triangle border
- //this.strokeStyle = this.options.bordercolor;
- //this.lineWidth = this.options.borderwidth;
- //this.beginPath();
- this.moveTo(t2[0]+6,t2[1]+6);
- this.lineTo(x1+6,y1+6);
- this.moveTo(t2[0]+6,t2[1]+6);
- this.lineTo(x2+6,y2+6);
- this.end();
- //this.lineTo(t2[0]+6,t2[1]+6);
- //this.stroke();
-
- }
-
-
+ //triangle fill
+ //this.fillStyle = this.options.color;
+ //this.beginPath();
+ /*this.moveTo(t2[0],t2[1]);
+ this.lineTo(x1,y1);
+ this.lineTo(x2,y2);*/
+ //this.fill();
+
+
+ //triangle border
+ //this.strokeStyle = this.options.bordercolor;
+ //this.lineWidth = this.options.borderwidth;
+ //this.beginPath();
+ this.moveTo(t2[0]+6,t2[1]+6);
+ this.lineTo(x1+6,y1+6);
+ this.moveTo(t2[0]+6,t2[1]+6);
+ this.lineTo(x2+6,y2+6);
+ this.end();
+ //this.lineTo(t2[0]+6,t2[1]+6);
+ //this.stroke();
+
+ }
+
});
Y.ArrowWire.ATTRS = Y.merge(Y.WireBase.ATTRS, {
- /**
- * TODO: normalize ?
- * @attribute srcDir
- * @type Array
- * @default [1,0]
- */
- srcDir: {
- validator: Y.Lang.isArray,
- value: [1,0]
- },
-
- /**
- * TODO: normalize ?
- * @attribute tgtDir
- * @type Array
- * @default -srcDir
- */
- tgtDir: {
- validator: Y.Lang.isArray,
- valueFn: function() {
- var d = this.get('srcDir');
- return [-d[0],-d[1]];
- }
- }
+ /**
+ *
+ * @attribute srcDir
+ * @type Array
+ * @default [1,0]
+ */
+ srcDir: {
+ validator: Y.Lang.isArray,
+ value: [1,0]
+ // TODO: normalize ?
+ },
+
+ /**
+ * TODO: normalize ?
+ * @attribute tgtDir
+ * @type Array
+ * @default -srcDir
+ */
+ tgtDir: {
+ validator: Y.Lang.isArray,
+ valueFn: function() {
+ var d = this.get('srcDir');
+ return [-d[0],-d[1]];
+ }
+ // TODO: normalize ?
+ }
});
-}, '3.6.0', {requires: ['wire-base']});
+}, '3.6.0', {requires: ['wire-base']});
View
279 src/bezier-wire/bezier-wire.js
@@ -5,57 +5,62 @@ YUI.add('bezier-wire', function(Y) {
/**
- * Extend CanvasWire to draw a bezier curve using a canvas
+ * Extend WireBase to draw a bezier curve
* @class BezierWire
- * @extends CanvasWire
+ * @extends WireBase
* @constructor
* @param {Object} config the configuration for the BezierWire attributes
*/
-//Y.BezierWire = Y.Base.create("bezier-wire", Y.CanvasWire, [], {
+Y.BezierWire = function(cfg) {
+
+ Y.BezierWire.superclass.constructor.apply(this, arguments);
+ this.draw();
+};
-Y.BezierWire = function(cfg) {
- Y.BezierWire.superclass.constructor.apply(this, arguments);
+// TODO: use Base.create
+
+Y.BezierWire.NAME = "bezierwire";
+
+Y.extend(Y.BezierWire, Y.WireBase, {
+
+ /**
+ * @method initializer
+ */
+ initializer: function() {
+
+ Y.BezierWire.superclass.initializer.apply(this, arguments);
- this.draw();
- };
- Y.BezierWire.NAME = "arrow";
- Y.extend(Y.BezierWire, Y.WireBase, {
+ if(this.get('src') && this.get('src').get)
+ this.set('srcDir', this.get('src').get('dir') );
+ if(this.get('tgt') && this.get('tgt').get)
+ this.set('tgtDir', this.get('src').get('dir') );
+ },
-
- /**
- * @method initializer
- */
- initializer: function() {
-
- Y.BezierWire.superclass.initializer.apply(this, arguments);
-
- if(this.get('src') && this.get('src').get)
- this.set('srcDir', this.get('src').get('dir') );
- if(this.get('tgt') && this.get('tgt').get)
- this.set('tgtDir', this.get('src').get('dir') );
- },
-
- /**
- * @method bindUI
- */
- bindUI: function() {
- Y.BezierWire.superclass.bindUI.call(this);
-
- //this.after("bezierTangentNormChange", this._afterChangeRedraw, this);
-
- this.on('srcChange', function(e) {
- this.set('srcDir', e.newVal.get('dir') );
- }, this);
-
- this.on('tgtChange', function(e) {
- this.set('tgtDir', e.newVal.get('dir') );
- }, this);
-
- },
-
-
-
+ /**
+ * @method bindUI
+ */
+ bindUI: function() {
+ Y.BezierWire.superclass.bindUI.call(this);
+
+ //this.after("bezierTangentNormChange", this._afterChangeRedraw, this);
+
+ this.on('srcChange', function(e) {
+ this.set('srcDir', e.newVal.get('dir') );
+ }, this);
+
+ this.on('tgtChange', function(e) {
+ this.set('tgtDir', e.newVal.get('dir') );
+ }, this);
+
+ },
+
+
+ /**
+ * Draw the bezier curve.
+ * The canvas is made bigger to contain the curls
+ * @method draw
+ */
draw: function() {
this.clear();
@@ -82,156 +87,52 @@ Y.BezierWire = function(cfg) {
this.end();
},
-
- /**
- * Draw the bezier curve.
- * The canvas is made bigger to contain the curls
- * @method draw
- */
- /*draw: function() {
-
- if(!this.get('canvas')) {
- return;
- }
-
- var src = this.get('src'), tgt = this.get('tgt');
- if( !src || !tgt) {
- return;
- }
-
- // Get the positions of the terminals
- var p1 = src.getXY(),
- p2 = tgt.getXY();
-
- // Coefficient multiplicateur de direction
- // 100 par defaut, si distance(p1,p2) < 100, on passe en distance/2
- var coeffMulDirection = this.get('bezierTangentNorm');
-
- var distance=Math.sqrt(Math.pow(p1[0]-p2[0],2)+Math.pow(p1[1]-p2[1],2));
- if(distance < coeffMulDirection){
- coeffMulDirection = distance/2;
- }
-
- // Calcul des vecteurs directeurs d1 et d2 :
- var d1 = [this.get('srcDir')[0]*coeffMulDirection,
- this.get('srcDir')[1]*coeffMulDirection];
- var d2 = [this.get('tgtDir')[0]*coeffMulDirection,
- this.get('tgtDir')[1]*coeffMulDirection];
-
- var bezierPoints=[];
- bezierPoints[0] = p1;
- bezierPoints[1] = [p1[0]+d1[0],p1[1]+d1[1]];
- bezierPoints[2] = [p2[0]+d2[0],p2[1]+d2[1]];
- bezierPoints[3] = p2;
- var min = [p1[0],p1[1]];
- var max = [p1[0],p1[1]];
- for(var i=1 ; i<bezierPoints.length ; i++){
- var p = bezierPoints[i];
- if(p[0] < min[0]){
- min[0] = p[0];
- }
- if(p[1] < min[1]){
- min[1] = p[1];
- }
- if(p[0] > max[0]){
- max[0] = p[0];
- }
- if(p[1] > max[1]){
- max[1] = p[1];
- }
- }
-
- // New canvas size
- var margin = [10,10];
- min[0] = min[0]-margin[0];
- min[1] = min[1]-margin[1];
- max[0] = max[0]+margin[0];
- max[1] = max[1]+margin[1];
- var lw = Math.abs(max[0]-min[0]);
- var lh = Math.abs(max[1]-min[1]);
-
- // Store the min, max positions to display the label later
- // w.min = min;
- // w.max = max;
-
- //w.SetCanvasRegion(min[0],min[1],lw,lh);
-
- this.get('canvas').resize(lw,lh);
- this.set('xy', [ min[0] +15 ,min[1]+15 ]);
-
- var ctxt=this.get('canvas').getContext();
-
- // TODO: extract:
- // Server-side
-
- for(i = 0 ; i<bezierPoints.length ; i++){
- bezierPoints[i][0] = bezierPoints[i][0]-min[0];
- bezierPoints[i][1] = bezierPoints[i][1]-min[1];
- }
-
- // Draw the border
- ctxt.lineCap = this.get('cap');
- ctxt.strokeStyle = this.get('bordercolor');
- ctxt.lineWidth = this.get('linewidth')+this.get('borderwidth')*2;
- ctxt.beginPath();
- ctxt.moveTo(bezierPoints[0][0],bezierPoints[0][1]);
- ctxt.bezierCurveTo(bezierPoints[1][0],bezierPoints[1][1],bezierPoints[2][0],bezierPoints[2][1],bezierPoints[3][0],bezierPoints[3][1]);
- ctxt.stroke();
-
- // Draw the inner bezier curve
- ctxt.lineCap = this.get('cap');
- ctxt.strokeStyle = this.get('color');
- ctxt.lineWidth = this.get('linewidth');
- ctxt.beginPath();
- ctxt.moveTo(bezierPoints[0][0],bezierPoints[0][1]);
- ctxt.bezierCurveTo(bezierPoints[1][0],bezierPoints[1][1],bezierPoints[2][0],bezierPoints[2][1],bezierPoints[3][0],bezierPoints[3][1]);
- ctxt.stroke();
-
- },*/
-
- SERIALIZABLE_ATTRS: ["color","width","bezierTangentNorm"]
-
+
+
+
+ SERIALIZABLE_ATTRS: ["color","width","bezierTangentNorm"]
+
});
Y.BezierWire.ATTRS = Y.merge(Y.WireBase.ATTRS, {
//Y.BezierWire.ATTRS = {
-
- /**
- * Norm of the tangeant vector at the endpoints.
- * @attribute bezierTangentNorm
- * @default 100
- * @type Integer
- */
- bezierTangentNorm: {
- setter: function(val) {
- return parseInt(val, 10);
- },
- value: 200
- },
- /**
- * TODO: normalize ?
- * @attribute srcDir
- * @type Array
- * @default [1,0]
- */
- srcDir: {
- validator: Y.Lang.isArray,
- value: [1,0]
- },
-
- /**
- * TODO: normalize ?
- * @attribute tgtDir
- * @type Array
- * @default -srcDir
- */
- tgtDir: {
- validator: Y.Lang.isArray,
- valueFn: function() {
- var d = this.get('srcDir');
- return [-d[0],-d[1]];
- }
- }
+
+ /**
+ * Norm of the tangeant vector at the endpoints.
+ * @attribute bezierTangentNorm
+ * @default 100
+ * @type Integer
+ */
+ bezierTangentNorm: {
+ setter: function(val) {
+ return parseInt(val, 10);
+ },
+ value: 200
+ },
+ /**
+ * TODO: normalize ?
+ * @attribute srcDir
+ * @type Array
+ * @default [1,0]
+ */
+ srcDir: {
+ validator: Y.Lang.isArray,
+ value: [1,0]
+ },
+
+ /**
+ * TODO: normalize ?
+ * @attribute tgtDir
+ * @type Array
+ * @default -srcDir
+ */
+ tgtDir: {
+ validator: Y.Lang.isArray,
+ valueFn: function() {
+ var d = this.get('srcDir');
+ return [-d[0],-d[1]];
+ }
+ }
});
View
337 src/bidirectional-arrow-wire/bidirectional-arrow-wire.js
@@ -10,190 +10,189 @@ Y.BidirectionalArrowWire = function(cfg) {
Y.BidirectionalArrowWire.NAME = "bidirectionalarrowwire";
Y.extend(Y.BidirectionalArrowWire, Y.WireBase, {
- /**
- * @method initializer
- */
- initializer: function() {
- Y.BidirectionalArrowWire.superclass.initializer.apply(this, arguments);
- if(this.get('src') && this.get('src').get)
- this.set('srcDir', this.get('src').get('dir') );
- if(this.get('tgt') && this.get('tgt').get)
- this.set('tgtDir', this.get('src').get('dir') );
- },
-
- /**
- * @method bindUI
- */
- bindUI: function() {
- Y.BidirectionalArrowWire.superclass.bindUI.call(this);
-
- //this.after("bezierTangentNormChange", this._afterChangeRedraw, this);
-
- this.on('srcChange', function(e) {
- this.set('srcDir', e.newVal.get('dir') );
- }, this);
-
- this.on('tgtChange', function(e) {
- this.set('tgtDir', e.newVal.get('dir') );
- }, this);
-
- },
- _draw: function() {
-
- var d = 7; // arrow width/2
- var redim = d+3; //we have to make the canvas a little bigger because of arrows
- var margin=[4+redim,4+redim];
-
- var src = this.get('src').getXY();
+ /**
+ * @method initializer
+ */
+ initializer: function() {
+ Y.BidirectionalArrowWire.superclass.initializer.apply(this, arguments);
+ if(this.get('src') && this.get('src').get)
+ this.set('srcDir', this.get('src').get('dir') );
+ if(this.get('tgt') && this.get('tgt').get)
+ this.set('tgtDir', this.get('src').get('dir') );
+ },
+
+ /**
+ * @method bindUI
+ */
+ bindUI: function() {
+ Y.BidirectionalArrowWire.superclass.bindUI.call(this);
+
+ //this.after("bezierTangentNormChange", this._afterChangeRedraw, this);
+
+ this.on('srcChange', function(e) {
+ this.set('srcDir', e.newVal.get('dir') );
+ }, this);
+
+ this.on('tgtChange', function(e) {
+ this.set('tgtDir', e.newVal.get('dir') );
+ }, this);
+
+ },
+ _draw: function() {
+
+ var d = 7; // arrow width/2
+ var redim = d+3; //we have to make the canvas a little bigger because of arrows
+ var margin=[4+redim,4+redim];
+
+ var src = this.get('src').getXY();
var tgt = this.get('tgt').getXY();
-
- var distance=Math.sqrt(Math.pow(src[0]-tgt[0],2)+Math.pow(src[1]-tgt[1],2));
- this.moveTo((src[0]+6), (src[1]+6));
- this.lineTo((tgt[0]+6), (tgt[1]+6));
+
+ var distance=Math.sqrt(Math.pow(src[0]-tgt[0],2)+Math.pow(src[1]-tgt[1],2));
+ this.moveTo((src[0]+6), (src[1]+6));
+ this.lineTo((tgt[0]+6), (tgt[1]+6));
- console.log(this);
- /* start drawing arrows */
+ // start drawing arrows
- var t1 = src;
- var t2 = tgt;
+ var t1 = src;
+ var t2 = tgt;
- var z = [0,0]; //point on the wire with constant distance (dlug) from terminal2
- var dlug = 20; //arrow length
- var t = (distance == 0) ? 0 : 1-(dlug/distance);
- z[0] = Math.abs( t1[0] + t*(t2[0]-t1[0]) );
- z[1] = Math.abs( t1[1] + t*(t2[1]-t1[1]) );
+ var z = [0,0]; //point on the wire with constant distance (dlug) from terminal2
+ var dlug = 20; //arrow length
+ var t = (distance === 0) ? 0 : 1-(dlug/distance);
+ z[0] = Math.abs( t1[0] + t*(t2[0]-t1[0]) );
+ z[1] = Math.abs( t1[1] + t*(t2[1]-t1[1]) );
- //line which connects the terminals: y=ax+b
- var W = t1[0] - t2[0];
- var Wa = t1[1] - t2[1];
- var Wb = t1[0]*t2[1] - t1[1]*t2[0];
- if (W !== 0) {
- a = Wa/W;
- b = Wb/W;
- }
- else {
- a = 0;
- }
- //line perpendicular to the main line: y = aProst*x + b
- if (a == 0) {
- aProst = 0;
- }
- else {
- aProst = -1/a;
- }
- bProst = z[1] - aProst*z[0]; //point z lays on this line
+ //line which connects the terminals: y=ax+b
+ var W = t1[0] - t2[0];
+ var Wa = t1[1] - t2[1];
+ var Wb = t1[0]*t2[1] - t1[1]*t2[0];
+ if (W !== 0) {
+ a = Wa/W;
+ b = Wb/W;
+ }
+ else {
+ a = 0;
+ }
+ //line perpendicular to the main line: y = aProst*x + b
+ if (a === 0) {
+ aProst = 0;
+ }
+ else {
+ aProst = -1/a;
+ }
+ bProst = z[1] - aProst*z[0]; //point z lays on this line
- //we have to calculate coordinates of 2 points, which lay on perpendicular line and have the same distance (d) from point z
- var A = 1 + Math.pow(aProst,2);
- var B = 2*aProst*bProst - 2*z[0] - 2*z[1]*aProst;
- var C = -2*z[1]*bProst + Math.pow(z[0],2) + Math.pow(z[1],2) - Math.pow(d,2) + Math.pow(bProst,2);
- var delta = Math.pow(B,2) - 4*A*C;
- if (delta < 0) { return; }
-
- var x1 = (-B + Math.sqrt(delta)) / (2*A);
- var x2 = (-B - Math.sqrt(delta)) / (2*A);
- var y1 = aProst*x1 + bProst;
- var y2 = aProst*x2 + bProst;
-
- if(t1[1] == t2[1]) {
- var o = (t1[0] > t2[0]) ? 1 : -1;
- x1 = t2[0]+o*dlug;
- x2 = x1;
- y1 -= d;
- y2 += d;
- }
+ //we have to calculate coordinates of 2 points, which lay on perpendicular line and have the same distance (d) from point z
+ var A = 1 + Math.pow(aProst,2);
+ var B = 2*aProst*bProst - 2*z[0] - 2*z[1]*aProst;
+ var C = -2*z[1]*bProst + Math.pow(z[0],2) + Math.pow(z[1],2) - Math.pow(d,2) + Math.pow(bProst,2);
+ var delta = Math.pow(B,2) - 4*A*C;
+ if (delta < 0) { return; }
+
+ var x1 = (-B + Math.sqrt(delta)) / (2*A);
+ var x2 = (-B - Math.sqrt(delta)) / (2*A);
+ var y1 = aProst*x1 + bProst;
+ var y2 = aProst*x2 + bProst;
+
+ if(t1[1] == t2[1]) {
+ var o = (t1[0] > t2[0]) ? 1 : -1;
+ x1 = t2[0]+o*dlug;
+ x2 = x1;
+ y1 -= d;
+ y2 += d;
+ }
- this.moveTo(t2[0]+6,t2[1]+6);
- this.lineTo(x1+6,y1+6);
- this.moveTo(t2[0]+6,t2[1]+6);
- this.lineTo(x2+6,y2+6);
+ this.moveTo(t2[0]+6,t2[1]+6);
+ this.lineTo(x1+6,y1+6);
+ this.moveTo(t2[0]+6,t2[1]+6);
+ this.lineTo(x2+6,y2+6);
- var t1 = tgt;
- var t2 = src;
+ t1 = tgt;
+ t2 = src;
- var z = [0,0]; //point on the wire with constant distance (dlug) from terminal2
- var dlug = 20; //arrow length
- var t = (distance == 0) ? 0 : 1-(dlug/distance);
- z[0] = Math.abs( t1[0] + t*(t2[0]-t1[0]) );
- z[1] = Math.abs( t1[1] + t*(t2[1]-t1[1]) );
+ var z = [0,0]; //point on the wire with constant distance (dlug) from terminal2
+ var dlug = 20; //arrow length
+ var t = (distance == 0) ? 0 : 1-(dlug/distance);
+ z[0] = Math.abs( t1[0] + t*(t2[0]-t1[0]) );
+ z[1] = Math.abs( t1[1] + t*(t2[1]-t1[1]) );
- //line which connects the terminals: y=ax+b
- var W = t1[0] - t2[0];
- var Wa = t1[1] - t2[1];
- var Wb = t1[0]*t2[1] - t1[1]*t2[0];
- if (W !== 0) {
- a = Wa/W;
- b = Wb/W;
- }
- else {
- a = 0;
- }
- //line perpendicular to the main line: y = aProst*x + b
- if (a == 0) {
- aProst = 0;
- }
- else {
- aProst = -1/a;
- }
- bProst = z[1] - aProst*z[0]; //point z lays on this line
+ //line which connects the terminals: y=ax+b
+ var W = t1[0] - t2[0];
+ var Wa = t1[1] - t2[1];
+ var Wb = t1[0]*t2[1] - t1[1]*t2[0];
+ if (W !== 0) {
+ a = Wa/W;
+ b = Wb/W;
+ }
+ else {
+ a = 0;
+ }
+ //line perpendicular to the main line: y = aProst*x + b
+ if (a == 0) {
+ aProst = 0;
+ }
+ else {
+ aProst = -1/a;
+ }
+ bProst = z[1] - aProst*z[0]; //point z lays on this line
- //we have to calculate coordinates of 2 points, which lay on perpendicular line and have the same distance (d) from point z
- var A = 1 + Math.pow(aProst,2);
- var B = 2*aProst*bProst - 2*z[0] - 2*z[1]*aProst;
- var C = -2*z[1]*bProst + Math.pow(z[0],2) + Math.pow(z[1],2) - Math.pow(d,2) + Math.pow(bProst,2);
- var delta = Math.pow(B,2) - 4*A*C;
- if (delta < 0) { return; }
-
- var x1 = (-B + Math.sqrt(delta)) / (2*A);
- var x2 = (-B - Math.sqrt(delta)) / (2*A);
- var y1 = aProst*x1 + bProst;
- var y2 = aProst*x2 + bProst;
-
- if(t1[1] == t2[1]) {
- var o = (t1[0] > t2[0]) ? 1 : -1;
- x1 = t2[0]+o*dlug;
- x2 = x1;
- y1 -= d;
- y2 += d;
- }
+ //we have to calculate coordinates of 2 points, which lay on perpendicular line and have the same distance (d) from point z
+ var A = 1 + Math.pow(aProst,2);
+ var B = 2*aProst*bProst - 2*z[0] - 2*z[1]*aProst;
+ var C = -2*z[1]*bProst + Math.pow(z[0],2) + Math.pow(z[1],2) - Math.pow(d,2) + Math.pow(bProst,2);
+ var delta = Math.pow(B,2) - 4*A*C;
+ if (delta < 0) { return; }
+
+ var x1 = (-B + Math.sqrt(delta)) / (2*A);
+ var x2 = (-B - Math.sqrt(delta)) / (2*A);
+ var y1 = aProst*x1 + bProst;
+ var y2 = aProst*x2 + bProst;
+
+ if(t1[1] == t2[1]) {
+ var o = (t1[0] > t2[0]) ? 1 : -1;
+ x1 = t2[0]+o*dlug;
+ x2 = x1;
+ y1 -= d;
+ y2 += d;
+ }
- this.moveTo(t2[0]+6,t2[1]+6);
- this.lineTo(x1+6,y1+6);
- this.moveTo(t2[0]+6,t2[1]+6);
- this.lineTo(x2+6,y2+6);
-
- this.end();
-
- }
-
-
+ this.moveTo(t2[0]+6,t2[1]+6);
+ this.lineTo(x1+6,y1+6);
+ this.moveTo(t2[0]+6,t2[1]+6);
+ this.lineTo(x2+6,y2+6);
+
+ this.end();
+
+ }
+
+
});
Y.BidirectionalArrowWire.ATTRS = Y.merge(Y.WireBase.ATTRS, {
- /**
- * TODO: normalize ?
- * @attribute srcDir
- * @type Array
- * @default [1,0]
- */
- srcDir: {
- validator: Y.Lang.isArray,
- value: [1,0]
- },
-
- /**
- * TODO: normalize ?
- * @attribute tgtDir
- * @type Array
- * @default -srcDir
- */
- tgtDir: {
- validator: Y.Lang.isArray,
- valueFn: function() {
- var d = this.get('srcDir');
- return [-d[0],-d[1]];
- }
- }
+ /**
+ * TODO: normalize ?
+ * @attribute srcDir
+ * @type Array
+ * @default [1,0]
+ */
+ srcDir: {
+ validator: Y.Lang.isArray,
+ value: [1,0]
+ },
+
+ /**
+ * TODO: normalize ?
+ * @attribute tgtDir
+ * @type Array
+ * @default -srcDir
+ */
+ tgtDir: {
+ validator: Y.Lang.isArray,
+ valueFn: function() {
+ var d = this.get('srcDir');
+ return [-d[0],-d[1]];
+ }
+ }
});
View
354 src/container-base/container-base.js
@@ -15,190 +15,190 @@ YUI.add('container-base', function(Y) {
* @constructor
*/
var ContainerBase = Y.Base.create('container-base', Y.Overlay, [Y.WidgetParent, Y.WidgetChild, Y.WiresDelegate], {
-
- /**
- * @method renderUI
- */
- renderUI: function() {
-
- // make the overlay draggable
- this.drag = new Y.DD.Drag({
- node: this.get('boundingBox'),
- handles : [ this._findStdModSection(Y.WidgetStdMod.HEADER) ]
- });
-
- this.drag.on('drag:drag', function() {
- this.redrawAllWires();
- }, this);
-
- // Make the overlay resizable
- if(this.get('resizable')) {
- var contentBox = this.get('contentBox');
- var resize = new Y.Resize({
- node: contentBox,
- handles: 'br'
- });
- /*resize.plug(Y.Plugin.ResizeConstrained, {
- minWidth: 50,
- minHeight: 50,
- maxWidth: 300,
- maxHeight: 300
- //preserveRatio: true
- });*/
- // On resize, fillHeight, & align terminals & wires
- resize.on('resize:resize', function() {
- // TODO: fillHeight
- this._fillHeight();
- this.alignTerminals();
- this.redrawAllWires();
- }, this);
-
- this.resize = resize;
- }
-
- // TODO: this is awful ! But we need to wait for everything to render & position
- Y.later(200, this, function() {
- this.alignTerminals();
- });
-
- },
-
- /**
- * @method alignTerminals
- */
- alignTerminals: function() {
- var contentBox = this.get('contentBox');
- this.each(function(term) {
- if(term.get('align')) {
- term.align( term.get('alignNode') || contentBox, ['tl',term.get('align').points[1]]);
- }
- }, this);
- },
-
- /**
- * @method syncUI
- */
- syncUI: function() {
-
- // Align terminals
- var c = this;
- this.each(function(term) {
- if(term.get('align')) {
- term.align( c.get('contentBox') , ['tl',term.get('align').points[1]]);
- }
- });
-
- },
-
- SERIALIZABLE_ATTRS: ['x','y'],
-
- toJSON: function() {
- var o = {}, a = this;
- Y.Array.each(this.SERIALIZABLE_ATTRS, function(attr) {
- o[attr] = a.get(attr);
- });
-
- return o;
- },
-
- /**
- * Get a terminal by name
- * @method getTerminal
- */
- getTerminal: function(name) {
- return Y.Array.find(this._items, function(item) {
- if(item.get('name') == name) {
- return true;
- }
- });
- },
-
- destructor: function() {
+
+ /**
+ * @method renderUI
+ */
+ renderUI: function() {
+
+ // make the overlay draggable
+ this.drag = new Y.DD.Drag({
+ node: this.get('boundingBox'),
+ handles : [ this._findStdModSection(Y.WidgetStdMod.HEADER) ]
+ });
+
+ this.drag.on('drag:drag', function() {
+ this.redrawAllWires();
+ }, this);
+
+ // Make the overlay resizable
+ if(this.get('resizable')) {
+ var contentBox = this.get('contentBox');
+ var resize = new Y.Resize({
+ node: contentBox,
+ handles: 'br'
+ });
+ /*resize.plug(Y.Plugin.ResizeConstrained, {
+ minWidth: 50,
+ minHeight: 50,
+ maxWidth: 300,
+ maxHeight: 300
+ //preserveRatio: true
+ });*/
+ // On resize, fillHeight, & align terminals & wires
+ resize.on('resize:resize', function() {
+ // TODO: fillHeight
+ this._fillHeight();
+ this.alignTerminals();
+ this.redrawAllWires();
+ }, this);
+
+ this.resize = resize;
+ }
+
+ // TODO: this is awful ! But we need to wait for everything to render & position
+ Y.later(200, this, function() {
+ this.alignTerminals();
+ });
+
+ },
+
+ /**
+ * @method alignTerminals
+ */
+ alignTerminals: function() {
+ var contentBox = this.get('contentBox');
+ this.each(function(term) {
+ if(term.get('align')) {
+ term.align( term.get('alignNode') || contentBox, ['tl',term.get('align').points[1]]);
+ }
+ }, this);
+ },
+
+ /**
+ * @method syncUI
+ */
+ syncUI: function() {
+
+ // Align terminals
+ var c = this;
+ this.each(function(term) {
+ if(term.get('align')) {
+ term.align( c.get('contentBox') , ['tl',term.get('align').points[1]]);
+ }
+ });
+
+ },
+
+ SERIALIZABLE_ATTRS: ['x','y'],
+
+ toJSON: function() {
+ var o = {}, a = this;
+ Y.Array.each(this.SERIALIZABLE_ATTRS, function(attr) {
+ o[attr] = a.get(attr);
+ });
+
+ return o;
+ },
+
+ /**
+ * Get a terminal by name
+ * @method getTerminal
+ */
+ getTerminal: function(name) {
+ return Y.Array.find(this._items, function(item) {
+ if(item.get('name') == name) {
+ return true;
+ }
+ });
+ },
+
+ destructor: function() {
- this.drag.destroy();
-
- if(this.resize) {
- this.resize.destroy();
+ this.drag.destroy();
+
+ if(this.resize) {
+ this.resize.destroy();
}
- }
+ }
}, {
- ATTRS: {
-
- /**
- * @attribute defaultChildType
- */
- defaultChildType: {
- value: 'Terminal'
- },
-
- /**
- * @attribute zIndex
- */
- zIndex: {
- value: 5
- },
-
- /**
- * @attribute resizable
- */
- resizable: {
- value: true
- },
-
- /**
- * @attribute fillHeight
- */
- fillHeight: {
- value: true
- },
-
- x: {
- getter: function() {
- var left = this.get('boundingBox').getStyle('left');
- return parseInt(left.substr(0,left.length-2),10);
- }
- },
-
- y: {
- getter: function() {
- var top = this.get('boundingBox').getStyle('top');
- return parseInt(top.substr(0,top.length-2),10);
- }
- },
-
- preventSelfWiring: {
- value: true
- }
-
- },
-
- EIGHT_POINTS: [
- { align: {points:['tl', 'tl']}, dir: [-0.5, -0.5], name: 'tl' },
- { align: {points:['tl', 'tc']}, dir: [0, -1], name: 'tc' },
- { align: {points:['tl', 'tr']}, dir: [0.5, -0.5], name: 'tr' },
- { align: {points:['tl', 'lc']}, dir: [-1, 0], name: 'lc' },
- { align: {points:['tl', 'rc']}, dir: [1, 0], name: 'rc' },
- { align: {points:['tl', 'br']}, dir: [0.5, 0.5], name: 'br' },
- { align: {points:['tl', 'bc']}, dir: [0,1], name: 'bc' },
- { align: {points:['tl', 'bl']}, dir: [-0.5, 0.5], name: 'bl' }
- ],
+ ATTRS: {
+
+ /**
+ * @attribute defaultChildType
+ */
+ defaultChildType: {
+ value: 'Terminal'
+ },
+
+ /**
+ * @attribute zIndex
+ */
+ zIndex: {
+ value: 5
+ },
+
+ /**
+ * @attribute resizable
+ */
+ resizable: {
+ value: true
+ },
+
+ /**
+ * @attribute fillHeight
+ */
+ fillHeight: {
+ value: true
+ },
+
+ x: {
+ getter: function() {
+ var left = this.get('boundingBox').getStyle('left');
+ return parseInt(left.substr(0,left.length-2),10);
+ }
+ },
+
+ y: {
+ getter: function() {
+ var top = this.get('boundingBox').getStyle('top');
+ return parseInt(top.substr(0,top.length-2),10);
+ }
+ },
+
+ preventSelfWiring: {
+ value: true
+ }
+
+ },
+
+ EIGHT_POINTS: [
+ { align: {points:['tl', 'tl']}, dir: [-0.5, -0.5], name: 'tl' },
+ { align: {points:['tl', 'tc']}, dir: [0, -1], name: 'tc' },
+ { align: {points:['tl', 'tr']}, dir: [0.5, -0.5], name: 'tr' },
+ { align: {points:['tl', 'lc']}, dir: [-1, 0], name: 'lc' },
+ { align: {points:['tl', 'rc']}, dir: [1, 0], name: 'rc' },
+ { align: {points:['tl', 'br']}, dir: [0.5, 0.5], name: 'br' },
+ { align: {points:['tl', 'bc']}, dir: [0,1], name: 'bc' },
+ { align: {points:['tl', 'bl']}, dir: [-0.5, 0.5], name: 'bl' }
+ ],
- FOUR_CORNERS: [
- { align: {points:['tl', 'tl']}, dir: [-0.5, -0.5], name: 'tl' },
- { align: {points:['tl', 'tr']}, dir: [0.5, -0.5], name: 'tr' },
- { align: {points:['tl', 'br']}, dir: [0.5, 0.5], name: 'br' },
- { align: {points:['tl', 'bl']}, dir: [-0.5, 0.5], name: 'bl' }
- ],
+ FOUR_CORNERS: [
+ { align: {points:['tl', 'tl']}, dir: [-0.5, -0.5], name: 'tl' },
+ { align: {points:['tl', 'tr']}, dir: [0.5, -0.5], name: 'tr' },
+ { align: {points:['tl', 'br']}, dir: [0.5, 0.5], name: 'br' },
+ { align: {points:['tl', 'bl']}, dir: [-0.5, 0.5], name: 'bl' }
+ ],
- FOUR_EDGES: [
- { align: {points:['tl', 'tc']}, dir: [0, -1], name: 'tc' },
- { align: {points:['tl', 'lc']}, dir: [-1, 0], name: 'lc' },
- { align: {points:['tl', 'rc']}, dir: [1, 0], name: 'rc' },
- { align: {points:['tl', 'bc']}, dir: [0,1], name: 'bc' }
- ]
-
+ FOUR_EDGES: [
+ { align: {points:['tl', 'tc']}, dir: [0, -1], name: 'tc' },
+ { align: {points:['tl', 'lc']}, dir: [-1, 0], name: 'lc' },
+ { align: {points:['tl', 'rc']}, dir: [1, 0], name: 'rc' },
+ { align: {points:['tl', 'bc']}, dir: [0,1], name: 'bc' }
+ ]
+
});
Y.ContainerBase = ContainerBase;
View
32 src/container/container.js
@@ -12,23 +12,23 @@ YUI.add('container', function(Y) {
* @constructor
*/
Y.Container = Y.Base.create("container", Y.ContainerBase, [Y.WidgetIcons], {
-
- _onCloseClick: function() {
- this.destroy();
- }
-
+
+ _onCloseClick: function() {
+ this.destroy();
+ }
+
}, {
-
- ATTRS: {
-
- icons: {
- value: [
- {title: 'close', click: '_onCloseClick', className: 'ui-silk ui-silk-cancel'}
- ]
- }
-
- }
-
+
+ ATTRS: {
+
+ icons: {
+ value: [
+ {title: 'close', click: '_onCloseClick', className: 'ui-silk ui-silk-cancel'}
+ ]
+ }
+
+ }
+
});
}, '3.6.0', {requires: ['container-base', 'widget-icons']});
View
226 src/form-container/form-container.js
@@ -18,92 +18,92 @@ YUI.add('form-container', function(Y) {
* @param {Layer} layer The Y.Layer (or subclass) instance that contains this container
*/
Y.FormContainer = Y.Base.create("form-container", Y.Container, [], {
-
- /**
- * @method renderUI
- */
- renderUI: function() {
- Y.FormContainer.superclass.renderUI.call(this);
- this._renderForm();
- },
-
- /**
- * Render the form in the widget body
- * @method _renderForm
- */
- _renderForm: function() {
- this.after('bodyContentChange', function() {
- var inputExContainer = this.getStdModNode(Y.WidgetStdMod.BODY).one('.inputex-container')._node;
-
- var that = this;
- this.form = new Y.inputEx.Group({
- parentEl: inputExContainer,
- fields: (new Y.Array(this.get('fields') ) ).map(function(i) {
- // add the container reference
- return Y.mix({container: that}, i);
- })
- });
-
- this.form.setValue(this.get('value'));
-
- this.alignTerminals();
-
- }, this);
- },
-
- SERIALIZABLE_ATTRS: Y.Container.prototype.SERIALIZABLE_ATTRS.concat(['value'])
-
+
+ /**
+ * @method renderUI
+ */
+ renderUI: function() {
+ Y.FormContainer.superclass.renderUI.call(this);
+ this._renderForm();
+ },
+
+ /**
+ * Render the form in the widget body
+ * @method _renderForm
+ */
+ _renderForm: function() {
+ this.after('bodyContentChange', function() {
+ var inputExContainer = this.getStdModNode(Y.WidgetStdMod.BODY).one('.inputex-container')._node;
+
+ var that = this;
+ this.form = new Y.inputEx.Group({
+ parentEl: inputExContainer,
+ fields: (new Y.Array(this.get('fields') ) ).map(function(i) {
+ // add the container reference
+ return Y.mix({container: that}, i);
+ })
+ });
+
+ this.form.setValue(this.get('value'));
+
+ this.alignTerminals();
+
+ }, this);
+ },
+
+ SERIALIZABLE_ATTRS: Y.Container.prototype.SERIALIZABLE_ATTRS.concat(['value'])
+
}, {
- ATTRS: {
-
- /**
- * Value of the form
- * @attribute value
- */
- value: {
- setter: function(val) {
- if(this.form) {
- return this.form.setValue(val);
- }
- },
- getter: function() {
- if(this.form) {
- return this.form.getValue();
- }
- else {
- return {};
- }
- }
- },
-
- /**
- * Keep to render the form
- * @attribute bodyContent
- */
- bodyContent: {
- value: '<div class="inputex-container" />'
- },
-
- /**
- * @attribute fields
- */
- fields: {
- value: []
- }//,
-
- /**
- * @attribute resizable
- */
- /*resizable: {
- value: false
- }*/
-
- }
+ ATTRS: {
+
+ /**
+ * Value of the form
+ * @attribute value
+ */
+ value: {
+ setter: function(val) {
+ if(this.form) {
+ return this.form.setValue(val);
+ }
+ },
+ getter: function() {
+ if(this.form) {
+ return this.form.getValue();
+ }
+ else {
+ return {};
+ }
+ }
+ },
+
+ /**
+ * Keep to render the form
+ * @attribute bodyContent
+ */
+ bodyContent: {
+ value: '<div class="inputex-container" />'
+ },
+
+ /**
+ * @attribute fields
+ */
+ fields: {
+ value: []
+ }//,
+
+ /**
+ * @attribute resizable
+ */
+ /*resizable: {
+ value: false
+ }*/
+
+ }
});
- /**
+ /**
* @attribute legend
* @description Legend
* @default null
@@ -111,54 +111,54 @@ Y.FormContainer = Y.Base.create("form-container", Y.Container, [], {
*/
//legend: null,
- /**
+ /**
* @attribute collapsible
* @description Collapsible
* @default false
* @type Boolean
*/
- //collapsible: false,
+ //collapsible: false,
/**
* Render the form
* @method renderForm
*/
/*renderForm: function() {
-
+
var groupParams = {parentEl: this.bodyEl, fields: this.fields, legend: this.legend, collapsible: this.collapsible};
this.form = new Y.inputEx.Group(groupParams);
- this.form.setContainer(this);
+ this.form.setContainer(this);
- for(var i = 0 ; i < this.form.inputs.length ; i++) {
- var field = this.form.inputs[i];
- field.setContainer(this);
- }
+ for(var i = 0 ; i < this.form.inputs.length ; i++) {
+ var field = this.form.inputs[i];
+ field.setContainer(this);
+ }
- // Redraw all wires when the form is collapsed
- if(this.form.legend) {
- Y.one(this.form.legend).on('click', function() {
-
- // Override the getXY method on field terminals:
- var that = this;
- for(var i = 0 ; i < this.form.inputs.length ; i++) {
- var field = this.form.inputs[i];
- if(field.terminal) {
- field.terminal.getXY = function() {
- if( Y.one(that.form.fieldset).hasClass("inputEx-Collapsed") ) {
- return that.getXY();
- }
- else {
- return Y.Terminal.prototype.getXY.call(this);
- }
-
- };
- }
- }
-
- this.redrawAllWires();
- }, this, true);
- }
+ // Redraw all wires when the form is collapsed
+ if(this.form.legend) {
+ Y.one(this.form.legend).on('click', function() {
+
+ // Override the getXY method on field terminals:
+ var that = this;
+ for(var i = 0 ; i < this.form.inputs.length ; i++) {
+ var field = this.form.inputs[i];
+ if(field.terminal) {
+ field.terminal.getXY = function() {
+ if( Y.one(that.form.fieldset).hasClass("inputEx-Collapsed") ) {
+ return that.getXY();
+ }
+ else {
+ return Y.Terminal.prototype.getXY.call(this);
+ }
+
+ };
+ }
+ }
+
+ this.redrawAllWires();
+ }, this, true);
+ }
},*/
//});
View
146 src/image-container/image-container.js
@@ -12,81 +12,81 @@ YUI.add('image-container', function(Y) {
* @constructor
*/
Y.ImageContainer = Y.Base.create("image-container", Y.ContainerBase, [], {
-
- /**
- * @method renderUI
- */
- renderUI: function() {
-
- // TODO:
- var image = Y.Node.create('<img src="'+this.get('imageUrl')+'" width="'+this.get('width')+'" height="'+this.get('height')+'"/>');
- image.appendTo( this.get('contentBox') );
- this.image = image;
-
- //console.log( Y.WidgetStdMod.BODY, this._getStdModContent(Y.WidgetStdMod.BODY) );
-
- // make the overlay draggable
- this.drag = new Y.DD.Drag({
- node: this.get('boundingBox'),
- handles : [ image ]
- });
-
- this.drag.on('drag:drag', function() {
- this.redrawAllWires();
- }, this);
-
-
- // Make the overlay resizable
- var contentBox = this.get('contentBox');
- var resize = new Y.Resize({
- node: contentBox,
- handles: 'br'
- });
- /*resize.plug(Y.Plugin.ResizeConstrained, {
- preserveRatio: true
- });*/
- // On resize, fillHeight, & align terminals & wires
- resize.on('resize:resize', function(e) {
- // TODO: fillHeight
- this._fillHeight();
-
- //console.log(e.details[0].info);
- var p = e.details[0].info;
- var w = p.right-p.left;
- var h = p.bottom-p.top;
- //console.log(w+"x"+h);
-
- // WARNING !!!
- this.image.set('width',w);
- this.image.set('height',h);
-
- this.each(function(term) {
- if(term.get('align')) {
- term.align( contentBox, ["tl",term.get('align').points[1]]);
- }
- }, this);
-
- this.redrawAllWires();
- }, this);
-
- }
-
+
+ /**
+ * @method renderUI
+ */
+ renderUI: function() {
+
+ // TODO:
+ var image = Y.Node.create('<img src="'+this.get('imageUrl')+'" width="'+this.get('width')+'" height="'+this.get('height')+'"/>');
+ image.appendTo( this.get('contentBox') );
+ this.image = image;
+
+ //console.log( Y.WidgetStdMod.BODY, this._getStdModContent(Y.WidgetStdMod.BODY) );
+
+ // make the overlay draggable
+ this.drag = new Y.DD.Drag({
+ node: this.get('boundingBox'),
+ handles : [ image ]
+ });
+
+ this.drag.on('drag:drag', function() {
+ this.redrawAllWires();
+ }, this);
+
+
+ // Make the overlay resizable
+ var contentBox = this.get('contentBox');
+ var resize = new Y.Resize({
+ node: contentBox,
+ handles: 'br'
+ });
+ /*resize.plug(Y.Plugin.ResizeConstrained, {
+ preserveRatio: true
+ });*/
+ // On resize, fillHeight, & align terminals & wires
+ resize.on('resize:resize', function(e) {
+ // TODO: fillHeight
+ this._fillHeight();
+
+ //console.log(e.details[0].info);
+ var p = e.details[0].info;
+ var w = p.right-p.left;
+ var h = p.bottom-p.top;
+ //console.log(w+"x"+h);
+
+ // WARNING !!!
+ this.image.set('width',w);
+ this.image.set('height',h);
+
+ this.each(function(term) {
+ if(term.get('align')) {
+ term.align( contentBox, ["tl",term.get('align').points[1]]);
+ }
+ }, this);
+
+ this.redrawAllWires();
+ }, this);
+
+ }
+
}, {
- ATTRS: {
- /**
- * Url of the image you want to render (relative to the script's page)
- * @attribute imageUrl
- */
- imageUrl: {
- value: ''
- },
-
- zIndex: {
- value: 5
- }
- }
-
+ ATTRS: {
+ /**
+ * Url of the image you want to render (relative to the script's page)
+ * @attribute imageUrl
+ */
+ imageUrl: {
+ value: ''
+ },
+
+ zIndex: {
+ value: 5
+ }
+ }
+
});
View
156 src/inout-container/inout-container.js
@@ -14,88 +14,88 @@ YUI.add("inout-container", function(Y){
Y.InOutContainer = Y.Base.create("inout-container", Y.Container, [], {
- /**
- * @method renderUI
- */
- renderUI: function() {
- Y.InOutContainer.superclass.renderUI.call(this);
- this._renderInputsOutputs();
- },
-
- /**
- * @method _renderInputsOutputs
- */
- _renderInputsOutputs: function() {
-
- var that = this;
- Y.on('available', function() {
-
- /*
- for(var i = 0 ; i < this.inputs.length ; i++) {
- var input = this.inputs[i];
- this.addTerminal({
- "name": input,
- "direction": [-1,0],
- "offsetPosition": {"left": -14, "top": 3+30*(i+1) },
- "ddConfig": {
- "type": "input",
- "allowedTypes": ["output"]
- }
- });
- this.bodyEl.appendChild(Y.WireIt.cn('div', null, {lineHeight: "30px"}, input));
- }
+ /**
+ * @method renderUI
+ */
+ renderUI: function() {
+ Y.InOutContainer.superclass.renderUI.call(this);
+ this._renderInputsOutputs();
+ },
+
+ /**
+ * @method _renderInputsOutputs
+ */
+ _renderInputsOutputs: function() {
+
+ var that = this;
+ Y.on('available', function() {
+
+ /*
+ for(var i = 0 ; i < this.inputs.length ; i++) {
+ var input = this.inputs[i];
+ this.addTerminal({
+ "name": input,
+ "direction": [-1,0],
+ "offsetPosition": {"left": -14, "top": 3+30*(i+1) },
+ "ddConfig": {
+ "type": "input",
+ "allowedTypes": ["output"]
+ }
+ });
+ this.bodyEl.appendChild(Y.WireIt.cn('div', null, {lineHeight: "30px"}, input));
+ }
- for(i = 0 ; i < this.outputs.length ; i++) {
- var output = this.outputs[i];
- this.addTerminal({
- "name": output,
- "direction": [1,0],
- "offsetPosition": {"right": -14, "top": 3+30*(i+1+this.inputs.length) },
- "ddConfig": {
- "type": "output",
- "allowedTypes": ["input"]
- },
- "alwaysSrc": true
- });
- this.bodyEl.appendChild(Y.WireIt.cn('div', null, {lineHeight: "30px", textAlign: "right"}, output));
- }
- */
-
-
- }, '#body-container');
-
- }
-
+ for(i = 0 ; i < this.outputs.length ; i++) {
+ var output = this.outputs[i];
+ this.addTerminal({
+ "name": output,
+ "direction": [1,0],
+ "offsetPosition": {"right": -14, "top": 3+30*(i+1+this.inputs.length) },
+ "ddConfig": {
+ "type": "output",
+ "allowedTypes": ["input"]
+ },
+ "alwaysSrc": true
+ });
+ this.bodyEl.appendChild(Y.WireIt.cn('div', null, {lineHeight: "30px", textAlign: "right"}, output));
+ }
+ */
+
+
+ }, '#body-container');
+
+ }
+
}, {
- ATTRS: {
-
-
- /**
- * Keep to render the form
- * @attribute bodyContent
- */
- bodyContent: {
- value: '<div id="body-container" />'
- },
-
- /**
- * @attribute inputs
- * @description Array of strings for which an Input terminal will be created.
- * @default []
- * @type Array
- */
- inputs: [],
+ ATTRS: {
+
+
+ /**
+ * Keep to render the form
+ * @attribute bodyContent
+ */
+ bodyContent: {
+ value: '<div id="body-container" />'
+ },
+
+ /**
+ * @attribute inputs
+ * @description Array of strings for which an Input terminal will be created.
+ * @default []
+ * @type Array
+ */
+ inputs: [],
- /**
- * @attribute outputs
- * @description Array of strings for which an Output terminal will be created.
- * @default []
- * @type Array
- */
- outputs: []
- }
-
+ /**
+ * @attribute outputs
+ * @description Array of strings for which an Output terminal will be created.
+ * @default []
+ * @type Array
+ */
+ outputs: []
+ }
+
});
View
54 src/inputex-wirable-fields/inputex-wirable-fields.js
@@ -8,11 +8,11 @@ YUI.add('inputex-wirable-fields', function(Y) {
* setFieldName might change the name of the terminal
*/
inputEx.StringField.prototype.setFieldName = function(name) {
- this.el.name = name;
- if(this.terminal) {
- this.terminal.set('name', name);
- // TODO: this.terminal.el.title = name;
- }
+ this.el.name = name;
+ if(this.terminal) {
+ this.terminal.set('name', name);
+ // TODO: this.terminal.el.title = name;
+ }
};
@@ -20,16 +20,16 @@ inputEx.StringField.prototype.setFieldName = function(name) {
* Groups must set the container recursively
*/
inputEx.Group.prototype.setContainer = function(container) {
-
- inputEx.Group.superclass.setContainer.call(this, container);
-
- // Group and inherited fields must set this recursively
- if(this.inputs) {
- for(var i = 0 ; i < this.inputs.length ; i++) {
- this.inputs[i].setContainer(container);
- }
- }
-
+
+ inputEx.Group.superclass.setContainer.call(this, container);
+
+ // Group and inherited fields must set this recursively
+ if(this.inputs) {
+ for(var i = 0 ; i < this.inputs.length ; i++) {
+ this.inputs[i].setContainer(container);
+ }
+ }
+
};
@@ -37,15 +37,15 @@ inputEx.Group.prototype.setContainer = function(container) {
* List must set the container recursively
*/
inputEx.ListField.prototype.setContainer = function(container) {
-
- inputEx.ListField.superclass.setContainer.call(this, container);
-
- if(this.subFields) {
- for(var i = 0 ; i < this.subFields.length ; i++) {
- this.subFields[i].setContainer(container);
- }
- }
-
+
+ inputEx.ListField.superclass.setContainer.call(this, container);
+
+ if(this.subFields) {
+ for(var i = 0 ; i < this.subFields.length ; i++) {
+ this.subFields[i].setContainer(container);
+ }
+ }
+
};
/**
@@ -53,9 +53,9 @@ inputEx.ListField.prototype.setContainer = function(container) {
*/
inputEx.ListField.prototype._addElement = inputEx.ListField.prototype.addElement;
inputEx.ListField.prototype.addElement = function(value) {
- var f = this._addElement(value);
- f.setContainer(this.options.container);
- return f;
+ var f = this._addElement(value);
+ f.setContainer(this.options.container);
+ return f;
};
View
50 src/inputex-wirable/inputex-wirable.js
@@ -63,31 +63,31 @@ Y.extend(inputEx.Field, inputEx.BaseField, {
},
- /**
- * Set the container for this field
- */
- setContainer: function(container) {
- if(!this.options.container) {
- this.renderTerminal();
- }
- this.options.container = container;
- /*if(this.terminal) {
- this.terminal.container = container;
- if( Y.Array.indexOf(container.terminals, this.terminal) == -1 ) {
- container.terminals.push(this.terminal);
- }
- }*/
- },
+ /**
+ * Set the container for this field
+ */
+ setContainer: function(container) {
+ if(!this.options.container) {
+ this.renderTerminal();
+ }
+ this.options.container = container;
+ /*if(this.terminal) {
+ this.terminal.container = container;
+ if( Y.Array.indexOf(container.terminals, this.terminal) == -1 ) {
+ container.terminals.push(this.terminal);
+ }
+ }*/
+ },
- /**
- * also change the terminal name when changing the field name
- */
- setFieldName: function(name) {
- if(this.terminal) {
- this.terminal.name = name;
- this.terminal.el.title = name;
- }
- },
+ /**
+ * also change the terminal name when changing the field name
+ */
+ setFieldName: function(name) {
+ if(this.terminal) {
+ this.terminal.name = name;
+ this.terminal.el.title = name;
+ }
+ },
/**
* Remove the input wired state on the
@@ -114,7 +114,7 @@ Y.extend(inputEx.Field, inputEx.BaseField, {
});
inputEx.Field.groupOptions = inputEx.BaseField.groupOptions.concat([
- { type: 'boolean', label: 'Wirable', name: 'wirable', value: false}
+ { type: 'boolean', label: 'Wirable', name: 'wirable', value: false}
]);
}, '3.6.0', {requires: ['terminal','inputex-field']});
View
50 src/layer/layer.js
@@ -11,32 +11,32 @@ YUI.add('layer', function(Y) {