1
+ // source: https://stackoverflow.com/a/6832721/1166642
2
+ function versionCompare ( v1 , v2 , options ) {
3
+ var lexicographical = options && options . lexicographical ,
4
+ zeroExtend = options && options . zeroExtend ,
5
+ v1parts = v1 . split ( '.' ) ,
6
+ v2parts = v2 . split ( '.' ) ;
7
+
8
+ function isValidPart ( x ) {
9
+ return ( lexicographical ? / ^ \d + [ A - Z a - z ] * $ / : / ^ \d + $ / ) . test ( x ) ;
10
+ }
11
+
12
+ if ( ! v1parts . every ( isValidPart ) || ! v2parts . every ( isValidPart ) ) {
13
+ return NaN ;
14
+ }
15
+
16
+ if ( zeroExtend ) {
17
+ while ( v1parts . length < v2parts . length ) v1parts . push ( "0" ) ;
18
+ while ( v2parts . length < v1parts . length ) v2parts . push ( "0" ) ;
19
+ }
20
+
21
+ if ( ! lexicographical ) {
22
+ v1parts = v1parts . map ( Number ) ;
23
+ v2parts = v2parts . map ( Number ) ;
24
+ }
25
+
26
+ for ( var i = 0 ; i < v1parts . length ; ++ i ) {
27
+ if ( v2parts . length == i ) {
28
+ return 1 ;
29
+ }
30
+
31
+ if ( v1parts [ i ] == v2parts [ i ] ) {
32
+ continue ;
33
+ }
34
+ else if ( v1parts [ i ] > v2parts [ i ] ) {
35
+ return 1 ;
36
+ }
37
+ else {
38
+ return - 1 ;
39
+ }
40
+ }
41
+
42
+ if ( v1parts . length != v2parts . length ) {
43
+ return - 1 ;
44
+ }
45
+
46
+ return 0 ;
47
+ }
48
+
1
49
ClientConfig . page . Home = function ( config ) {
2
50
config = config || { } ;
3
51
Ext . applyIf ( config , {
@@ -130,7 +178,24 @@ Ext.extend(ClientConfig.page.Home,MODx.Component,{
130
178
field . checked = ( value . value ) ;
131
179
}
132
180
133
- if ( ( field . xtype === 'radiogroup' ) || ( field . xtype === 'xradiogroup' ) ) {
181
+ var hasRadioGroupCompatibleVersion = false ,
182
+ minModx2RGVersion = "2.8.7" ,
183
+ minModx3RGVersion = "3.0.4" ;
184
+
185
+ if ( MODx && MODx . config && MODx . config . version ) {
186
+ var modxVersion = MODx . config . version . substring ( 0 , MODx . config . version . length - 3 ) ,
187
+ modxVersionMajor = parseInt ( modxVersion . substring ( 0 , 1 ) ) ;
188
+
189
+ if ( modxVersionMajor === 2 ) {
190
+ hasRadioGroupCompatibleVersion = versionCompare ( modxVersion , minModx2RGVersion ) !== - 1 ;
191
+ } else if ( modxVersionMajor === 3 ) {
192
+ hasRadioGroupCompatibleVersion = versionCompare ( modxVersion , minModx3RGVersion ) !== - 1 ;
193
+ } else if ( modxVersionMajor > 3 ) {
194
+ hasRadioGroupCompatibleVersion = true ;
195
+ }
196
+ }
197
+
198
+ if ( ( ( field . xtype === 'radiogroup' ) || ( field . xtype === 'xradiogroup' ) ) && hasRadioGroupCompatibleVersion ) {
134
199
field . xtype = 'radiogroup' ;
135
200
field . columns = 4 ;
136
201
field . items = [ ] ;
@@ -154,7 +219,22 @@ Ext.extend(ClientConfig.page.Home,MODx.Component,{
154
219
} )
155
220
}
156
221
} ) ;
157
- }
222
+ } else if ( ( field . xtype === 'radiogroup' ) || ( field . xtype === 'xradiogroup' ) ) {
223
+ field . xtype = 'radiogroup' ;
224
+
225
+ var extMC = new Ext . util . MixedCollection ( ) ;
226
+
227
+ field . items = [ {
228
+ boxLabel : 'Feature not available in your MODX-version, please update to at least version ' + ( modxVersionMajor === 2 ? minModx2RGVersion : minModx3RGVersion ) ,
229
+ inputValue : 0 ,
230
+ checked : true ,
231
+ name : field . name
232
+ } ] ;
233
+
234
+ extMC . addAll ( field . items ) ;
235
+ field . items = extMC ;
236
+ field . items [ 0 ] = extMC . items ;
237
+ }
158
238
159
239
if ( field . xtype === 'datefield' ) {
160
240
field . format = MODx . config . manager_date_format ;
0 commit comments