@@ -26,7 +26,7 @@ sf.controller.run('bench-mark', function(self, root){
2626 for ( var i = 0 ; i < count ; i ++ )
2727 data . push ( {
2828 id : nextId ++ ,
29- status :'' ,
29+ isSelected :'' ,
3030 label : adjectives [ _random ( adjectives . length ) ] + " " + colours [ _random ( colours . length ) ] + " " + nouns [ _random ( nouns . length ) ]
3131 } ) ;
3232
@@ -37,7 +37,7 @@ sf.controller.run('bench-mark', function(self, root){
3737 if ( self . selected === - 1 ) return ;
3838
3939 if ( self . list [ self . selected ] !== undefined ) {
40- self . list [ self . selected ] . status = '' ;
40+ self . list [ self . selected ] . isSelected = false ;
4141 self . list . softRefresh ( self . selected ) ;
4242 }
4343
@@ -46,64 +46,64 @@ sf.controller.run('bench-mark', function(self, root){
4646
4747 // Handle button
4848 self . b_run = function ( ) {
49- Measurer . start ( "run" ) ;
49+ // Measurer.start("run");
5050 self . list = self . buildData ( ) ;
5151 self . selected = - 1 ;
52- Measurer . stop ( ) ;
52+ // Measurer.stop();
5353 }
5454
5555 self . b_runlots = function ( ) {
56- Measurer . start ( "runLots" ) ;
56+ // Measurer.start("runLots");
5757 self . list = self . buildData ( 10000 ) ;
5858 self . selected = - 1 ;
59- Measurer . stop ( ) ;
59+ // Measurer.stop();
6060 }
6161
6262 self . b_add = function ( ) {
63- Measurer . start ( "add" ) ;
63+ // Measurer.start("add");
6464 self . list = self . list . concat ( self . buildData ( 1000 ) ) ;
65- Measurer . stop ( ) ;
65+ // Measurer.stop();
6666 }
6767
6868 self . b_update = function ( ) {
69- Measurer . start ( "update" ) ;
69+ // Measurer.start("update");
7070 for ( var i = 0 ; i < self . list . length ; i += 10 ) {
7171 self . list [ i ] . label += ' !!!' ;
7272 self . list . softRefresh ( i ) ;
7373 }
74- Measurer . stop ( ) ;
74+ // Measurer.stop();
7575 }
7676
7777 self . b_clear = function ( ) {
78- Measurer . start ( "clear" ) ;
78+ // Measurer.start("clear");
7979 self . list . splice ( 0 ) ;
8080 self . selected = - 1 ;
81- Measurer . stop ( ) ;
81+ // Measurer.stop();
8282 }
8383
8484 self . b_swaprows = function ( ) {
85- Measurer . start ( "swapRows" ) ;
85+ // Measurer.start("swapRows");
8686
8787 if ( self . list . length > 998 )
8888 self . list . swap ( 1 , 998 ) ;
8989
90- Measurer . stop ( ) ;
90+ // Measurer.stop();
9191 }
9292
9393 self . b_select = function ( el ) {
94- Measurer . start ( "select" ) ;
94+ // Measurer.start("select");
9595 self . unselect ( ) ;
9696
9797 var rowIndex = $ . parent ( el , '[sf-bind-list]' ) ;
9898 self . selected = rowIndex = sf . model . index ( rowIndex ) ;
9999
100- self . list [ rowIndex ] . status = 'danger' ;
100+ self . list [ rowIndex ] . isSelected = true ;
101101 self . list . softRefresh ( rowIndex ) ;
102- Measurer . stop ( ) ;
102+ // Measurer.stop();
103103 }
104104
105105 self . b_remove = function ( el ) {
106- Measurer . start ( "delete" ) ;
106+ // Measurer.start("delete");
107107
108108 var rowIndex = $ . parent ( el , '[sf-bind-list]' ) ;
109109 rowIndex = sf . model . index ( rowIndex ) ;
@@ -113,7 +113,7 @@ sf.controller.run('bench-mark', function(self, root){
113113 if ( rowIndex === self . selected )
114114 self . selected = - 1 ;
115115
116- Measurer . stop ( ) ;
116+ // Measurer.stop();
117117 }
118118} ) ;
119119
@@ -139,5 +139,21 @@ sf.controller.run('measurer', function(self){
139139 }
140140} ) ;
141141
142- // We're not using dynamic resource loader
143- sf . loader . off ( ) ;
142+ // Fix for (https://github.com/krausest/js-framework-benchmark/pull/519#issuecomment-464855788)
143+ sf ( function ( ) {
144+ tbody . innerHTML =
145+ `<tr sf-repeat-this="x in list" class="{{ x.isSelected ? 'danger' : '' }}">
146+ <td class="col-md-1">{{ x.id }}</td>
147+ <td class="col-md-4">
148+ <a class="lbl" sf-click="b_select(this)">{{ x.label }}</a>
149+ </td>
150+ <td class="col-md-1">
151+ <a class="remove" sf-click="b_remove(this)">
152+ <span class="remove glyphicon glyphicon-remove" aria-hidden="true"></span>
153+ </a>
154+ </td>
155+ <td class="col-md-6"></td>
156+ </tr>` ;
157+
158+ sf . model . init ( tbody ) ;
159+ } ) ;
0 commit comments