diff --git a/apps/common/forms/resources/less/common.less b/apps/common/forms/resources/less/common.less index a1f29bb12..9246cb8ca 100644 --- a/apps/common/forms/resources/less/common.less +++ b/apps/common/forms/resources/less/common.less @@ -687,6 +687,7 @@ font-weight: bold; font-size: 11px; box-shadow: 0 6px 12px rgba(0,0,0,0.175); + max-width: 350px; padding: 5px 12px; white-space: pre-wrap; diff --git a/apps/documenteditor/forms/app/controller/ApplicationController.js b/apps/documenteditor/forms/app/controller/ApplicationController.js index 262c8c9fd..4a0a63a24 100644 --- a/apps/documenteditor/forms/app/controller/ApplicationController.js +++ b/apps/documenteditor/forms/app/controller/ApplicationController.js @@ -16,7 +16,10 @@ define([ labelDocName, btnSubmit, _submitFail, $submitedTooltip, $requiredTooltip, - $ttEl, $tooltip; + $ttEl, $tooltip, + $listControlMenu, listControlItems = [], listObj, + bodyWidth = 0, + ttOffset = [0, -10]; DE.Controllers.ApplicationController = Backbone.Controller.extend(_.assign({ views: [ @@ -173,6 +176,7 @@ define([ onDocumentResize: function() { this.api && this.api.Resize(); + bodyWidth = $('body').width(); }, onBeforeUnload: function() { @@ -324,10 +328,11 @@ define([ $('#toolbar').addClass('bottom'); this.boxSdk.addClass('bottom'); $('#box-tools').removeClass('dropdown').addClass('dropup'); - // ttOffset[1] = -40; + ttOffset[1] = -40; } else { $('#toolbar').addClass('top'); this.boxSdk.addClass('top'); + ttOffset[1] = 40; } this.appOptions.customization = this.editorConfig.customization; @@ -665,34 +670,50 @@ define([ }, onDocMouseMove: function(data) { + var me = this; if (data) { - if (data.get_Type() == 1) { // hyperlink + var type = data.get_Type(); + if (type == Asc.c_oAscMouseMoveDataTypes.Hyperlink || type==Asc.c_oAscMouseMoveDataTypes.Form) { // hyperlink this.isHideBodyTip = false; + var str = (type == Asc.c_oAscMouseMoveDataTypes.Hyperlink) ? me.txtPressLink : data.get_FormHelpText(); + if (str.length>500) + str = str.substr(0, 500) + '...'; + str = Common.Utils.String.htmlEncode(str); + if ( !$ttEl ) { $ttEl = $('.hyperlink-tooltip'); $ttEl.tooltip({'container':'body', 'trigger':'manual'}); - $ttEl.on('shown.bs.tooltip', function(e) { - $tooltip = $ttEl.data('bs.tooltip').tip(); - - $tooltip.css({ - left: $ttEl.ttpos[0] + ttOffset[0], - top: $ttEl.ttpos[1] + ttOffset[1] - }); - - $tooltip.find('.tooltip-arrow').css({left: 10}); - }); } - if ( !$tooltip ) { - $ttEl.ttpos = [data.get_X(), data.get_Y()]; - $ttEl.tooltip('show'); - } else { - $tooltip.css({ - left:data.get_X() + ttOffset[0], - top:data.get_Y() + ttOffset[1] - }); + $ttEl.ttpos = [data.get_X(), data.get_Y()]; + if ( !$tooltip) + $tooltip = $ttEl.data('bs.tooltip').tip(); + + if (!$tooltip.is(':visible')) { + var tip = $ttEl.data('bs.tooltip'); + tip.options.title = str; + tip.show([-1000, -1000]); + } else + $tooltip.find('.tooltip-inner')['text'](str); + + var ttHeight = $tooltip.height(), + ttWidth = $tooltip.width(); + !bodyWidth && (bodyWidth = $('body').width()); + + $ttEl.ttpos[1] -= (ttHeight - ttOffset[1] + 20); + if ($ttEl.ttpos[0] + ttWidth + 10 >bodyWidth) { + $ttEl.ttpos[0] = bodyWidth - ttWidth - 5; + if ($ttEl.ttpos[1] < 0) + $ttEl.ttpos[1] += ttHeight + ttOffset[1] + 20; + } else if ($ttEl.ttpos[1] < 0) { + $ttEl.ttpos[1] = 0; + $ttEl.ttpos[0] += 20; } + $tooltip.css({ + left: $ttEl.ttpos[0], + top: $ttEl.ttpos[1] + }); } } }, @@ -784,6 +805,99 @@ define([ } }, + onShowContentControlsActions: function(obj, x, y) { + var me = this; + switch (obj.type) { + case Asc.c_oAscContentControlSpecificType.Picture: + if (obj.pr && obj.pr.get_Lock) { + var lock = obj.pr.get_Lock(); + if (lock == Asc.c_oAscSdtLockType.SdtContentLocked || lock==Asc.c_oAscSdtLockType.ContentLocked) + return; + } + this.api.asc_addImage(obj); + setTimeout(function(){ + me.api.asc_UncheckContentControlButtons(); + }, 500); + break; + case Asc.c_oAscContentControlSpecificType.DropDownList: + case Asc.c_oAscContentControlSpecificType.ComboBox: + this.onShowListActions(obj, x, y); + break; + } + }, + + onHideContentControlsActions: function() { + $listControlMenu && $listControlMenu.hide(); + this.api.asc_UncheckContentControlButtons(); + }, + + onShowListActions: function(obj, x, y) { + var type = obj.type, + props = obj.pr, + specProps = (type == Asc.c_oAscContentControlSpecificType.ComboBox) ? props.get_ComboBoxPr() : props.get_DropDownListPr(), + isForm = !!props.get_FormPr(), + me = this; + + var menuContainer = this.view.getMenuForm(); + + if (!$listControlMenu) { + $listControlMenu = menuContainer.find('ul'); + $listControlMenu.on('click', 'li', function(e) { + var value = $(e.target).attr('value'); + if (value) { + value = parseInt(value); + setTimeout(function(){ + (value!==-1) && me.api.asc_SelectContentControlListItem(listControlItems[value], listObj.get_InternalId()); + }, 1); + } + }); + $('#editor_sdk').on('click', function(e){ + if (e.target.localName == 'canvas') { + if (me._preventClick) + me._preventClick = false; + else { + $listControlMenu && $listControlMenu.hide(); + me.api.asc_UncheckContentControlButtons(); + } + } + }); + } + $listControlMenu.find('li').remove(); + listControlItems = []; + listObj = props; + + if (specProps) { + var k = 0; + if (isForm){ // for dropdown and combobox form control always add placeholder item + var text = props.get_PlaceholderText(); + $listControlMenu.append('