@@ -32,7 +32,7 @@ export default function(this:TomSelect) {
32
32
if ( ! self . settings . shouldLoadMore ) {
33
33
34
34
// return true if additional results should be loaded
35
- self . settings . shouldLoadMore = function ( ) :boolean {
35
+ self . settings . shouldLoadMore = ( ) :boolean => {
36
36
37
37
const scroll_percent = dropdown_content . clientHeight / ( dropdown_content . scrollHeight - dropdown_content . scrollTop ) ;
38
38
if ( scroll_percent > 0.9 ) {
@@ -64,7 +64,7 @@ export default function(this:TomSelect) {
64
64
65
65
66
66
// can we load more results for given query?
67
- function canLoadMore ( query :string ) :boolean {
67
+ const canLoadMore = ( query :string ) :boolean => {
68
68
69
69
if ( typeof self . settings . maxOptions === 'number' && dropdown_content . children . length >= self . settings . maxOptions ) {
70
70
return false ;
@@ -75,23 +75,23 @@ export default function(this:TomSelect) {
75
75
}
76
76
77
77
return false ;
78
- }
78
+ } ;
79
79
80
- function clearFilter ( option :TomOption , value :string ) :boolean {
80
+ const clearFilter = ( option :TomOption , value :string ) :boolean => {
81
81
if ( self . items . indexOf ( value ) >= 0 || default_values . indexOf ( value ) >= 0 ) {
82
82
return true ;
83
83
}
84
84
return false ;
85
- }
85
+ } ;
86
86
87
87
88
88
// set the next url that will be
89
- self . setNextUrl = function ( value :string , next_url :any ) :void {
89
+ self . setNextUrl = ( value :string , next_url :any ) :void => {
90
90
pagination [ value ] = next_url ;
91
91
} ;
92
92
93
93
// getUrl() to be used in settings.load()
94
- self . getUrl = function ( query :string ) :any {
94
+ self . getUrl = ( query :string ) :any => {
95
95
96
96
if ( query in pagination ) {
97
97
const next_url = pagination [ query ] ;
@@ -175,22 +175,22 @@ export default function(this:TomSelect) {
175
175
176
176
// add scroll listener and default templates
177
177
self . on ( 'initialize' , ( ) => {
178
- default_values = Object . keys ( this . options ) ;
178
+ default_values = Object . keys ( self . options ) ;
179
179
dropdown_content = self . dropdown_content ;
180
180
181
181
// default templates
182
182
self . settings . render = Object . assign ( { } , {
183
- loading_more :function ( ) {
183
+ loading_more :( ) => {
184
184
return `<div class="loading-more-results">Loading more results ... </div>` ;
185
185
} ,
186
- no_more_results :function ( ) {
186
+ no_more_results :( ) => {
187
187
return `<div class="no-more-results">No more results</div>` ;
188
188
}
189
189
} , self . settings . render ) ;
190
190
191
191
192
192
// watch dropdown content scroll position
193
- dropdown_content . addEventListener ( 'scroll' , function ( ) {
193
+ dropdown_content . addEventListener ( 'scroll' , ( ) => {
194
194
195
195
if ( ! self . settings . shouldLoadMore . call ( self ) ) {
196
196
return ;
0 commit comments