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 @@
"../../Excel/model/CellComment.js",
"../../Excel/view/mobileTouch.js",
"../../Excel/view/iscroll.js",
"../../Excel/view/PopUpSelector.js",
"../../Excel/view/StringRender.js",
"../../Excel/view/CellTextRender.js",
"../../Excel/view/CellEditorView.js",
......
......@@ -65,7 +65,6 @@
"../../Excel/model/CellComment.js",
"../../Excel/view/mobileTouch.js",
"../../Excel/view/iscroll.js",
"../../Excel/view/PopUpSelector.js",
"../../Excel/view/StringRender.js",
"../../Excel/view/CellTextRender.js",
"../../Excel/view/CellEditorView.js",
......
......@@ -60,7 +60,6 @@
"../../Excel/model/CellComment.js",
"../../Excel/view/mobileTouch.js",
"../../Excel/view/iscroll.js",
"../../Excel/view/PopUpSelector.js",
"../../Excel/view/StringRender.js",
"../../Excel/view/CellTextRender.js",
"../../Excel/view/CellEditorView.js",
......
......@@ -83,7 +83,6 @@
<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/CellTextRender.js"></script>
<script type="text/javascript" src="../view/CellEditorView.js"></script>
......
......@@ -100,7 +100,6 @@
<script type="text/javascript" src="model/FormulaObjects/logicalFunctions.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/CellTextRender.js"></script>
<script type="text/javascript" src="view/CellEditorView.js"></script>
......
......@@ -90,7 +90,6 @@
<script type="text/javascript" src="../Common/scroll.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/PopUpSelector.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/CellEditorView.js"></script>
......
......@@ -2768,7 +2768,6 @@ var editor;
this.controller._onWindowMouseUpExternal(event, x, y);
};
//
spreadsheet_api.prototype.asc_selectFunction = function() {
......@@ -2783,8 +2782,8 @@ var editor;
this.wb.removeHyperlink();
};
spreadsheet_api.prototype.asc_insertFormula = function(functionName, autoComplet, isDefName) {
this.wb.insertFormulaInEditor(functionName, autoComplet, isDefName);
spreadsheet_api.prototype.asc_insertFormula = function(functionName, type, autoComplete) {
this.wb.insertFormulaInEditor(functionName, type, autoComplete);
this.wb.restoreFocus();
};
......
......@@ -346,7 +346,8 @@ var c_oAscDefinedNameReason = {
};
var c_oAscPopUpSelectorType = {
Func: 0,
Range: 1,
Table: 2
None: 0,
Func: 1,
Range: 2,
Table: 3
};
......@@ -303,7 +303,6 @@
<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/view/PopUpSelector.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/CellEditorView.js"></script>
......
......@@ -270,7 +270,6 @@
<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/PopUpSelector.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/CellEditorView.js"></script>
......
......@@ -1573,6 +1573,14 @@
asc_CFindOptions.prototype.asc_setReplaceWith = function (val) {this.replaceWith = 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
* -----------------------------------------------------------------------------
......@@ -1723,5 +1731,10 @@
prot["asc_setLookIn"] = prot.asc_setLookIn;
prot["asc_setReplaceWith"] = prot.asc_setReplaceWith;
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);
......@@ -230,10 +230,7 @@
}
this.fKeyDown = function(event) {
if (t.handlers.trigger("popUpSelectorKeyDown", event)) {
return t._onWindowKeyDown(event);
}
return false;
};
this.fKeyPress = function() {
return t._onWindowKeyPress.apply(t, arguments);
......
......@@ -696,13 +696,6 @@
t.skipKeyPress = true;
if (!t.isCellEditMode) {
if (!t.handlers.trigger("popUpSelectorKeyDown", event)) {
stop();
return result;
}
}
switch (event.which) {
case 113: // F2
......@@ -825,9 +818,6 @@
case 38: // up
stop(); // Отключим стандартную обработку браузера нажатия up
// Если у нас открыто меню для подстановки формулы, то мы не обрабатываем верх/вниз
if (t.isCellEditMode && t.handlers.trigger("isPopUpSelectorOpen"))
return result;
dr = ctrlKey ? -1.5 : -1; // Движение стрелками (влево-вправо, вверх-вниз)
break;
......@@ -838,9 +828,6 @@
case 40: // down
stop(); // Отключим стандартную обработку браузера нажатия down
// Если у нас открыто меню для подстановки формулы, то мы не обрабатываем верх/вниз
if (t.isCellEditMode && t.handlers.trigger("isPopUpSelectorOpen"))
return result;
// Обработка Alt + down
if (!isViewerMode && !t.isCellEditMode && !t.isSelectionDialogMode && event.altKey) {
t.handlers.trigger("showAutoComplete");
......@@ -937,7 +924,7 @@
if (isViewerMode || t.isCellEditMode || t.isSelectionDialogMode) {return true;}
if (event.altKey) {
t.handlers.trigger("addFunction", /*functionName*/"SUM", /*autoComplet*/true);
t.handlers.trigger('addFunction', 'SUM', c_oAscPopUpSelectorType.Func, true);
} else {
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
......@@ -148,10 +148,9 @@
this.fontRenderingMode = null;
this.lockDraw = false; // Lock отрисовки на некоторое время
this.popUpSelector = null;
this.formulasList = null; // Список всех формул
this.lastFormulaPos = -1; // Последняя позиция формулы
this.lastFormulaName = ""; // Последний кусок формулы
this.lastFormulaNameLength = ''; // Последний кусок формулы
this.skipHelpSelector = false; // Пока true - не показываем окно подсказки
this.lastFindOptions = null; // Последний поиск (параметры)
......@@ -362,9 +361,6 @@
// AutoComplete
"showAutoComplete": function () {self._onShowAutoComplete.apply(self, arguments);},
"popUpSelectorKeyDown": function (event) {return self._onPopUpSelectorKeyDown(event);},
"isPopUpSelectorOpen": function () {return self.popUpSelector.getVisible();},
"onContextMenu": function (event) {self.handlers.trigger("asc_onContextMenu", event);}
});
......@@ -416,7 +412,6 @@
},
"applyCloseEvent" : function () {self.controller._onWindowKeyDown.apply(self.controller, arguments);},
"isViewerMode" : function () {return self.controller.settings.isViewerMode;},
"popUpSelectorKeyDown" : function (event) {return self._onPopUpSelectorKeyDown(event);},
"getFormulaRanges" : function () {return self.getWorksheet().getFormulaRanges();},
"setStrictClose" : function (val) {self.controller.setStrictClose(val);},
"updateEditorSelectionInfo" : function (info) {self.handlers.trigger("asc_onEditorSelectionChanged", info);},
......@@ -426,10 +421,6 @@
font: this.defaultFont,
padding: this.defaults.worksheetView.cells.padding
});
this.popUpSelector = new asc.PopUpSelector(this.element, /*handlers*/{
"insert" : function () {self._onPopUpSelectorInsert.apply(self, arguments);}
});
}
if (window['IS_NATIVE_EDITOR']) {
......@@ -461,7 +452,6 @@
},
"applyCloseEvent" : function () {self.controller._onWindowKeyDown.apply(self.controller, arguments);},
"isViewerMode" : function () {return self.controller.settings.isViewerMode;},
"popUpSelectorKeyDown" : function (event) {return self._onPopUpSelectorKeyDown(event);},
"getFormulaRanges" : function () {return self.getWorksheet().getFormulaRanges();},
"setStrictClose" : function (val) {self.controller.setStrictClose(val);},
"updateEditorSelectionInfo" : function (info) {self.handlers.trigger("asc_onEditorSelectionChanged", info);},
......@@ -979,15 +969,13 @@
ws.applyFrozenAnchor(x, y, target);
};
WorkbookView.prototype._onShowAutoComplete = function () {
WorkbookView.prototype._onShowAutoComplete = function() {
var ws = this.getWorksheet();
var arrValues = ws.getCellAutoCompleteValues(ws.activeRange.startCol, ws.activeRange.startRow);
if (!window['IS_NATIVE_EDITOR'])
this.popUpSelector.show(false, arrValues, this.getWorksheet().getActiveCellCoord());
this.handlers.trigger('asc_onEntriesListMenu', arrValues);
};
WorkbookView.prototype._onAutoFiltersClick = function (idFilter) {
WorkbookView.prototype._onAutoFiltersClick = function(idFilter) {
this.getWorksheet().autoFilters.onAutoFilterClick(idFilter);
};
......@@ -1176,10 +1164,10 @@
this._onWSSelectionChanged(null);
// Закрываем подбор формулы
if (this.popUpSelector) {
this.popUpSelector.hide();
if (-1 !== this.lastFormulaPos) {
this.handlers.trigger('asc_onFormulaCompleteMenu', null);
this.lastFormulaPos = -1;
this.lastFormulaName = "";
this.lastFormulaNameLength = 0;
}
};
......@@ -1581,131 +1569,123 @@
this._onStopCellEditing();
};
WorkbookView.prototype.restoreFocus = function () {
if (window["NATIVE_EDITOR_ENJINE"])
WorkbookView.prototype.restoreFocus = function() {
if (window["NATIVE_EDITOR_ENJINE"]) {
return;
}
if (this.cellEditor.hasFocus) {
this.cellEditor.restoreFocus();
}
};
WorkbookView.prototype._onUpdateCellEditor = function ( text, cursorPosition, isFormula, formulaPos, formulaName ) {
if ( this.skipHelpSelector ) {
WorkbookView.prototype._onUpdateCellEditor = function(text, cursorPosition, isFormula, formulaPos, formulaName) {
if (this.skipHelpSelector) {
return;
}
// ToDo для ускорения можно завести объект, куда класть результаты поиска по формулам и второй раз не искать.
var arrResult = [], defNamesList, defName;
if ( isFormula && formulaName ) {
var i, arrResult = [], defNamesList, defName;
if (isFormula && formulaName) {
formulaName = formulaName.toUpperCase();
for ( var i = 0; i < this.formulasList.length; ++i ) {
if ( 0 === this.formulasList[i].indexOf( formulaName ) ) {
// arrResult.push(this.formulasList[i]);
arrResult.push( {name:this.formulasList[i], type:c_oAscPopUpSelectorType.Func} )
}
}
defNamesList = this.getDefinedNames( c_oAscGetDefinedNamesList.WorksheetWorkbook )
for ( var id in defNamesList ) {
defName = defNamesList[id];
if ( 0 === defName.Name.toLowerCase().indexOf( formulaName.toLowerCase() ) ) {
if ( !defName.isTable )
arrResult.push( {name:defName.Name, type:c_oAscPopUpSelectorType.Range} );
else
arrResult.push( {name:defName.Name, type:c_oAscPopUpSelectorType.Table} );
for (i = 0; i < this.formulasList.length; ++i) {
if (0 === this.formulasList[i].indexOf(formulaName)) {
arrResult.push(new Asc.asc_CCompleteMenu(this.formulasList[i], c_oAscPopUpSelectorType.Func));
}
}
defNamesList = this.getDefinedNames(c_oAscGetDefinedNamesList.WorksheetWorkbook);
formulaName = formulaName.toLowerCase();
for (i = 0; i < defNamesList.length; ++i) {
defName = defNamesList[i];
if (0 === defName.Name.toLowerCase().indexOf(formulaName)) {
arrResult.push(new Asc.asc_CCompleteMenu(defName.Name, !defName.isTable ? c_oAscPopUpSelectorType.Range : c_oAscPopUpSelectorType.Table));
}
}
if ( 0 < arrResult.length ) {
if (!window['IS_NATIVE_EDITOR'])
this.popUpSelector.show( true, arrResult, this.getWorksheet().getActiveCellCoord() );
}
if (0 < arrResult.length) {
this.handlers.trigger('asc_onFormulaCompleteMenu', arrResult);
this.lastFormulaPos = formulaPos;
this.lastFormulaName = formulaName;
}
else {
if (!window['IS_NATIVE_EDITOR'])
this.popUpSelector.hide();
this.lastFormulaNameLength = formulaName.length;
} else {
this.handlers.trigger('asc_onFormulaCompleteMenu', null);
this.lastFormulaPos = -1;
this.lastFormulaName = '';
this.lastFormulaNameLength = 0;
}
};
WorkbookView.prototype._onPopUpSelectorKeyDown = function (event) {
if (!this.popUpSelector.getVisible())
return true;
return this.popUpSelector.onKeyDown(event);
};
WorkbookView.prototype._onPopUpSelectorInsert = function (value) {
var name;
if (this.controller.isCellEditMode) {
name = value.name;
if (-1 === this.arrExcludeFormulas.indexOf(value.name) && value.type == c_oAscPopUpSelectorType.Func )
name += '('; // ToDo сделать проверки при добавлении, чтобы не вызывать постоянно окно
this.cellEditor.replaceText(this.lastFormulaPos, this.lastFormulaName.length, name);
} else
this.getWorksheet().setSelectionInfo("value", name, /*onlyActive*/true);
};
// Вставка формулы в редактор
WorkbookView.prototype.insertFormulaInEditor = function (functionName, autoComplete, isDefName) {
var t = this, ws = this.getWorksheet(), cursorPos;
WorkbookView.prototype.insertFormulaInEditor = function(name, type, autoComplete) {
var t = this, ws = this.getWorksheet(), cursorPos, isNotFunction;
if (c_oAscPopUpSelectorType.None === type) {
this.getWorksheet().setSelectionInfo("value", name, /*onlyActive*/true);
return;
}
isNotFunction = c_oAscPopUpSelectorType.Func !== type;
// Проверяем, открыт ли редактор
if (ws.getCellEditMode()) {
if (isDefName)
if (isNotFunction) {
this.skipHelpSelector = true;
// При autoComplete заканчиваем ввод
if (autoComplete)
this.cellEditor.close(true);
else if (false === this.cellEditor.insertFormula(functionName, isDefName)) {
}
if (-1 !== this.lastFormulaPos) {
if (-1 === this.arrExcludeFormulas.indexOf(name) && !isNotFunction) {
name += '('; // ToDo сделать проверки при добавлении, чтобы не вызывать постоянно окно
} else {
this.skipHelpSelector = true;
}
this.cellEditor.replaceText(this.lastFormulaPos, this.lastFormulaNameLength, name);
} else if (false === this.cellEditor.insertFormula(name, isNotFunction)) {
// Не смогли вставить формулу, закроем редактор, с сохранением текста
this.cellEditor.close(true);
}
if (isDefName)
this.skipHelpSelector = false;
} else {
// Проверка глобального лока
if (this.collaborativeEditing.getGlobalLock())
if (this.collaborativeEditing.getGlobalLock()) {
return false;
}
// Редактор закрыт
var cellRange = null;
// Если нужно сделать автозаполнение формулы, то ищем ячейки)
if (autoComplete) {
cellRange = ws.autoCompleteFormula(functionName);
cellRange = ws.autoCompleteFormula(name);
}
if (isDefName) {
functionName = "=" + functionName;
} else{
if (isNotFunction) {
name = "=" + name;
} else {
if (cellRange) {
if (cellRange.notEditCell) {
// Мы уже ввели все что нужно, редактор открывать не нужно
return;
}
// Меняем значение ячейки
functionName = "=" + functionName + "(" + cellRange.text + ")";
name = "=" + name + "(" + cellRange.text + ")";
} else {
// Меняем значение ячейки
functionName = "=" + functionName + "()";
name = "=" + name + "()";
}
// Вычисляем позицию курсора (он должен быть в функции)
cursorPos = functionName.length - 1;
cursorPos = name.length - 1;
}
var arn = ws.activeRange.clone(true);
var openEditor = function (res) {
var openEditor = function(res) {
if (res) {
// Выставляем переменные, что мы редактируем
t.controller.setCellEditMode(true);
ws.setCellEditMode(true);
t.handlers.trigger("asc_onEditCell", c_oAscCellEditorState.editStart);
if (isDefName)
if (isNotFunction) {
t.skipHelpSelector = true;
}
// Открываем, с выставлением позиции курсора
if (!ws.openCellEditorWithText(t.cellEditor, functionName, cursorPos, /*isFocus*/false,
/*activeRange*/arn)) {
if (!ws.openCellEditorWithText(t.cellEditor, name, cursorPos, /*isFocus*/false, /*activeRange*/arn)) {
t.handlers.trigger("asc_onEditCell", c_oAscCellEditorState.editEnd);
t.controller.setCellEditMode(false);
t.controller.setStrictClose(false);
......@@ -1713,8 +1693,9 @@
ws.setCellEditMode(false);
ws.setFormulaEditMode(false);
}
if (isDefName)
if (isNotFunction) {
t.skipHelpSelector = false;
}
} else {
t.controller.setCellEditMode(false);
t.controller.setStrictClose(false);
......
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