Merge pull request #64 from ONLYOFFICE/release/v5.1.0

Release/v5.1.0
This commit is contained in:
Alexander Vnuchkov 2018-03-19 15:32:46 +03:00 committed by GitHub
commit 366d7fcae6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 183 additions and 64 deletions

View file

@ -324,7 +324,7 @@
}
if (typeof _config.document.fileType === 'string' && _config.document.fileType != '') {
var type = /^(?:(xls|xlsx|ods|csv|xlst|xlsy|gsheet|xlsm|xlt|xltm|xltx|fods)|(pps|ppsx|ppt|pptx|odp|pptt|ppty|gslides|pot|potm|potx|ppsm|pptm|fodp)|(doc|docx|doct|odt|gdoc|txt|rtf|pdf|mht|htm|html|epub|djvu|xps|docm|dot|dotm|dotx|fodt))$/
var type = /^(?:(xls|xlsx|ods|csv|xlst|xlsy|gsheet|xlsm|xlt|xltm|xltx|fods|ots)|(pps|ppsx|ppt|pptx|odp|pptt|ppty|gslides|pot|potm|potx|ppsm|pptm|fodp|otp)|(doc|docx|doct|odt|gdoc|txt|rtf|pdf|mht|htm|html|epub|djvu|xps|docm|dot|dotm|dotx|fodt|ott))$/
.exec(_config.document.fileType);
if (!type) {
window.alert("The \"document.fileType\" parameter for the config object is invalid. Please correct it.");

View file

@ -112,6 +112,8 @@ define([
this._input.on('keyup', _.bind(this.onInputKeyUp, this));
this._input.on('keydown', _.bind(this.onInputKeyDown, this));
this._input.on('focus', _.bind(function() {this.inFormControl = true;}, this));
this._input.on('blur', _.bind(function() {this.inFormControl = false;}, this));
this._modalParents = this.cmpEl.closest('.asc-window');
@ -318,6 +320,15 @@ define([
},
onApiChangeFont: function(font) {
var me = this;
setTimeout(function () {
me.onApiChangeFontInternal(font);
}, 100);
},
onApiChangeFontInternal: function(font) {
if (this.inFormControl) return;
var name = (_.isFunction(font.get_Name) ? font.get_Name() : font.asc_getName());
if (this.getRawValue() !== name) {

View file

@ -197,6 +197,7 @@ define([
emptyText: '',
listenStoreEvents: true,
allowScrollbar: true,
scrollAlwaysVisible: false,
showLast: true,
useBSKeydown: false
},
@ -239,6 +240,7 @@ 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;
me.scrollAlwaysVisible = me.options.scrollAlwaysVisible || false;
if (me.parentMenu)
me.parentMenu.options.restoreHeight = (me.options.restoreHeight>0);
me.rendered = false;
@ -308,7 +310,8 @@ define([
el: $(this.el).find('.inner').addBack().filter('.inner'),
useKeyboard: this.enableKeyEvents && !this.handleSelect,
minScrollbarLength : 40,
wheelSpeed: 10
wheelSpeed: 10,
alwaysVisibleY: this.scrollAlwaysVisible
});
}
@ -361,11 +364,12 @@ define([
if (suspendEvents)
this.resumeEvents();
return record;
},
selectByIndex: function(index, suspendEvents) {
if (this.store.length > 0 && index > -1 && index < this.store.length) {
this.selectRecord(this.store.at(index), suspendEvents);
return this.selectRecord(this.store.at(index), suspendEvents);
}
},
@ -480,7 +484,8 @@ define([
el: $(this.el).find('.inner').addBack().filter('.inner'),
useKeyboard: this.enableKeyEvents && !this.handleSelect,
minScrollbarLength : 40,
wheelSpeed: 10
wheelSpeed: 10,
alwaysVisibleY: this.scrollAlwaysVisible
});
}
@ -568,18 +573,21 @@ define([
},
scrollToRecord: function (record) {
if (!record) return;
var innerEl = $(this.el).find('.inner'),
inner_top = innerEl.offset().top,
idx = _.indexOf(this.store.models, record),
div = (idx>=0 && this.dataViewItems.length>idx) ? $(this.dataViewItems[idx].el) : innerEl.find('#' + record.get('id'));
if (div.length<=0) return;
var div_top = div.offset().top;
if (div_top < inner_top+div[0].offsetTop || div_top+div.outerHeight() > inner_top + innerEl.height()) {
var div_top = div.offset().top,
div_first = $(this.dataViewItems[0].el),
div_first_top = (div_first.length>0) ? div_first[0].offsetTop : 0;
if (div_top < inner_top + div_first_top || div_top+div.outerHeight() > inner_top + innerEl.height()) {
if (this.scroller && this.allowScrollbar) {
this.scroller.scrollTop(innerEl.scrollTop() + div_top - inner_top - div[0].offsetTop, 0);
this.scroller.scrollTop(innerEl.scrollTop() + div_top - inner_top - div_first_top, 0);
} else {
innerEl.scrollTop(innerEl.scrollTop() + div_top - inner_top - div[0].offsetTop);
innerEl.scrollTop(innerEl.scrollTop() + div_top - inner_top - div_first_top);
}
}
},
@ -716,14 +724,16 @@ define([
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'));
top = parseInt(menuRoot.css('top')),
props = {minScrollbarLength : 40};
this.scrollAlwaysVisible && (props.alwaysVisibleY = this.scrollAlwaysVisible);
if (top + menuH > docH ) {
innerEl.css('max-height', (docH - top - paddings - margins) + 'px');
if (this.allowScrollbar) this.scroller.update({minScrollbarLength : 40});
if (this.allowScrollbar) 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');
if (this.allowScrollbar) this.scroller.update({minScrollbarLength : 40});
if (this.allowScrollbar) this.scroller.update(props);
}
},

View file

@ -225,6 +225,8 @@ define([
},
resizeStart: function(e) {
if (this.freeze) return;
this.clearSelection();
this.addHandler(window.document, 'selectstart', this.onSelectStart);

View file

@ -448,7 +448,7 @@ define([
if (isNaN(val))
val = this.oldValue;
} else {
val = me.options.defaultValue;
val = me.options.defaultValue - me.options.step;
}
me.setValue((this._add(val, me.options.step, (me.options.allowDecimal) ? 3 : 0) + ' ' + this.options.defaultUnit).trim(), suspend);
}

View file

@ -158,6 +158,7 @@ define([
handleSelect: true,
showLast: true,
allowScrollbar: true,
scrollAlwaysVisible: true,
emptyItemText: ''
},
@ -245,24 +246,24 @@ define([
var isExpanded = !record.get('isExpanded');
record.set('isExpanded', isExpanded);
this.store[(isExpanded) ? 'expandSubItems' : 'collapseSubItems'](record);
this.scroller.update({minScrollbarLength: 40});
this.scroller.update({minScrollbarLength: 40, alwaysVisibleY: this.scrollAlwaysVisible});
} else
Common.UI.DataView.prototype.onClickItem.call(this, view, record, e);
},
expandAll: function() {
this.store.expandAll();
this.scroller.update({minScrollbarLength: 40});
this.scroller.update({minScrollbarLength: 40, alwaysVisibleY: this.scrollAlwaysVisible});
},
collapseAll: function() {
this.store.collapseAll();
this.scroller.update({minScrollbarLength: 40});
this.scroller.update({minScrollbarLength: 40, alwaysVisibleY: this.scrollAlwaysVisible});
},
expandToLevel: function(expandLevel) {
this.store.expandToLevel(expandLevel);
this.scroller.update({minScrollbarLength: 40});
this.scroller.update({minScrollbarLength: 40, alwaysVisibleY: this.scrollAlwaysVisible});
}
}
})());

View file

@ -191,6 +191,10 @@ function clearMenus(isFromInputControl) {
$('.dropdown-toggle').each(function (e) {
var $parent = ($(this)).parent();
if (!$parent.hasClass('open')) return;
if ($parent.attr('data-value') == 'prevent-canvas-click') {
$parent.attr('data-value','');
return;
}
$parent.trigger(e = $.Event('hide.bs.dropdown'));
if (e.isDefaultPrevented()) return;
$parent.removeClass('open').trigger('hidden.bs.dropdown', isFromInputControl);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View file

@ -37,7 +37,7 @@
.tree-item {
width: 100%;
min-height: 28px;
padding: 0px 0 0 24px;
padding: 0px 6px 0 24px;
}
.name {

View file

@ -85,6 +85,9 @@ define([
this.api.asc_registerCallback('asc_onCanAddHyperlink', _.bind(this.onApiCanAddHyperlink, this));
this.api.asc_registerCallback('asc_onCoAuthoringDisconnect',_.bind(this.onCoAuthoringDisconnect, this));
Common.NotificationCenter.on('api:disconnect', _.bind(this.onCoAuthoringDisconnect, this));
this.api.asc_registerCallback('asc_onShowContentControlsActions',_.bind(this.onShowContentControlsActions, this));
this.api.asc_registerCallback('asc_onHideContentControlsActions',_.bind(this.onHideContentControlsActions, this));
}
return this;
},
@ -206,10 +209,10 @@ define([
},
onTableContents: function(type, currentTOC){
currentTOC = !!currentTOC;
var props = this.api.asc_GetTableOfContentsPr(currentTOC);
switch (type) {
case 0:
var props = this.api.asc_GetTableOfContentsPr(),
hasTable = !!props;
if (!props) {
props = new Asc.CTableOfContentsPr();
props.put_OutlineRange(1, 9);
@ -218,11 +221,9 @@ define([
props.put_ShowPageNumbers(true);
props.put_RightAlignTab(true);
props.put_TabLeader( Asc.c_oAscTabLeader.Dot);
this.api.asc_AddTableOfContents(null, props);
(currentTOC) ? this.api.asc_SetTableOfContentsPr(props) : this.api.asc_AddTableOfContents(null, props);
break;
case 1:
var props = this.api.asc_GetTableOfContentsPr(),
hasTable = !!props;
if (!props) {
props = new Asc.CTableOfContentsPr();
props.put_OutlineRange(1, 9);
@ -230,13 +231,11 @@ define([
props.put_Hyperlink(true);
props.put_ShowPageNumbers(false);
props.put_TabLeader( Asc.c_oAscTabLeader.None);
this.api.asc_AddTableOfContents(null, props);
(currentTOC) ? this.api.asc_SetTableOfContentsPr(props) : this.api.asc_AddTableOfContents(null, props);
break;
case 'settings':
currentTOC = !!currentTOC;
var props = this.api.asc_GetTableOfContentsPr(currentTOC),
me = this;
var win = new DE.Views.TableOfContentsSettings({
var me = this,
win = new DE.Views.TableOfContentsSettings({
api: this.api,
props: props,
handler: function(result, value) {
@ -249,15 +248,19 @@ define([
win.show();
break;
case 'remove':
this.api.asc_RemoveTableOfContents();
if (currentTOC)
currentTOC = props.get_InternalClass();
this.api.asc_RemoveTableOfContents(currentTOC);
break;
}
Common.NotificationCenter.trigger('edit:complete', this.toolbar);
},
onTableContentsUpdate: function(type, currentTOC){
if (currentTOC)
currentTOC = this.api.asc_GetTableOfContentsPr(currentTOC).get_InternalClass();
this.api.asc_UpdateTableOfContents(type == 'pages', currentTOC);
Common.NotificationCenter.trigger('edit:complete', this.toolbar);
},
onNotesClick: function(type) {
@ -306,6 +309,48 @@ define([
}, 50);
break;
}
},
onShowContentControlsActions: function(action, x, y) {
var menu = (action==1) ? this.view.contentsUpdateMenu : this.view.contentsMenu,
documentHolderView = this.getApplication().getController('DocumentHolder').documentHolder,
menuContainer = documentHolderView.cmpEl.find(Common.Utils.String.format('#menu-container-{0}', menu.id)),
me = this;
if (!menu) return;
this._fromShowContentControls = true;
Common.UI.Menu.Manager.hideAll();
if (!menu.rendered) {
// Prepare menu container
if (menuContainer.length < 1) {
menuContainer = $(Common.Utils.String.format('<div id="menu-container-{0}" style="position: absolute; z-index: 10000;"><div class="dropdown-toggle" data-toggle="dropdown"></div></div>', menu.id));
documentHolderView.cmpEl.append(menuContainer);
}
menu.render(menuContainer);
menu.cmpEl.attr({tabindex: "-1"});
menu.on('hide:after', function(){
if (!me._fromShowContentControls)
me.api.asc_UncheckContentControlButtons();
});
}
menuContainer.css({left: x, top : y});
menuContainer.attr('data-value', 'prevent-canvas-click');
documentHolderView._preventClick = true;
menu.show();
menu.alignPosition();
_.delay(function() {
menu.cmpEl.focus();
}, 10);
this._fromShowContentControls = false;
},
onHideContentControlsActions: function() {
this.view.contentsMenu && this.view.contentsMenu.hide();
this.view.contentsUpdateMenu && this.view.contentsUpdateMenu.hide();
}
}, DE.Controllers.Links || {}));

View file

@ -210,6 +210,8 @@ define([
me.dontCloseDummyComment = true;
else if (/chat-msg-text/.test(e.target.id))
me.dontCloseChat = true;
else if (/form-control/.test(e.target.className))
me.inFormControl = true;
}
});
@ -226,6 +228,8 @@ define([
me.dontCloseDummyComment = false;
else if (/chat-msg-text/.test(e.target.id))
me.dontCloseChat = false;
else if (/form-control/.test(e.target.className))
me.inFormControl = false;
}
}
}).on('dragover', function(e) {
@ -665,7 +669,7 @@ define([
if ( type == Asc.c_oAscAsyncActionType.BlockInteraction &&
(!this.getApplication().getController('LeftMenu').dlgSearch || !this.getApplication().getController('LeftMenu').dlgSearch.isVisible()) &&
!( id == Asc.c_oAscAsyncAction['ApplyChanges'] && (this.dontCloseDummyComment || this.dontCloseChat || this.isModalShowed )) ) {
!( id == Asc.c_oAscAsyncAction['ApplyChanges'] && (this.dontCloseDummyComment || this.dontCloseChat || this.isModalShowed || this.inFormControl)) ) {
// this.onEditComplete(this.loadMask); //если делать фокус, то при принятии чужих изменений, заканчивается свой композитный ввод
this.api.asc_enableKeyEvents(true);
}

View file

@ -136,6 +136,7 @@ define([
arr[0].set('tip', this.txtGotoBeginning);
}
this.getApplication().getCollection('Navigation').reset(arr);
this.onChangeOutlinePosition(this._navigationObject.get_CurrentPosition());
},
updateChangeNavigation: function(index) {
@ -152,7 +153,7 @@ define([
},
onChangeOutlinePosition: function(index) {
this.panelNavigation.viewNavigationList.selectByIndex(index);
this.panelNavigation.viewNavigationList.scrollToRecord(this.panelNavigation.viewNavigationList.selectByIndex(index));
},
onItemContextMenu: function(picker, item, record, e){

View file

@ -316,7 +316,10 @@ define([
});
meEl.on('click', function(e){
if (e.target.localName == 'canvas') {
meEl.focus();
if (me._preventClick)
me._preventClick = false;
else
meEl.focus();
}
});
meEl.on('mousedown', function(e){

View file

@ -57,6 +57,11 @@ define([
me.fireEvent('links:contents', [0]);
});
});
this.contentsMenu.on('item:click', function (menu, item, e) {
setTimeout(function(){
me.fireEvent('links:contents', [item.value, true]);
}, 10);
});
this.btnContentsUpdate.menu.on('item:click', function (menu, item, e) {
me.fireEvent('links:update', [item.value]);
@ -64,6 +69,11 @@ define([
this.btnContentsUpdate.on('click', function (b, e) {
me.fireEvent('links:update', ['all']);
});
this.contentsUpdateMenu.on('item:click', function (menu, item, e) {
setTimeout(function(){
me.fireEvent('links:update', [item.value, true]);
}, 10);
});
this.btnsNotes.forEach(function(button) {
button.menu.on('item:click', function (menu, item, e) {
@ -180,7 +190,16 @@ define([
btn.setMenu(_menu);
});
me.btnContentsUpdate.updateHint(me.tipContentsUpdate);
me.contentsMenu = new Common.UI.Menu({
items: [
{template: contentsTemplate, offsety: 0, value: 0},
{template: contentsTemplate, offsety: 72, value: 1},
{caption: me.textContentsSettings, value: 'settings'},
{caption: me.textContentsRemove, value: 'remove'}
]
});
me.btnContentsUpdate.updateHint([me.textUpdateAll, me.tipContentsUpdate]);
me.btnContentsUpdate.setMenu(new Common.UI.Menu({
items: [
{caption: me.textUpdateAll, value: 'all'},
@ -188,6 +207,13 @@ define([
]
}));
me.contentsUpdateMenu = new Common.UI.Menu({
items: [
{caption: me.textUpdateAll, value: 'all'},
{caption: me.textUpdatePages, value: 'pages'}
]
});
me.btnsNotes.forEach( function(btn, index) {
btn.updateHint( me.tipNotes );

View file

@ -91,8 +91,8 @@ define([
'<tr>',
'<td class="padding-small">',
'<label class="input-label padding-small" style="display: block;">' + me.textBuildTable + '</label>',
'<div id="tableofcontents-radio-styles" class="padding-small" style="display: block;"></div>',
'<div id="tableofcontents-radio-levels" class="" style="display: block;"></div>',
'<div id="tableofcontents-radio-levels" class="padding-small" style="display: block;"></div>',
'<div id="tableofcontents-radio-styles" class="" style="display: block;"></div>',
'</td>',
'</tr>',
'<tr>',
@ -358,7 +358,8 @@ define([
var me = this,
docStyles = this.api.asc_GetStylesArray(),
styles = [];
styles = [],
checkStyles = false;
_.each(docStyles, function (style) {
var name = style.get_Name(),
level = me.api.asc_GetHeadingLevel(name);
@ -456,7 +457,7 @@ define([
}
this.spnLevels.setValue(new_end>0 ? new_end : '', true);
this.spnLevels.setDisabled(disable_outlines || new_start>1 );
checkStyles = (disable_outlines || new_start>1);
} else {
for (var i=this.startLevel; i<=this.endLevel; i++) {
var rec = _.findWhere(styles, {headerLevel: i});
@ -466,8 +467,15 @@ define([
}
}
}
styles.sort(function(a, b){
var aname = a.name.toLocaleLowerCase(),
bname = b.name.toLocaleLowerCase();
if (aname < bname) return -1;
if (aname > bname) return 1;
return 0;
});
this.stylesLevels.reset(styles);
if (this.spnLevels.isDisabled()) {
if (checkStyles) {
this.radioStyles.setValue(true);
this.stylesList.scroller.update({alwaysVisibleY: true});
var rec = this.stylesLevels.findWhere({checked: true});
@ -550,12 +558,11 @@ define([
this.endLevel = new_end;
this.spnLevels.setValue(new_end>0 ? new_end : '', true);
this.spnLevels.setDisabled(disable_outlines || new_start>1 );
this._needUpdateOutlineLevels = false;
},
getSettings: function () {
var props = new Asc.CTableOfContentsPr();
var props = this._originalProps;
props.put_Hyperlink(this.chLinks.getValue() == 'checked');
props.put_ShowPageNumbers(this.chPages.getValue() == 'checked');

View file

@ -17,9 +17,12 @@
#navigation-list {
height: 100%;
overflow: hidden;
padding: 8px 0;
font-size: 12px;
.treeview {
padding: 8px 0;
}
.name.not-header {
font-style: italic;
}

View file

@ -54,37 +54,31 @@
height: 38px;
}
a.item-contents {
}
.dropdown-menu {
> li > a.item-contents {
div {
.background-ximage('@{app-image-path}/toolbar/contents.png', '@{app-image-path}/toolbar/contents@2x.png', 246px);
width: 246px;
height: 72px;
.btn-contents {
.dropdown-menu {
> li > a.item-contents {
div {
.background-ximage('@{app-image-path}/toolbar/contents.png', '@{app-image-path}/toolbar/contents@2x.png', 246px);
width: 246px;
height: 72px;
.box-shadow(0 0 0 1px @gray);
.box-shadow(0 0 0 1px @gray);
&:hover,
&.selected {
.box-shadow(0 0 0 2px @primary);
}
&:hover,
&.selected {
.box-shadow(0 0 0 2px @primary);
}
}
&:hover, &:focus {
background-color: transparent;
&:hover, &:focus {
background-color: transparent;
div {
.box-shadow(0 0 0 2px @primary);
}
div {
.box-shadow(0 0 0 2px @primary);
}
}
}
}
.color-schemas-menu {
span {
&.colors {

View file

@ -191,6 +191,8 @@ define([
me.dontCloseDummyComment = true;
else if (/chat-msg-text/.test(e.target.id))
me.dontCloseChat = true;
else if (/form-control/.test(e.target.className))
me.inFormControl = true;
}
});
@ -207,6 +209,8 @@ define([
me.dontCloseDummyComment = false;
else if (/chat-msg-text/.test(e.target.id))
me.dontCloseChat = false;
else if (/form-control/.test(e.target.className))
me.inFormControl = false;
}
}
}).on('dragover', function(e) {
@ -456,7 +460,7 @@ define([
if ((id==Asc.c_oAscAsyncAction['Save'] || id==Asc.c_oAscAsyncAction['ForceSaveButton']) && (!this._state.fastCoauth || this._state.usersCount<2))
this.synchronizeChanges();
if (type == Asc.c_oAscAsyncActionType.BlockInteraction && !((id == Asc.c_oAscAsyncAction['LoadDocumentFonts'] || id == Asc.c_oAscAsyncAction['ApplyChanges']) && (this.dontCloseDummyComment || this.dontCloseChat || this.isModalShowed ))) {
if (type == Asc.c_oAscAsyncActionType.BlockInteraction && !((id == Asc.c_oAscAsyncAction['LoadDocumentFonts'] || id == Asc.c_oAscAsyncAction['ApplyChanges']) && (this.dontCloseDummyComment || this.dontCloseChat || this.isModalShowed || this.inFormControl))) {
this.onEditComplete(this.loadMask);
this.api.asc_enableKeyEvents(true);
}

View file

@ -197,6 +197,8 @@ define([
me.dontCloseDummyComment = true;
else if (/chat-msg-text/.test(e.target.id))
me.dontCloseChat = true;
else if (/form-control/.test(e.target.className))
me.inFormControl = true;
}
});
@ -215,6 +217,8 @@ define([
me.dontCloseDummyComment = false;
else if (/chat-msg-text/.test(e.target.id))
me.dontCloseChat = false;
else if (/form-control/.test(e.target.className))
me.inFormControl = false;
}
}
}).on('dragover', function(e) {
@ -476,12 +480,12 @@ define([
this.setLongActionView(action);
} else {
if (this.loadMask) {
if (this.loadMask.isVisible() && !this.dontCloseDummyComment && !this.dontCloseChat && !this.isModalShowed )
if (this.loadMask.isVisible() && !this.dontCloseDummyComment && !this.dontCloseChat && !this.isModalShowed && !this.inFormControl)
this.api.asc_enableKeyEvents(true);
this.loadMask.hide();
}
if (type == Asc.c_oAscAsyncActionType.BlockInteraction && !( (id == Asc.c_oAscAsyncAction['LoadDocumentFonts'] || id == Asc.c_oAscAsyncAction['ApplyChanges']) && (this.dontCloseDummyComment || this.dontCloseChat || this.isModalShowed ) ))
if (type == Asc.c_oAscAsyncActionType.BlockInteraction && !( (id == Asc.c_oAscAsyncAction['LoadDocumentFonts'] || id == Asc.c_oAscAsyncAction['ApplyChanges']) && (this.dontCloseDummyComment || this.dontCloseChat || this.isModalShowed || this.inFormControl) ))
this.onEditComplete(this.loadMask, {restorefocus:true});
}
},