[DE] Show menu for table of contents and date content control

This commit is contained in:
Julia Radzhabova 2019-11-20 14:56:32 +03:00
parent 75f61c4943
commit 3a74ce2335

View file

@ -94,10 +94,8 @@ define([
this.api.asc_registerCallback('asc_onCanAddHyperlink', _.bind(this.onApiCanAddHyperlink, this)); this.api.asc_registerCallback('asc_onCanAddHyperlink', _.bind(this.onApiCanAddHyperlink, this));
this.api.asc_registerCallback('asc_onCoAuthoringDisconnect',_.bind(this.onCoAuthoringDisconnect, this)); this.api.asc_registerCallback('asc_onCoAuthoringDisconnect',_.bind(this.onCoAuthoringDisconnect, this));
Common.NotificationCenter.on('api:disconnect', _.bind(this.onCoAuthoringDisconnect, this)); Common.NotificationCenter.on('api:disconnect', _.bind(this.onCoAuthoringDisconnect, this));
this.api.asc_registerCallback('asc_onShowContentControlsActions',_.bind(this.onShowControlsActions, this)); this.api.asc_registerCallback('asc_onShowContentControlsActions',_.bind(this.onShowContentControlsActions, this));
this.api.asc_registerCallback('asc_onHideContentControlsActions',_.bind(this.onHideControlsActions, this)); this.api.asc_registerCallback('asc_onHideContentControlsActions',_.bind(this.onHideContentControlsActions, this));
// this.api.asc_registerCallback('asc_onShowContentControlsActions',_.bind(this.onShowContentControlsActions, this));
// this.api.asc_registerCallback('asc_onHideContentControlsActions',_.bind(this.onHideContentControlsActions, this));
} }
return this; return this;
@ -354,8 +352,9 @@ define([
})).show(); })).show();
}, },
onShowContentControlsActions: function(action, x, y) { onShowTOCActions: function(obj, x, y) {
var menu = (action==1) ? this.view.contentsUpdateMenu : this.view.contentsMenu, var action = obj.button,
menu = (action==AscCommon.CCButtonType.Toc) ? this.view.contentsUpdateMenu : this.view.contentsMenu,
documentHolderView = this.getApplication().getController('DocumentHolder').documentHolder, documentHolderView = this.getApplication().getController('DocumentHolder').documentHolder,
menuContainer = documentHolderView.cmpEl.find(Common.Utils.String.format('#menu-container-{0}', menu.id)), menuContainer = documentHolderView.cmpEl.find(Common.Utils.String.format('#menu-container-{0}', menu.id)),
me = this; me = this;
@ -394,15 +393,22 @@ define([
onHideContentControlsActions: function() { onHideContentControlsActions: function() {
this.view.contentsMenu && this.view.contentsMenu.hide(); this.view.contentsMenu && this.view.contentsMenu.hide();
this.view.contentsUpdateMenu && this.view.contentsUpdateMenu.hide(); this.view.contentsUpdateMenu && this.view.contentsUpdateMenu.hide();
var controlsContainer = this.getApplication().getController('DocumentHolder').documentHolder.cmpEl.find('#calendar-control-container');
if (controlsContainer.is(':visible'))
controlsContainer.hide();
}, },
onShowControlsActions: function(action, x, y) { onShowDateActions: function(obj, x, y) {
var documentHolderView = this.getApplication().getController('DocumentHolder').documentHolder, var action = obj.button,
props = obj.pr,
specProps = props.get_DateTimePr(),
id = props.get_InternalId(),
documentHolderView = this.getApplication().getController('DocumentHolder').documentHolder,
controlsContainer = documentHolderView.cmpEl.find('#calendar-control-container'), controlsContainer = documentHolderView.cmpEl.find('#calendar-control-container'),
me = this; me = this;
if (controlsContainer.length < 1) { if (controlsContainer.length < 1) {
controlsContainer = $('<div id="calendar-control-container" style="position: absolute;z-index: 1000;"><div id="id-document-calendar-control"></div></div>'); controlsContainer = $('<div id="calendar-control-container" style="position: absolute;z-index: 1000;"><div id="id-document-calendar-control" style="position: fixed; left: -1000px; top: -1000px;"></div></div>');
documentHolderView.cmpEl.append(controlsContainer); documentHolderView.cmpEl.append(controlsContainer);
} }
@ -418,7 +424,10 @@ define([
firstday: 1 firstday: 1
}); });
this.cmpCalendar.on('date:click', function (cmp, date) { this.cmpCalendar.on('date:click', function (cmp, date) {
me.selectDate = new Date(date); specProps.put_FullDate(new Date(date));
me.api.asc_SetContentControlProperties(props, id);
controlsContainer.hide();
me.api.asc_UncheckContentControlButtons();
}); });
this.cmpCalendar.on('calendar:keydown', function (cmp, e) { this.cmpCalendar.on('calendar:keydown', function (cmp, e) {
if (e.keyCode==Common.UI.Keys.ESC) { if (e.keyCode==Common.UI.Keys.ESC) {
@ -427,16 +436,45 @@ define([
} }
}); });
} }
this.cmpCalendar.setDate(this.selectDate ? this.selectDate : new Date()); this.cmpCalendar.setDate(new Date(specProps ? specProps.get_FullDate() : undefined));
// align
var offset = controlsContainer.offset(),
docW = Common.Utils.innerWidth(),
docH = Common.Utils.innerHeight() - 10, // Yep, it's magic number
menuW = this.cmpCalendar.cmpEl.outerWidth(),
menuH = this.cmpCalendar.cmpEl.outerHeight(),
buttonOffset = 22,
left = offset.left - menuW + buttonOffset,
top = offset.top;
if (top + menuH > docH) {
top = docH - menuH;
left -= buttonOffset;
}
if (top < 0)
top = 0;
if (left + menuW > docW)
left = docW - menuW;
this.cmpCalendar.cmpEl.css({left: left, top : top});
documentHolderView._preventClick = true; documentHolderView._preventClick = true;
}, },
onHideControlsActions: function() { onShowContentControlsActions: function(obj, x, y) {
var controlsContainer = this.getApplication().getController('DocumentHolder').documentHolder.cmpEl.find('#calendar-control-container'); var type = obj.type;
if (controlsContainer.is(':visible')) switch (type) {
controlsContainer.hide(); case Asc.c_oAscContentControlSpecificType.TOC:
this.onShowTOCActions(obj, x, y);
break;
case Asc.c_oAscContentControlSpecificType.DateTime:
this.onShowDateActions(obj, x, y);
break;
case Asc.c_oAscContentControlSpecificType.Picture:
break;
case Asc.c_oAscContentControlSpecificType.DropDownList:
case Asc.c_oAscContentControlSpecificType.ComboBox:
break;
}
} }
}, DE.Controllers.Links || {})); }, DE.Controllers.Links || {}));