diff --git a/apps/common/main/lib/component/DataView.js b/apps/common/main/lib/component/DataView.js index 8bb1399aa..e2413e9d8 100644 --- a/apps/common/main/lib/component/DataView.js +++ b/apps/common/main/lib/component/DataView.js @@ -1368,12 +1368,30 @@ define([ props = {minScrollbarLength : this.minScrollbarLength}; this.scrollAlwaysVisible && (props.alwaysVisibleY = this.scrollAlwaysVisible); - if (top + menuH > docH ) { - innerEl.css('max-height', (docH - top - paddings - margins) + 'px'); - this.scroller.update(props); - } else if ( top + menuH < docH && innerEl.height() < this.options.restoreHeight ) { - innerEl.css('max-height', (Math.min(docH - top - paddings - margins, this.options.restoreHeight)) + 'px'); - this.scroller.update(props); + var menuUp = false; + if (this.parentMenu.menuAlign) { + var m = this.parentMenu.menuAlign.match(/^([a-z]+)-([a-z]+)/); + menuUp = (m[1]==='bl' || m[1]==='br'); + } + if (menuUp) { + var bottom = top + menuH; + if (top<0) { + innerEl.css('max-height', (bottom - paddings - margins) + 'px'); + menuRoot.css('top', 0); + this.scroller.update(props); + } else if (top>0 && innerEl.height() < this.options.restoreHeight) { + innerEl.css('max-height', (Math.min(bottom - paddings - margins, this.options.restoreHeight)) + 'px'); + menuRoot.css('top', bottom - menuRoot.outerHeight()); + this.scroller.update(props); + } + } else { + if (top + menuH > docH ) { + innerEl.css('max-height', (docH - top - paddings - margins) + 'px'); + this.scroller.update(props); + } else if ( top + menuH < docH && innerEl.height() < this.options.restoreHeight ) { + innerEl.css('max-height', (Math.min(docH - top - paddings - margins, this.options.restoreHeight)) + 'px'); + this.scroller.update(props); + } } }, diff --git a/apps/common/main/lib/component/Menu.js b/apps/common/main/lib/component/Menu.js index c58a1b5f1..8b2c0e30d 100644 --- a/apps/common/main/lib/component/Menu.js +++ b/apps/common/main/lib/component/Menu.js @@ -145,7 +145,7 @@ define([ style : '', itemTemplate: null, items : [], - menuAlign : 'tl-bl', + menuAlign : 'tl-bl',//menu - parent menuAlignEl : null, offset : [0, 0], cyclic : true, diff --git a/apps/documenteditor/main/app/controller/DocumentHolder.js b/apps/documenteditor/main/app/controller/DocumentHolder.js index a9cbed995..1dfdd92a6 100644 --- a/apps/documenteditor/main/app/controller/DocumentHolder.js +++ b/apps/documenteditor/main/app/controller/DocumentHolder.js @@ -2367,7 +2367,7 @@ define([ store: group.get('groupStore'), scrollAlwaysVisible: true, showLast: false, - restoreHeight: 10000, + restoreHeight: 450, itemTemplate: _.template( '
' + '
' + @@ -2381,6 +2381,12 @@ define([ }); menu.off('show:before', onShowBefore); }; + var bringForward = function (menu) { + eqContainer.addClass('has-open-menu'); + }; + var sendBackward = function (menu) { + eqContainer.removeClass('has-open-menu'); + }; for (var i = 0; i < equationsStore.length; ++i) { var equationGroup = equationsStore.at(i); var btn = new Common.UI.Button({ @@ -2399,6 +2405,8 @@ define([ }) }); btn.menu.on('show:before', onShowBefore); + btn.menu.on('show:before', bringForward); + btn.menu.on('hide:after', sendBackward); me.equationBtns.push(btn); } @@ -2430,8 +2438,14 @@ define([ showPoint[1] = bounds[3] + 10; !Common.Utils.InternalSettings.get("de-hidden-rulers") && (showPoint[1] -= 26); } - eqContainer.css({left: showPoint[0], top : Math.min(this._Height - eqContainer.outerHeight(), Math.max(0, showPoint[1]))}); - // menu.menuAlign = validation ? 'tr-br' : 'tl-bl'; + showPoint[1] = Math.min(me._Height - eqContainer.outerHeight(), Math.max(0, showPoint[1])); + eqContainer.css({left: showPoint[0], top : showPoint[1]}); + + var menuAlign = (me._Height - showPoint[1] - eqContainer.outerHeight() < 220) ? 'bl-tl' : 'tl-bl'; + me.equationBtns.forEach(function(item){ + item && (item.menu.menuAlign = menuAlign); + }); + me.equationSettingsBtn.menu.menuAlign = menuAlign; if (eqContainer.is(':visible')) { if (me.equationSettingsBtn.menu.isVisible()) { me.equationSettingsBtn.menu.options.initMenu(); diff --git a/apps/documenteditor/main/resources/less/toolbar.less b/apps/documenteditor/main/resources/less/toolbar.less index d389e8cfc..0f8711ab4 100644 --- a/apps/documenteditor/main/resources/less/toolbar.less +++ b/apps/documenteditor/main/resources/less/toolbar.less @@ -179,7 +179,9 @@ .separator { height: 20px; } - z-index: @zindex-dropdown - 19; + &.has-open-menu { + z-index: @zindex-navbar + 1; + } } .dropdown-menu.list-settings-level { diff --git a/apps/presentationeditor/main/app/controller/DocumentHolder.js b/apps/presentationeditor/main/app/controller/DocumentHolder.js index 2bb85ec97..9344c8a9d 100644 --- a/apps/presentationeditor/main/app/controller/DocumentHolder.js +++ b/apps/presentationeditor/main/app/controller/DocumentHolder.js @@ -2282,7 +2282,7 @@ define([ store: group.get('groupStore'), scrollAlwaysVisible: true, showLast: false, - restoreHeight: group.get('groupHeight') ? parseInt(group.get('groupHeight')) : true, + restoreHeight: 450, itemTemplate: _.template( '
' + '
' + @@ -2296,6 +2296,12 @@ define([ }); menu.off('show:before', onShowBefore); }; + var bringForward = function (menu) { + eqContainer.addClass('has-open-menu'); + }; + var sendBackward = function (menu) { + eqContainer.removeClass('has-open-menu'); + }; for (var i = 0; i < equationsStore.length; ++i) { var equationGroup = equationsStore.at(i); var btn = new Common.UI.Button({ @@ -2315,6 +2321,8 @@ define([ }) }); btn.menu.on('show:before', onShowBefore); + btn.menu.on('show:before', bringForward); + btn.menu.on('hide:after', sendBackward); me.equationBtns.push(btn); } @@ -2341,8 +2349,14 @@ define([ if (showPoint[1]<0) { showPoint[1] = bounds[3] + 10; } - eqContainer.css({left: showPoint[0], top : Math.min(me._Height - eqContainer.outerHeight(), Math.max(0, showPoint[1]))}); - // menu.menuAlign = validation ? 'tr-br' : 'tl-bl'; + showPoint[1] = Math.min(me._Height - eqContainer.outerHeight(), Math.max(0, showPoint[1])); + eqContainer.css({left: showPoint[0], top : showPoint[1]}); + + var menuAlign = (me._Height - showPoint[1] - eqContainer.outerHeight() < 220) ? 'bl-tl' : 'tl-bl'; + me.equationBtns.forEach(function(item){ + item && (item.menu.menuAlign = menuAlign); + }); + me.equationSettingsBtn.menu.menuAlign = menuAlign; if (eqContainer.is(':visible')) { if (me.equationSettingsBtn.menu.isVisible()) { me.equationSettingsBtn.menu.options.initMenu(); diff --git a/apps/presentationeditor/main/resources/less/toolbar.less b/apps/presentationeditor/main/resources/less/toolbar.less index 56c12be3b..c601d2feb 100644 --- a/apps/presentationeditor/main/resources/less/toolbar.less +++ b/apps/presentationeditor/main/resources/less/toolbar.less @@ -111,6 +111,9 @@ .separator { height: 20px; } + &.has-open-menu { + z-index: @zindex-navbar + 1; + } } .item-theme { diff --git a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js index c895ba0f8..6364a2ca4 100644 --- a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js +++ b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js @@ -4348,7 +4348,7 @@ define([ store: group.get('groupStore'), scrollAlwaysVisible: true, showLast: false, - restoreHeight: group.get('groupHeight') ? parseInt(group.get('groupHeight')) : true, + restoreHeight: 450, itemTemplate: _.template( '
' + '
' + @@ -4362,6 +4362,12 @@ define([ }); menu.off('show:before', onShowBefore); }; + var bringForward = function (menu) { + eqContainer.addClass('has-open-menu'); + }; + var sendBackward = function (menu) { + eqContainer.removeClass('has-open-menu'); + }; for (var i = 0; i < equationsStore.length; ++i) { var equationGroup = equationsStore.at(i); var btn = new Common.UI.Button({ @@ -4381,6 +4387,8 @@ define([ }) }); btn.menu.on('show:before', onShowBefore); + btn.menu.on('show:before', bringForward); + btn.menu.on('hide:after', sendBackward); me.equationBtns.push(btn); } @@ -4410,8 +4418,14 @@ define([ if (showPoint[1]<0) { showPoint[1] = bounds[3] + 10; } - eqContainer.css({left: showPoint[0], top : Math.min(me.tooltips.coauth.apiHeight - eqContainer.outerHeight(), Math.max(0, showPoint[1]))}); - // menu.menuAlign = validation ? 'tr-br' : 'tl-bl'; + showPoint[1] = Math.min(me.tooltips.coauth.apiHeight - eqContainer.outerHeight(), Math.max(0, showPoint[1])); + eqContainer.css({left: showPoint[0], top : showPoint[1]}); + + var menuAlign = (me.tooltips.coauth.apiHeight - showPoint[1] - eqContainer.outerHeight() < 220) ? 'bl-tl' : 'tl-bl'; + me.equationBtns.forEach(function(item){ + item && (item.menu.menuAlign = menuAlign); + }); + me.equationSettingsBtn.menu.menuAlign = menuAlign; if (eqContainer.is(':visible')) { if (me.equationSettingsBtn.menu.isVisible()) { me.equationSettingsBtn.menu.options.initMenu(); diff --git a/apps/spreadsheeteditor/main/resources/less/toolbar.less b/apps/spreadsheeteditor/main/resources/less/toolbar.less index f985c69c3..f9eb5429a 100644 --- a/apps/spreadsheeteditor/main/resources/less/toolbar.less +++ b/apps/spreadsheeteditor/main/resources/less/toolbar.less @@ -123,6 +123,9 @@ .separator { height: 20px; } + &.has-open-menu { + z-index: @zindex-navbar + 1; + } } #slot-field-fontsize {