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