@@ -75,14 +75,33 @@ JSONEditor.defaults.editors.filefly = JSONEditor.AbstractEditor.extend({
7575 self . initSelectize ( ) ;
7676 } ) ;
7777
78+ self . jsoneditor . on ( 'addRow' , function ( ) {
79+ self . initSelectize ( ) ;
80+ } ) ;
81+
82+ self . jsoneditor . on ( 'moveRow' , function ( ) {
83+ self . destroySelectize ( ) ;
84+ self . initSelectize ( ) ;
85+ } ) ;
86+
87+ self . jsoneditor . on ( 'deleteRow' , function ( ) {
88+ self . destroySelectize ( ) ;
89+ self . initSelectize ( ) ;
90+ } ) ;
91+
7892 } ,
7993 postBuild : function ( ) {
8094 this . _super ( ) ;
8195 this . theme . afterInputReady ( this . input ) ;
8296 } ,
8397 initSelectize : function ( ) {
8498 var self = this ;
85- this . path = this . schema . path || '/filefly/api' ;
99+ this . ajaxPath = '/filefly/api' ;
100+
101+ if ( this . schema && this . schema . ajaxPath ) {
102+ this . ajaxPath = this . schema . ajaxPath ;
103+ }
104+
86105 var firstLoad = false ;
87106
88107 this . selectize = $ ( this . input ) . selectize ( {
@@ -99,21 +118,21 @@ JSONEditor.defaults.editors.filefly = JSONEditor.AbstractEditor.extend({
99118 render : {
100119 item : function ( item , escape ) {
101120 return '<div class="" style="height: 70px">' +
102- '<img class="pull-left img-responsive" alt="filefly image" style="max-width: 100px; max-height: 70px" src="' + self . path + '?action=stream&path=' + ( item . path ) + '" />' +
121+ '<img class="pull-left img-responsive" alt="filefly image" style="max-width: 100px; max-height: 70px" src="' + self . ajaxPath + '?action=stream&path=' + ( item . path ) + '" />' +
103122 '<span class="">' + escape ( item . path ) + '</span><br/>' +
104123 '</div>' ;
105124 } ,
106125 option : function ( item , escape ) {
107126 return '<div class="col-xs-6 col-sm-4 col-md-3 col-lg-2" style="height: 150px">' +
108- '<img class="img-responsive" alt="filefly image" style="max-height: 100px" src="' + self . path + '?action=stream&path=' + ( item . path ) + '" />' +
127+ '<img class="img-responsive" alt="filefly image" style="max-height: 100px" src="' + self . ajaxPath + '?action=stream&path=' + ( item . path ) + '" />' +
109128 '<span class="">' + escape ( item . path ) + '</span>' +
110129 '</div>' ;
111130 }
112131 } ,
113132 load : function ( query , callback ) {
114133 var selectize = this ;
115134 $ . ajax ( {
116- url : self . path ,
135+ url : self . ajaxPath ,
117136 type : 'GET' ,
118137 dataType : 'json' ,
119138 data : {
@@ -125,7 +144,6 @@ JSONEditor.defaults.editors.filefly = JSONEditor.AbstractEditor.extend({
125144 console . log ( 'error' , e )
126145 } ,
127146 success : function ( data ) {
128- //selectize.addOption({path: self.input.value, id: self.input.value, mime: ""});
129147 callback ( data ) ;
130148 if ( ! firstLoad ) {
131149 selectize . setValue ( self . input . value ) ;
@@ -144,11 +162,6 @@ JSONEditor.defaults.editors.filefly = JSONEditor.AbstractEditor.extend({
144162 onInputChange : function ( ) {
145163 this . value = this . input . value ;
146164 this . onChange ( true ) ;
147-
148- } ,
149- onMove : function ( ) {
150- this . destroySelectize ( ) ;
151- this . initSelectize ( ) ;
152165 } ,
153166 enable : function ( ) {
154167 if ( ! this . always_disabled ) {
@@ -168,10 +181,10 @@ JSONEditor.defaults.editors.filefly = JSONEditor.AbstractEditor.extend({
168181 this . _super ( ) ;
169182 } ,
170183 destroy : function ( ) {
184+ this . destroySelectize ( ) ;
171185 if ( this . label && this . label . parentNode ) this . label . parentNode . removeChild ( this . label ) ;
172186 if ( this . description && this . description . parentNode ) this . description . parentNode . removeChild ( this . description ) ;
173187 if ( this . input && this . input . parentNode ) this . input . parentNode . removeChild ( this . input ) ;
174- this . destroySelectize ( ) ;
175188 this . _super ( ) ;
176189 } ,
177190 destroySelectize : function ( ) {
0 commit comments