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 * 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) if (Common === undefined)
@ -143,7 +148,8 @@ define([
menuAlign : 'tl-bl', menuAlign : 'tl-bl',
menuAlignEl : null, menuAlignEl : null,
offset : [0, 0], offset : [0, 0],
cyclic : true cyclic : true,
scrollAlwaysVisible: true
}, },
template: _.template([ template: _.template([
@ -162,6 +168,12 @@ define([
this.offset = [0, 0]; this.offset = [0, 0];
this.menuAlign = this.options.menuAlign; this.menuAlign = this.options.menuAlign;
this.menuAlignEl = this.options.menuAlignEl; 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'; 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({ menuRoot.css({
'max-height': me.options.maxHeight||'none',
position : 'fixed', position : 'fixed',
right : 'auto', right : 'auto',
left : -1000, left : -1000,
@ -243,7 +264,6 @@ define([
this.parentEl.on('hide.bs.dropdown', _.bind(me.onBeforeHideMenu, me)); this.parentEl.on('hide.bs.dropdown', _.bind(me.onBeforeHideMenu, me));
this.parentEl.on('hidden.bs.dropdown', _.bind(me.onAfterHideMenu, me)); this.parentEl.on('hidden.bs.dropdown', _.bind(me.onAfterHideMenu, me));
this.parentEl.on('keydown.after.bs.dropdown', _.bind(me.onAfterKeydownMenu, me)); this.parentEl.on('keydown.after.bs.dropdown', _.bind(me.onAfterKeydownMenu, me));
menuRoot.on('scroll', _.bind(me.onScroll, me));
menuRoot.hover( menuRoot.hover(
function(e) { me.isOver = true;}, 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) { addItem: function(item) {
this.insertItem(-1, item); this.insertItem(-1, item);
}, },
@ -405,19 +367,12 @@ define([
item.off('click').off('toggle'); item.off('click').off('toggle');
item.remove(); item.remove();
}); });
this.rendered && this.cmpEl.find('.menu-scroll').off('click').remove();
me.items = []; me.items = [];
}, },
onBeforeShowMenu: function(e) { onBeforeShowMenu: function(e) {
Common.NotificationCenter.trigger('menu:show'); Common.NotificationCenter.trigger('menu:show');
if (this.mustLayout) {
delete this.mustLayout;
this.doLayout.call(this);
}
this.trigger('show:before', this, e); this.trigger('show:before', this, e);
this.alignPosition(); this.alignPosition();
}, },
@ -425,9 +380,7 @@ define([
onAfterShowMenu: function(e) { onAfterShowMenu: function(e) {
this.trigger('show:after', this, e); this.trigger('show:after', this, e);
if (this.scroller) { 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]'), var menuRoot = (this.cmpEl.attr('role') === 'menu') ? this.cmpEl : this.cmpEl.find('[role=menu]'),
$selected = menuRoot.find('> li .checked'); $selected = menuRoot.find('> li .checked');
if ($selected.length) { 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) { 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) { onItemClick: function(item, e) {
if (!item.menu) this.isOver = false; if (!item.menu) this.isOver = false;
if (item.options.stopPropagation) { if (item.options.stopPropagation) {
@ -514,32 +442,6 @@ define([
this.trigger('item:toggle', this, item, state, e); 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) { setOffset: function(offsetX, offsetY) {
this.offset[0] = _.isUndefined(offsetX) ? this.offset[0] : offsetX; this.offset[0] = _.isUndefined(offsetX) ? this.offset[0] : offsetX;
this.offset[1] = _.isUndefined(offsetY) ? this.offset[1] : offsetY; this.offset[1] = _.isUndefined(offsetY) ? this.offset[1] : offsetY;
@ -590,10 +492,14 @@ define([
if (typeof (this.options.restoreHeight) == "number") { if (typeof (this.options.restoreHeight) == "number") {
if (top + menuH > docH) { if (top + menuH > docH) {
menuRoot.css('max-height', (docH - top) + 'px'); menuRoot.css('max-height', (docH - top) + 'px');
menuH = menuRoot.outerHeight(); (!this.scroller) && (this.scroller = new Common.UI.Scroller({
} else if ( top + menuH < docH && menuRoot.height() < this.options.restoreHeight ) { 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'); menuRoot.css('max-height', (Math.min(docH - top, this.options.restoreHeight)) + 'px');
menuH = menuRoot.outerHeight();
} }
} }
} else { } else {

View file

@ -2711,6 +2711,7 @@ define([
caption : me.moreText, caption : me.moreText,
menu : new Common.UI.Menu({ menu : new Common.UI.Menu({
menuAlign: 'tl-tr', menuAlign: 'tl-tr',
restoreHeight: true,
items : [ items : [
] ]
}) })
@ -2721,19 +2722,8 @@ define([
menu : new Common.UI.Menu({ menu : new Common.UI.Menu({
cls: 'lang-menu', cls: 'lang-menu',
menuAlign: 'tl-tr', menuAlign: 'tl-tr',
maxHeight: 300,
restoreHeight: 300, restoreHeight: 300,
items : [ 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
});
}
}) })
}); });
@ -3345,9 +3335,8 @@ define([
caption : me.moreText, caption : me.moreText,
menu : new Common.UI.Menu({ menu : new Common.UI.Menu({
menuAlign: 'tl-tr', menuAlign: 'tl-tr',
style : 'max-height: 300px;', restoreHeight: true,
items: [ items: []
]
}) })
}); });
@ -3356,19 +3345,8 @@ define([
menu : new Common.UI.Menu({ menu : new Common.UI.Menu({
cls: 'lang-menu', cls: 'lang-menu',
menuAlign: 'tl-tr', menuAlign: 'tl-tr',
maxHeight: 300,
restoreHeight: 300, restoreHeight: 300,
items : [ 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

@ -101,13 +101,6 @@ define([
style: 'min-width: 190px;max-width: 400px;', style: 'min-width: 190px;max-width: 400px;',
maxHeight: 200, maxHeight: 200,
items: [] 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)) ; this.btnInsField.render( $('#mmerge-btn-ins-field',me.$el)) ;

View file

@ -231,7 +231,6 @@ define([
this.langMenu = new Common.UI.Menu({ this.langMenu = new Common.UI.Menu({
cls: 'lang-menu', cls: 'lang-menu',
style: 'margin-top:-5px;', style: 'margin-top:-5px;',
maxHeight: 300,
restoreHeight: 300, restoreHeight: 300,
itemTemplate: _.template([ itemTemplate: _.template([
'<a id="<%= id %>" tabindex="-1" type="menuitem" style="padding-left: 28px !important;" langval="<%= options.value.value %>">', '<a id="<%= id %>" tabindex="-1" type="menuitem" style="padding-left: 28px !important;" langval="<%= options.value.value %>">',
@ -240,15 +239,6 @@ define([
'</a>' '</a>'
].join('')), ].join('')),
menuAlign: 'bl-tl' 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({ this.zoomMenu = new Common.UI.Menu({

View file

@ -827,6 +827,7 @@ define([
iconCls: 'btn-pagesize', iconCls: 'btn-pagesize',
caption: me.capBtnPageSize, caption: me.capBtnPageSize,
menu: new Common.UI.Menu({ menu: new Common.UI.Menu({
restoreHeight: true,
items: [ items: [
{ {
caption: 'US Letter', caption: 'US Letter',
@ -961,17 +962,7 @@ define([
iconCls: 'btn-colorschemas', iconCls: 'btn-colorschemas',
menu: new Common.UI.Menu({ menu: new Common.UI.Menu({
items: [], items: [],
maxHeight: 560, restoreHeight: true
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
});
}
}) })
}); });
this.toolbarControls.push(this.btnColorSchemas); this.toolbarControls.push(this.btnColorSchemas);
@ -2078,14 +2069,7 @@ define([
if (this.mnuColorSchema == null) { if (this.mnuColorSchema == null) {
this.mnuColorSchema = new Common.UI.Menu({ this.mnuColorSchema = new Common.UI.Menu({
maxHeight: 560, restoreHeight: true
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.items = []; this.mnuColorSchema.items = [];

View file

@ -2147,6 +2147,7 @@ define([
caption : me.moreText, caption : me.moreText,
menu : new Common.UI.Menu({ menu : new Common.UI.Menu({
menuAlign: 'tl-tr', menuAlign: 'tl-tr',
restoreHeight: true,
items : [ items : [
] ]
}) })
@ -2157,19 +2158,9 @@ define([
menu : new Common.UI.Menu({ menu : new Common.UI.Menu({
cls: 'lang-menu', cls: 'lang-menu',
menuAlign: 'tl-tr', menuAlign: 'tl-tr',
maxHeight: 300,
restoreHeight: 300, restoreHeight: 300,
items : [ 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, caption : me.moreText,
menu : new Common.UI.Menu({ menu : new Common.UI.Menu({
menuAlign: 'tl-tr', menuAlign: 'tl-tr',
style : 'max-height: 300px;', restoreHeight: true,
items: [ items: [
] ]
}) })
@ -2235,19 +2226,9 @@ define([
menu : new Common.UI.Menu({ menu : new Common.UI.Menu({
cls: 'lang-menu', cls: 'lang-menu',
menuAlign: 'tl-tr', menuAlign: 'tl-tr',
maxHeight: 300,
restoreHeight: 300, restoreHeight: 300,
items : [ 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({ this.langMenu = new Common.UI.Menu({
cls: 'lang-menu', cls: 'lang-menu',
style: 'margin-top:-5px;', style: 'margin-top:-5px;',
maxHeight: 300,
restoreHeight: 300, restoreHeight: 300,
itemTemplate: _.template([ itemTemplate: _.template([
'<a id="<%= id %>" tabindex="-1" type="menuitem" style="padding-left: 28px !important;" langval="<%= options.value.value %>">', '<a id="<%= id %>" tabindex="-1" type="menuitem" style="padding-left: 28px !important;" langval="<%= options.value.value %>">',
@ -274,15 +273,6 @@ define([
'</a>' '</a>'
].join('')), ].join('')),
menuAlign: 'bl-tl' 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({ this.btnLanguage = new Common.UI.Button({

View file

@ -578,15 +578,7 @@ define([
lock: [_set.themeLock, _set.slideDeleted, _set.lostConnect, _set.noSlides, _set.disableOnStart], lock: [_set.themeLock, _set.slideDeleted, _set.lostConnect, _set.noSlides, _set.disableOnStart],
menu: new Common.UI.Menu({ menu: new Common.UI.Menu({
items: [], items: [],
maxHeight: 560, restoreHeight: true
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
});
}) })
}); });
me.slideOnlyControls.push(me.btnColorSchemas); me.slideOnlyControls.push(me.btnColorSchemas);
@ -1275,14 +1267,7 @@ define([
if (mnuColorSchema == null) { if (mnuColorSchema == null) {
mnuColorSchema = new Common.UI.Menu({ mnuColorSchema = new Common.UI.Menu({
maxHeight: 560, restoreHeight: true
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
});
}); });
} }
mnuColorSchema.items = []; mnuColorSchema.items = [];

View file

@ -62,12 +62,6 @@ define([
{ caption: this.textManager, value: 'manager' }, { caption: this.textManager, value: 'manager' },
{ caption: '--' } { 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 () { }).on('show:after', function () {
this.scroller.update({alwaysVisibleY: true}); this.scroller.update({alwaysVisibleY: true});
}) })

View file

@ -926,13 +926,6 @@ define([
maxHeight: 200, maxHeight: 200,
cyclic: false, cyclic: false,
items: [] 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 () { }).on('show:after', function () {
this.scroller.update({alwaysVisibleY: true}); this.scroller.update({alwaysVisibleY: true});
}); });
@ -943,12 +936,6 @@ define([
items: [] items: []
}).on('render:after', function(mnu) { }).on('render:after', function(mnu) {
mnu.cmpEl.removeAttr('oo_editor_input').attr('oo_editor_keyboard', true); 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]); me.fireEvent('createdelayedelements', [me]);

View file

@ -201,13 +201,6 @@ define([
var menuHiddenItems = new Common.UI.Menu({ var menuHiddenItems = new Common.UI.Menu({
maxHeight: 260, maxHeight: 260,
menuAlign: 'tl-tr' 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 () { }).on('show:after', function () {
this.scroller.update({alwaysVisibleY: true}); this.scroller.update({alwaysVisibleY: true});
}); });

View file

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