@@ -57,13 +57,19 @@ COMPONENT('configuration', 'dateformat:yyyy-MM-dd', function(self, config, cls)
57
57
prev . element . aclass ( cls + '-last' ) ;
58
58
} ;
59
59
60
- self . types = { } ;
60
+ self . compilefn = function ( fn ) {
61
+ var index = fn . indexOf ( '=>' ) ;
62
+ if ( index !== - 1 )
63
+ fn = fn . substring ( index + 2 ) ;
64
+ return new Function ( 'value' , 'model' , fn ) ;
65
+ } ;
61
66
67
+ self . types = { } ;
62
68
self . types . template = function ( item ) {
63
69
64
70
var icon = '' ;
65
71
if ( item . icon )
66
- icon = '<i class="' + self . faicon ( item . icon ) + '"></i>' ;
72
+ icon = '<i class="' + self . icon ( item . icon ) + '"></i>' ;
67
73
68
74
var builder = [ ] ;
69
75
var align = item . align || 0 ;
@@ -101,30 +107,35 @@ COMPONENT('configuration', 'dateformat:yyyy-MM-dd', function(self, config, cls)
101
107
val = T . prepare ( val ) ;
102
108
if ( old != val ) {
103
109
model [ item . id ] = val ;
104
- if ( empty )
105
- SET ( self . path , model ) ;
106
- else
107
- UPD ( self . path + '.' + item . id , 2 ) ;
110
+
111
+ if ( empty ) {
112
+ self . bind ( '@modified @touched' , model ) ;
113
+ } else {
114
+ self . bind ( '@modified @touched' ) ;
115
+ UPD ( self . path . toString ( ) + '.' + item . id ) ;
116
+ }
117
+
108
118
self . change ( true ) ;
109
119
return true ;
110
120
}
111
121
} ;
112
122
113
123
var el = $ ( builder . join ( '' ) ) ;
114
124
item . required && el . aclass ( cls + '-required' ) ;
125
+
115
126
var control = el . find ( cls2 + '-item-control' ) ;
116
127
var type = self . types [ item . type || 'string' ] ( item , control , set , get ) ;
128
+
117
129
T = type ;
118
130
type . element = el ;
119
131
type . control = control ;
120
132
type . id = item . id ;
121
133
type . required = item . required ;
122
134
123
- var fndisable = item . disable ? FN ( item . disable ) : null ;
124
-
135
+ var fndisable = item . disable ? self . compilefn ( item . disable ) : null ;
125
136
if ( fndisable ) {
126
137
type . $disable = function ( model ) {
127
- var is = ! ! fndisable ( model ) ;
138
+ var is = ! ! fndisable ( model , model ) ;
128
139
item . button && type . element . find ( cls2 + '-button button' ) . prop ( 'disabled' , is ) ;
129
140
type . isdisabled = is ;
130
141
return is ;
@@ -134,10 +145,10 @@ COMPONENT('configuration', 'dateformat:yyyy-MM-dd', function(self, config, cls)
134
145
type . isdisabled = false ;
135
146
}
136
147
137
- var fnvisible = item . visible ? FN ( item . visible ) : null ;
148
+ var fnvisible = item . visible ? self . compilefn ( item . visible ) : null ;
138
149
if ( fnvisible ) {
139
150
type . $visible = function ( model ) {
140
- var is = ! ! fnvisible ( model ) ;
151
+ var is = ! ! fnvisible ( model , model ) ;
141
152
type . isvisible = is ;
142
153
return is ;
143
154
} ;
@@ -160,11 +171,11 @@ COMPONENT('configuration', 'dateformat:yyyy-MM-dd', function(self, config, cls)
160
171
} ;
161
172
162
173
self . types . string = function ( item , el , set , get ) {
174
+
163
175
var obj = { } ;
164
176
165
177
obj . bind = function ( val ) {
166
178
var input = el . find ( 'input' ) ;
167
-
168
179
if ( item . camouflage ) {
169
180
var arr = [ ] ;
170
181
for ( var i = 0 ; i < val . length ; i ++ )
@@ -272,7 +283,7 @@ COMPONENT('configuration', 'dateformat:yyyy-MM-dd', function(self, config, cls)
272
283
273
284
var icon = '' ;
274
285
if ( item . icon )
275
- icon = '<i class="' + self . faicon ( item . icon ) + '"></i>' ;
286
+ icon = '<i class="' + self . icon ( item . icon ) + '"></i>' ;
276
287
277
288
var builder = [ '<div>' ] ;
278
289
builder . push ( '<div class="{0}-group">{1}</div>' . format ( cls , icon + item . name || item . text ) ) ;
@@ -576,7 +587,7 @@ COMPONENT('configuration', 'dateformat:yyyy-MM-dd', function(self, config, cls)
576
587
var builder = [ ] ;
577
588
578
589
for ( var i = 0 ; i < items . length ; i ++ )
579
- builder . push ( '<div class="{0}-type-selectable-item"><i class="{icon}"></i><span>{name}</div>' . format ( cls ) . arg ( items [ i ] ) ) ;
590
+ builder . push ( '<div class="{0}-type-selectable-item"><i class="{icon}"></i><span>{name}</div>' . format ( cls ) . args ( items [ i ] ) ) ;
580
591
581
592
el . append ( '<div class="{0}-type-selectable">{1}</div>' . format ( cls , builder . join ( '' ) ) ) ;
582
593
@@ -667,7 +678,8 @@ COMPONENT('configuration', 'dateformat:yyyy-MM-dd', function(self, config, cls)
667
678
if ( ! value )
668
679
value = { } ;
669
680
670
- var diff = path . substring ( self . path . length + 1 ) ;
681
+ var p = self . path . toString ( ) ;
682
+ var diff = path . substring ( p . length + 1 ) ;
671
683
672
684
for ( var key in value ) {
673
685
var val = value [ key ] ;
0 commit comments