1
- /*! JSON Editor v0.6.16 - JSON Schema -> HTML Editor
1
+ /*! JSON Editor v0.6.17 - JSON Schema -> HTML Editor
2
2
* By Jeremy Dorn - https://github.com/jdorn/json-editor/
3
3
* Released under the MIT license
4
4
*
5
- * Date: 2014-06-18
5
+ * Date: 2014-06-22
6
6
*/
7
7
8
8
/**
@@ -504,17 +504,18 @@ JSONEditor.Validator = Class.extend({
504
504
} ) ;
505
505
} ) ;
506
506
} ,
507
- _getRefs : function ( schema , callback ) {
507
+ _getRefs : function ( schema , callback , path , in_definitions ) {
508
508
var self = this ;
509
509
var is_root = schema === this . original_schema ;
510
+ path = path || "#" ;
510
511
511
512
var waiting , finished , check_if_finished , called ;
512
513
513
514
// Work on a deep copy of the schema
514
515
schema = $extend ( { } , schema ) ;
515
516
516
517
// First expand out any definition in the root node
517
- if ( is_root && schema . definitions ) {
518
+ if ( schema . definitions && ( is_root || in_definitions ) ) {
518
519
var defs = schema . definitions ;
519
520
delete schema . definitions ;
520
521
@@ -523,7 +524,7 @@ JSONEditor.Validator = Class.extend({
523
524
if ( finished >= waiting ) {
524
525
if ( called ) return ;
525
526
called = true ;
526
- self . _getRefs ( schema , callback ) ;
527
+ self . _getRefs ( schema , callback , path ) ;
527
528
}
528
529
} ;
529
530
@@ -535,10 +536,10 @@ JSONEditor.Validator = Class.extend({
535
536
$each ( defs , function ( i , definition ) {
536
537
// Expand the definition recursively
537
538
self . _getRefs ( definition , function ( def_schema ) {
538
- self . refs [ '# /definitions/'+ i ] = def_schema ;
539
+ self . refs [ path + ' /definitions/'+ i ] = def_schema ;
539
540
finished ++ ;
540
541
check_if_finished ( schema ) ;
541
- } ) ;
542
+ } , path + '/definitions/' + i , true ) ;
542
543
} ) ;
543
544
}
544
545
else {
@@ -585,7 +586,7 @@ JSONEditor.Validator = Class.extend({
585
586
$each ( list , function ( i , v ) {
586
587
v ( ) ;
587
588
} ) ;
588
- } ) ;
589
+ } , path ) ;
589
590
return ;
590
591
}
591
592
@@ -633,7 +634,7 @@ JSONEditor.Validator = Class.extend({
633
634
634
635
finished ++ ;
635
636
check_if_finished ( schema ) ;
636
- } ) ;
637
+ } , path + '/' + key + '/' + j ) ;
637
638
}
638
639
} ) ;
639
640
}
@@ -644,7 +645,7 @@ JSONEditor.Validator = Class.extend({
644
645
645
646
finished ++ ;
646
647
check_if_finished ( schema ) ;
647
- } ) ;
648
+ } , path + '/' + key ) ;
648
649
}
649
650
} ) ;
650
651
}
@@ -3275,7 +3276,7 @@ JSONEditor.defaults.editors.array = JSONEditor.AbstractEditor.extend({
3275
3276
this . _super ( ) ;
3276
3277
this . row_holder . style . display = '' ;
3277
3278
if ( this . tabs_holder ) this . tabs_holder . style . display = '' ;
3278
- this . controls . style . display = '' ;
3279
+ if ( ! this . collapsed ) this . controls . style . display = '' ;
3279
3280
this . title_controls . style . display = '' ;
3280
3281
this . theme . enableHeader ( this . title ) ;
3281
3282
} ,
@@ -3689,7 +3690,7 @@ JSONEditor.defaults.editors.array = JSONEditor.AbstractEditor.extend({
3689
3690
controls_needed = true ;
3690
3691
}
3691
3692
3692
- if ( controls_needed ) {
3693
+ if ( ! this . collapsed && controls_needed ) {
3693
3694
this . controls . style . display = '' ;
3694
3695
}
3695
3696
else {
@@ -3826,6 +3827,7 @@ JSONEditor.defaults.editors.array = JSONEditor.AbstractEditor.extend({
3826
3827
this . toggle_button . addEventListener ( 'click' , function ( ) {
3827
3828
if ( self . collapsed ) {
3828
3829
self . collapsed = false ;
3830
+ if ( self . panel ) self . panel . style . display = '' ;
3829
3831
self . row_holder . style . display = row_holder_display ;
3830
3832
if ( self . tabs_holder ) self . tabs_holder . style . display = '' ;
3831
3833
self . controls . style . display = controls_display ;
@@ -3836,6 +3838,7 @@ JSONEditor.defaults.editors.array = JSONEditor.AbstractEditor.extend({
3836
3838
self . row_holder . style . display = 'none' ;
3837
3839
if ( self . tabs_holder ) self . tabs_holder . style . display = 'none' ;
3838
3840
self . controls . style . display = 'none' ;
3841
+ if ( self . panel ) self . panel . style . display = 'none' ;
3839
3842
self . setButtonText ( this , '' , 'expand' , 'Expand' ) ;
3840
3843
}
3841
3844
} ) ;
0 commit comments