From eb5f62a0419f4a95ad2f71505229446c94509212 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 15 Sep 2017 13:31:59 +0300 Subject: [PATCH] Fix Bug 35630. --- apps/common/main/lib/component/DataView.js | 19 ++++++------- apps/common/main/lib/component/Menu.js | 23 +++++++++++++--- apps/documenteditor/main/app/view/Toolbar.js | 25 +++-------------- .../main/app/view/DocumentHolder.js | 4 +-- .../main/app/view/Toolbar.js | 27 ++++--------------- .../main/app/view/Toolbar.js | 25 +++-------------- 6 files changed, 44 insertions(+), 79 deletions(-) diff --git a/apps/common/main/lib/component/DataView.js b/apps/common/main/lib/component/DataView.js index 5aa890434..e6fa66907 100644 --- a/apps/common/main/lib/component/DataView.js +++ b/apps/common/main/lib/component/DataView.js @@ -233,6 +233,8 @@ define([ me.emptyText = me.options.emptyText || ''; me.listenStoreEvents= (me.options.listenStoreEvents!==undefined) ? me.options.listenStoreEvents : true; me.allowScrollbar = (me.options.allowScrollbar!==undefined) ? me.options.allowScrollbar : true; + if (me.parentMenu) + me.parentMenu.options.restoreHeight = (me.options.restoreHeight>0); me.rendered = false; me.dataViewItems = []; if (me.options.keyMoveDirection=='vertical') @@ -688,20 +690,19 @@ define([ var menuRoot = (this.parentMenu.cmpEl.attr('role') === 'menu') ? this.parentMenu.cmpEl : this.parentMenu.cmpEl.find('[role=menu]'), + docH = Common.Utils.innerHeight()-10, innerEl = $(this.el).find('.inner').addBack().filter('.inner'), - docH = Common.Utils.innerHeight(), + parent = innerEl.parent(), + margins = parseInt(parent.css('margin-top')) + parseInt(parent.css('margin-bottom')) + parseInt(menuRoot.css('margin-top')), + paddings = parseInt(menuRoot.css('padding-top')) + parseInt(menuRoot.css('padding-bottom')), menuH = menuRoot.outerHeight(), top = parseInt(menuRoot.css('top')); - if (menuH > docH) { - innerEl.css('max-height', (docH - parseInt(menuRoot.css('padding-top')) - parseInt(menuRoot.css('padding-bottom'))-5) + 'px'); + if (top + menuH > docH ) { + innerEl.css('max-height', (docH - top - paddings - margins) + 'px'); if (this.allowScrollbar) this.scroller.update({minScrollbarLength : 40}); - } else if ( innerEl.height() < this.options.restoreHeight ) { - innerEl.css('max-height', (Math.min(docH - parseInt(menuRoot.css('padding-top')) - parseInt(menuRoot.css('padding-bottom'))-5, this.options.restoreHeight)) + 'px'); - menuH = menuRoot.outerHeight(); - if (top+menuH > docH) { - menuRoot.css('top', 0); - } + } else if ( top + menuH < docH && innerEl.height() < this.options.restoreHeight ) { + innerEl.css('max-height', (Math.min(docH - top - paddings - margins, this.options.restoreHeight)) + 'px'); if (this.allowScrollbar) this.scroller.update({minScrollbarLength : 40}); } }, diff --git a/apps/common/main/lib/component/Menu.js b/apps/common/main/lib/component/Menu.js index c28a62d3d..e83899c9f 100644 --- a/apps/common/main/lib/component/Menu.js +++ b/apps/common/main/lib/component/Menu.js @@ -424,6 +424,9 @@ define([ onAfterShowMenu: function(e) { this.trigger('show:after', this, e); + if (this.options.restoreHeight && this.scroller) + this.scroller.update({minScrollbarLength : 40}); + if (this.$el.find('> ul > .menu-scroll').length) { var el = this.$el.find('li .checked')[0]; if (el) { @@ -562,11 +565,23 @@ define([ left = docW - menuW; } - if (top + menuH > docH) - top = docH - menuH; + if (this.options.restoreHeight) { + if (typeof (this.options.restoreHeight) == "number") { + if (top + menuH > docH) { + menuRoot.css('max-height', (docH - top) + 'px'); + menuH = menuRoot.outerHeight(); + } else if ( top + menuH < docH && menuRoot.height() < this.options.restoreHeight ) { + menuRoot.css('max-height', (Math.min(docH - top, this.options.restoreHeight)) + 'px'); + menuH = menuRoot.outerHeight(); + } + } + } else { + if (top + menuH > docH) + top = docH - menuH; - if (top < 0) - top = 0; + if (top < 0) + top = 0; + } if (this.options.additionalAlign) this.options.additionalAlign.call(this, menuRoot, left, top); diff --git a/apps/documenteditor/main/app/view/Toolbar.js b/apps/documenteditor/main/app/view/Toolbar.js index d9505331f..955ecd0a2 100644 --- a/apps/documenteditor/main/app/view/Toolbar.js +++ b/apps/documenteditor/main/app/view/Toolbar.js @@ -893,8 +893,8 @@ define([ iconCls: 'btn-colorschemas', menu: new Common.UI.Menu({ items: [], - maxHeight: 600, - restoreHeight: 600 + maxHeight: 560, + restoreHeight: 560 }).on('show:before', function (mnu) { if (!this.scroller) { this.scroller = new Common.UI.Scroller({ @@ -904,23 +904,6 @@ define([ alwaysVisibleY: true }); } - }).on('show:after', function (btn, e) { - var mnu = $(this.el).find('.dropdown-menu '), - docH = $(document).height(), - menuH = mnu.outerHeight(), - top = parseInt(mnu.css('top')); - - if (menuH > docH) { - mnu.css('max-height', (docH - parseInt(mnu.css('padding-top')) - parseInt(mnu.css('padding-bottom')) - 5) + 'px'); - this.scroller.update({minScrollbarLength: 40}); - } else if (mnu.height() < this.options.restoreHeight) { - mnu.css('max-height', (Math.min(docH - parseInt(mnu.css('padding-top')) - parseInt(mnu.css('padding-bottom')) - 5, this.options.restoreHeight)) + 'px'); - menuH = mnu.outerHeight(); - if (top + menuH > docH) { - mnu.css('top', 0); - } - this.scroller.update({minScrollbarLength: 40}); - } }) }); this.toolbarControls.push(this.btnColorSchemas); @@ -2165,8 +2148,8 @@ define([ if (this.mnuColorSchema == null) { this.mnuColorSchema = new Common.UI.Menu({ - maxHeight: 600, - restoreHeight: 600 + maxHeight: 560, + restoreHeight: 560 }).on('show:before', function (mnu) { this.scroller = new Common.UI.Scroller({ el: $(this.el).find('.dropdown-menu '), diff --git a/apps/presentationeditor/main/app/view/DocumentHolder.js b/apps/presentationeditor/main/app/view/DocumentHolder.js index 207903d55..c1dcb8796 100644 --- a/apps/presentationeditor/main/app/view/DocumentHolder.js +++ b/apps/presentationeditor/main/app/view/DocumentHolder.js @@ -1900,7 +1900,7 @@ define([ el : $('#id-docholder-menu-changeslide'), parentMenu : mnuChangeSlide.menu, showLast: false, - restoreHeight: 300, + // restoreHeight: 300, style: 'max-height: 300px;', store : PE.getCollection('SlideLayouts'), itemTemplate: _.template([ @@ -1934,7 +1934,7 @@ define([ me.slideThemeMenu = new Common.UI.DataView({ el : $('#id-docholder-menu-changetheme'), parentMenu : mnuChangeTheme.menu, - restoreHeight: 300, + // restoreHeight: 300, style: 'max-height: 300px;', store : PE.getCollection('SlideThemes'), itemTemplate: _.template([ diff --git a/apps/presentationeditor/main/app/view/Toolbar.js b/apps/presentationeditor/main/app/view/Toolbar.js index 916e2a247..212234db0 100644 --- a/apps/presentationeditor/main/app/view/Toolbar.js +++ b/apps/presentationeditor/main/app/view/Toolbar.js @@ -610,8 +610,8 @@ define([ lock : [_set.themeLock, _set.slideDeleted, _set.lostConnect, _set.noSlides, _set.disableOnStart], menu : new Common.UI.Menu({ items : [], - maxHeight : 600, - restoreHeight: 600 + maxHeight : 560, + restoreHeight: 560 }).on('show:before', function(mnu) { this.scroller = new Common.UI.Scroller({ el: $(this.el).find('.dropdown-menu '), @@ -619,24 +619,7 @@ define([ minScrollbarLength : 40, alwaysVisibleY: true }); - }).on('show:after', function(btn, e) { - var mnu = $(this.el).find('.dropdown-menu '), - docH = Common.Utils.innerHeight(), - menuH = mnu.outerHeight(), - top = parseInt(mnu.css('top')); - - if (menuH > docH) { - mnu.css('max-height', (docH - parseInt(mnu.css('padding-top')) - parseInt(mnu.css('padding-bottom'))-5) + 'px'); - this.scroller.update({minScrollbarLength : 40}); - } else if ( mnu.height() < this.options.restoreHeight ) { - mnu.css('max-height', (Math.min(docH - parseInt(mnu.css('padding-top')) - parseInt(mnu.css('padding-bottom'))-5, this.options.restoreHeight)) + 'px'); - menuH = mnu.outerHeight(); - if (top+menuH > docH) { - mnu.css('top', 0); - } - this.scroller.update({minScrollbarLength : 40}); - } - }) + }) }); me.slideOnlyControls.push(me.btnColorSchemas); @@ -1489,8 +1472,8 @@ define([ if (mnuColorSchema == null) { mnuColorSchema = new Common.UI.Menu({ - maxHeight: 600, - restoreHeight: 600 + maxHeight: 560, + restoreHeight: 560 }).on('render:after', function (mnu) { this.scroller = new Common.UI.Scroller({ el: $(this.el).find('.dropdown-menu '), diff --git a/apps/spreadsheeteditor/main/app/view/Toolbar.js b/apps/spreadsheeteditor/main/app/view/Toolbar.js index 7f15a7d56..fec8aa831 100644 --- a/apps/spreadsheeteditor/main/app/view/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/view/Toolbar.js @@ -989,8 +989,8 @@ define([ lock : [_set.editCell, _set.lostConnect, _set.coAuth], menu : new Common.UI.Menu({ items: [], - maxHeight : 600, - restoreHeight: 600 + maxHeight : 560, + restoreHeight: 560 }).on('show:before', function(mnu) { if ( !this.scroller ) { this.scroller = new Common.UI.Scroller({ @@ -1000,23 +1000,6 @@ define([ alwaysVisibleY: true }); } - }).on('show:after', function(btn, e) { - var mnu = $(this.el).find('.dropdown-menu '), - docH = Common.Utils.innerHeight(), - menuH = mnu.outerHeight(), - top = parseInt(mnu.css('top')); - - if (menuH > docH) { - mnu.css('max-height', (docH - parseInt(mnu.css('padding-top')) - parseInt(mnu.css('padding-bottom'))-5) + 'px'); - this.scroller.update({minScrollbarLength : 40}); - } else if ( mnu.height() < this.options.restoreHeight ) { - mnu.css('max-height', (Math.min(docH - parseInt(mnu.css('padding-top')) - parseInt(mnu.css('padding-bottom'))-5, this.options.restoreHeight)) + 'px'); - menuH = mnu.outerHeight(); - if (top+menuH > docH) { - mnu.css('top', 0); - } - this.scroller.update({minScrollbarLength : 40}); - } }) }); @@ -1749,8 +1732,8 @@ define([ } if (this.mnuColorSchema == null) { - this.mnuColorSchema = new Common.UI.Menu({maxHeight : 600, - restoreHeight: 600 + this.mnuColorSchema = new Common.UI.Menu({maxHeight : 560, + restoreHeight: 560 }).on('show:before', function(mnu) { this.scroller = new Common.UI.Scroller({ el: $(this.el).find('.dropdown-menu '),