Commit 38cd2c29 authored by Alexander.Trofimov's avatar Alexander.Trofimov Committed by Alexander.Trofimov

Добавил span для отображения иконки в списке формул.

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@65393 954022d7-b5bf-4e40-9824-e11837661b57
parent 9c292f0a
......@@ -5,7 +5,7 @@
* Author: Alexander.Trofimov@avsmedia.net
* Date: April 7, 2014
*/
( /**
(/**
* @param {jQuery} $
* @param {Window} window
* @param {undefined} undefined
......@@ -18,15 +18,15 @@
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
wheelPropagation: false,
minScrollbarLength: null,
useBothWheelAxes: false,
useKeyboard: true,
suppressScrollX: false,
suppressScrollY: false,
scrollXMarginOffset: 5,
scrollYMarginOffset: 5,
includePadding: false
};
this.element = element;
......@@ -50,7 +50,8 @@
this._init();
return this;
}
PopUpSelector.prototype._init = function () {
PopUpSelector.prototype._init = function() {
var t = this;
if (null != this.element) {
this.selector = document.createElement('div');
......@@ -62,17 +63,23 @@
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);};
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 () {
this.selector.addEventListener('mousedown', function() {
t.skipClose = true;
}, false);
}
if (window.addEventListener) {
window.addEventListener('mousedown', function () {
window.addEventListener('mousedown', function() {
if (t.skipClose) {
t.skipClose = false;
return;
......@@ -83,13 +90,14 @@
// Для того, чтобы работал scroll
this.selectorListJQ = $('#apiPopUpList');
if (this.selectorListJQ.perfectScrollbar)
if (this.selectorListJQ.perfectScrollbar) {
this.selectorListJQ.perfectScrollbar(this.scrollOptions);
}
this.setAlwaysVisibleY(true);
}
};
PopUpSelector.prototype.show = function (isFormula, arrItems, cellRect) {
PopUpSelector.prototype.show = function(isFormula, arrItems, cellRect) {
this._clearList();
if (!this.isVisible) {
this.selector.className = 'combobox open';
......@@ -101,24 +109,27 @@
for (var i = 0; i < arrItems.length; ++i) {
item = document.createElement('li');
isFirst = (0 === i);
if (isFirst)
if (isFirst) {
this.firstElement = item;
}
if (this.isFormula) {
if (isFirst)
if (isFirst) {
selectElement = item;
}
value = arrItems[i];
item.setAttribute('title', arrItems[i].arg);
} else
} else {
value = arrItems[i];
}
item.innerHTML = '<a>' + value + '</a>';
item.innerHTML = '<a><span class="menu-item-icon mnu-popup-func"></span>' + value + '</a>';
item.setAttribute('val', value);
if (item.addEventListener) {
item.addEventListener('mousedown' , this.fMouseDown , false);
item.addEventListener('dblclick' , this.fMouseDblClick , false);
item.addEventListener('mousedown', this.fMouseDown, false);
item.addEventListener('dblclick', this.fMouseDblClick, false);
if (!this.isFormula) {
item.addEventListener('mouseover', this.fMouseOver, false);
}
......@@ -135,7 +146,7 @@
this._onChangeSelection(selectElement);
};
PopUpSelector.prototype.hide = function () {
PopUpSelector.prototype.hide = function() {
if (this.isVisible) {
// Чтобы не было непонятных анимаций
this.selectorListJQ.scrollTop(0);
......@@ -146,23 +157,23 @@
this._clearList();
}
};
PopUpSelector.prototype.setPosition = function (cellRect) {
var top = cellRect.asc_getY() + cellRect.asc_getHeight(),
left = cellRect.asc_getX();
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
} else {
left += 10;
}
this.selectorStyle['left'] = left + 'px';
this.selectorStyle['top'] = top + 'px';
};
PopUpSelector.prototype.getVisible = function () {
PopUpSelector.prototype.getVisible = function() {
return this.isVisible;
};
PopUpSelector.prototype._clearList = function () {
PopUpSelector.prototype._clearList = function() {
var i;
for (i = 0; i < this.selectorListEl.length; ++i)
this.selectorList.removeChild(this.selectorListEl[i]);
......@@ -174,7 +185,7 @@
this.isFormula = false;
};
PopUpSelector.prototype.onKeyDown = function (event) {
PopUpSelector.prototype.onKeyDown = function(event) {
var retVal = false;
switch (event.which) {
case 9: // Tab
......@@ -182,57 +193,61 @@
event.stopPropagation();
event.preventDefault();
this._onMouseDblClick();
} else
} else {
retVal = true;
}
break;
case 13: // Enter
if (null !== this.selectElement) {
event.stopPropagation();
event.preventDefault();
if (this.isFormula)
if (this.isFormula) {
this._onMouseDblClick();
else
} else {
this._onInsert(this.selectElement.getAttribute('val'));
} else
}
} else {
retVal = true;
}
break;
case 27: // Esc
this.hide();
break;
case 38: // Up
this._onChangeSelection(null !== this.selectElement ?
this.selectElement.previousSibling : this.firstElement);
this._onChangeSelection(null !== this.selectElement ? this.selectElement.previousSibling : this.firstElement);
break;
case 40: // Down
this._onChangeSelection(null !== this.selectElement ?
this.selectElement.nextSibling : this.firstElement);
this._onChangeSelection(null !== this.selectElement ? this.selectElement.nextSibling : this.firstElement);
break;
case 16: // Shift
break;
default:
retVal = true;
}
if (retVal)
if (retVal) {
this.hide();
}
return retVal;
};
PopUpSelector.prototype._onInsert = function (value) {
PopUpSelector.prototype._onInsert = function(value) {
this.hide();
this.handlers.trigger('insert', value);
};
PopUpSelector.prototype._onMouseDown = function (event) {
PopUpSelector.prototype._onMouseDown = function(event) {
this.skipClose = true;
var element = event.currentTarget;
if (this.isFormula)
if (this.isFormula) {
this._onChangeSelection(element);
else
} else {
this._onInsert(element.getAttribute('val'));
}
};
PopUpSelector.prototype._onMouseDblClick = function (event) {
if (!this.isVisible)
PopUpSelector.prototype._onMouseDblClick = function(event) {
if (!this.isVisible) {
return;
}
if (!this.isFormula) {
this._onMouseDown(event);
......@@ -241,18 +256,21 @@
var elementVal = (event ? event.currentTarget : this.selectElement).getAttribute('val');
this._onInsert(elementVal);
};
PopUpSelector.prototype._onMouseOver = function (event) {
if (this.isFormula)
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'))
PopUpSelector.prototype._onChangeSelection = function(newElement) {
if (null === newElement || null === newElement.getAttribute('val')) {
return;
}
if (null !== this.selectElement)
if (null !== this.selectElement) {
this.selectElement.className = '';
}
this.selectElement = newElement;
this.selectElement.className = 'selected';
......@@ -260,7 +278,7 @@
this.scrollToRecord();
};
PopUpSelector.prototype.scrollToRecord = function () {
PopUpSelector.prototype.scrollToRecord = function() {
var innerEl = $(this.selectorList);
var inner_top = innerEl.offset().top;
var div = $(this.selectElement);
......@@ -271,7 +289,7 @@
}
};
PopUpSelector.prototype.setAlwaysVisibleY = function (flag) {
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');
......@@ -286,5 +304,4 @@
* -----------------------------------------------------------------------------
*/
window["Asc"].PopUpSelector = PopUpSelector;
}
)(jQuery, window);
\ No newline at end of file
})(jQuery, window);
\ No newline at end of file
......@@ -1522,17 +1522,19 @@
}
};
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) {
formulaName = formulaName.toUpperCase();
for (var i = 0; i < this.formulasList.length; ++i) {
if (0 === this.formulasList[i].indexOf(formulaName))
if (0 === this.formulasList[i].indexOf(formulaName)) {
arrResult.push(this.formulasList[i]);
}
}
/*defNamesList = this.getDefinedNames(c_oAscGetDefinedNamesList.WorksheetWorkbook)
for(var id in defNamesList){
defName = defNamesList[id];
......@@ -1548,7 +1550,7 @@
} else {
this.popUpSelector.hide();
this.lastFormulaPos = -1;
this.lastFormulaName = "";
this.lastFormulaName = '';
}
};
WorkbookView.prototype._onPopUpSelectorKeyDown = function (event) {
......
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