Fix Bug 35630.

This commit is contained in:
Julia Radzhabova 2017-09-15 13:31:59 +03:00
parent 3eb03d128f
commit eb5f62a041
6 changed files with 44 additions and 79 deletions

View file

@ -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});
}
},

View file

@ -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);

View file

@ -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 '),

View file

@ -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([

View file

@ -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 '),

View file

@ -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 '),