11// DRAFT JUST to have a look at it again.
22
33import Morph from "src/components/widgets/lively-morph.js"
4-
4+ import { pt } from "src/client/graphics.js"
55
66/**
77 * Fabrik.js. This file contains Fabrik
@@ -29,6 +29,14 @@ import Morph from "src/components/widgets/lively-morph.js"
2929
3030
3131// STUBS
32+ var Global = {
33+
34+ }
35+
36+ class WorldMorph {
37+
38+ }
39+
3240class Widget {
3341
3442}
@@ -37,6 +45,9 @@ class SelectionMorph {
3745
3846}
3947
48+ class Class {
49+
50+ }
4051
4152// logMethod(Morph.prototype, 'onMouseDown');
4253
@@ -52,9 +63,9 @@ export default class Fabrik {
5263 }
5364
5465 addTextComponent ( toComponent ) {
55- var c = new TextComponent ( ) ;
56- toComponent . plugin ( c ) ;
57- return c ;
66+ var c = new TextComponent ( ) ;
67+ toComponent . plugin ( c ) ;
68+ return c ;
5869 }
5970
6071 addFunctionComponent ( toComponent ) {
@@ -130,11 +141,11 @@ export default class Fabrik {
130141
131142 openFabrikTextListExample ( ) {
132143 // the next variables are intentionally defined global
133- f = this . openFabrikComponent ( ) ;
134- input = this . addFunctionComponent ( f ) ;
144+ var f = this . openFabrikComponent ( ) ;
145+ var input = this . addFunctionComponent ( f ) ;
135146 input . setFunctionBody ( "return ['eins', 'zwei', 'drei']" )
136- list = this . addTextListComponent ( f ) ;
137- out = this . addTextComponent ( f ) ;
147+ var list = this . addTextListComponent ( f ) ;
148+ var out = this . addTextComponent ( f ) ;
138149 f . connectComponents ( input , "Result" , list , "List" ) ;
139150 f . connectComponents ( list , "Selection" , out , "Text" ) ;
140151 f . morph . automaticLayout ( ) ;
@@ -152,7 +163,7 @@ export default class Fabrik {
152163 m1 . changed = function ( ) { c . updateView ( ) } ;
153164 m2 . changed = function ( ) { c . updateView ( ) } ;
154165
155- world = WorldMorph . current ( ) ;
166+ var world = WorldMorph . current ( ) ;
156167 world . addMorph ( c ) ;
157168 world . addMorph ( m1 ) ;
158169 world . addMorph ( m2 ) ;
@@ -284,8 +295,8 @@ export default class Fabrik {
284295 var zipInput = this . addTextComponent ( base ) ; zipInput . panel . setExtent ( pt ( 100 , 50 ) ) ;
285296
286297 /*
287- * Building the requester Fabrik
288- */
298+ * Building the requester Fabrik
299+ */
289300 var requestor = this . openFabrikComponent ( world , loc , pt ( 700 , 250 ) , 'Request Weather' ) ;
290301 requestor . morph . owner . remove ( ) ; // FIXME hack so that window morph disappears...
291302 base . morph . addMorph ( requestor . morph ) ;
@@ -1294,7 +1305,7 @@ class PinConnector extends Widget {
12941305
12951306
12961307 this . fromPin = fromPinHandle ;
1297- this . toPin = toPinHandle ;
1308+ this . toPin = toPinHandle ;
12981309 this . isBidirectional = false ;
12991310
13001311 if ( toPinHandle . isFakeHandle ) return ;
@@ -1503,8 +1514,8 @@ class ComponentMorph extends Morph {
15031514 var self = this ;
15041515 menu . addItem ( [ "add pin named..." , function ( ) {
15051516 WorldMorph . current ( ) . prompt ( 'Name for Pin?' , function ( name ) {
1506- self . component . addFieldAndPinHandle ( name ) } , 'Test' ) } ]
1507- ) ;
1517+ self . component . addFieldAndPinHandle ( name ) } , 'Test' ) } ]
1518+ ) ;
15081519 return menu ;
15091520 }
15101521
@@ -2003,7 +2014,7 @@ class Component extends Widget {
20032014 this . morph = null ;
20042015 this . pinHandles . each ( function ( ea ) { ea . deleteView } ) ;
20052016 }
2006-
2017+
20072018 addField ( fieldName , coercionSpec , forceSet ) {
20082019 this . formalModel . addField ( fieldName , coercionSpec , forceSet ) ;
20092020 this . pvtCreateAccessorsForField ( fieldName ) ;
@@ -2257,10 +2268,10 @@ class FabrikMorph extends ComponentMorph {
22572268
22582269 // remove and put stuff in setupforcomponent instead
22592270 setupForFabrik ( fabrik ) {
2260- this . fabrik = fabrik ; // remove instance var, component is sufficient
2261- this . component = fabrik ;
2262- this . component . components . each ( function ( ea ) { this . addMorphForComponent ( ea ) } , this ) ;
2263- this . component . connectors . each ( function ( ea ) { this . addMorph ( ea . morph || ea . buildView ( ) ) } , this ) ;
2271+ this . fabrik = fabrik ; // remove instance var, component is sufficient
2272+ this . component = fabrik ;
2273+ this . component . components . each ( function ( ea ) { this . addMorphForComponent ( ea ) } , this ) ;
2274+ this . component . connectors . each ( function ( ea ) { this . addMorph ( ea . morph || ea . buildView ( ) ) } , this ) ;
22642275 }
22652276
22662277 setupHaloItems ( ) {
@@ -2328,8 +2339,8 @@ class FabrikMorph extends ComponentMorph {
23282339 // var handle = new HandleMorph(pt(0,0), lively.scene.Rectangle, evt.hand, this.userFrame, "bottomRight");
23292340 // handle.setExtent(pt(0, 0));
23302341 // handle.mode = 'reshape';
2331- // this.userFrame.addMorph(handle);
2332- // evt.hand.setMouseFocus(handle);
2342+ // this.userFrame.addMorph(handle);
2343+ // evt.hand.setMouseFocus(handle);
23332344 }
23342345
23352346 makeSelection ( evt ) { //default behavior is to grab a submorph
@@ -2357,7 +2368,7 @@ class FabrikMorph extends ComponentMorph {
23572368 updateAfterCollapse ( ) {
23582369 this . updateHaloItemPositions ( ) ;
23592370 if ( this . isFramed ( ) )
2360- this . setExtent ( this . getExtent ( ) . addPt ( this . owner . titleBar . getExtent ( ) . withX ( 0 ) ) ) ;
2371+ this . setExtent ( this . getExtent ( ) . addPt ( this . owner . titleBar . getExtent ( ) . withX ( 0 ) ) ) ;
23612372 }
23622373
23632374 collapse ( ) {
@@ -2378,7 +2389,7 @@ class FabrikMorph extends ComponentMorph {
23782389 ea . panel . dimMorph . remove ( ) ;
23792390 if ( ea . panel . isCollapsed == false ) {
23802391 // console.log("collapse " + ea);
2381- ea . panel . collapseToggle ( true ) ;
2392+ ea . panel . collapseToggle ( true ) ;
23822393 } ;
23832394 } ) ;
23842395
@@ -2392,7 +2403,7 @@ class FabrikMorph extends ComponentMorph {
23922403 this . removeMorph ( ea . morph ) ;
23932404 this . hiddenContainer . addMorph ( ea . morph ) } . bind ( this ) ) ;
23942405 this . positionAndExtentChange ( this . collapsedPosition || this . getPosition ( ) ,
2395- this . collapsedExtent || this . component . defaultCollapsedExtent ) ;
2406+ this . collapsedExtent || this . component . defaultCollapsedExtent ) ;
23962407 }
23972408 }
23982409
@@ -2430,12 +2441,12 @@ class FabrikMorph extends ComponentMorph {
24302441 minExtent ( ) {
24312442 return pt ( 10 , 5 ) ;
24322443 // if (this.isCollapsed) return pt(10,5);
2433- // var borderMorphs = this.getComponentMorphsNearBorders();
2434- // var topY = borderMorphs.top ? borderMorphs.top.getPosition().y : 0;
2435- // var leftX = borderMorphs.left ? borderMorphs.left.getPosition().y : 0;
2436- // var bottomY = borderMorphs.bottom ? borderMorphs.bottom.bounds().maxY() : 50;
2437- // var rightX = borderMorphs.right ? borderMorphs.right.bounds().maxX() : 50;
2438- // return pt(rightX - leftX, bottomY - topY);
2444+ // var borderMorphs = this.getComponentMorphsNearBorders();
2445+ // var topY = borderMorphs.top ? borderMorphs.top.getPosition().y : 0;
2446+ // var leftX = borderMorphs.left ? borderMorphs.left.getPosition().y : 0;
2447+ // var bottomY = borderMorphs.bottom ? borderMorphs.bottom.bounds().maxY() : 50;
2448+ // var rightX = borderMorphs.right ? borderMorphs.right.bounds().maxX() : 50;
2449+ // return pt(rightX - leftX, bottomY - topY);
24392450 }
24402451
24412452 getComponentMorphsNearBorders ( ) {
@@ -2797,7 +2808,7 @@ class FunctionComponentMorph extends ComponentMorph {
27972808
27982809 setupHaloItems ( ) {
27992810 super . setupHaloItems ( ) ;
2800- var inputHalo = this . addHaloItem ( "+input" , new Rectangle ( 0 , 0 , 45 , 20 ) ,
2811+ var inputHalo = this . addHaloItem ( "+input" , new Rectangle ( 0 , 0 , 45 , 20 ) ,
28012812 { relativePosition : pt ( 0 , 0 ) , positionOffset : pt ( 0 , - 20 ) } ,
28022813 { fill : Color . blue . lighter ( ) . lighter ( ) /*, fillOpacity: 0.5*/ } ) ;
28032814 inputHalo . connectModel ( { model : this . component , setValue : "interactiveAndNewInputField" } ) ;
@@ -2816,7 +2827,7 @@ class FunctionComponentMorph extends ComponentMorph {
28162827 // this.functionBodyMorph.boundEval = this.functionBodyMorph.boundEval.wrap(function(proceed, str) {
28172828 // var forceImplicit = !str.match(/^[ ]*return /);
28182829 // var source = self.component.composeFunction(self.component.formalModel.getFunctionHeader(), str, interactiveEval, forceImplicit);
2819- // console.log("eval: " + source)
2830+ // console.log("eval: " + source)
28202831 // return eval(source).apply(self.component, self.component.parameterValues());
28212832 // });
28222833 }
@@ -3246,15 +3257,15 @@ class ComponentBoxMorph extends Morph {
32463257
32473258 buildContent ( ) {
32483259 this . addMorphOfComponent ( new FabrikComponent ( ) , function ( ) {
3249- var extent = pt ( 300 , 250 ) ;
3250- var fabrik = new FabrikComponent ( ) ;
3251- fabrik . defaultViewExtent = extent ;
3252- fabrik . viewTitle = 'Fabrik' ;
3253- fabrik . openIn ( WorldMorph . current ( ) , WorldMorph . current ( ) . hands . first ( ) . getPosition ( ) . midPt ( extent ) ) ;
3254- return fabrik . panel . owner ;
3260+ var extent = pt ( 300 , 250 ) ;
3261+ var fabrik = new FabrikComponent ( ) ;
3262+ fabrik . defaultViewExtent = extent ;
3263+ fabrik . viewTitle = 'Fabrik' ;
3264+ fabrik . openIn ( WorldMorph . current ( ) , WorldMorph . current ( ) . hands . first ( ) . getPosition ( ) . midPt ( extent ) ) ;
3265+ return fabrik . panel . owner ;
32553266 } ) ;
32563267 var defaultCreateFunc = function ( theClass , optExtent ) {
3257- return new theClass ( ) . buildView ( optExtent ) ;
3268+ return new theClass ( ) . buildView ( optExtent ) ;
32583269 } ;
32593270 this . addMorphOfComponent ( new FunctionComponent ( ) , defaultCreateFunc . curry ( FunctionComponent ) ) ;
32603271 this . addMorphOfComponent ( new TextComponent ( ) , defaultCreateFunc . curry ( TextComponent ) ) ;
0 commit comments