1+ import  *  as  mim  from  "mimbl" 
2+ import  { IMainContainer }  from  "./Row" 
3+ import  { Store }  from  "./Store" 
4+ import  { TBody }  from "./TBody" 
5+ 
6+ 
7+ // var startTime; 
8+ // var lastMeasure; 
9+ // var startMeasure = function(name) { 
10+ //     //console.timeStamp(name); 
11+ //     startTime = performance.now(); 
12+ //     lastMeasure = name; 
13+ // } 
14+ // var stopMeasure = function() { 
15+ //     var last = lastMeasure; 
16+ //     if (lastMeasure) { 
17+ //         window.setTimeout(function () { 
18+ //             lastMeasure = null; 
19+ //             var stop = performance.now(); 
20+ //             var duration = 0; 
21+ //             console.log(last+" took "+(stop-startTime)); 
22+ //         }, 0); 
23+ //     } 
24+ // } 
25+ 
26+ export  class  Main  extends  mim . Component  implements  IMainContainer 
27+ { 
28+     store : Store ; 
29+     tbody : TBody ; 
30+ 
31+     constructor ( ) 
32+     { 
33+         super ( ) ; 
34+ 
35+         this . add  =  this . add . bind ( this ) ; 
36+         this . run  =  this . run . bind ( this ) ; 
37+         this . update  =  this . update . bind ( this ) ; 
38+         this . runLots  =  this . runLots . bind ( this ) ; 
39+         this . clear  =  this . clear . bind ( this ) ; 
40+         this . swapRows  =  this . swapRows . bind ( this ) ; 
41+ 
42+         this . store  =  new  Store ( ) ;         
43+         this . tbody  =  new  TBody (  this ) ; 
44+ 
45+         ( window  as  any ) . app  =  this ; 
46+     } 
47+ 
48+     // schedulePrintDuration() { 
49+     //     this.callMe( () => stopMeasure(), false); 
50+     // } 
51+ 
52+     run ( )  { 
53+         // startMeasure("run"); 
54+         this . tbody . run ( ) ; 
55+         // this.schedulePrintDuration(); 
56+     } 
57+     
58+     add ( )  { 
59+         // startMeasure("add"); 
60+         this . tbody . add ( ) ; 
61+         // this.schedulePrintDuration(); 
62+     } 
63+     
64+     update ( )  { 
65+         // startMeasure("update"); 
66+         this . tbody . update ( ) ; 
67+         // this.schedulePrintDuration(); 
68+     } 
69+     
70+     runLots ( )  { 
71+         // startMeasure("runLots"); 
72+         this . tbody . runLots ( ) ; 
73+         // this.schedulePrintDuration(); 
74+     } 
75+     
76+     clear ( )  { 
77+         // startMeasure("clear"); 
78+         this . tbody . clear ( ) ; 
79+         this . tbody  =  new  TBody (  this ) ; 
80+         this . updateMe ( ) ; 
81+         // this.schedulePrintDuration(); 
82+     } 
83+     
84+     swapRows ( )  { 
85+         // startMeasure("swapRows"); 
86+         this . tbody . swapRows ( ) ; 
87+         // this.schedulePrintDuration(); 
88+     } 
89+     
90+     onSelectRowClicked ( row ) 
91+     { 
92+         // startMeasure("select"); 
93+         this . tbody . onSelectRowClicked ( row ) ; 
94+         // this.schedulePrintDuration(); 
95+     } 
96+     
97+     onDeleteRowClicked ( row ) 
98+     { 
99+         // startMeasure("delete"); 
100+         this . tbody . onDeleteRowClicked ( row ) ; 
101+         // this.schedulePrintDuration(); 
102+     } 
103+     
104+     render ( ) 
105+     { 
106+         return  ( < div  class = "container" > 
107+             < div  class = "jumbotron" > 
108+                 < div  class = "row" > 
109+                     < div  class = "col-md-6" > 
110+                         < h1 > Mimbl</ h1 > 
111+                     </ div > 
112+                     < div  class = "col-md-6" > 
113+                         < div  class = "row" > 
114+                             < div  class = "col-sm-6 smallpad" > 
115+                                 < button  type = "button"  class = "btn btn-primary btn-block"  id = "run"  click = { this . run } > Create 1,000 rows</ button > 
116+                             </ div > 
117+                             < div  class = "col-sm-6 smallpad" > 
118+                                 < button  type = "button"  class = "btn btn-primary btn-block"  id = "runlots"  click = { this . runLots } > Create 10,000 rows</ button > 
119+                             </ div > 
120+                             < div  class = "col-sm-6 smallpad" > 
121+                                 < button  type = "button"  class = "btn btn-primary btn-block"  id = "add"  click = { this . add } > Append 1,000 rows</ button > 
122+                             </ div > 
123+                             < div  class = "col-sm-6 smallpad" > 
124+                                 < button  type = "button"  class = "btn btn-primary btn-block"  id = "update"  click = { this . update } > Update every 10th row</ button > 
125+                             </ div > 
126+                             < div  class = "col-sm-6 smallpad" > 
127+                                 < button  type = "button"  class = "btn btn-primary btn-block"  id = "clear"  click = { this . clear } > Clear</ button > 
128+                             </ div > 
129+                             < div  class = "col-sm-6 smallpad" > 
130+                                 < button  type = "button"  class = "btn btn-primary btn-block"  id = "swaprows"  click = { this . swapRows } > Swap Rows</ button > 
131+                             </ div > 
132+                         </ div > 
133+                     </ div > 
134+                 </ div > 
135+             </ div > 
136+             < table  class = "table table-hover table-striped test-data"  updateStrategy = { { allowKeyedNodeRecycling :false } } > 
137+                 { this . tbody } 
138+             </ table > 
139+             < span  class = "preloadicon glyphicon glyphicon-remove"  aria-hidden = "true" > </ span > 
140+         </ div > ) ; 
141+     } 
142+ } 
143+ 
144+ mim . mount (  < Main /> ,  document . getElementById ( 'main' ) ) ; 
0 commit comments