ruote-kit 2.1.8.1 → 2.1.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/ruote-kit.rb CHANGED
@@ -4,7 +4,7 @@ require 'ruote/part/storage_participant'
4
4
 
5
5
  module RuoteKit
6
6
 
7
- VERSION = '2.1.8'
7
+ VERSION = '2.1.8.2'
8
8
 
9
9
  autoload :Configuration, "ruote-kit/configuration"
10
10
  autoload :Application, "ruote-kit/application"
@@ -3,7 +3,7 @@
3
3
  * OpenWFEru - open source ruby workflow and bpm engine
4
4
  * (c) 2008 John Mettraux
5
5
  *
6
- * OpenWFEru is freely distributable under the terms
6
+ * OpenWFEru is freely distributable under the terms
7
7
  * of a BSD-style license.
8
8
  * For details, see the OpenWFEru web site: http://openwferu.rubyforge.org
9
9
  *
@@ -83,7 +83,7 @@ var FluoDial = function() {
83
83
  }
84
84
 
85
85
  function newDialog (title, width, height) {
86
-
86
+
87
87
  var sheet = newRectangle
88
88
  ("dial_sheet", "dial_sheet", width, height);
89
89
  var dialog = newRectangle
@@ -127,8 +127,8 @@ var FluoDial = function() {
127
127
 
128
128
  var hmenu = new Element("div", { "class": "dial_menu" });
129
129
  var hclose = new Element
130
- ("a",
131
- { "href": "#",
130
+ ("a",
131
+ { "href": "#",
132
132
  "title": "close this dialog",
133
133
  "onclick": "$('dial_dialog').close(); return false;" });
134
134
  hclose.innerHTML = "close";
@@ -1,11 +1,9 @@
1
-
2
1
  /*
3
2
  * Ruote - open source ruby workflow engine
4
- * (c) 2005-2009 jmettraux@gmail.com
3
+ * (c) 2005-2010 jmettraux@gmail.com
5
4
  *
6
- * OpenWFEru is freely distributable under the terms
7
- * of a BSD-style license.
8
- * For details, see the OpenWFEru web site: http://openwferu.rubyforge.org
5
+ * Ruote is freely distributable under the terms of the MIT license.
6
+ * For details, see the ruote web site: http://ruote.rubyforge.org
9
7
  *
10
8
  * Made in Japan
11
9
  *
@@ -23,12 +21,13 @@
23
21
  // return s;
24
22
  //}
25
23
 
26
- var FluoCon = {
24
+ var FluoConstants = {
27
25
 
28
- RGB_WHITE: 'rgb(255, 255, 255)',
29
- RGB_HIGHLIGHT: 'rgb(220, 220, 220)',
26
+ WHITE: 'rgb(255, 255, 255)',
27
+ HIGHLIGHT: 'rgb(220, 220, 220)',
30
28
  LINE_HEIGHT: 20,
31
- MIN_ACTIVITY_WIDTH: 110
29
+ MIN_ACTIVITY_WIDTH: 110,
30
+ FONT: '12px Helvetica Neue'
32
31
  }
33
32
 
34
33
  var FluoCanvas = function() {
@@ -124,7 +123,7 @@ var FluoCanvas = function() {
124
123
  c.lineTo(0, 0);
125
124
  if (i == 0) {
126
125
  c.save();
127
- c.fillStyle = FluoCon.RGB_WHITE;
126
+ c.fillStyle = FluoConstants.WHITE;
128
127
  c.fill();
129
128
  c.restore();
130
129
  }
@@ -138,7 +137,7 @@ var FluoCanvas = function() {
138
137
  c.save();
139
138
  c.beginPath();
140
139
  c.lineWidth = 1.4;
141
- c.fillStyle = FluoCon.RGB_WHITE;
140
+ c.fillStyle = FluoConstants.WHITE;
142
141
  c.arc(0, 0, height / 2 - 1, 0, Math.PI * 2, true);
143
142
  c.arc(0, 0, height / 2 - 2.3, 0, Math.PI * 2, true);
144
143
  c.stroke();
@@ -149,7 +148,7 @@ var FluoCanvas = function() {
149
148
  c.save();
150
149
  c.beginPath();
151
150
  c.lineWidth = 0.5;
152
- c.fillStyle = FluoCon.RGB_WHITE;
151
+ c.fillStyle = FluoConstants.WHITE;
153
152
  c.arc(0, 0, height / 2, 0, Math.PI * 2, true);
154
153
  c.arc(0, 0, height / 2 - 2.3, 0, Math.PI * 2, true);
155
154
  c.stroke();
@@ -295,7 +294,7 @@ var FluoCanvas = function() {
295
294
  };
296
295
  }();
297
296
 
298
- var FluoCan = function() {
297
+ var Fluo = function () {
299
298
 
300
299
  //
301
300
  // MISC METHODS
@@ -304,7 +303,7 @@ var FluoCan = function() {
304
303
  var children = getChildren(c, exp);
305
304
  var max = 0;
306
305
  for (var i = 0; i < children.length; i++) {
307
- var val = FluoCan[funcname](c, children[i]);
306
+ var val = Fluo[funcname](c, children[i]);
308
307
  if (val > max) max = val;
309
308
  }
310
309
  return max;
@@ -314,7 +313,7 @@ var FluoCan = function() {
314
313
  var children = getChildren(c, exp);
315
314
  var sum = 0;
316
315
  for (var i = 0; i < children.length; i++) {
317
- sum += FluoCan[funcname](c, children[i]);
316
+ sum += Fluo[funcname](c, children[i]);
318
317
  }
319
318
  return sum;
320
319
  }
@@ -323,7 +322,7 @@ var FluoCan = function() {
323
322
  var max = 0;
324
323
  if (title) max = c.measure(title);
325
324
  for (var attname in exp[1]) {
326
- var text = '' + attname + ': ' + fluoToJson(exp[1][attname], false);
325
+ var text = '' + attname + ': ' + JSON.stringify(exp[1][attname]);
327
326
  var l = c.measure(text);
328
327
  //if (attname.match(/^on[-\_](error|cancel)$/)) l += 30;
329
328
  if (l > max) max = l;
@@ -331,17 +330,6 @@ var FluoCan = function() {
331
330
  return max;
332
331
  }
333
332
 
334
- function childText (exp) {
335
- //var exp2 = exp[2];
336
- //if (exp2.length == 1 && ((typeof exp2[0]) == 'string')) return exp2[0];
337
- //return null;
338
- for (var k in exp[1]) {
339
- var v = exp[1][k];
340
- if (v == null) return k;
341
- }
342
- return null;
343
- }
344
-
345
333
  // returns the list of attribute names (sorted)
346
334
  //
347
335
  function attributeNames (exp) {
@@ -358,8 +346,10 @@ var FluoCan = function() {
358
346
  }
359
347
 
360
348
  function carriageReturn (c) {
361
- if (c.canvas.horizontal == true) c.translate(-FluoCon.LINE_HEIGHT, 0);
362
- else c.translate(0, FluoCon.LINE_HEIGHT);
349
+ if (c.canvas.horizontal == true) {
350
+ c.translate(-FluoConstants.LINE_HEIGHT, 0);
351
+ }
352
+ else c.translate(0, FluoConstants.LINE_HEIGHT);
363
353
  }
364
354
 
365
355
  function drawAttributes (c, exp, expname, namePlus, width, height) {
@@ -369,20 +359,12 @@ var FluoCan = function() {
369
359
  carriageReturn(c);
370
360
  }
371
361
 
372
- //var ct = strchild && childText(exp);
373
- var ct = childText(exp);
374
- if (namePlus && ct) {
375
- FluoCanvas.drawText(c, ct, width, height);
376
- carriageReturn(c);
377
- }
378
-
379
362
  var attname;
380
363
  var attnames = attributeNames(exp, expname);
381
364
 
382
365
  while (attname = attnames.shift()) {
383
366
 
384
- var v = exp[1][attname];
385
- if (v != null) v = fluoToJson(v, false);
367
+ var v = JSON.stringify(exp[1][attname]);
386
368
 
387
369
  if (attname.match(/^on[-\_]error$/)) {
388
370
  FluoCanvas.drawText(c, v, width, height, 'drawError');
@@ -394,12 +376,9 @@ var FluoCan = function() {
394
376
  }
395
377
  else {
396
378
  var t = attname;
397
- //alert(fluoToJson([ t, ct, namePlus ]));
398
- if (t != ct) {
399
- if (v != null) t = t + ': ' + v;
400
- FluoCanvas.drawText(c, t, width, height);
401
- carriageReturn(c);
402
- }
379
+ if (v != 'null') t = t + ': ' + v;
380
+ FluoCanvas.drawText(c, t, width, height);
381
+ carriageReturn(c);
403
382
  }
404
383
  }
405
384
  }
@@ -448,8 +427,8 @@ var FluoCan = function() {
448
427
 
449
428
  var GenericHandler = newHandler();
450
429
  GenericHandler.adjust = function (exp) {
451
- var ct = childText(exp);
452
- if (ct) exp[0] = exp[0] + ' ' + ct;
430
+ //var ct = childText(exp);
431
+ //if (ct) exp[0] = exp[0] + ' ' + ct;
453
432
  }
454
433
  GenericHandler.render = function (c, exp) {
455
434
  var width = this.getWidth(c, exp);
@@ -460,17 +439,16 @@ var FluoCan = function() {
460
439
  c.restore();
461
440
  };
462
441
  GenericHandler.getRealHeight = function (c, exp) {
463
- return 7 + (1 + attributeCount(exp)) * FluoCon.LINE_HEIGHT;
442
+ return 7 + (1 + attributeCount(exp)) * FluoConstants.LINE_HEIGHT;
464
443
  };
465
444
  GenericHandler.getRealWidth = function (c, exp) {
466
- //return 10 + attributeMaxWidth(c, exp, exp[0]);
467
- return Math.max(10 + attributeMaxWidth(c, exp, exp[0]), FluoCon.MIN_ACTIVITY_WIDTH);
445
+ return Math.max(10 + attributeMaxWidth(c, exp, exp[0]), FluoConstants.MIN_ACTIVITY_WIDTH);
468
446
  };
469
447
 
470
448
  var AttributeOnlyHandler = newHandler();
471
449
  AttributeOnlyHandler.adjust = function (exp) {
472
- var ct = childText(exp);
473
- if (ct) exp[0] = exp[0] + ' ' + ct;
450
+ //var ct = childText(exp);
451
+ //if (ct) exp[0] = exp[0] + ' ' + ct;
474
452
  }
475
453
  AttributeOnlyHandler.render = function (c, exp) {
476
454
  var width = this.getWidth(c, exp);
@@ -480,7 +458,7 @@ var FluoCan = function() {
480
458
  c.restore();
481
459
  };
482
460
  AttributeOnlyHandler.getRealHeight = function (c, exp) {
483
- return 7 + attributeCount(exp) * FluoCon.LINE_HEIGHT;
461
+ return 7 + attributeCount(exp) * FluoConstants.LINE_HEIGHT;
484
462
  };
485
463
  AttributeOnlyHandler.getRealWidth = function (c, exp) {
486
464
  return attributeMaxWidth(c, exp, exp[0]);
@@ -500,7 +478,7 @@ var FluoCan = function() {
500
478
  FluoCanvas.drawCrossInABox(c, height);
501
479
  };
502
480
  SubprocessHandler.getRealHeight = function (c, exp) {
503
- return 12 + 7 + (1 + attributeCount(exp)) * FluoCon.LINE_HEIGHT;
481
+ return 12 + 7 + (1 + attributeCount(exp)) * FluoConstants.LINE_HEIGHT;
504
482
  };
505
483
 
506
484
 
@@ -511,14 +489,16 @@ var FluoCan = function() {
511
489
  var width = this.getWidth(c, exp);
512
490
  var height = this.getHeight(c, exp);
513
491
  var attWidth = attributeMaxWidth(c, exp, exp[0]) + 7;
514
- var attHeight = attributeCount(exp) * FluoCon.LINE_HEIGHT;
492
+ var attHeight = attributeCount(exp) * FluoConstants.LINE_HEIGHT;
515
493
  var children = getChildren(c, exp);
516
494
  if (c.canvas.horizontal == true) {
517
495
  var w = attWidth;
518
496
  attWidth = attHeight;
519
497
  attHeight = w;
520
498
  }
521
- FluoCanvas.drawRoundedRect(c, width, height, 8);
499
+ if ((c.canvas.noOuterBorder != true) || (exp.expid != "0")) {
500
+ FluoCanvas.drawRoundedRect(c, width, height, 8);
501
+ }
522
502
  c.save();
523
503
  c.translate(-width/2 + attWidth/2 + 5 , 7);
524
504
  if (c.canvas.horizontal == true) c.translate(attHeight/2, 0);
@@ -529,8 +509,7 @@ var FluoCan = function() {
529
509
  for (var i = 0; i < children.length; i++) {
530
510
  var child = children[i];
531
511
  renderExp(c, child);
532
- //c.translate(0, 7 + FluoCan.getHeight(c, child));
533
- c.translate(0, FluoCan.getHeight(c, child));
512
+ c.translate(0, Fluo.getHeight(c, child));
534
513
  if (this.drawArrow && i < children.length -1) FluoCanvas.drawArrow(c, 10);
535
514
  c.translate(0, 10);
536
515
  }
@@ -581,7 +560,7 @@ var FluoCan = function() {
581
560
  };
582
561
  TextHandler.getText = function (exp) {
583
562
  var t = exp[0];
584
- var ct = childText(exp); if (ct) t += (' ' + ct);
563
+ //var ct = childText(exp); if (ct) t += (' ' + ct);
585
564
  for (var attname in exp[1]) {
586
565
  var v = exp[1][attname];
587
566
  t += (' ' + attname + ': "' + v + '"');
@@ -589,7 +568,7 @@ var FluoCan = function() {
589
568
  return t;
590
569
  };
591
570
  TextHandler.getRealHeight = function (c, exp) {
592
- return FluoCon.LINE_HEIGHT;
571
+ return FluoConstants.LINE_HEIGHT;
593
572
  };
594
573
  TextHandler.getRealWidth = function (c, exp) {
595
574
  return c.measure(this.getText(exp));
@@ -614,7 +593,7 @@ var FluoCan = function() {
614
593
  c.restore();
615
594
  };
616
595
  SymbolHandler.getRealHeight = function (c, exp) {
617
- return attributeCount(exp) * FluoCon.LINE_HEIGHT + SymbolHandler.SYMBOL_HEIGHT;
596
+ return attributeCount(exp) * FluoConstants.LINE_HEIGHT + SymbolHandler.SYMBOL_HEIGHT;
618
597
  };
619
598
  SymbolHandler.getRealWidth = function (c, exp) {
620
599
  return attributeMaxWidth(c, exp, exp[0]);
@@ -627,7 +606,7 @@ var FluoCan = function() {
627
606
 
628
607
  var VerticalHandler = newHandler();
629
608
  VerticalHandler.adjust = function (exp) {
630
- if (attributeCount(exp) > 0) exp[2].unshift([ '_atts_', exp[1], [] ]);
609
+ //if (attributeCount(exp) > 0) exp[2].unshift([ '_atts_', exp[1], [] ]);
631
610
  }
632
611
  VerticalHandler.render = function (c, exp) {
633
612
  c.save();
@@ -635,7 +614,7 @@ var FluoCan = function() {
635
614
  for (var i = 0; i < children.length; i++) {
636
615
  var child = children[i];
637
616
  renderExp(c, child);
638
- c.translate(0, FluoCan.getHeight(c, child));
617
+ c.translate(0, Fluo.getHeight(c, child));
639
618
  if (i < children.length - 1) {
640
619
  FluoCanvas.drawArrow(c, 14);
641
620
  c.translate(0, 14);
@@ -670,7 +649,7 @@ var FluoCan = function() {
670
649
  };
671
650
  HorizontalHandler.getHeaderHeight = function (c, exp) {
672
651
  if (c.canvas.horizontal == true) return 23 + attributeMaxWidth(c, exp);
673
- return 23 + attributeCount(exp) * FluoCon.LINE_HEIGHT;
652
+ return 23 + attributeCount(exp) * FluoConstants.LINE_HEIGHT;
674
653
  };
675
654
  HorizontalHandler.getChildrenHeight = function (c, exp) {
676
655
  return childrenMax(c, exp, 'getHeight');
@@ -690,7 +669,7 @@ var FluoCan = function() {
690
669
  var offset = -totalWidth/2;
691
670
  var dist = new Array(children.length);
692
671
  for (var i = 0; i < children.length; i++) {
693
- var cWidth = FluoCan.getWidth(c, children[i]);
672
+ var cWidth = Fluo.getWidth(c, children[i]);
694
673
  dist[i] = offset + cWidth / 2;
695
674
  offset += (cWidth + 3);
696
675
  }
@@ -712,27 +691,27 @@ var FluoCan = function() {
712
691
  this.renderHeaderLabel(c, exp);
713
692
  };
714
693
  HorizontalHandler.renderHeaderSymbol = function (c) {
715
- FluoCanvas.drawDiamond(c, FluoCon.LINE_HEIGHT);
694
+ FluoCanvas.drawDiamond(c, FluoConstants.LINE_HEIGHT);
716
695
  };
717
696
  HorizontalHandler.renderHeaderLabel = function (c, exp) {
718
697
  var width = attributeMaxWidth(c, exp);
719
- var height = attributeCount(exp) * FluoCon.LINE_HEIGHT;
698
+ var height = attributeCount(exp) * FluoConstants.LINE_HEIGHT;
720
699
  if (c.canvas.horizontal == true) {
721
700
  var w = width;
722
701
  width = height;
723
702
  height = w;
724
703
  }
725
704
  c.save();
726
- c.translate(0, FluoCon.LINE_HEIGHT);
705
+ c.translate(0, FluoConstants.LINE_HEIGHT);
727
706
  c.save();
728
- c.fillStyle = FluoCon.RGB_WHITE;
707
+ c.fillStyle = FluoConstants.WHITE;
729
708
  c.fillRect(-width/2, 0, width, height);
730
709
  c.restore();
731
710
  drawAttributes(c, exp, false, false, width, height);
732
711
  c.restore();
733
712
  };
734
713
  HorizontalHandler.renderChild = function (c, exp, childrenHeight) {
735
- var cheight = FluoCan.getHeight(c, exp);
714
+ var cheight = Fluo.getHeight(c, exp);
736
715
  renderExp(c, exp);
737
716
  c.beginPath();
738
717
  c.moveTo(0, cheight); c.lineTo(0, childrenHeight);
@@ -765,12 +744,21 @@ var FluoCan = function() {
765
744
  FluoCanvas.drawParaDiamond(c, 20);
766
745
  };
767
746
 
747
+ function hasNoCondition (attributes) {
748
+ if (attributes['test']) return false;
749
+ if (attributes['not']) return false;
750
+ for (k in attributes) {
751
+ if (attributes[k] == null) return false;
752
+ }
753
+ return true;
754
+ }
755
+
768
756
  var IfHandler = newHandler(HorizontalHandler);
769
757
  IfHandler.adjust = function (exp) {
770
758
  //
771
759
  // all the crazy legwork to adapt to the 'if' expression
772
760
  //
773
- if ( ! (exp[1]['test'] || exp[1]['not'])) {
761
+ if (hasNoCondition(exp[1])) {
774
762
  // ok, steal first exp
775
763
  var cond = exp[2].shift();
776
764
  if (cond) {
@@ -822,7 +810,7 @@ var FluoCan = function() {
822
810
  'jump': TextHandler,
823
811
  // 'commands'
824
812
 
825
- '_atts_': AttributeOnlyHandler,
813
+ //'_atts_': AttributeOnlyHandler,
826
814
  '_': GhostHandler
827
815
  };
828
816
 
@@ -876,15 +864,14 @@ var FluoCan = function() {
876
864
  context.rotate(-Math.PI/2);
877
865
  }
878
866
 
879
- context.mozTextStyle = "12px Helvetica Neue";
880
- context.font = "12px Helvetica Neue";
867
+ context.mozTextStyle = FluoConstants.FONT;
868
+ context.font = FluoConstants.FONT;
881
869
 
882
870
  var fs = context.fillStyle;
883
- context.fillStyle = FluoCon.RGB_WHITE;
871
+ context.fillStyle = FluoConstants.WHITE;
884
872
  context.fillRect(0, 0, context.canvas.width, context.canvas.height);
885
873
  context.fillStyle = fs;
886
874
 
887
- //context.translate(context.canvas.width/2, 0);
888
875
  var w = getWidth(context, flow);
889
876
  context.translate(w/2 + 1, 1); // aligning left
890
877
 
@@ -892,17 +879,13 @@ var FluoCan = function() {
892
879
 
893
880
  context.restore();
894
881
 
895
- //flow.width = getWidth(context, flow);
896
- //flow.height = getHeight(context, flow);
897
882
  getWidth(context, flow);
898
883
  getHeight(context, flow);
899
884
  }
900
885
 
901
886
  function highlight (c, highlight) {
902
887
  canvas = resolveCanvas(c);
903
- //clear(canvas);
904
- //renderFlow(canvas, canvas.flow, canvas.workitems, highlight);
905
- renderFlow(canvas, canvas.flow, {'highlight': highlight});
888
+ renderFlow(canvas, canvas.flow, { 'highlight': highlight });
906
889
  }
907
890
 
908
891
  function drawWorkitem (c, exp) {
@@ -913,7 +896,7 @@ var FluoCan = function() {
913
896
  c.translate(5, -14);
914
897
  }
915
898
  else {
916
- c.translate(20, -7);
899
+ c.translate(49, 2);
917
900
  }
918
901
  c.fillStyle = '#F4D850';
919
902
  c.moveTo(0, 0);
@@ -948,9 +931,9 @@ var FluoCan = function() {
948
931
  var h = getHeight(c, exp);
949
932
  var t = 7;
950
933
  c.save();
951
- c.fillStyle = FluoCon.RGB_HIGHLIGHT;
934
+ c.fillStyle = FluoConstants.HIGHLIGHT;
952
935
  c.fillRect(-w/2, 0, w, h);
953
- c.fillStyle = FluoCon.RGB_WHITE;
936
+ c.fillStyle = FluoConstants.WHITE;
954
937
  c.fillRect(-w/2 + t, 0 + t , w - 2 * t, h - 2 * t);
955
938
  c.restore();
956
939
  }
@@ -1002,20 +985,13 @@ var FluoCan = function() {
1002
985
  nc.hideMinor = canvas.hideMinor;
1003
986
  nc.horizontal = canvas.horizontal;
1004
987
  nc.workitems = canvas.workitems;
988
+ nc.noOuterBorder = canvas.noOuterBorder;
1005
989
 
1006
- //renderFlow(nc, canvas.flow, canvas.workitems, canvas.highlight);
1007
990
  renderFlow(nc, canvas.flow);
1008
991
  canvas.parentNode.replaceChild(nc, canvas);
1009
992
  }
1010
993
 
1011
994
  function neutralizeContext (c) {
1012
- //if (window.navigator.userAgent.match(/Firefox/)) return;
1013
- //c.mozDrawText = function (t) {
1014
- // // do nothing
1015
- //};
1016
- //c.mozMeasureText = function (t) {
1017
- // return t.length * 5;
1018
- //};
1019
995
  if (window.navigator.userAgent.match(/Firefox/)) {
1020
996
  c.write = function (t) {
1021
997
  this.mozDrawText(t);
@@ -6,6 +6,6 @@
6
6
 
7
7
  module RuoteKit
8
8
 
9
- VERSION = '2.1.8.1'
9
+ VERSION = '2.1.8.2'
10
10
  end
11
11
 
@@ -33,6 +33,6 @@
33
33
 
34
34
  :javascript
35
35
  var proc_rep = #{process_tree( @process )};
36
- FluoCan.renderFlow( 'fluo', proc_rep );
37
- FluoCan.crop('fluo');
38
- FluoCan.highlight('fluo', '#{@expression.fei.expid}');
36
+ Fluo.renderFlow( 'fluo', proc_rep );
37
+ Fluo.crop('fluo');
38
+ Fluo.highlight('fluo', '#{@expression.fei.expid}');
@@ -26,5 +26,5 @@
26
26
 
27
27
  :javascript
28
28
  var proc_rep = #{process_tree( @process )};
29
- FluoCan.renderFlow( 'fluo', proc_rep );
30
- FluoCan.crop('fluo');
29
+ Fluo.renderFlow( 'fluo', proc_rep );
30
+ Fluo.crop('fluo');
@@ -8,10 +8,8 @@
8
8
  %link{ :type => "text/css", :href => "/_ruote/stylesheets/rk.css", :rel => "stylesheet" }
9
9
  %script{ :type => "text/javascript", :src => "/_ruote/javascripts/SimplyButtons.js" }
10
10
  - if @_uses_fluo
11
- %script{ :type => "text/javascript", :src => "/_ruote/javascripts/fluo-can.js" }
11
+ %script{ :type => "text/javascript", :src => "/_ruote/javascripts/ruote-fluo.js" }
12
12
  %script{ :type => "text/javascript", :src => "/_ruote/javascripts/fluo-dial.js" }
13
- %script{ :type => "text/javascript", :src => "/_ruote/javascripts/fluo-json.js" }
14
- %script{ :type => "text/javascript", :src => "/_ruote/javascripts/fluo-tred.js" }
15
13
 
16
14
  :javascript
17
15
  window.onload = function() { SimplyButtons.init(); }
@@ -51,5 +51,5 @@
51
51
 
52
52
  :javascript
53
53
  var proc_rep = #{process_tree( @process )};
54
- FluoCan.renderFlow( 'fluo', proc_rep );
55
- FluoCan.crop('fluo');
54
+ Fluo.renderFlow( 'fluo', proc_rep );
55
+ Fluo.crop('fluo');
@@ -35,5 +35,5 @@
35
35
 
36
36
  :javascript
37
37
  var proc_rep = #{process_tree( @workitem )};
38
- FluoCan.renderFlow( 'fluo', proc_rep, { 'workitems' : ['#{@workitem.fei.expid}'] } );
39
- FluoCan.crop('fluo');
38
+ Fluo.renderFlow( 'fluo', proc_rep, { 'workitems' : ['#{@workitem.fei.expid}'] } );
39
+ Fluo.crop('fluo');
data/ruote-kit.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ruote-kit}
8
- s.version = "2.1.8.1"
8
+ s.version = "2.1.8.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["kenneth.kalmer@gmail.com"]
@@ -37,10 +37,8 @@ Gem::Specification.new do |s|
37
37
  "lib/ruote-kit/public/_ruote/images/bg_button_left_submit.gif",
38
38
  "lib/ruote-kit/public/_ruote/images/bg_button_right.gif",
39
39
  "lib/ruote-kit/public/_ruote/javascripts/SimplyButtons.js",
40
- "lib/ruote-kit/public/_ruote/javascripts/fluo-can.js",
41
40
  "lib/ruote-kit/public/_ruote/javascripts/fluo-dial.js",
42
- "lib/ruote-kit/public/_ruote/javascripts/fluo-json.js",
43
- "lib/ruote-kit/public/_ruote/javascripts/fluo-tred.js",
41
+ "lib/ruote-kit/public/_ruote/javascripts/ruote-fluo.js",
44
42
  "lib/ruote-kit/public/_ruote/stylesheets/SimplyButtons.css",
45
43
  "lib/ruote-kit/public/_ruote/stylesheets/base.css",
46
44
  "lib/ruote-kit/public/_ruote/stylesheets/rk.css",
metadata CHANGED
@@ -6,8 +6,8 @@ version: !ruby/object:Gem::Version
6
6
  - 2
7
7
  - 1
8
8
  - 8
9
- - 1
10
- version: 2.1.8.1
9
+ - 2
10
+ version: 2.1.8.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - kenneth.kalmer@gmail.com
@@ -166,10 +166,8 @@ files:
166
166
  - lib/ruote-kit/public/_ruote/images/bg_button_left_submit.gif
167
167
  - lib/ruote-kit/public/_ruote/images/bg_button_right.gif
168
168
  - lib/ruote-kit/public/_ruote/javascripts/SimplyButtons.js
169
- - lib/ruote-kit/public/_ruote/javascripts/fluo-can.js
170
169
  - lib/ruote-kit/public/_ruote/javascripts/fluo-dial.js
171
- - lib/ruote-kit/public/_ruote/javascripts/fluo-json.js
172
- - lib/ruote-kit/public/_ruote/javascripts/fluo-tred.js
170
+ - lib/ruote-kit/public/_ruote/javascripts/ruote-fluo.js
173
171
  - lib/ruote-kit/public/_ruote/stylesheets/SimplyButtons.css
174
172
  - lib/ruote-kit/public/_ruote/stylesheets/base.css
175
173
  - lib/ruote-kit/public/_ruote/stylesheets/rk.css
@@ -1,183 +0,0 @@
1
- // Copyright (C) 2008 Google Inc.
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
14
-
15
- /**
16
- * @param {string} json per RFC 4627
17
- * @return {Object|Array}
18
- * @author Mike Samuel <mikesamuel@gmail.com>
19
- */
20
- //var jsonParse = (function () {
21
- var fluoFromJson = (function () {
22
- var number
23
- = '(?:-?\\b(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\\b)';
24
- var oneChar = '(?:[^\\0-\\x08\\x0a-\\x1f\"\\\\]'
25
- + '|\\\\(?:[\"/\\\\bfnrt]|u[0-9A-Fa-f]{4}))';
26
- var string = '(?:\"' + oneChar + '*\")';
27
-
28
- // Will match a value in a well-formed JSON file.
29
- // If the input is not well-formed, may match strangely, but not in an unsafe
30
- // way.
31
- // Since this only matches value tokens, it does not match whitespace, colons,
32
- // or commas.
33
- var jsonToken = new RegExp(
34
- '(?:false|true|null|[\\{\\}\\[\\]]'
35
- + '|' + number
36
- + '|' + string
37
- + ')', 'g');
38
-
39
- // Matches escape sequences in a string literal
40
- var escapeSequence = new RegExp('\\\\(?:([^u])|u(.{4}))', 'g');
41
-
42
- // Decodes escape sequences in object literals
43
- var escapes = {
44
- '"': '"',
45
- '/': '/',
46
- '\\': '\\',
47
- 'b': '\b',
48
- 'f': '\f',
49
- 'n': '\n',
50
- 'r': '\r',
51
- 't': '\t'
52
- };
53
- function unescapeOne(_, ch, hex) {
54
- return ch ? escapes[ch] : String.fromCharCode(parseInt(hex, 16));
55
- }
56
-
57
- // A non-falsy value that coerces to the empty string when used as a key.
58
- var EMPTY_STRING = new String('');
59
- var SLASH = '\\';
60
-
61
- // Constructor to use based on an open token.
62
- var firstTokenCtors = { '{': Object, '[': Array };
63
-
64
- return function (json) {
65
- // Split into tokens
66
- var toks = json.match(jsonToken);
67
- // Construct the object to return
68
- var result;
69
- var tok = toks[0];
70
- if ('{' === tok) {
71
- result = {};
72
- } else if ('[' === tok) {
73
- result = [];
74
- } else {
75
- throw new Error(tok);
76
- }
77
-
78
- // If undefined, the key in an object key/value record to use for the next
79
- // value parsed.
80
- var key;
81
- // Loop over remaining tokens maintaining a stack of uncompleted objects and
82
- // arrays.
83
- var stack = [result];
84
- for (var i = 1, n = toks.length; i < n; ++i) {
85
- tok = toks[i];
86
-
87
- var cont;
88
- switch (tok.charCodeAt(0)) {
89
- default: // sign or digit
90
- cont = stack[0];
91
- cont[key || cont.length] = +(tok);
92
- key = void 0;
93
- break;
94
- case 0x22: // '"'
95
- tok = tok.substring(1, tok.length - 1);
96
- if (tok.indexOf(SLASH) !== -1) {
97
- tok = tok.replace(escapeSequence, unescapeOne);
98
- }
99
- cont = stack[0];
100
- if (!key) {
101
- if (cont instanceof Array) {
102
- key = cont.length;
103
- } else {
104
- key = tok || EMPTY_STRING; // Use as key for next value seen.
105
- break;
106
- }
107
- }
108
- cont[key] = tok;
109
- key = void 0;
110
- break;
111
- case 0x5b: // '['
112
- cont = stack[0];
113
- stack.unshift(cont[key || cont.length] = []);
114
- key = void 0;
115
- break;
116
- case 0x5d: // ']'
117
- stack.shift();
118
- break;
119
- case 0x66: // 'f'
120
- cont = stack[0];
121
- cont[key || cont.length] = false;
122
- key = void 0;
123
- break;
124
- case 0x6e: // 'n'
125
- cont = stack[0];
126
- cont[key || cont.length] = null;
127
- key = void 0;
128
- break;
129
- case 0x74: // 't'
130
- cont = stack[0];
131
- cont[key || cont.length] = true;
132
- key = void 0;
133
- break;
134
- case 0x7b: // '{'
135
- cont = stack[0];
136
- stack.unshift(cont[key || cont.length] = {});
137
- key = void 0;
138
- break;
139
- case 0x7d: // '}'
140
- stack.shift();
141
- break;
142
- }
143
- }
144
- // Fail if we've got an uncompleted object.
145
- if (stack.length) { throw new Error(); }
146
- return result;
147
- };
148
- })();
149
-
150
-
151
- //
152
- // the following code is ruote-fluo code, under the BSD license.
153
- //
154
- function fluoToJson (o, quotes) {
155
- if (quotes != false) quotes = true;
156
- if (o == null) return 'null';
157
- var t = (typeof o);
158
- if (t == 'undefined') return 'null' // really ?
159
- if (t == 'number') return o;
160
- if (t == 'string') {
161
- //return quotes ? '"' + o + '"' : o;
162
- if ( ! quotes) return o;
163
- return '"' +
164
- o
165
- .replace(/"/g, '\\"')
166
- .replace(/\r/g, '')
167
- .replace(/\n/g, '\\n') +
168
- '"';
169
- // this global replace works with safari (webkit) and ffox
170
- }
171
- if (o.constructor.toString().indexOf(' Array()') == 8) {
172
- var a = [];
173
- for (var i = 0; i < o.length; i++) a.push(fluoToJson(o[i]));
174
- return '[' + a.join(', ') + ']';
175
- }
176
- if (t == 'object') {
177
- var a = [];
178
- for (var key in o) a.push(fluoToJson(key) + ': ' + fluoToJson(o[key]));
179
- return '{' + a.join(', ') + '}';
180
- }
181
- return o.toString();
182
- }
183
-
@@ -1,515 +0,0 @@
1
-
2
- /*
3
- * Ruote - open source ruby workflow engine
4
- * (c) 2005-2009 John Mettraux
5
- *
6
- * Ruote is freely distributable under the terms
7
- * of a BSD-style license.
8
- * For details, see the OpenWFEru web site: http://openwferu.rubyforge.org
9
- *
10
- * This piece of hack was created during the RubyKaigi2008,
11
- * between Tsukuba and Akihabara.
12
- */
13
-
14
- //var flow = [ 'process-definition', { 'name': 'toto', 'revision': '1.0' }, [
15
- // [ 'sequence', {}, [
16
- // [ 'participant', { 'ref': 'alpha' }, [] ],
17
- // [ 'bravo', {}, [] ]
18
- // ]]
19
- // ]
20
- //]
21
-
22
- try {
23
- HTMLElement.prototype.firstChildOfClass = function (className) {
24
- for (var i=0; i < this.childNodes.length; i++) {
25
- var c = this.childNodes[i];
26
- if (c.className == className) return c;
27
- }
28
- return null;
29
- }
30
- } catch (e) {
31
- // probably testing via Rhino
32
- }
33
-
34
- String.prototype.tstrip = function () {
35
- var s = this;
36
- while (s.charAt(0) == ' ') s = s.substring(1);
37
- while (s.charAt(s.length - 1) == ' ') s = s.substring(0, s.length - 1);
38
- return s;
39
- }
40
- String.prototype.qstrip = function () {
41
- var s = this;
42
- if (s.match(/".*"/)) s = s.substring(1, s.length - 1);
43
- return s;
44
- }
45
- String.prototype.tqstrip = function () {
46
- return this.tstrip().qstrip();
47
- }
48
-
49
- var FluoTred = function () {
50
-
51
- //
52
- // it's easy to override this var to let FluoTred point to another root
53
- //
54
- // FluoTred.imageRoot = 'http://my.image.server.exmaple.com/img'
55
- //
56
- var imageRoot = '/images';
57
-
58
- var ExpressionHead = function () {
59
-
60
- function createButton (imgsrc, tooltip, callback) {
61
-
62
- var i = document.createElement("img");
63
- i.callback = callback;
64
- i.className = "tred_button";
65
- i.setAttribute('src', imgsrc);
66
- i.setAttribute('title', tooltip);
67
- i.setAttribute("onclick", "this.callback()");
68
- return i;
69
- }
70
-
71
- function addHeadButtons (expdiv) {
72
-
73
- var outOpacity = 0.0;
74
-
75
- var buttons = document.createElement('span');
76
- buttons.style.opacity = outOpacity;
77
-
78
- var root = findTredRoot(expdiv);
79
-
80
- expdiv.onmouseover = function () {
81
- buttons.style.opacity = 1.0;
82
- //var root = findTredRoot(expdiv);
83
- if (root.onOver) root.onOver(computeExpId(expdiv.parentNode));
84
- };
85
- expdiv.onmouseout = function () {
86
- buttons.style.opacity = outOpacity;
87
- //var root = findTredRoot(expdiv);
88
- if (root.onOver) root.onOver(null);
89
- };
90
-
91
- buttons.appendChild(createButton(
92
- FluoTred.imageRoot+'/btn-add.gif',
93
- 'add a child expression',
94
- function () {
95
- FluoTred.addExpression(expdiv.parentNode, [ '---', {}, [] ]);
96
- }));
97
-
98
- if (expdiv.parentNode.parentNode != root) {
99
-
100
- buttons.appendChild(createButton(
101
- FluoTred.imageRoot+'/btn-cut.gif',
102
- 'cut expression',
103
- function () {
104
- FluoTred.removeExpression(expdiv.parentNode);
105
- }));
106
- buttons.appendChild(createButton(
107
- FluoTred.imageRoot+'/btn-moveup.gif',
108
- 'move expression up',
109
- function () {
110
- FluoTred.moveExpression(expdiv.parentNode, -1);
111
- buttons.style.opacity = outOpacity;
112
- }));
113
- buttons.appendChild(createButton(
114
- FluoTred.imageRoot+'/btn-movedown.gif',
115
- 'move expression down',
116
- function () {
117
- FluoTred.moveExpression(expdiv.parentNode, +1);
118
- buttons.style.opacity = outOpacity;
119
- }));
120
- buttons.appendChild(createButton(
121
- FluoTred.imageRoot+'/btn-paste.gif',
122
- 'paste expression here',
123
- function () {
124
- var clip = document._tred_clipboard;
125
- if (clip) FluoTred.insertExpression(expdiv.parentNode, clip);
126
- }));
127
- }
128
-
129
- expdiv.appendChild(buttons);
130
- }
131
-
132
- var headPattern = /^(\S*)( [.]*[^:]*)?( .*)?$/;
133
- var keyPattern = /([^ :]+|".*") *:/;
134
-
135
- function quoteKeys (s) {
136
- var ss = '';
137
- while (s) {
138
- var m = s.match(keyPattern);
139
- if ( ! m) {
140
- ss += s;
141
- break;
142
- }
143
- ss += s.substring(0, m.index - 1);
144
- var m1 = m[1].tstrip();
145
- if (m1.match(/^".*"$/)) ss += m1;
146
- else ss += ('"' + m1 + '"');
147
- ss += ':';
148
- s = s.substring(m.index + m[0].length);
149
- }
150
- return ss;
151
- }
152
-
153
- function renderAttributes (h) {
154
- s = '';
155
- for (var k in h) {
156
- s += ('' + k + ': ' + fluoToJson(h[k]) + ', ');
157
- }
158
- if (s.length > 1) s = s.substring(0, s.length - 2);
159
- return s;
160
- }
161
-
162
- return {
163
-
164
- render: function (node, exp) {
165
-
166
- var expname = exp[0];
167
-
168
- var text = '';
169
- if ((typeof exp[2][0]) == 'string') text = exp[2].shift();
170
-
171
- //var atts = fluoToJson(exp[1]);
172
- //atts = atts.substring(1, atts.length - 1);
173
- var atts = renderAttributes(exp[1]);
174
-
175
- var d = document.createElement('div');
176
- d.setAttribute('class', 'tred_exp');
177
- node.appendChild(d);
178
-
179
- var sen = document.createElement('span');
180
- sen.setAttribute('class', 'tred_exp_span tred_expression_name');
181
- sen.appendChild(document.createTextNode(expname));
182
- d.appendChild(sen);
183
-
184
- var ses = document.createElement('span');
185
- ses.setAttribute('class', 'tred_exp_span tred_expression_string');
186
- var t = text;
187
- if (t != '') t = ' ' + t;
188
- ses.appendChild(document.createTextNode(t));
189
- d.appendChild(ses);
190
-
191
- var sea = document.createElement('span');
192
- sea.setAttribute('class', 'tred_exp_span tred_expression_atts');
193
- sea.appendChild(document.createTextNode(' ' + atts));
194
- d.appendChild(sea);
195
-
196
- addHeadButtons(d);
197
-
198
- var onblur = function () {
199
-
200
- var p = d.parentNode;
201
- var d2 = ExpressionHead.render(p, ExpressionHead.parse(this.value));
202
- p.replaceChild(d2, d);
203
-
204
- triggerChange(p); // trigger onChange()...
205
- };
206
-
207
- var onkeyup = function (evt) {
208
-
209
- var e = evt || window.event;
210
- var c = e.charCode || e.keyCode;
211
- if (c == 13) this.blur();
212
-
213
- return false;
214
- }
215
-
216
- var onclick = function () {
217
- d.removeChild(sen);
218
- d.removeChild(ses);
219
- var input = document.createElement('input');
220
- input.setAttribute('type', 'text');
221
- input.value = expname + ' ' + atts;
222
- if (text != '') input.value = expname + ' ' + text + ' ' + atts;
223
- d.replaceChild(input, sea);
224
- input.onblur = onblur;
225
- input.onkeyup = onkeyup;
226
- input.focus();
227
- };
228
-
229
- sen.onclick = onclick;
230
- ses.onclick = onclick;
231
- sea.onclick = onclick;
232
-
233
- return d;
234
- },
235
-
236
- parseAttributes: function (s) {
237
- return fluoFromJson("{" + quoteKeys(s) + "}");
238
- },
239
-
240
- parse: function (s) {
241
-
242
- var m = s.match(headPattern);
243
-
244
- if (m == null) return [ '---', {}, [] ];
245
-
246
- var expname = m[1];
247
-
248
- var children = [];
249
- if (m[2]) {
250
- var t = m[2].tstrip();
251
- if (t.match(/".*"/)) t = t.substring(1, t.length - 1);
252
- if (t != '') children.push(t);
253
- }
254
-
255
- atts = ExpressionHead.parseAttributes(m[3]);
256
-
257
- return [ expname, atts, children ];
258
- },
259
-
260
- toExp: function (node) {
261
-
262
- node = node.firstChild;
263
-
264
- var name = node.childNodes[0].firstChild.nodeValue;
265
- var text = node.childNodes[1].firstChild.nodeValue;
266
- var atts = node.childNodes[2].firstChild.nodeValue;
267
-
268
- atts = ExpressionHead.parseAttributes(atts);
269
-
270
- var children = [];
271
- if (text != '') children.push(text.tstrip());
272
- // child is just a string...
273
-
274
- return [ name, atts, children ];
275
- }
276
- };
277
- }();
278
-
279
- function asJson (node) {
280
-
281
- if ((typeof node) == 'string')
282
- node = document.getElementById(node);
283
-
284
- return fluoToJson(toTree(node));
285
- }
286
-
287
- function renderEnding (node, exp) {
288
-
289
- var ending = document.createElement('div');
290
- ending.className = 'tred_text';
291
- if (exp[2].length > 0) ending.appendChild(document.createTextNode('end'));
292
- node.appendChild(ending);
293
- }
294
-
295
- function renderExpressionString (node, s) {
296
-
297
- var opening = document.createElement('div');
298
-
299
- var sname = document.createElement('span');
300
- sname.appendChild(document.createTextNode(s));
301
- sname.setAttribute('onclick', 'EditableSpan.toInput(this);');
302
- sname.className = 'tred_expression_string';
303
- opening.appendChild(sname);
304
-
305
- node.appendChild(opening);
306
- }
307
-
308
- function addExpression (parentExpNode, exp) {
309
-
310
- var end = parentExpNode.lastChild;
311
- var node = renderExpression(parentExpNode, exp);
312
- parentExpNode.replaceChild(node, end);
313
- parentExpNode.appendChild(end);
314
-
315
- if (end.childNodes.length == 0)
316
- end.appendChild(document.createTextNode('end'));
317
-
318
- triggerChange(parentExpNode);
319
- }
320
-
321
- function removeExpression (expNode) {
322
-
323
- var p = expNode.parentNode;
324
- p.removeChild(expNode);
325
-
326
- if (p.childNodes.length == 2)
327
- p.lastChild.removeChild(p.lastChild.firstChild);
328
-
329
- document._tred_clipboard = toTree(expNode);
330
-
331
- triggerChange(p);
332
- }
333
-
334
- function renderExpression (parentNode, exp, isRootExp) {
335
-
336
- //
337
- // draw expression
338
-
339
- var node = document.createElement('div');
340
- node.className = 'tred_expression';
341
-
342
- if ( ! isRootExp)
343
- node.setAttribute('style', 'margin-left: 14px;');
344
-
345
- parentNode.appendChild(node);
346
-
347
- if ( ! (exp instanceof Array)) {
348
- renderExpressionString(node, exp.toString());
349
- return;
350
- }
351
-
352
- ExpressionHead.render(node, exp);
353
-
354
- //
355
- // draw children
356
-
357
- for (var i=0; i < exp[2].length; i++) renderExpression(node, exp[2][i]);
358
-
359
- //
360
- // over
361
-
362
- renderEnding(node, exp);
363
-
364
- return node;
365
- }
366
-
367
- function renderFlow (parentNode, flow) {
368
-
369
- parentNode.className = 'tred_root';
370
-
371
- renderExpression(parentNode, flow, true);
372
-
373
- parentNode.stack = []; // the undo stack
374
- parentNode.currentTree = flow;
375
- }
376
-
377
- function moveExpression (elt, delta) {
378
-
379
- var p = elt.parentNode;
380
-
381
- if (delta == -1) { // move up
382
- if (elt.previousSibling.className != 'tred_expression') return;
383
- p.insertBefore(elt, elt.previousSibling);
384
- }
385
- else { // move down
386
- if (elt.nextSibling.className != 'tred_expression') return;
387
- p.insertBefore(elt, elt.nextSibling.nextSibling);
388
- }
389
-
390
- FluoTred.triggerChange(p);
391
- }
392
-
393
- function insertExpression (before, exp) {
394
-
395
- var newNode = renderExpression(before.parentNode, exp);
396
-
397
- before.parentNode.insertBefore(newNode, before);
398
-
399
- FluoTred.triggerChange(before.parentNode);
400
- }
401
-
402
- function triggerChange (elt) {
403
-
404
- var tredRoot = findTredRoot(elt);
405
- var tree = toTree(tredRoot);
406
-
407
- stack(tredRoot, tree);
408
-
409
- //FluoTred.onChange(tree);
410
- if (tredRoot.onChange) tredRoot.onChange(tree);
411
- }
412
-
413
- function stack(root, tree) {
414
- root.stack.push(root.currentTree);
415
- root.currentTree = tree;
416
- }
417
-
418
- function undo (root) {
419
-
420
- if ((typeof root) == 'string') root = document.getElementById(root);
421
- if (root.stack.length < 1) return;
422
-
423
- while (root.firstChild != null) root.removeChild(root.firstChild);
424
-
425
- var tree = root.stack.pop();
426
-
427
- root.currentTree = tree;
428
- renderExpression(root, tree, true);
429
-
430
- if (root.onChange) root.onChange(tree);
431
- }
432
-
433
- function findTredRoot (node) {
434
-
435
- if (node.className == 'tred_root') return node;
436
- return findTredRoot(node.parentNode);
437
- }
438
-
439
- function computeExpId (node, from, expid) {
440
-
441
- if (from == null) {
442
- from = findTredRoot(node);
443
- expid = '';
444
- }
445
- if (from == node) return expid.substring(1, expid.length);
446
-
447
- var divs = from.childNodes;
448
- var childid = -1;
449
-
450
- for (var i=0; i<divs.length; i++) {
451
- var e = divs[i];
452
- if (e.nodeType != 1) continue;
453
- if (e.className != 'tred_expression') continue;
454
- childid += 1;
455
- var ei = computeExpId(node, e, expid + '.' + childid);
456
- if (ei != null) return ei;
457
- }
458
-
459
- return null;
460
- }
461
-
462
- function toTree (node) {
463
-
464
- node.focus();
465
- //
466
- // making sure all the input boxes get blurred...
467
-
468
- if (node.className != 'tred_expression') {
469
- node = node.firstChildOfClass('tred_expression');
470
- }
471
-
472
- //
473
- // expression itself
474
-
475
- var exp = ExpressionHead.toExp(node);
476
-
477
- //
478
- // children
479
-
480
- var divs = node.childNodes;
481
-
482
- var children = exp[2];
483
-
484
- for (var i=0; i<divs.length; i++) {
485
- var e = divs[i];
486
- if (e.nodeType != 1) continue;
487
- if (e.className != 'tred_expression') continue;
488
- children.push(toTree(e));
489
- }
490
-
491
- //
492
- // done
493
-
494
- return exp;
495
- }
496
-
497
- //
498
- // public methods
499
- //
500
- return {
501
-
502
- ExpressionHead: ExpressionHead, // for testing purposes
503
-
504
- renderFlow: renderFlow,
505
- addExpression: addExpression,
506
- removeExpression: removeExpression,
507
- moveExpression: moveExpression,
508
- insertExpression: insertExpression,
509
- triggerChange: triggerChange,
510
- undo: undo,
511
- asJson: asJson,
512
- imageRoot: imageRoot
513
- };
514
- }();
515
-