Commit f6a2b0a4 authored by Alexander.Trofimov's avatar Alexander.Trofimov Committed by Alexander.Trofimov

Работа с подсказкой в формулах перенесена в меню

bugs #26382, #24970, #30905

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@68002 954022d7-b5bf-4e40-9824-e11837661b57
parent 1b86d5ac
...@@ -65,7 +65,6 @@ ...@@ -65,7 +65,6 @@
"../../Excel/model/CellComment.js", "../../Excel/model/CellComment.js",
"../../Excel/view/mobileTouch.js", "../../Excel/view/mobileTouch.js",
"../../Excel/view/iscroll.js", "../../Excel/view/iscroll.js",
"../../Excel/view/PopUpSelector.js",
"../../Excel/view/StringRender.js", "../../Excel/view/StringRender.js",
"../../Excel/view/CellTextRender.js", "../../Excel/view/CellTextRender.js",
"../../Excel/view/CellEditorView.js", "../../Excel/view/CellEditorView.js",
......
...@@ -65,7 +65,6 @@ ...@@ -65,7 +65,6 @@
"../../Excel/model/CellComment.js", "../../Excel/model/CellComment.js",
"../../Excel/view/mobileTouch.js", "../../Excel/view/mobileTouch.js",
"../../Excel/view/iscroll.js", "../../Excel/view/iscroll.js",
"../../Excel/view/PopUpSelector.js",
"../../Excel/view/StringRender.js", "../../Excel/view/StringRender.js",
"../../Excel/view/CellTextRender.js", "../../Excel/view/CellTextRender.js",
"../../Excel/view/CellEditorView.js", "../../Excel/view/CellEditorView.js",
......
...@@ -60,7 +60,6 @@ ...@@ -60,7 +60,6 @@
"../../Excel/model/CellComment.js", "../../Excel/model/CellComment.js",
"../../Excel/view/mobileTouch.js", "../../Excel/view/mobileTouch.js",
"../../Excel/view/iscroll.js", "../../Excel/view/iscroll.js",
"../../Excel/view/PopUpSelector.js",
"../../Excel/view/StringRender.js", "../../Excel/view/StringRender.js",
"../../Excel/view/CellTextRender.js", "../../Excel/view/CellTextRender.js",
"../../Excel/view/CellEditorView.js", "../../Excel/view/CellEditorView.js",
......
...@@ -83,7 +83,6 @@ ...@@ -83,7 +83,6 @@
<script type="text/javascript" src="../../Common/scroll.js"></script> <script type="text/javascript" src="../../Common/scroll.js"></script>
<script type="text/javascript" src="../view/PopUpSelector.js"></script>
<script type="text/javascript" src="../view/StringRender.js"></script> <script type="text/javascript" src="../view/StringRender.js"></script>
<script type="text/javascript" src="../view/CellTextRender.js"></script> <script type="text/javascript" src="../view/CellTextRender.js"></script>
<script type="text/javascript" src="../view/CellEditorView.js"></script> <script type="text/javascript" src="../view/CellEditorView.js"></script>
......
...@@ -100,7 +100,6 @@ ...@@ -100,7 +100,6 @@
<script type="text/javascript" src="model/FormulaObjects/logicalFunctions.js"></script> <script type="text/javascript" src="model/FormulaObjects/logicalFunctions.js"></script>
<script type="text/javascript" src="../Common/scroll.js"></script> <script type="text/javascript" src="../Common/scroll.js"></script>
<script type="text/javascript" src="view/PopUpSelector.js"></script>
<script type="text/javascript" src="view/StringRender.js"></script> <script type="text/javascript" src="view/StringRender.js"></script>
<script type="text/javascript" src="view/CellTextRender.js"></script> <script type="text/javascript" src="view/CellTextRender.js"></script>
<script type="text/javascript" src="view/CellEditorView.js"></script> <script type="text/javascript" src="view/CellEditorView.js"></script>
......
...@@ -90,7 +90,6 @@ ...@@ -90,7 +90,6 @@
<script type="text/javascript" src="../Common/scroll.js"></script> <script type="text/javascript" src="../Common/scroll.js"></script>
<script type="text/javascript" src="view/mobileTouch.js"></script> <script type="text/javascript" src="view/mobileTouch.js"></script>
<script type="text/javascript" src="view/iscroll.js"></script> <script type="text/javascript" src="view/iscroll.js"></script>
<script type="text/javascript" src="view/PopUpSelector.js"></script>
<script type="text/javascript" src="view/StringRender.js"></script> <script type="text/javascript" src="view/StringRender.js"></script>
<script type="text/javascript" src="view/CellTextRender.js"></script> <script type="text/javascript" src="view/CellTextRender.js"></script>
<script type="text/javascript" src="view/CellEditorView.js"></script> <script type="text/javascript" src="view/CellEditorView.js"></script>
......
...@@ -2768,7 +2768,6 @@ var editor; ...@@ -2768,7 +2768,6 @@ var editor;
this.controller._onWindowMouseUpExternal(event, x, y); this.controller._onWindowMouseUpExternal(event, x, y);
}; };
// //
spreadsheet_api.prototype.asc_selectFunction = function() { spreadsheet_api.prototype.asc_selectFunction = function() {
...@@ -2783,8 +2782,8 @@ var editor; ...@@ -2783,8 +2782,8 @@ var editor;
this.wb.removeHyperlink(); this.wb.removeHyperlink();
}; };
spreadsheet_api.prototype.asc_insertFormula = function(functionName, autoComplet, isDefName) { spreadsheet_api.prototype.asc_insertFormula = function(functionName, type, autoComplete) {
this.wb.insertFormulaInEditor(functionName, autoComplet, isDefName); this.wb.insertFormulaInEditor(functionName, type, autoComplete);
this.wb.restoreFocus(); this.wb.restoreFocus();
}; };
......
...@@ -346,7 +346,8 @@ var c_oAscDefinedNameReason = { ...@@ -346,7 +346,8 @@ var c_oAscDefinedNameReason = {
}; };
var c_oAscPopUpSelectorType = { var c_oAscPopUpSelectorType = {
Func: 0, None: 0,
Range: 1, Func: 1,
Table: 2 Range: 2,
Table: 3
}; };
...@@ -303,7 +303,6 @@ ...@@ -303,7 +303,6 @@
<script type="text/javascript" src="../../../../OfficeWeb/Excel/model/History.js"></script> <script type="text/javascript" src="../../../../OfficeWeb/Excel/model/History.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Excel/model/UndoRedo.js"></script> <script type="text/javascript" src="../../../../OfficeWeb/Excel/model/UndoRedo.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Excel/view/PopUpSelector.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Excel/view/StringRender.js"></script> <script type="text/javascript" src="../../../../OfficeWeb/Excel/view/StringRender.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Excel/view/CellTextRender.js"></script> <script type="text/javascript" src="../../../../OfficeWeb/Excel/view/CellTextRender.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Excel/view/CellEditorView.js"></script> <script type="text/javascript" src="../../../../OfficeWeb/Excel/view/CellEditorView.js"></script>
......
...@@ -270,7 +270,6 @@ ...@@ -270,7 +270,6 @@
<script type="text/javascript" src="../../../../OfficeWeb/Excel/view/mobileTouch.js"></script> <script type="text/javascript" src="../../../../OfficeWeb/Excel/view/mobileTouch.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Excel/view/iscroll.js"></script> <script type="text/javascript" src="../../../../OfficeWeb/Excel/view/iscroll.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Excel/view/PopUpSelector.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Excel/view/StringRender.js"></script> <script type="text/javascript" src="../../../../OfficeWeb/Excel/view/StringRender.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Excel/view/CellTextRender.js"></script> <script type="text/javascript" src="../../../../OfficeWeb/Excel/view/CellTextRender.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Excel/view/CellEditorView.js"></script> <script type="text/javascript" src="../../../../OfficeWeb/Excel/view/CellEditorView.js"></script>
......
...@@ -1573,6 +1573,14 @@ ...@@ -1573,6 +1573,14 @@
asc_CFindOptions.prototype.asc_setReplaceWith = function (val) {this.replaceWith = val;}; asc_CFindOptions.prototype.asc_setReplaceWith = function (val) {this.replaceWith = val;};
asc_CFindOptions.prototype.asc_setIsReplaceAll = function (val) {this.isReplaceAll = val;}; asc_CFindOptions.prototype.asc_setIsReplaceAll = function (val) {this.isReplaceAll = val;};
/** @constructor */
function asc_CCompleteMenu(name, type) {
this.name = name;
this.type = type;
}
asc_CCompleteMenu.prototype.asc_getName = function () {return this.name;};
asc_CCompleteMenu.prototype.asc_getType = function () {return this.type;};
/* /*
* Export * Export
* ----------------------------------------------------------------------------- * -----------------------------------------------------------------------------
...@@ -1723,5 +1731,10 @@ ...@@ -1723,5 +1731,10 @@
prot["asc_setLookIn"] = prot.asc_setLookIn; prot["asc_setLookIn"] = prot.asc_setLookIn;
prot["asc_setReplaceWith"] = prot.asc_setReplaceWith; prot["asc_setReplaceWith"] = prot.asc_setReplaceWith;
prot["asc_setIsReplaceAll"] = prot.asc_setIsReplaceAll; prot["asc_setIsReplaceAll"] = prot.asc_setIsReplaceAll;
window["Asc"]["asc_CCompleteMenu"] = window["Asc"].asc_CCompleteMenu = asc_CCompleteMenu;
prot = asc_CCompleteMenu.prototype;
prot["asc_getName"] = prot.asc_getName;
prot["asc_getType"] = prot.asc_getType;
} }
)(jQuery, window); )(jQuery, window);
...@@ -230,10 +230,7 @@ ...@@ -230,10 +230,7 @@
} }
this.fKeyDown = function(event) { this.fKeyDown = function(event) {
if (t.handlers.trigger("popUpSelectorKeyDown", event)) {
return t._onWindowKeyDown(event); return t._onWindowKeyDown(event);
}
return false;
}; };
this.fKeyPress = function() { this.fKeyPress = function() {
return t._onWindowKeyPress.apply(t, arguments); return t._onWindowKeyPress.apply(t, arguments);
......
...@@ -696,13 +696,6 @@ ...@@ -696,13 +696,6 @@
t.skipKeyPress = true; t.skipKeyPress = true;
if (!t.isCellEditMode) {
if (!t.handlers.trigger("popUpSelectorKeyDown", event)) {
stop();
return result;
}
}
switch (event.which) { switch (event.which) {
case 113: // F2 case 113: // F2
...@@ -825,9 +818,6 @@ ...@@ -825,9 +818,6 @@
case 38: // up case 38: // up
stop(); // Отключим стандартную обработку браузера нажатия up stop(); // Отключим стандартную обработку браузера нажатия up
// Если у нас открыто меню для подстановки формулы, то мы не обрабатываем верх/вниз
if (t.isCellEditMode && t.handlers.trigger("isPopUpSelectorOpen"))
return result;
dr = ctrlKey ? -1.5 : -1; // Движение стрелками (влево-вправо, вверх-вниз) dr = ctrlKey ? -1.5 : -1; // Движение стрелками (влево-вправо, вверх-вниз)
break; break;
...@@ -838,9 +828,6 @@ ...@@ -838,9 +828,6 @@
case 40: // down case 40: // down
stop(); // Отключим стандартную обработку браузера нажатия down stop(); // Отключим стандартную обработку браузера нажатия down
// Если у нас открыто меню для подстановки формулы, то мы не обрабатываем верх/вниз
if (t.isCellEditMode && t.handlers.trigger("isPopUpSelectorOpen"))
return result;
// Обработка Alt + down // Обработка Alt + down
if (!isViewerMode && !t.isCellEditMode && !t.isSelectionDialogMode && event.altKey) { if (!isViewerMode && !t.isCellEditMode && !t.isSelectionDialogMode && event.altKey) {
t.handlers.trigger("showAutoComplete"); t.handlers.trigger("showAutoComplete");
...@@ -937,7 +924,7 @@ ...@@ -937,7 +924,7 @@
if (isViewerMode || t.isCellEditMode || t.isSelectionDialogMode) {return true;} if (isViewerMode || t.isCellEditMode || t.isSelectionDialogMode) {return true;}
if (event.altKey) { if (event.altKey) {
t.handlers.trigger("addFunction", /*functionName*/"SUM", /*autoComplet*/true); t.handlers.trigger('addFunction', 'SUM', c_oAscPopUpSelectorType.Func, true);
} else { } else {
t.skipKeyPress = false; t.skipKeyPress = false;
} }
......
"use strict";
/* PopUpSelector.js
*
* Author: Alexander.Trofimov@avsmedia.net
* Date: April 7, 2014
*/
(/**
* @param {jQuery} $
* @param {Window} window
* @param {undefined} undefined
*/
function($, window, undefined) {
var asc = window["Asc"];
var asc_HL = asc.HandlersList;
function PopUpSelector(element, handlers) {
this.handlers = new asc_HL(handlers);
this.scrollOptions = {
wheelPropagation: false,
minScrollbarLength: null,
useBothWheelAxes: false,
useKeyboard: true,
suppressScrollX: false,
suppressScrollY: false,
scrollXMarginOffset: 5,
scrollYMarginOffset: 5,
includePadding: false
};
this.element = element;
this.selector = null;
this.selectorStyle = null;
this.selectorList = null;
this.selectorListEl = [];
this.selectorListJQ = null;
this.selectElement = null;
this.firstElement = null;
this.isFormula = false;
this.isVisible = false;
this.skipClose = false;
this.fMouseDown = null;
this.fMouseDblClick = null;
this.fMouseOver = null;
this._init();
return this;
}
PopUpSelector.prototype._init = function() {
var t = this;
if (null != this.element) {
this.selector = document.createElement('div');
this.selectorStyle = this.selector.style;
this.selector.id = 'apiPopUpSelector';
this.selector.className = 'combobox';
this.selector.innerHTML = '<ul id="apiPopUpList" class="dropdown-menu"></ul>';
this.element.appendChild(this.selector);
this.selectorList = document.getElementById('apiPopUpList');
this.fMouseDown = function(event) {
t._onMouseDown(event);
};
this.fMouseDblClick = function(event) {
t._onMouseDblClick(event);
};
this.fMouseOver = function(event) {
t._onMouseOver(event);
};
if (this.selector.addEventListener) {
this.selector.addEventListener('mousedown', function() {
t.skipClose = true;
}, false);
}
if (window.addEventListener) {
window.addEventListener('mousedown', function() {
if (t.skipClose) {
t.skipClose = false;
return;
}
t.hide();
}, false);
}
// Для того, чтобы работал scroll
this.selectorListJQ = $('#apiPopUpList');
if (this.selectorListJQ.perfectScrollbar) {
this.selectorListJQ.perfectScrollbar(this.scrollOptions);
}
this.setAlwaysVisibleY(true);
}
};
PopUpSelector.prototype.show = function(isFormula, arrItems, cellRect) {
this._clearList();
if (!this.isVisible) {
this.selector.className = 'combobox open';
this.isVisible = true;
}
this.isFormula = isFormula;
var item, isFirst, value, selectElement = null, obj
var sIcon = this.isFormula ? '<span class="menu-item-icon %1%"></span>' : '', _sIcon;
for (var i = 0; i < arrItems.length; ++i) {
obj = arrItems[i];
item = document.createElement('li');
isFirst = (0 === i);
if (isFirst) {
this.firstElement = item;
}
if (this.isFormula) {
if (isFirst) {
selectElement = item;
}
value = obj.name;
item.setAttribute('title', obj.arg);
} else {
value = obj.name;
}
if( c_oAscPopUpSelectorType.Range === obj.type )
_sIcon = sIcon.replace("%1%","mnu-popup-range");
else if( c_oAscPopUpSelectorType.Table === obj.type )
_sIcon = sIcon.replace("%1%","mnu-popup-table");
else if( c_oAscPopUpSelectorType.Func === obj.type )
_sIcon = sIcon.replace("%1%","mnu-popup-func");
else
_sIcon = sIcon.replace("%1%","");
item.innerHTML = '<a>' + _sIcon + value + '</a>';
item.setAttribute('val', value);
item.setAttribute('type', obj.type);
if (item.addEventListener) {
item.addEventListener('mousedown', this.fMouseDown, false);
item.addEventListener('dblclick', this.fMouseDblClick, false);
if (!this.isFormula) {
item.addEventListener('mouseover', this.fMouseOver, false);
}
}
this.selectorList.appendChild(item);
this.selectorListEl.push(item);
}
this.setPosition(cellRect);
// Для того, чтобы работал scroll
this.selectorListJQ.perfectScrollbar("update");
this._onChangeSelection(selectElement);
};
PopUpSelector.prototype.hide = function() {
if (this.isVisible) {
// Чтобы не было непонятных анимаций
this.selectorListJQ.scrollTop(0);
this.selector.className = 'combobox';
this.isVisible = false;
this._clearList();
}
};
PopUpSelector.prototype.setPosition = function(cellRect) {
var top = cellRect.asc_getY() + cellRect.asc_getHeight(), left = cellRect.asc_getX();
var diff = top + this.selectorList.offsetHeight - this.element.offsetHeight;
if (0 < diff) {
top -= diff;
left += cellRect.asc_getWidth();
} else {
left += 10;
}
this.selectorStyle['left'] = left + 'px';
this.selectorStyle['top'] = top + 'px';
};
PopUpSelector.prototype.getVisible = function() {
return this.isVisible;
};
PopUpSelector.prototype._clearList = function() {
var i;
for (i = 0; i < this.selectorListEl.length; ++i)
this.selectorList.removeChild(this.selectorListEl[i]);
this.selectorListEl.length = 0;
this.selectElement = null;
this.firstElement = null;
this.isFormula = false;
};
PopUpSelector.prototype.onKeyDown = function(event) {
var retVal = false;
switch (event.which) {
case 9: // Tab
if (this.isFormula) {
event.stopPropagation();
event.preventDefault();
this._onMouseDblClick();
} else {
retVal = true;
}
break;
case 13: // Enter
if (null !== this.selectElement) {
event.stopPropagation();
event.preventDefault();
if (this.isFormula) {
this._onMouseDblClick();
} else {
this._onInsert({name:this.selectElement.getAttribute('val'),type:this.selectElement.getAttribute('type')});
}
} else {
retVal = true;
}
break;
case 27: // Esc
this.hide();
break;
case 38: // Up
this._onChangeSelection(null !== this.selectElement ? this.selectElement.previousSibling : this.firstElement);
break;
case 40: // Down
this._onChangeSelection(null !== this.selectElement ? this.selectElement.nextSibling : this.firstElement);
break;
case 16: // Shift
break;
default:
retVal = true;
}
if (retVal) {
this.hide();
}
return retVal;
};
PopUpSelector.prototype._onInsert = function(value) {
this.hide();
this.handlers.trigger('insert', value);
};
PopUpSelector.prototype._onMouseDown = function(event) {
this.skipClose = true;
var element = event.currentTarget;
if (this.isFormula) {
this._onChangeSelection(element);
} else {
this._onInsert({name:element.getAttribute('val'),type:element.getAttribute('type')});
}
};
PopUpSelector.prototype._onMouseDblClick = function(event) {
if (!this.isVisible) {
return;
}
if (!this.isFormula) {
this._onMouseDown(event);
return;
}
var elementVal = event ? event.currentTarget : this.selectElement;
this._onInsert({name:elementVal.getAttribute('val'),type:elementVal.getAttribute('type')});
};
PopUpSelector.prototype._onMouseOver = function(event) {
if (this.isFormula) {
return;
}
this._onChangeSelection(event.currentTarget);
};
PopUpSelector.prototype._onChangeSelection = function(newElement) {
if (null === newElement || null === newElement.getAttribute('val')) {
return;
}
if (null !== this.selectElement) {
this.selectElement.className = '';
}
this.selectElement = newElement;
this.selectElement.className = 'selected';
this.scrollToRecord();
};
PopUpSelector.prototype.scrollToRecord = function() {
var innerEl = $(this.selectorList);
var inner_top = innerEl.offset().top;
var div = $(this.selectElement);
var div_top = div.offset().top;
if (div_top < inner_top || div_top + div.height() > inner_top + innerEl.height()) {
this.selectorListJQ.scrollTop(this.selectorListJQ.scrollTop() + div_top - inner_top);
}
};
PopUpSelector.prototype.setAlwaysVisibleY = function(flag) {
if (flag) {
$(this.selectorList).find('.ps-scrollbar-y-rail').addClass('always-visible-y');
$(this.selectorList).find('.ps-scrollbar-y').addClass('always-visible-y');
} else {
$(this.selectorList).find('.ps-scrollbar-y-rail').removeClass('always-visible-y');
$(this.selectorList).find('.ps-scrollbar-y').removeClass('always-visible-y');
}
};
/*
* Export
* -----------------------------------------------------------------------------
*/
window["Asc"].PopUpSelector = PopUpSelector;
})(jQuery, window);
\ No newline at end of file
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment