@@ -106,74 +106,72 @@ class FileflyEditor extends StringEditor {
106106
107107 initSelectize ( ) {
108108 var self = this ;
109- setTimeout ( function ( ) {
110- self . ajaxPath = '/filefly/api' ;
109+ this . ajaxPath = '/filefly/api' ;
111110
112- if ( self . schema && self . schema . ajaxPath ) {
113- self . ajaxPath = self . schema . ajaxPath ;
114- }
111+ if ( this . schema && this . schema . ajaxPath ) {
112+ this . ajaxPath = this . schema . ajaxPath ;
113+ }
115114
116- var firstLoad = false ;
117-
118- self . selectize = $ ( self . input ) . selectize ( {
119- valueField : 'path' ,
120- labelField : 'path' ,
121- searchField : 'path' ,
122- placeholder : 'Select a file...' ,
123- maxItems : 1 ,
124- plugins : [ 'remove_button' ] ,
125- /* DO NOT enable Preload
126- when enabled it causes item loading issues when triggering multiple move row actions
127- in a short amount of time
128- */
129- preload : false ,
130- options : [ ] ,
131- create : true ,
132- persist : true ,
133- render : {
134- item : function ( item , escape ) {
135- return '<div class="" style="height: 70px">' +
136- '<img class="pull-left img-responsive" alt="filefly image" style="max-width: 100px; max-height: 70px" src="' + self . ajaxPath + '?action=stream&path=' + ( item . path ) + '" />' +
137- '<span class="">' + escape ( item . path ) + '</span><br/>' +
138- '</div>' ;
139- } ,
140- option : function ( item , escape ) {
141- return '<div class="col-xs-6 col-sm-4 col-md-3 col-lg-2" style="height: 150px">' +
142- '<img class="img-responsive" alt="filefly image" style="max-height: 100px" src="' + self . ajaxPath + '?action=stream&path=' + ( item . path ) + '" />' +
143- '<span class="">' + escape ( item . path ) + '</span>' +
144- '</div>' ;
145- }
146- } ,
147- load : function ( query , callback ) {
148- var selectize = this ;
149- $ . ajax ( {
150- url : self . ajaxPath ,
151- type : 'GET' ,
152- dataType : 'json' ,
153- data : {
154- action : 'search' ,
155- q : query ,
156- limit : 5
157- } ,
158- error : function ( e ) {
159- console . log ( 'error' , e )
160- } ,
161- success : function ( data ) {
162- callback ( data ) ;
163- if ( ! firstLoad ) {
164- selectize . setValue ( self . input . value ) ;
165- firstLoad = true ;
166- self . onInputChange ( ) ;
167- }
168- }
169- } ) ;
115+ var firstLoad = false ;
116+
117+ this . selectize = $ ( this . input ) . selectize ( {
118+ valueField : 'path' ,
119+ labelField : 'path' ,
120+ searchField : 'path' ,
121+ placeholder : 'Select a file...' ,
122+ maxItems : 1 ,
123+ plugins : [ 'remove_button' ] ,
124+ /* DO NOT enable Preload
125+ when enabled it causes item loading issues when triggering multiple move row actions
126+ in a short amount of time
127+ */
128+ preload : false ,
129+ options : [ ] ,
130+ create : true ,
131+ persist : true ,
132+ render : {
133+ item : function ( item , escape ) {
134+ return '<div class="" style="height: 70px">' +
135+ '<img class="pull-left img-responsive" alt="filefly image" style="max-width: 100px; max-height: 70px" src="' + self . ajaxPath + '?action=stream&path=' + ( item . path ) + '" />' +
136+ '<span class="">' + escape ( item . path ) + '</span><br/>' +
137+ '</div>' ;
170138 } ,
171- onChange : function ( ) {
172- self . input . value = self . getValue ( ) ;
173- self . onInputChange ( ) ;
139+ option : function ( item , escape ) {
140+ return '<div class="col-xs-6 col-sm-4 col-md-3 col-lg-2" style="height: 150px">' +
141+ '<img class="img-responsive" alt="filefly image" style="max-height: 100px" src="' + self . ajaxPath + '?action=stream&path=' + ( item . path ) + '" />' +
142+ '<span class="">' + escape ( item . path ) + '</span>' +
143+ '</div>' ;
174144 }
175- } ) ;
176- } , 0 )
145+ } ,
146+ load : function ( query , callback ) {
147+ var selectize = this ;
148+ $ . ajax ( {
149+ url : self . ajaxPath ,
150+ type : 'GET' ,
151+ dataType : 'json' ,
152+ data : {
153+ action : 'search' ,
154+ q : query ,
155+ limit : 5
156+ } ,
157+ error : function ( e ) {
158+ console . log ( 'error' , e )
159+ } ,
160+ success : function ( data ) {
161+ callback ( data ) ;
162+ if ( ! firstLoad ) {
163+ selectize . setValue ( self . input . value ) ;
164+ firstLoad = true ;
165+ self . onInputChange ( ) ;
166+ }
167+ }
168+ } ) ;
169+ } ,
170+ onChange : function ( ) {
171+ self . input . value = this . getValue ( ) ;
172+ self . onInputChange ( ) ;
173+ }
174+ } ) ;
177175 }
178176
179177 onInputChange ( ) {
0 commit comments