1- var $table = null ;
2-
31function Array2DTracer ( module ) {
42 if ( Tracer . call ( this , module || Array2DTracer ) ) {
53 Array2DTracer . prototype . init . call ( this ) ;
@@ -11,8 +9,8 @@ function Array2DTracer(module) {
119Array2DTracer . prototype = $ . extend ( true , Object . create ( Tracer . prototype ) , {
1210 constructor : Array2DTracer ,
1311 init : function ( ) {
14- $table = $ ( '<div class="mtbl-table">' ) ;
15- this . $container . append ( $table ) ;
12+ this . $table = this . capsule . $table = $ ( '<div class="mtbl-table">' ) ;
13+ this . $container . append ( this . $table ) ;
1614 } ,
1715 resize : function ( ) {
1816 Tracer . prototype . resize . call ( this ) ;
@@ -40,10 +38,10 @@ Array2DTracer.prototype = $.extend(true, Object.create(Tracer.prototype), {
4038 return true ;
4139 }
4240
43- $table . empty ( ) ;
41+ this . $table . empty ( ) ;
4442 for ( var i = 0 ; i < D . length ; i ++ ) {
4543 var $row = $ ( '<div class="mtbl-row">' ) ;
46- $table . append ( $row ) ;
44+ this . $table . append ( $row ) ;
4745 for ( var j = 0 ; j < D [ i ] . length ; j ++ ) {
4846 var $cell = $ ( '<div class="mtbl-cell">' )
4947 . css ( this . getCellCss ( ) )
@@ -156,7 +154,7 @@ Array2DTracer.prototype = $.extend(true, Object.create(Tracer.prototype), {
156154
157155 switch ( step . type ) {
158156 case 'notifying' :
159- var $row = $table . find ( '.mtbl-row' ) . eq ( step . x ) ;
157+ var $row = this . $table . find ( '.mtbl-row' ) . eq ( step . x ) ;
160158 $row . find ( '.mtbl-cell' ) . eq ( step . y ) . text ( step . value ) ;
161159 case 'notified' :
162160 case 'select' :
@@ -192,11 +190,11 @@ Array2DTracer.prototype = $.extend(true, Object.create(Tracer.prototype), {
192190 refresh : function ( ) {
193191 Tracer . prototype . refresh . call ( this ) ;
194192
195- var $parent = $table . parent ( ) ;
196- var top = $parent . height ( ) / 2 - $table . height ( ) / 2 + this . viewY ;
197- var left = $parent . width ( ) / 2 - $table . width ( ) / 2 + this . viewX ;
198- $table . css ( 'margin-top' , top ) ;
199- $table . css ( 'margin-left' , left ) ;
193+ var $parent = this . $table . parent ( ) ;
194+ var top = $parent . height ( ) / 2 - this . $table . height ( ) / 2 + this . viewY ;
195+ var left = $parent . width ( ) / 2 - this . $table . width ( ) / 2 + this . viewX ;
196+ this . $table . css ( 'margin-top' , top ) ;
197+ this . $table . css ( 'margin-left' , left ) ;
200198 } ,
201199 mousedown : function ( e ) {
202200 Tracer . prototype . mousedown . call ( this , e ) ;
@@ -240,7 +238,7 @@ Array2DTracer.prototype = $.extend(true, Object.create(Tracer.prototype), {
240238 } ,
241239 paintColor : function ( sx , sy , ex , ey , colorClass , addClass ) {
242240 for ( var i = sx ; i <= ex ; i ++ ) {
243- var $row = $table . find ( '.mtbl-row' ) . eq ( i ) ;
241+ var $row = this . $table . find ( '.mtbl-row' ) . eq ( i ) ;
244242 for ( var j = sy ; j <= ey ; j ++ ) {
245243 var $cell = $row . find ( '.mtbl-cell' ) . eq ( j ) ;
246244 if ( addClass ) $cell . addClass ( colorClass ) ;
@@ -249,7 +247,7 @@ Array2DTracer.prototype = $.extend(true, Object.create(Tracer.prototype), {
249247 }
250248 } ,
251249 clearColor : function ( ) {
252- $table . find ( '.mtbl-cell' ) . removeClass ( Object . keys ( this . colorClass ) . join ( ' ' ) ) ;
250+ this . $table . find ( '.mtbl-cell' ) . removeClass ( Object . keys ( this . colorClass ) . join ( ' ' ) ) ;
253251 } ,
254252 colorClass : {
255253 selected : 'selected' ,
0 commit comments