Merge branch 'develop' into feature/formula-tab

This commit is contained in:
Julia Radzhabova 2019-06-21 11:18:55 +03:00
commit c71c83b4a6
12 changed files with 47 additions and 281 deletions

View file

@ -76,6 +76,11 @@
* Arrow of the {Common.UI.MenuItem} menu items
*
*
* @property {Boolean/Number} restoreHeight
*
* Adjust to the browser height and restore to restoreHeight when it's Number
*
*
*/
if (Common === undefined)
@ -143,7 +148,8 @@ define([
menuAlign : 'tl-bl',
menuAlignEl : null,
offset : [0, 0],
cyclic : true
cyclic : true,
scrollAlwaysVisible: true
},
template: _.template([
@ -162,6 +168,12 @@ define([
this.offset = [0, 0];
this.menuAlign = this.options.menuAlign;
this.menuAlignEl = this.options.menuAlignEl;
this.scrollAlwaysVisible = this.options.scrollAlwaysVisible;
if (this.options.restoreHeight) {
this.options.restoreHeight = (typeof (this.options.restoreHeight) == "number") ? this.options.restoreHeight : (this.options.maxHeight ? this.options.maxHeight : 100000);
!this.options.maxHeight && (this.options.maxHeight = this.options.restoreHeight);
}
if (!this.options.cyclic) this.options.cls += ' no-cyclic';
@ -228,8 +240,17 @@ define([
});
}
if (this.options.maxHeight) {
menuRoot.css({'max-height': me.options.maxHeight});
this.scroller = new Common.UI.Scroller({
el: $(this.el).find('.dropdown-menu '),
minScrollbarLength: 30,
suppressScrollX: true,
alwaysVisibleY: this.scrollAlwaysVisible
});
}
menuRoot.css({
'max-height': me.options.maxHeight||'none',
position : 'fixed',
right : 'auto',
left : -1000,
@ -243,7 +264,6 @@ define([
this.parentEl.on('hide.bs.dropdown', _.bind(me.onBeforeHideMenu, me));
this.parentEl.on('hidden.bs.dropdown', _.bind(me.onAfterHideMenu, me));
this.parentEl.on('keydown.after.bs.dropdown', _.bind(me.onAfterKeydownMenu, me));
menuRoot.on('scroll', _.bind(me.onScroll, me));
menuRoot.hover(
function(e) { me.isOver = true;},
@ -313,64 +333,6 @@ define([
}
},
doLayout: function() {
if (this.options.maxHeight > 0) {
if (!this.rendered) {
this.mustLayout = true;
return;
}
var me = this,
el = this.cmpEl;
var menuRoot = (el.attr('role') === 'menu') ? el : el.find('[role=menu]');
if (!menuRoot.is(':visible')) {
var pos = [menuRoot.css('left'), menuRoot.css('top')];
menuRoot.css({
left : '-1000px',
top : '-1000px',
display : 'block'
});
}
var $items = menuRoot.find('li');
if ($items.height() * $items.length > this.options.maxHeight) {
var scroll = '<div class="menu-scroll top"></div>';
menuRoot.prepend(scroll);
scroll = '<div class="menu-scroll bottom"></div>';
menuRoot.append(scroll);
menuRoot.css({
'box-shadow' : 'none',
'overflow-y' : 'hidden',
'padding-top' : '18px'
// 'padding-bottom' : '18px'
});
menuRoot.find('> li:last-of-type').css('margin-bottom',18);
var addEvent = function( elem, type, fn ) {
elem.addEventListener ? elem.addEventListener( type, fn, false ) : elem.attachEvent( "on" + type, fn );
};
var eventname=(/Firefox/i.test(navigator.userAgent))? 'DOMMouseScroll' : 'mousewheel';
addEvent(menuRoot[0], eventname, _.bind(this.onMouseWheel,this));
menuRoot.find('.menu-scroll').on('click', _.bind(this.onScrollClick, this));
}
if (pos) {
menuRoot.css({
display : '',
left : pos[0],
top : pos[1]
});
}
}
},
addItem: function(item) {
this.insertItem(-1, item);
},
@ -405,19 +367,12 @@ define([
item.off('click').off('toggle');
item.remove();
});
this.rendered && this.cmpEl.find('.menu-scroll').off('click').remove();
me.items = [];
},
onBeforeShowMenu: function(e) {
Common.NotificationCenter.trigger('menu:show');
if (this.mustLayout) {
delete this.mustLayout;
this.doLayout.call(this);
}
this.trigger('show:before', this, e);
this.alignPosition();
},
@ -425,9 +380,7 @@ define([
onAfterShowMenu: function(e) {
this.trigger('show:after', this, e);
if (this.scroller) {
if (this.options.restoreHeight)
this.scroller.update();
this.scroller.update();
var menuRoot = (this.cmpEl.attr('role') === 'menu') ? this.cmpEl : this.cmpEl.find('[role=menu]'),
$selected = menuRoot.find('> li .checked');
if ($selected.length) {
@ -439,14 +392,6 @@ define([
}
}
}
if (this.$el.find('> ul > .menu-scroll').length) {
var el = this.$el.find('li .checked')[0];
if (el) {
var offset = el.offsetTop - this.options.maxHeight / 2;
this.scrollMenu(offset < 0 ? 0 : offset);
}
}
},
onBeforeHideMenu: function(e) {
@ -480,23 +425,6 @@ define([
}
},
onScroll: function(item, e) {
if (this.scroller) return;
var menuRoot = (this.cmpEl.attr('role') === 'menu')
? this.cmpEl
: this.cmpEl.find('[role=menu]'),
scrollTop = menuRoot.scrollTop(),
top = menuRoot.find('.menu-scroll.top'),
bottom = menuRoot.find('.menu-scroll.bottom');
if (this.fromKeyDown) {
top.css('top', scrollTop + 'px');
bottom.css('bottom', (-scrollTop) + 'px');
}
top.toggleClass('disabled', scrollTop<1);
bottom.toggleClass('disabled', scrollTop + this.options.maxHeight > menuRoot[0].scrollHeight-1);
},
onItemClick: function(item, e) {
if (!item.menu) this.isOver = false;
if (item.options.stopPropagation) {
@ -514,32 +442,6 @@ define([
this.trigger('item:toggle', this, item, state, e);
},
onScrollClick: function(e) {
if (/disabled/.test(e.currentTarget.className)) return false;
this.scrollMenu(/top/.test(e.currentTarget.className));
return false;
},
onMouseWheel: function(e) {
this.scrollMenu(((e.detail && -e.detail) || e.wheelDelta) > 0);
},
scrollMenu: function(up) {
this.fromKeyDown = false;
var menuRoot = (this.cmpEl.attr('role') === 'menu')
? this.cmpEl
: this.cmpEl.find('[role=menu]'),
value = typeof(up)==='boolean'
? menuRoot.scrollTop() + (up ? -20 : 20)
: up;
menuRoot.scrollTop(value);
menuRoot.find('.menu-scroll.top').css('top', menuRoot.scrollTop() + 'px');
menuRoot.find('.menu-scroll.bottom').css('bottom', (-menuRoot.scrollTop()) + 'px');
},
setOffset: function(offsetX, offsetY) {
this.offset[0] = _.isUndefined(offsetX) ? this.offset[0] : offsetX;
this.offset[1] = _.isUndefined(offsetY) ? this.offset[1] : offsetY;
@ -590,10 +492,14 @@ define([
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 ) {
(!this.scroller) && (this.scroller = new Common.UI.Scroller({
el: $(this.el).find('.dropdown-menu '),
minScrollbarLength: 30,
suppressScrollX: true,
alwaysVisibleY: this.scrollAlwaysVisible
}));
} 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 {

View file

@ -2711,6 +2711,7 @@ define([
caption : me.moreText,
menu : new Common.UI.Menu({
menuAlign: 'tl-tr',
restoreHeight: true,
items : [
]
})
@ -2721,19 +2722,8 @@ define([
menu : new Common.UI.Menu({
cls: 'lang-menu',
menuAlign: 'tl-tr',
maxHeight: 300,
restoreHeight: 300,
items : [
]
}).on('show:before', function (mnu) {
if (!this.scroller) {
this.scroller = new Common.UI.Scroller({
el: $(this.el).find('.dropdown-menu '),
useKeyboard: this.enableKeyEvents && !this.handleSelect,
minScrollbarLength: 30,
alwaysVisibleY: true
});
}
items : []
})
});
@ -3345,9 +3335,8 @@ define([
caption : me.moreText,
menu : new Common.UI.Menu({
menuAlign: 'tl-tr',
style : 'max-height: 300px;',
items: [
]
restoreHeight: true,
items: []
})
});
@ -3356,19 +3345,8 @@ define([
menu : new Common.UI.Menu({
cls: 'lang-menu',
menuAlign: 'tl-tr',
maxHeight: 300,
restoreHeight: 300,
items : [
]
}).on('show:before', function (mnu) {
if (!this.scroller) {
this.scroller = new Common.UI.Scroller({
el: $(this.el).find('.dropdown-menu '),
useKeyboard: this.enableKeyEvents && !this.handleSelect,
minScrollbarLength: 30,
alwaysVisibleY: true
});
}
items : []
})
});

View file

@ -101,13 +101,6 @@ define([
style: 'min-width: 190px;max-width: 400px;',
maxHeight: 200,
items: []
}).on('render:after', function(mnu) {
this.scroller = new Common.UI.Scroller({
el: this.$el.find('.dropdown-menu'),
useKeyboard: this.enableKeyEvents && !this.handleSelect,
suppressScrollX: true,
minScrollbarLength : 40
});
})
});
this.btnInsField.render( $('#mmerge-btn-ins-field',me.$el)) ;

View file

@ -231,7 +231,6 @@ define([
this.langMenu = new Common.UI.Menu({
cls: 'lang-menu',
style: 'margin-top:-5px;',
maxHeight: 300,
restoreHeight: 300,
itemTemplate: _.template([
'<a id="<%= id %>" tabindex="-1" type="menuitem" style="padding-left: 28px !important;" langval="<%= options.value.value %>">',
@ -240,15 +239,6 @@ define([
'</a>'
].join('')),
menuAlign: 'bl-tl'
}).on('show:before', function (mnu) {
if (!this.scroller) {
this.scroller = new Common.UI.Scroller({
el: $(this.el).find('.dropdown-menu '),
useKeyboard: this.enableKeyEvents && !this.handleSelect,
minScrollbarLength: 30,
alwaysVisibleY: true
});
}
});
this.zoomMenu = new Common.UI.Menu({

View file

@ -827,6 +827,7 @@ define([
iconCls: 'btn-pagesize',
caption: me.capBtnPageSize,
menu: new Common.UI.Menu({
restoreHeight: true,
items: [
{
caption: 'US Letter',
@ -961,17 +962,7 @@ define([
iconCls: 'btn-colorschemas',
menu: new Common.UI.Menu({
items: [],
maxHeight: 560,
restoreHeight: 560
}).on('show:before', function (mnu) {
if (!this.scroller) {
this.scroller = new Common.UI.Scroller({
el: $(this.el).find('.dropdown-menu '),
useKeyboard: this.enableKeyEvents && !this.handleSelect,
minScrollbarLength: 40,
alwaysVisibleY: true
});
}
restoreHeight: true
})
});
this.toolbarControls.push(this.btnColorSchemas);
@ -2078,14 +2069,7 @@ define([
if (this.mnuColorSchema == null) {
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 '),
useKeyboard: this.enableKeyEvents && !this.handleSelect,
minScrollbarLength: 40
});
restoreHeight: true
});
}
this.mnuColorSchema.items = [];

View file

@ -2147,6 +2147,7 @@ define([
caption : me.moreText,
menu : new Common.UI.Menu({
menuAlign: 'tl-tr',
restoreHeight: true,
items : [
]
})
@ -2157,19 +2158,9 @@ define([
menu : new Common.UI.Menu({
cls: 'lang-menu',
menuAlign: 'tl-tr',
maxHeight: 300,
restoreHeight: 300,
items : [
]
}).on('show:before', function (mnu) {
if (!this.scroller) {
this.scroller = new Common.UI.Scroller({
el: $(this.el).find('.dropdown-menu '),
useKeyboard: this.enableKeyEvents && !this.handleSelect,
minScrollbarLength: 30,
alwaysVisibleY: true
});
}
})
});
@ -2224,7 +2215,7 @@ define([
caption : me.moreText,
menu : new Common.UI.Menu({
menuAlign: 'tl-tr',
style : 'max-height: 300px;',
restoreHeight: true,
items: [
]
})
@ -2235,19 +2226,9 @@ define([
menu : new Common.UI.Menu({
cls: 'lang-menu',
menuAlign: 'tl-tr',
maxHeight: 300,
restoreHeight: 300,
items : [
]
}).on('show:before', function (mnu) {
if (!this.scroller) {
this.scroller = new Common.UI.Scroller({
el: $(this.el).find('.dropdown-menu '),
useKeyboard: this.enableKeyEvents && !this.handleSelect,
minScrollbarLength: 30,
alwaysVisibleY: true
});
}
})
});

View file

@ -265,7 +265,6 @@ define([
this.langMenu = new Common.UI.Menu({
cls: 'lang-menu',
style: 'margin-top:-5px;',
maxHeight: 300,
restoreHeight: 300,
itemTemplate: _.template([
'<a id="<%= id %>" tabindex="-1" type="menuitem" style="padding-left: 28px !important;" langval="<%= options.value.value %>">',
@ -274,15 +273,6 @@ define([
'</a>'
].join('')),
menuAlign: 'bl-tl'
}).on('show:before', function (mnu) {
if (!this.scroller) {
this.scroller = new Common.UI.Scroller({
el: $(this.el).find('.dropdown-menu '),
useKeyboard: this.enableKeyEvents && !this.handleSelect,
minScrollbarLength: 30,
alwaysVisibleY: true
});
}
});
this.btnLanguage = new Common.UI.Button({

View file

@ -578,15 +578,7 @@ define([
lock: [_set.themeLock, _set.slideDeleted, _set.lostConnect, _set.noSlides, _set.disableOnStart],
menu: new Common.UI.Menu({
items: [],
maxHeight: 560,
restoreHeight: 560
}).on('show:before', function (mnu) {
this.scroller = new Common.UI.Scroller({
el: $(this.el).find('.dropdown-menu '),
useKeyboard: this.enableKeyEvents && !this.handleSelect,
minScrollbarLength: 40,
alwaysVisibleY: true
});
restoreHeight: true
})
});
me.slideOnlyControls.push(me.btnColorSchemas);
@ -1275,14 +1267,7 @@ define([
if (mnuColorSchema == null) {
mnuColorSchema = new Common.UI.Menu({
maxHeight: 560,
restoreHeight: 560
}).on('render:after', function (mnu) {
this.scroller = new Common.UI.Scroller({
el: $(this.el).find('.dropdown-menu '),
useKeyboard: this.enableKeyEvents && !this.handleSelect,
minScrollbarLength: 40
});
restoreHeight: true
});
}
mnuColorSchema.items = [];

View file

@ -62,12 +62,6 @@ define([
{ caption: this.textManager, value: 'manager' },
{ caption: '--' }
]
}).on('render:after', function(mnu) {
this.scroller = new Common.UI.Scroller({
el: $(this.el).find('.dropdown-menu '),
useKeyboard: this.enableKeyEvents && !this.handleSelect,
minScrollbarLength : 40
});
}).on('show:after', function () {
this.scroller.update({alwaysVisibleY: true});
})

View file

@ -926,13 +926,6 @@ define([
maxHeight: 200,
cyclic: false,
items: []
}).on('render:after', function(mnu) {
this.scroller = new Common.UI.Scroller({
el: $(this.el).find('.dropdown-menu '),
useKeyboard: this.enableKeyEvents && !this.handleSelect,
minScrollbarLength : 40,
alwaysVisibleY: true
});
}).on('show:after', function () {
this.scroller.update({alwaysVisibleY: true});
});
@ -943,12 +936,6 @@ define([
items: []
}).on('render:after', function(mnu) {
mnu.cmpEl.removeAttr('oo_editor_input').attr('oo_editor_keyboard', true);
this.scroller = new Common.UI.Scroller({
el: $(this.el).find('.dropdown-menu '),
useKeyboard: this.enableKeyEvents && !this.handleSelect,
minScrollbarLength : 40,
alwaysVisibleY: true
});
});
me.fireEvent('createdelayedelements', [me]);

View file

@ -201,13 +201,6 @@ define([
var menuHiddenItems = new Common.UI.Menu({
maxHeight: 260,
menuAlign: 'tl-tr'
}).on('render:after', function(mnu) {
this.scroller = new Common.UI.Scroller({
el: $(this.el).find('.dropdown-menu '),
useKeyboard: this.enableKeyEvents && !this.handleSelect,
minScrollbarLength : 40,
alwaysVisibleY: true
});
}).on('show:after', function () {
this.scroller.update({alwaysVisibleY: true});
});

View file

@ -1006,17 +1006,7 @@ define([
lock : [_set.editCell, _set.lostConnect, _set.coAuth],
menu : new Common.UI.Menu({
items: [],
maxHeight : 560,
restoreHeight: 560
}).on('show:before', function(mnu) {
if ( !this.scroller ) {
this.scroller = new Common.UI.Scroller({
el: $(this.el).find('.dropdown-menu '),
useKeyboard: this.enableKeyEvents && !this.handleSelect,
minScrollbarLength : 40,
alwaysVisibleY: true
});
}
restoreHeight: true
})
});
@ -1202,6 +1192,7 @@ define([
caption: me.capBtnPageSize,
lock : [_set.docPropsLock, _set.lostConnect, _set.coAuth],
menu: new Common.UI.Menu({
restoreHeight: true,
items: [
{
caption: 'US Letter',
@ -1924,14 +1915,8 @@ define([
}
if (this.mnuColorSchema == null) {
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 '),
useKeyboard: this.enableKeyEvents && !this.handleSelect,
minScrollbarLength : 40
});
this.mnuColorSchema = new Common.UI.Menu({
restoreHeight: true
});
}