Merge pull request #150 from ONLYOFFICE/feature/sse-formula-args-hint
Feature/sse formula args hint
This commit is contained in:
commit
17f1126348
|
@ -194,7 +194,22 @@ define([
|
||||||
el.attr('data-toggle', 'tooltip');
|
el.attr('data-toggle', 'tooltip');
|
||||||
el.tooltip({
|
el.tooltip({
|
||||||
title : me.options.hint,
|
title : me.options.hint,
|
||||||
placement : me.options.hintAnchor||'cursor'
|
placement : me.options.hintAnchor||function(tip, element) {
|
||||||
|
var pos = this.getPosition(),
|
||||||
|
actualWidth = tip.offsetWidth,
|
||||||
|
actualHeight = tip.offsetHeight,
|
||||||
|
innerWidth = Common.Utils.innerWidth(),
|
||||||
|
innerHeight = Common.Utils.innerHeight();
|
||||||
|
var top = pos.top,
|
||||||
|
left = pos.left + pos.width + 2;
|
||||||
|
if (top + actualHeight > innerHeight) {
|
||||||
|
top = innerHeight - actualHeight - 2;
|
||||||
|
}
|
||||||
|
if (left + actualWidth > innerWidth) {
|
||||||
|
left = pos.left - actualWidth - 2;
|
||||||
|
}
|
||||||
|
$(tip).offset({top: top,left: left}).addClass('in');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -127,15 +127,12 @@
|
||||||
if (this.hasContent() && this.enabled && !this.dontShow) {
|
if (this.hasContent() && this.enabled && !this.dontShow) {
|
||||||
if (!this.$element.is(":visible") && this.$element.closest('[role=menu]').length>0) return;
|
if (!this.$element.is(":visible") && this.$element.closest('[role=menu]').length>0) return;
|
||||||
var $tip = this.tip();
|
var $tip = this.tip();
|
||||||
var placement = typeof this.options.placement === 'function' ?
|
|
||||||
this.options.placement.call(this, $tip[0], this.$element[0]) : this.options.placement;
|
|
||||||
|
|
||||||
if (this.options.arrow === false) $tip.addClass('arrow-free');
|
if (this.options.arrow === false) $tip.addClass('arrow-free');
|
||||||
if (this.options.cls) $tip.addClass(this.options.cls);
|
if (this.options.cls) $tip.addClass(this.options.cls);
|
||||||
|
|
||||||
var placementEx = /^([a-zA-Z]+)-?([a-zA-Z]*)$/.exec(placement);
|
|
||||||
|
|
||||||
if (!at && !placementEx[2].length) {
|
var placementEx = (typeof this.options.placement !== 'function') ? /^([a-zA-Z]+)-?([a-zA-Z]*)$/.exec(this.options.placement) : null;
|
||||||
|
if (!at && placementEx && !placementEx[2].length) {
|
||||||
_superclass.prototype.show.apply(this, arguments);
|
_superclass.prototype.show.apply(this, arguments);
|
||||||
} else {
|
} else {
|
||||||
var e = $.Event('show.bs.tooltip');
|
var e = $.Event('show.bs.tooltip');
|
||||||
|
@ -152,7 +149,9 @@
|
||||||
this.options.container ?
|
this.options.container ?
|
||||||
$tip.appendTo(this.options.container) : $tip.insertAfter(this.$element);
|
$tip.appendTo(this.options.container) : $tip.insertAfter(this.$element);
|
||||||
|
|
||||||
if (typeof at == 'object') {
|
if (typeof this.options.placement === 'function') {
|
||||||
|
this.options.placement.call(this, $tip[0], this.$element[0]);
|
||||||
|
} else if (typeof at == 'object') {
|
||||||
var tp = {top: at[1] + 15, left: at[0] + 18},
|
var tp = {top: at[1] + 15, left: at[0] + 18},
|
||||||
innerWidth = Common.Utils.innerWidth(),
|
innerWidth = Common.Utils.innerWidth(),
|
||||||
innerHeight = Common.Utils.innerHeight();
|
innerHeight = Common.Utils.innerHeight();
|
||||||
|
|
|
@ -75,7 +75,8 @@ define([
|
||||||
row_column: {
|
row_column: {
|
||||||
ttHeight: 20
|
ttHeight: 20
|
||||||
},
|
},
|
||||||
filter: {ttHeight: 40}
|
filter: {ttHeight: 40},
|
||||||
|
func_arg: {}
|
||||||
};
|
};
|
||||||
me.mouse = {};
|
me.mouse = {};
|
||||||
me.popupmenu = false;
|
me.popupmenu = false;
|
||||||
|
@ -280,6 +281,7 @@ define([
|
||||||
this.api.asc_registerCallback('asc_onShowSpecialPasteOptions', _.bind(this.onShowSpecialPasteOptions, this));
|
this.api.asc_registerCallback('asc_onShowSpecialPasteOptions', _.bind(this.onShowSpecialPasteOptions, this));
|
||||||
this.api.asc_registerCallback('asc_onHideSpecialPasteOptions', _.bind(this.onHideSpecialPasteOptions, this));
|
this.api.asc_registerCallback('asc_onHideSpecialPasteOptions', _.bind(this.onHideSpecialPasteOptions, this));
|
||||||
this.api.asc_registerCallback('asc_onToggleAutoCorrectOptions', _.bind(this.onToggleAutoCorrectOptions, this));
|
this.api.asc_registerCallback('asc_onToggleAutoCorrectOptions', _.bind(this.onToggleAutoCorrectOptions, this));
|
||||||
|
this.api.asc_registerCallback('asc_onFormulaInfo', _.bind(this.onFormulaInfo, this));
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
@ -841,14 +843,15 @@ define([
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
hideHyperlinkTip: function() {
|
hideHyperlinkTip: function(callback) {
|
||||||
if (!this.tooltips.hyperlink.isHidden && this.tooltips.hyperlink.ref) {
|
if (!this.tooltips.hyperlink.isHidden && this.tooltips.hyperlink.ref) {
|
||||||
this.tooltips.hyperlink.ref.hide();
|
this.tooltips.hyperlink.ref.hide(callback);
|
||||||
this.tooltips.hyperlink.isHidden = true;
|
this.tooltips.hyperlink.isHidden = true;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onApiMouseMove: function(dataarray) {
|
onApiMouseMove: function(dataarray) {
|
||||||
|
var darray = dataarray;
|
||||||
if (!this._isFullscreenMenu && dataarray.length) {
|
if (!this._isFullscreenMenu && dataarray.length) {
|
||||||
var index_hyperlink,
|
var index_hyperlink,
|
||||||
/** coauthoring begin **/
|
/** coauthoring begin **/
|
||||||
|
@ -894,11 +897,66 @@ define([
|
||||||
pos = [
|
pos = [
|
||||||
me.documentHolder.cmpEl.offset().left - $(window).scrollLeft(),
|
me.documentHolder.cmpEl.offset().left - $(window).scrollLeft(),
|
||||||
me.documentHolder.cmpEl.offset().top - $(window).scrollTop()
|
me.documentHolder.cmpEl.offset().top - $(window).scrollTop()
|
||||||
];
|
],
|
||||||
|
need_return = false;
|
||||||
|
|
||||||
hyperlinkTip.isHidden = false;
|
if (this._state.index_hyperlink !== index_hyperlink ||this._state.index_comments !== index_comments ||
|
||||||
row_columnTip.isHidden = false;
|
this._state.index_locked !== index_locked || this._state.index_column !== index_column ||
|
||||||
filterTip.isHidden = false;
|
this._state.index_row !== index_row || this._state.index_filter !== index_filter) {
|
||||||
|
if (!index_hyperlink) {
|
||||||
|
need_return = true;
|
||||||
|
me.hideHyperlinkTip(function () {
|
||||||
|
me.onApiMouseMove(darray);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (index_column===undefined && index_row===undefined) {
|
||||||
|
if (!row_columnTip.isHidden && row_columnTip.ref) {
|
||||||
|
need_return = true;
|
||||||
|
row_columnTip.ref.hide(function () {
|
||||||
|
me.onApiMouseMove(darray);
|
||||||
|
});
|
||||||
|
row_columnTip.isHidden = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (me.permissions.isEdit || me.permissions.canViewComments) {
|
||||||
|
if (!index_comments || this.popupmenu) {
|
||||||
|
commentTip.moveCommentId = undefined;
|
||||||
|
if (commentTip.viewCommentId != undefined) {
|
||||||
|
commentTip = {};
|
||||||
|
|
||||||
|
var commentsController = this.getApplication().getController('Common.Controllers.Comments');
|
||||||
|
if (commentsController) {
|
||||||
|
if (this.permissions.canCoAuthoring && this.permissions.canViewComments)
|
||||||
|
setTimeout(function() {commentsController.onApiHideComment(true);}, 200);
|
||||||
|
else
|
||||||
|
commentsController.onApiHideComment(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (me.permissions.isEdit) {
|
||||||
|
if (!index_locked) {
|
||||||
|
me.hideCoAuthTips();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (index_filter===undefined || (me.dlgFilter && me.dlgFilter.isVisible()) || (me.currentMenu && me.currentMenu.isVisible())) {
|
||||||
|
if (!filterTip.isHidden && filterTip.ref) {
|
||||||
|
need_return = true;
|
||||||
|
filterTip.ref.hide(function () {
|
||||||
|
me.onApiMouseMove(darray);
|
||||||
|
});
|
||||||
|
filterTip.isHidden = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this._state.index_hyperlink = index_hyperlink;
|
||||||
|
this._state.index_comments = index_comments;
|
||||||
|
this._state.index_locked = index_locked;
|
||||||
|
this._state.index_column = index_column;
|
||||||
|
this._state.index_row = index_row;
|
||||||
|
this._state.index_filter = index_filter;
|
||||||
|
|
||||||
|
if (need_return) return;
|
||||||
|
}
|
||||||
|
|
||||||
/** coauthoring begin **/
|
/** coauthoring begin **/
|
||||||
var getUserName = function(id){
|
var getUserName = function(id){
|
||||||
|
@ -942,28 +1000,28 @@ define([
|
||||||
html : true,
|
html : true,
|
||||||
title : linkstr
|
title : linkstr
|
||||||
}).on('tooltip:hide', function(tip) {
|
}).on('tooltip:hide', function(tip) {
|
||||||
|
if (tip !== hyperlinkTip) return;
|
||||||
hyperlinkTip.ref = undefined;
|
hyperlinkTip.ref = undefined;
|
||||||
hyperlinkTip.text = '';
|
hyperlinkTip.text = '';
|
||||||
});
|
});
|
||||||
|
|
||||||
hyperlinkTip.ref.show([-10000, -10000]);
|
hyperlinkTip.ref.show([-10000, -10000]);
|
||||||
hyperlinkTip.isHidden = false;
|
hyperlinkTip.isHidden = false;
|
||||||
|
|
||||||
|
showPoint = [data.asc_getX(), data.asc_getY()];
|
||||||
|
showPoint[0] += (pos[0] + 6);
|
||||||
|
showPoint[1] += (pos[1] - 20);
|
||||||
|
showPoint[1] -= hyperlinkTip.ref.getBSTip().$tip.height();
|
||||||
|
var tipwidth = hyperlinkTip.ref.getBSTip().$tip.width();
|
||||||
|
if (showPoint[0] + tipwidth > me.tooltips.coauth.bodyWidth )
|
||||||
|
showPoint[0] = me.tooltips.coauth.bodyWidth - tipwidth;
|
||||||
|
|
||||||
|
hyperlinkTip.ref.getBSTip().$tip.css({
|
||||||
|
top : showPoint[1] + 'px',
|
||||||
|
left: showPoint[0] + 'px'
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
showPoint = [data.asc_getX(), data.asc_getY()];
|
|
||||||
showPoint[0] += (pos[0] + 6);
|
|
||||||
showPoint[1] += (pos[1] - 20);
|
|
||||||
showPoint[1] -= hyperlinkTip.ref.getBSTip().$tip.height();
|
|
||||||
var tipwidth = hyperlinkTip.ref.getBSTip().$tip.width();
|
|
||||||
if (showPoint[0] + tipwidth > me.tooltips.coauth.bodyWidth )
|
|
||||||
showPoint[0] = me.tooltips.coauth.bodyWidth - tipwidth;
|
|
||||||
|
|
||||||
hyperlinkTip.ref.getBSTip().$tip.css({
|
|
||||||
top : showPoint[1] + 'px',
|
|
||||||
left: showPoint[0] + 'px'
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
me.hideHyperlinkTip();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (index_column!==undefined || index_row!==undefined) {
|
if (index_column!==undefined || index_row!==undefined) {
|
||||||
|
@ -984,6 +1042,7 @@ define([
|
||||||
html : true,
|
html : true,
|
||||||
title : str
|
title : str
|
||||||
}).on('tooltip:hide', function(tip) {
|
}).on('tooltip:hide', function(tip) {
|
||||||
|
if (tip !== row_columnTip) return;
|
||||||
row_columnTip.ref = undefined;
|
row_columnTip.ref = undefined;
|
||||||
row_columnTip.text = '';
|
row_columnTip.text = '';
|
||||||
});
|
});
|
||||||
|
@ -1004,12 +1063,7 @@ define([
|
||||||
left: showPoint[0] + 'px'
|
left: showPoint[0] + 'px'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else
|
||||||
if (!row_columnTip.isHidden && row_columnTip.ref) {
|
|
||||||
row_columnTip.ref.hide();
|
|
||||||
row_columnTip.isHidden = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (me.permissions.isEdit || me.permissions.canViewComments) {
|
if (me.permissions.isEdit || me.permissions.canViewComments) {
|
||||||
if (index_comments && !this.popupmenu) {
|
if (index_comments && !this.popupmenu) {
|
||||||
|
@ -1039,19 +1093,6 @@ define([
|
||||||
}
|
}
|
||||||
}, 400);
|
}, 400);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
commentTip.moveCommentId = undefined;
|
|
||||||
if (commentTip.viewCommentId != undefined) {
|
|
||||||
commentTip = {};
|
|
||||||
|
|
||||||
var commentsController = this.getApplication().getController('Common.Controllers.Comments');
|
|
||||||
if (commentsController) {
|
|
||||||
if (this.permissions.canCoAuthoring && this.permissions.canViewComments)
|
|
||||||
setTimeout(function() {commentsController.onApiHideComment(true);}, 200);
|
|
||||||
else
|
|
||||||
commentsController.onApiHideComment(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1105,8 +1146,6 @@ define([
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
me.hideCoAuthTips();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1129,6 +1168,7 @@ define([
|
||||||
title : str,
|
title : str,
|
||||||
cls: 'auto-tooltip'
|
cls: 'auto-tooltip'
|
||||||
}).on('tooltip:hide', function(tip) {
|
}).on('tooltip:hide', function(tip) {
|
||||||
|
if (tip !== filterTip) return;
|
||||||
filterTip.ref = undefined;
|
filterTip.ref = undefined;
|
||||||
filterTip.text = '';
|
filterTip.text = '';
|
||||||
});
|
});
|
||||||
|
@ -1153,11 +1193,6 @@ define([
|
||||||
left: showPoint[0] + 'px'
|
left: showPoint[0] + 'px'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if (!filterTip.isHidden && filterTip.ref) {
|
|
||||||
filterTip.ref.hide();
|
|
||||||
filterTip.isHidden = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -1918,8 +1953,7 @@ define([
|
||||||
mnu = new Common.UI.MenuItem({
|
mnu = new Common.UI.MenuItem({
|
||||||
iconCls: (type==Asc.c_oAscPopUpSelectorType.Func) ? 'mnu-popup-func': ((type==Asc.c_oAscPopUpSelectorType.Table) ? 'mnu-popup-table' : 'mnu-popup-range') ,
|
iconCls: (type==Asc.c_oAscPopUpSelectorType.Func) ? 'mnu-popup-func': ((type==Asc.c_oAscPopUpSelectorType.Table) ? 'mnu-popup-table' : 'mnu-popup-range') ,
|
||||||
caption: name,
|
caption: name,
|
||||||
hint : (funcdesc && funcdesc[origname]) ? funcdesc[origname].d : '',
|
hint : (funcdesc && funcdesc[origname]) ? funcdesc[origname].d : ''
|
||||||
hintAnchor: 'right'
|
|
||||||
}).on('click', function(item, e) {
|
}).on('click', function(item, e) {
|
||||||
setTimeout(function(){ me.api.asc_insertFormula(item.caption, type, false ); }, 10);
|
setTimeout(function(){ me.api.asc_insertFormula(item.caption, type, false ); }, 10);
|
||||||
});
|
});
|
||||||
|
@ -2013,6 +2047,60 @@ define([
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onFormulaInfo: function(name) {
|
||||||
|
var functip = this.tooltips.func_arg;
|
||||||
|
functip.isHidden = false;
|
||||||
|
|
||||||
|
if (name) {
|
||||||
|
var funcdesc = SSE.Views.FormulaLang.getDescription(Common.Utils.InternalSettings.get("sse-settings-func-locale")),
|
||||||
|
hint = ((funcdesc && funcdesc[name]) ? (this.api.asc_getFormulaLocaleName(name) + funcdesc[name].a) : '').replace(/[,;]/g, this.api.asc_getFunctionArgumentSeparator());
|
||||||
|
|
||||||
|
if (functip.ref && functip.ref.isVisible()) {
|
||||||
|
if (functip.text != hint) {
|
||||||
|
functip.ref.hide();
|
||||||
|
functip.isHidden = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!functip.ref || !functip.ref.isVisible()) {
|
||||||
|
functip.text = hint;
|
||||||
|
functip.ref = new Common.UI.Tooltip({
|
||||||
|
owner : this.documentHolder,
|
||||||
|
html : true,
|
||||||
|
title : hint,
|
||||||
|
cls: 'auto-tooltip'
|
||||||
|
}).on('tooltip:hide', function(tip) {
|
||||||
|
if (tip !== functip) return;
|
||||||
|
functip.ref = undefined;
|
||||||
|
functip.text = '';
|
||||||
|
});
|
||||||
|
|
||||||
|
functip.ref.show([-10000, -10000]);
|
||||||
|
functip.isHidden = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var pos = [
|
||||||
|
this.documentHolder.cmpEl.offset().left - $(window).scrollLeft(),
|
||||||
|
this.documentHolder.cmpEl.offset().top - $(window).scrollTop()
|
||||||
|
],
|
||||||
|
coord = this.api.asc_getActiveCellCoord(),
|
||||||
|
showPoint = [coord.asc_getX() + pos[0] - 3, coord.asc_getY() + pos[1] - functip.ref.getBSTip().$tip.height() - 5];
|
||||||
|
var tipwidth = functip.ref.getBSTip().$tip.width();
|
||||||
|
if (showPoint[0] + tipwidth > this.tooltips.coauth.bodyWidth )
|
||||||
|
showPoint[0] = this.tooltips.coauth.bodyWidth - tipwidth;
|
||||||
|
|
||||||
|
functip.ref.getBSTip().$tip.css({
|
||||||
|
top : showPoint[1] + 'px',
|
||||||
|
left: showPoint[0] + 'px'
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
if (!functip.isHidden && functip.ref) {
|
||||||
|
functip.ref.hide();
|
||||||
|
functip.isHidden = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
onShowSpecialPasteOptions: function(specialPasteShowOptions) {
|
onShowSpecialPasteOptions: function(specialPasteShowOptions) {
|
||||||
var me = this,
|
var me = this,
|
||||||
documentHolderView = me.documentHolder,
|
documentHolderView = me.documentHolder,
|
||||||
|
|
Loading…
Reference in a new issue