13
13
</div >
14
14
</div >
15
15
16
- <transition name =" settings" >
16
+ <transition name =" settings"
17
+ @before-enter =" beforeSettingsEnter"
18
+ @after-enter =" afterSettingsEnter"
19
+ @after-leave =" afterSettingsLeave" >
17
20
<div class =" settings" v-show =" showSettings" >
18
21
<v-textfield v-model =" customUrl"
19
22
:placeholder =" getText('inputPlaceholder_customURL')"
22
25
</div >
23
26
</transition >
24
27
25
- <ul class =" mdc- list list " >
26
- < li class =" mdc-list-item item ripple-surface "
27
- v-if = " searchAllEngines "
28
+ <div class =" list-padding-top " ></ div >
29
+ < ul class =" mdc-list list list-bulk-button " v-if = " searchAllEngines " >
30
+ < li class = " mdc-list-item list-item ripple-surface "
28
31
@click =" selectEngine('allEngines')" >
29
- <img class =" mdc-list-item__start-detail item-icon"
32
+ <img class =" mdc-list-item__start-detail list- item-icon"
30
33
:src =" getIcon('allEngines')" >
31
34
{{ getText('engineName_allEngines_full') }}
32
35
</li >
33
- <li role =" separator" class =" mdc-list-divider"
34
- v-if =" searchAllEngines || engines.length > 8" >
35
- </li >
36
- <div class =" items" >
37
- <li class =" mdc-list-item item ripple-surface"
36
+ </ul >
37
+ <ul class =" mdc-list list list-separator"
38
+ v-if =" searchAllEngines || hasScrollBar" >
39
+ <li role =" separator" class =" mdc-list-divider" ></li >
40
+ </ul >
41
+ <div class =" list-items-wrap" ref =" items" :class =" listClasses" >
42
+ <resize-observer @notify =" handleSizeChange" ></resize-observer >
43
+ <ul class =" mdc-list list list-items" >
44
+ <li class =" mdc-list-item list-item ripple-surface"
38
45
v-for =" engine in engines"
39
46
:key =" engine.id"
40
47
@click =" selectEngine(engine)" >
41
- <img class =" mdc-list-item__start-detail item-icon"
48
+ <img class =" mdc-list-item__start-detail list- item-icon"
42
49
:src =" getIcon(engine)" >
43
50
{{ getText(`engineName_${engine}_short`) }}
44
51
</li >
45
- </div >
46
- </ul >
52
+ </ul >
53
+ </div >
54
+
47
55
</div >
48
56
</template >
49
57
50
58
<script >
51
59
import browser from ' webextension-polyfill' ;
60
+ import {ResizeObserver } from ' vue-resize' ;
52
61
import {TextField } from ' ext-components' ;
53
62
54
63
import storage from ' storage/storage' ;
@@ -63,21 +72,34 @@ import {targetEnv} from 'utils/config';
63
72
64
73
export default {
65
74
components: {
66
- [TextField .name ]: TextField
75
+ [TextField .name ]: TextField,
76
+ [ResizeObserver .name ]: ResizeObserver
67
77
},
68
78
69
79
data : function () {
70
80
return {
71
81
dataLoaded: false ,
72
82
73
83
showSettings: false ,
84
+ hasScrollBar: false ,
85
+ hideScrollBar: false ,
86
+ isAndroid: false ,
74
87
75
88
engines: [],
76
89
searchAllEngines: false ,
77
90
customUrl: ' '
78
91
};
79
92
},
80
93
94
+ computed: {
95
+ listClasses : function () {
96
+ return {
97
+ ' list-items-scroll-bar-hidden' : this .hideScrollBar ,
98
+ ' list-items-max-height' : ! this .isAndroid
99
+ };
100
+ }
101
+ },
102
+
81
103
methods: {
82
104
getText: getText,
83
105
@@ -117,6 +139,24 @@ export default {
117
139
} else {
118
140
window .close ();
119
141
}
142
+ },
143
+
144
+ handleSizeChange : function () {
145
+ const items = this .$refs .items ;
146
+ this .hasScrollBar = items .scrollHeight > items .clientHeight ;
147
+ },
148
+
149
+ beforeSettingsEnter : function () {
150
+ this .hideScrollBar = ! this .hasScrollBar ;
151
+ },
152
+
153
+ afterSettingsEnter : function () {
154
+ this .handleSizeChange ();
155
+ this .hideScrollBar = false ;
156
+ },
157
+
158
+ afterSettingsLeave : function () {
159
+ this .handleSizeChange ();
120
160
}
121
161
},
122
162
@@ -127,14 +167,13 @@ export default {
127
167
);
128
168
const enEngines = await getEnabledEngines (options);
129
169
130
- if (
131
- targetEnv === ' firefox' &&
132
- (await isAndroid ()) &&
133
- (enEngines .length <= 1 || options .searchAllEnginesAction === ' main' )
134
- ) {
135
- // Removing the action popup has no effect on Android
136
- showNotification ({messageId: ' error_optionsNotApplied' });
137
- return ;
170
+ if (targetEnv === ' firefox' && (await isAndroid ())) {
171
+ this .isAndroid = true ;
172
+ if (enEngines .length <= 1 || options .searchAllEnginesAction === ' main' ) {
173
+ // Removing the action popup has no effect on Android
174
+ showNotification ({messageId: ' error_optionsNotApplied' });
175
+ return ;
176
+ }
138
177
}
139
178
140
179
this .searchAllEngines = options .searchAllEnginesAction === ' sub' ;
@@ -143,11 +182,11 @@ export default {
143
182
this .dataLoaded = true ;
144
183
145
184
const mq = window .matchMedia (' (min-width: 413px)' );
146
- const widthChange = function (mq ) {
185
+ const mqChange = function (mq ) {
147
186
document .body .style .minWidth = mq .matches ? ' 413px' : ' initial' ;
148
187
};
149
- mq .addListener (widthChange );
150
- widthChange (mq);
188
+ mq .addListener (mqChange );
189
+ mqChange (mq);
151
190
}
152
191
};
153
192
</script >
@@ -160,6 +199,19 @@ $mdc-theme-primary: #1abc9c;
160
199
@import ' @material/typography/mixins' ;
161
200
@import " @material/ripple/mixins" ;
162
201
202
+ @import ' vue-resize/dist/vue-resize' ;
203
+
204
+ html ,
205
+ body ,
206
+ #app {
207
+ height : 100% ;
208
+ }
209
+
210
+ #app {
211
+ display : flex ;
212
+ flex-direction : column ;
213
+ }
214
+
163
215
body {
164
216
margin : 0 ;
165
217
min-width : 413px ;
@@ -222,23 +274,46 @@ body {
222
274
opacity : 0 ;
223
275
}
224
276
225
- .items {
226
- max-height : 392px ;
277
+ .list {
278
+ padding : 0 !important ;
279
+ }
280
+
281
+ .list-padding-top {
282
+ margin-bottom : 8px ;
283
+ }
284
+
285
+ .list-bulk-button {
286
+ height : 48px ;
287
+ }
288
+
289
+ .list-separator {
290
+ height : 1px ;
291
+ }
292
+
293
+ .list-items-wrap {
227
294
overflow-y : auto ;
295
+ position : relative ;
228
296
}
229
297
230
- .list {
231
- padding-left : 0 !important ;
232
- padding-right : 0 !important ;
298
+ .list-items-max-height {
299
+ max-height : 392px ;
300
+ }
301
+
302
+ .list-items-scroll-bar-hidden {
303
+ overflow-y : hidden ;
304
+ }
305
+
306
+ .list-items {
307
+ padding-bottom : 8px !important ;
233
308
}
234
309
235
- .item {
310
+ .list- item {
236
311
padding-left : 16px ;
237
312
padding-right : 48px ;
238
313
cursor : pointer ;
239
314
}
240
315
241
- .item-icon {
316
+ .list- item-icon {
242
317
margin-right : 16px !important ;
243
318
}
244
319
0 commit comments