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+
149ClientConfig . page . Home = function ( config ) {
250 config = config || { } ;
351 Ext . applyIf ( config , {
@@ -130,7 +178,24 @@ Ext.extend(ClientConfig.page.Home,MODx.Component,{
130178 field . checked = ( value . value ) ;
131179 }
132180
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 ) {
134199 field . xtype = 'radiogroup' ;
135200 field . columns = 4 ;
136201 field . items = [ ] ;
@@ -154,7 +219,22 @@ Ext.extend(ClientConfig.page.Home,MODx.Component,{
154219 } )
155220 }
156221 } ) ;
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+ }
158238
159239 if ( field . xtype === 'datefield' ) {
160240 field . format = MODx . config . manager_date_format ;
0 commit comments