[DE] Show menu for table of contents in canvas.

This commit is contained in:
Julia Radzhabova 2018-03-14 13:19:41 +03:00
parent 38a77c0a7d
commit 8665373465
5 changed files with 90 additions and 22 deletions

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

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;
},
@ -252,12 +255,14 @@ define([
this.api.asc_RemoveTableOfContents();
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 +311,42 @@ 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));
if (!menu) return;
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"});
}
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);
},
onHideContentControlsActions: function() {
this.view.contentsMenu && this.view.contentsMenu.hide();
this.view.contentsUpdateMenu && this.view.contentsUpdateMenu.hide();
}
}, DE.Controllers.Links || {}));

View file

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

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,6 +190,15 @@ define([
btn.setMenu(_menu);
});
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.tipContentsUpdate);
me.btnContentsUpdate.setMenu(new Common.UI.Menu({
items: [
@ -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

@ -54,11 +54,7 @@
height: 38px;
}
a.item-contents {
}
.btn-contents {
.dropdown-menu {
.dropdown-menu {
> li > a.item-contents {
div {
.background-ximage('@{app-image-path}/toolbar/contents.png', '@{app-image-path}/toolbar/contents@2x.png', 246px);
@ -81,10 +77,8 @@ a.item-contents {
}
}
}
}
}
.color-schemas-menu {
span {
&.colors {