@@ -304,6 +304,7 @@ define([
304
304
return ;
305
305
}
306
306
this . state . code = variable ;
307
+ var prevVarType = that . state . type ;
307
308
308
309
if ( variable == '' ) {
309
310
if ( ! this . isFirstPage ) {
@@ -338,7 +339,10 @@ define([
338
339
339
340
var varType = varObj . type ;
340
341
var varList = varObj . list ;
341
- var prevVarType = that . state . type ;
342
+ if ( varType == 'module' ) {
343
+ // get module name
344
+ varType = varObj . name ;
345
+ }
342
346
343
347
that . state . type = varType ;
344
348
that . state . list = varList ;
@@ -431,45 +435,49 @@ define([
431
435
432
436
// get parameter
433
437
var splitList = variable . split ( '.' ) ;
434
- var hasOption = false ;
438
+ // var hasOption = false;
435
439
436
440
if ( splitList && splitList . length > 0 ) {
437
441
var lastSplit = splitList [ splitList . length - 1 ] ;
438
- // get target code
439
- var methodName = lastSplit . match ( / [ a - z A - Z _ ] + / i) [ 0 ] ;
440
- var targetCode = splitList . slice ( 0 , splitList . length - 1 ) . join ( '.' ) ;
441
- if ( ( prevVarType in instanceLibrary . INSTANCE_MATCHING_LIBRARY ) && ( methodName in instanceLibrary . INSTANCE_MATCHING_LIBRARY [ prevVarType ] ) ) {
442
- // get target library
443
- var targetLib = instanceLibrary . INSTANCE_MATCHING_LIBRARY [ prevVarType ] [ methodName ] ;
444
- var targetId = targetLib . target ;
445
- that . optionPopup = new LibraryComponent ( {
446
- [ targetId ] : targetCode ,
447
- config : {
448
- name : methodName , category : 'Instance' ,
449
- id : targetLib . id ,
450
- saveOnly : true ,
451
- noOutput : true
452
- }
453
- } ,
454
- {
455
- pageThis : that ,
456
- useInputVariable : true ,
457
- targetSelector : that . pageThis . wrapSelector ( '#' + that . targetId ) ,
458
-
459
- finish : function ( code ) {
460
- // TODO: save state
461
-
462
- $ ( that . pageThis . wrapSelector ( '#' + that . targetId ) ) . trigger ( {
463
- type : "instance_editor_replaced" ,
464
- originCode : that . state . code ,
465
- newCode : code
466
- } ) ;
467
- }
468
- } ) ;
469
- hasOption = true ;
470
- } else {
471
- that . optionPopup = null ;
472
- }
442
+ // // get target code
443
+ // var methodName = lastSplit.match(/[a-zA-Z_]+/i)[0];
444
+ // var targetCode = splitList.slice(0, splitList.length - 1).join('.');
445
+ // if ((prevVarType in instanceLibrary.INSTANCE_MATCHING_LIBRARY) && (methodName in instanceLibrary.INSTANCE_MATCHING_LIBRARY[prevVarType])) {
446
+ // // get target library
447
+ // var targetLib = instanceLibrary.INSTANCE_MATCHING_LIBRARY[prevVarType][methodName];
448
+ // var targetId = targetLib.target;
449
+ // var popupState = {
450
+ // config: {
451
+ // name: methodName, category: 'Instance',
452
+ // id: targetLib.id,
453
+ // saveOnly: true,
454
+ // noOutput: true
455
+ // }
456
+ // }
457
+ // // add targetid as state if exists
458
+ // if (targetId) {
459
+ // popupState[targetId] = targetCode;
460
+ // }
461
+ // that.optionPopup = new LibraryComponent(popupState,
462
+ // {
463
+ // pageThis: that,
464
+ // useInputVariable: true,
465
+ // targetSelector: that.pageThis.wrapSelector('#' + that.targetId),
466
+
467
+ // finish: function(code) {
468
+ // // TODO: save state
469
+
470
+ // $(that.pageThis.wrapSelector('#' + that.targetId)).trigger({
471
+ // type: "instance_editor_replaced",
472
+ // originCode: that.state.code,
473
+ // newCode: code
474
+ // });
475
+ // }
476
+ // });
477
+ // hasOption = true;
478
+ // } else {
479
+ // that.optionPopup = null;
480
+ // }
473
481
474
482
// if bracket is at the end of code
475
483
var matchList = lastSplit . match ( / \( .* ?\) $ / gi) ;
@@ -479,27 +487,27 @@ define([
479
487
var parameter = lastBracket . substr ( 1 , lastBracket . length - 2 ) ;
480
488
$ ( that . wrapSelector ( '.' + VP_INS_PARAMETER ) ) . val ( parameter ) ;
481
489
$ ( that . wrapSelector ( '.' + VP_INS_PARAMETER ) ) . prop ( 'disabled' , false ) ;
482
- if ( hasOption ) {
483
- if ( $ ( that . wrapSelector ( '.vp-ins-opt-button' ) ) . hasClass ( 'disabled' ) ) {
484
- $ ( that . wrapSelector ( '.vp-ins-opt-button' ) ) . removeClass ( 'disabled' ) ;
485
- }
486
- } else {
487
- if ( ! $ ( that . wrapSelector ( '.vp-ins-opt-button' ) ) . hasClass ( 'disabled' ) ) {
488
- $ ( that . wrapSelector ( '.vp-ins-opt-button' ) ) . addClass ( 'disabled' ) ;
489
- }
490
- }
490
+ // if (hasOption) {
491
+ // if ($(that.wrapSelector('.vp-ins-opt-button')).hasClass('disabled')) {
492
+ // $(that.wrapSelector('.vp-ins-opt-button')).removeClass('disabled');
493
+ // }
494
+ // } else {
495
+ // if (!$(that.wrapSelector('.vp-ins-opt-button')).hasClass('disabled')) {
496
+ // $(that.wrapSelector('.vp-ins-opt-button')).addClass('disabled');
497
+ // }
498
+ // }
491
499
} else {
492
500
$ ( that . wrapSelector ( '.' + VP_INS_PARAMETER ) ) . val ( '' ) ;
493
501
$ ( that . wrapSelector ( '.' + VP_INS_PARAMETER ) ) . prop ( 'disabled' , true ) ;
494
- if ( ! $ ( that . wrapSelector ( '.vp-ins-opt-button' ) ) . hasClass ( 'disabled' ) ) {
495
- $ ( that . wrapSelector ( '.vp-ins-opt-button' ) ) . addClass ( 'disabled' ) ;
496
- }
502
+ // if (!$(that.wrapSelector('.vp-ins-opt-button')).hasClass('disabled')) {
503
+ // $(that.wrapSelector('.vp-ins-opt-button')).addClass('disabled');
504
+ // }
497
505
}
498
506
} else {
499
507
$ ( that . wrapSelector ( '.' + VP_INS_PARAMETER ) ) . prop ( 'disabled' , true ) ;
500
- if ( ! $ ( that . wrapSelector ( '.vp-ins-opt-button' ) ) . hasClass ( 'disabled' ) ) {
501
- $ ( that . wrapSelector ( '.vp-ins-opt-button' ) ) . addClass ( 'disabled' ) ;
502
- }
508
+ // if (!$(that.wrapSelector('.vp-ins-opt-button')).hasClass('disabled')) {
509
+ // $(that.wrapSelector('.vp-ins-opt-button')).addClass('disabled');
510
+ // }
503
511
}
504
512
}
505
513
@@ -521,6 +529,68 @@ define([
521
529
if ( callback ) {
522
530
callback ( '' ) ;
523
531
}
532
+ } ) . finally ( function ( ) {
533
+
534
+ // get parameter
535
+ var splitList = variable . split ( '.' ) ;
536
+ var hasOption = false ;
537
+
538
+ if ( splitList && splitList . length > 0 ) {
539
+ var lastSplit = splitList [ splitList . length - 1 ] ;
540
+ // get target code
541
+ var methodName = lastSplit . match ( / [ a - z A - Z _ ] + / i) [ 0 ] ;
542
+ var targetCode = splitList . slice ( 0 , splitList . length - 1 ) . join ( '.' ) ;
543
+ if ( ( prevVarType in instanceLibrary . INSTANCE_MATCHING_LIBRARY ) && ( methodName in instanceLibrary . INSTANCE_MATCHING_LIBRARY [ prevVarType ] ) ) {
544
+ // get target library
545
+ var targetLib = instanceLibrary . INSTANCE_MATCHING_LIBRARY [ prevVarType ] [ methodName ] ;
546
+ var targetId = targetLib . target ;
547
+ var popupState = {
548
+ config : {
549
+ name : methodName , category : 'Instance' ,
550
+ id : targetLib . id ,
551
+ saveOnly : true ,
552
+ noOutput : true
553
+ }
554
+ }
555
+ // add targetid as state if exists
556
+ if ( targetId ) {
557
+ popupState [ targetId ] = targetCode ;
558
+ }
559
+ that . optionPopup = new LibraryComponent ( popupState ,
560
+ {
561
+ pageThis : that ,
562
+ useInputVariable : true ,
563
+ targetSelector : that . pageThis . wrapSelector ( '#' + that . targetId ) ,
564
+
565
+ finish : function ( code ) {
566
+ // TODO: save state
567
+
568
+ $ ( that . pageThis . wrapSelector ( '#' + that . targetId ) ) . trigger ( {
569
+ type : "instance_editor_replaced" ,
570
+ originCode : that . state . code ,
571
+ newCode : code
572
+ } ) ;
573
+ }
574
+ } ) ;
575
+ hasOption = true ;
576
+ } else {
577
+ that . optionPopup = null ;
578
+ }
579
+
580
+ if ( hasOption ) {
581
+ if ( $ ( that . wrapSelector ( '.vp-ins-opt-button' ) ) . hasClass ( 'disabled' ) ) {
582
+ $ ( that . wrapSelector ( '.vp-ins-opt-button' ) ) . removeClass ( 'disabled' ) ;
583
+ }
584
+ } else {
585
+ if ( ! $ ( that . wrapSelector ( '.vp-ins-opt-button' ) ) . hasClass ( 'disabled' ) ) {
586
+ $ ( that . wrapSelector ( '.vp-ins-opt-button' ) ) . addClass ( 'disabled' ) ;
587
+ }
588
+ }
589
+ } else {
590
+ if ( ! $ ( that . wrapSelector ( '.vp-ins-opt-button' ) ) . hasClass ( 'disabled' ) ) {
591
+ $ ( that . wrapSelector ( '.vp-ins-opt-button' ) ) . addClass ( 'disabled' ) ;
592
+ }
593
+ }
524
594
} ) ;
525
595
526
596
0 commit comments