@@ -188,6 +188,7 @@ class TopToolbar extends JSDialog.Toolbar {
188
188
{ type : 'customtoolitem' , id : 'insertannotation' , text : _UNO ( '.uno:InsertAnnotation' , '' , true ) , visible : false , lockUno : '.uno:InsertAnnotation' } ,
189
189
{ type : 'customtoolitem' , id : 'inserthyperlink' , command : 'inserthyperlink' , text : _UNO ( '.uno:HyperlinkDialog' , '' , true ) , lockUno : '.uno:HyperlinkDialog' } ,
190
190
{ type : 'toolitem' , id : 'insertsymbol' , text : _UNO ( '.uno:InsertSymbol' , '' , true ) , command : '.uno:InsertSymbol' } ,
191
+ { type : 'customtoolitem' , id : 'menuoverflow' , text : _ ( 'More' ) , desktop : true , mobile : false , visible : true } ,
191
192
{ type : 'spacer' , id : 'topspacer' } ,
192
193
{ type : 'separator' , orientation : 'vertical' , id : 'breaksidebar' , visible : false } ,
193
194
{ type : 'toolitem' , id : 'sidebar' , text : _UNO ( '.uno:Sidebar' , '' , true ) , command : '.uno:SidebarDeck.PropertyDeck' , visible : false } ,
@@ -226,14 +227,123 @@ class TopToolbar extends JSDialog.Toolbar {
226
227
}
227
228
}
228
229
230
+ createOverflowMenu ( ) {
231
+ const topBarMenu = this . parentContainer . querySelector (
232
+ '.root-container .vertical' ,
233
+ ) ;
234
+
235
+ const overflowMenu = L . DomUtil . create (
236
+ 'div' ,
237
+ 'menu-overflow-wrapper' ,
238
+ this . parentContainer ,
239
+ ) ;
240
+
241
+ const overflowMenuButton =
242
+ this . parentContainer . querySelector ( '#menuoverflow' ) ;
243
+
244
+ const showOverflowMenu = ( ) => {
245
+ overflowMenu . style . opacity = 1 ;
246
+ overflowMenu . style . pointerEvents = 'revert' ;
247
+ L . DomUtil . addClass ( overflowMenuButton , 'selected' ) ;
248
+ } ;
249
+
250
+ const hideOverflowMenu = ( ) => {
251
+ overflowMenu . style . opacity = 0 ;
252
+ overflowMenu . style . pointerEvents = 'none' ;
253
+ L . DomUtil . removeClass ( overflowMenuButton , 'selected' ) ;
254
+ } ;
255
+
256
+ overflowMenuButton . addEventListener ( 'click' , ( ) => {
257
+ if (
258
+ overflowMenu . style . opacity === '0' ||
259
+ overflowMenu . style . opacity === ''
260
+ ) {
261
+ showOverflowMenu ( ) ;
262
+ } else {
263
+ hideOverflowMenu ( ) ;
264
+ }
265
+ } ) ;
266
+
267
+ const breakSidebar = this . parentContainer . querySelector ( '#breaksidebar' ) ;
268
+ const foldButton = this . parentContainer . querySelector ( '#fold' ) ;
269
+
270
+ const getMenuWidth = ( ) => {
271
+ const splitPosition =
272
+ foldButton . offsetLeft +
273
+ foldButton . offsetWidth * 2 -
274
+ breakSidebar . offsetLeft ;
275
+ return window . innerWidth - splitPosition ;
276
+ } ;
277
+
278
+ let overflowMenuDebounced = 0 ;
279
+ const originalTopbar = topBarMenu . querySelectorAll ( '.jsdialog' ) ;
280
+
281
+ const overflowMenuHandler = ( ) => {
282
+ overflowMenuDebounced && clearTimeout ( overflowMenuDebounced ) ;
283
+
284
+ hideOverflowMenu ( ) ;
285
+
286
+ overflowMenuDebounced = setTimeout ( ( ) => {
287
+ topBarMenu . replaceChildren ( ...originalTopbar ) ;
288
+
289
+ const topBarButtons = topBarMenu . querySelectorAll ( '.jsdialog:not(.hidden)' ) ;
290
+ const menuWidth = getMenuWidth ( ) ;
291
+
292
+ const overflowMenuOffscreen = document . createElement ( 'div' ) ;
293
+ overflowMenuOffscreen . className = 'menu-overfow-vertical' ;
294
+
295
+ let section = [ ] ;
296
+ let overflow = false ;
297
+
298
+ const appendSection = ( ) => {
299
+ for ( const element of section ) {
300
+ overflowMenuOffscreen . appendChild ( element ) ;
301
+ }
302
+ section . length = 0 ;
303
+ } ;
304
+
305
+ for ( const button of topBarButtons ) {
306
+ if ( button . id === 'topspacer' || button . id === 'menuoverflow' ) {
307
+ break ;
308
+ }
309
+
310
+ if ( button . offsetLeft > menuWidth || overflow ) {
311
+ overflow = true ;
312
+ appendSection ( ) ;
313
+ overflowMenuOffscreen . appendChild ( button ) ;
314
+ } else if ( button . className . includes ( 'vertical' ) ) {
315
+ section = [ button ] ;
316
+ } else {
317
+ section . push ( button ) ;
318
+ }
319
+ }
320
+
321
+ overflowMenu . replaceChildren ( overflowMenuOffscreen ) ;
322
+
323
+ if ( overflowMenuOffscreen . children . length <= 0 ) {
324
+ overflowMenuButton . style . display = 'none' ;
325
+ } else {
326
+ overflowMenuButton . style . display = 'revert' ;
327
+ }
328
+
329
+ overflowMenu . style . left =
330
+ overflowMenuButton . offsetLeft -
331
+ overflowMenu . clientWidth +
332
+ overflowMenuButton . offsetWidth +
333
+ 'px' ;
334
+ } , 250 ) ;
335
+ } ;
336
+
337
+ window . addEventListener ( 'resize' , overflowMenuHandler ) ;
338
+ }
339
+
229
340
create ( ) {
230
341
this . reset ( ) ;
231
342
232
343
var items = this . getToolItems ( ) ;
233
344
this . builder . build ( this . parentContainer , items ) ;
234
345
235
- JSDialog . MakeScrollable ( this . parentContainer , this . parentContainer . querySelector ( 'div' ) ) ;
236
- JSDialog . RefreshScrollables ( ) ;
346
+ this . createOverflowMenu ( ) ;
237
347
238
348
if ( this . map . isRestrictedUser ( ) ) {
239
349
for ( var i = 0 ; i < items . length ; i ++ ) {
@@ -254,8 +364,7 @@ class TopToolbar extends JSDialog.Toolbar {
254
364
this . map . createFontSelector ( '#fontnamecombobox-input' ) ;
255
365
256
366
// on mode switch NB -> Compact
257
- if ( this . map . _docLoadedOnce )
258
- this . onDocLayerInit ( ) ;
367
+ if ( this . map . _docLoadedOnce ) this . onDocLayerInit ( ) ;
259
368
}
260
369
261
370
onDocLayerInit ( ) {
0 commit comments