@@ -38,27 +38,27 @@ export class FileUploadModel extends CoreDOMWidgetModel {
38
38
39
39
export class FileUploadView extends DOMWidgetView {
40
40
41
- el : HTMLDivElement ;
42
- btn : HTMLButtonElement ;
41
+ el : HTMLButtonElement ;
43
42
fileInput : HTMLInputElement ;
44
43
fileReader : FileReader ;
45
44
45
+ get tagName ( ) {
46
+ return 'button' ;
47
+ }
48
+
46
49
render ( ) {
47
50
super . render ( ) ;
48
51
49
52
this . el . classList . add ( 'jupyter-widgets' ) ;
50
53
this . el . classList . add ( 'widget-upload' ) ;
54
+ this . el . classList . add ( 'jupyter-button' ) ;
51
55
52
56
this . fileInput = document . createElement ( 'input' ) ;
53
57
this . fileInput . type = 'file' ;
54
58
this . fileInput . style . display = 'none' ;
55
59
this . el . appendChild ( this . fileInput ) ;
56
60
57
- this . btn = document . createElement ( 'button' ) ;
58
- this . btn . classList . add ( 'jupyter-button' ) ;
59
- this . el . appendChild ( this . btn ) ;
60
-
61
- this . btn . addEventListener ( 'click' , ( ) => {
61
+ this . el . addEventListener ( 'click' , ( ) => {
62
62
this . fileInput . click ( ) ;
63
63
} ) ;
64
64
@@ -129,24 +129,24 @@ export class FileUploadView extends DOMWidgetView {
129
129
}
130
130
131
131
update ( ) {
132
- this . btn . disabled = this . model . get ( 'disabled' ) ;
133
- this . btn . setAttribute ( 'title' , this . model . get ( 'tooltip' ) ) ;
132
+ this . el . disabled = this . model . get ( 'disabled' ) ;
133
+ this . el . setAttribute ( 'title' , this . model . get ( 'tooltip' ) ) ;
134
134
135
135
let model_description = this . model . get ( 'description' ) ;
136
136
let description = `${ this . model . get ( 'description' ) } (${ this . model . get ( '_counter' ) } )`
137
137
let icon = this . model . get ( 'icon' ) ;
138
138
if ( description . length || icon . length ) {
139
- this . btn . textContent = '' ;
139
+ this . el . textContent = '' ;
140
140
if ( icon . length ) {
141
141
let i = document . createElement ( 'i' ) ;
142
142
i . classList . add ( 'fa' ) ;
143
143
i . classList . add ( 'fa-' + icon ) ;
144
144
if ( description . length === 0 ) {
145
145
i . classList . add ( 'center' ) ;
146
146
}
147
- this . btn . appendChild ( i ) ;
147
+ this . el . appendChild ( i ) ;
148
148
}
149
- this . btn . appendChild ( document . createTextNode ( description ) ) ;
149
+ this . el . appendChild ( document . createTextNode ( description ) ) ;
150
150
}
151
151
152
152
this . fileInput . accept = this . model . get ( 'accept' ) ;
@@ -156,11 +156,11 @@ export class FileUploadView extends DOMWidgetView {
156
156
}
157
157
158
158
update_button_style ( ) {
159
- this . update_mapped_classes ( FileUploadView . class_map , 'button_style' , this . btn ) ;
159
+ this . update_mapped_classes ( FileUploadView . class_map , 'button_style' , this . el ) ;
160
160
}
161
161
162
162
set_button_style ( ) {
163
- this . set_mapped_classes ( FileUploadView . class_map , 'button_style' , this . btn ) ;
163
+ this . set_mapped_classes ( FileUploadView . class_map , 'button_style' , this . el ) ;
164
164
}
165
165
166
166
static class_map = {
0 commit comments