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