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

Поправил работу PopUpSelector при нажатии стрелок и при scroll-е.

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@56048 954022d7-b5bf-4e40-9824-e11837661b57
parent a6e15c5b
......@@ -136,31 +136,16 @@
}
#apiPopUpSelector {
/*z-index: 3000;
height: auto;
background-color: #FFF;
border: 1px solid Grey;*/
position: absolute;
display: none;
/* cursor: default;
font-size: 12px;
padding: 4px;*/
}
#apiPopUpList {
display: block;
max-height: 210px;
width: 100%;
height: 100%;
max-height: 100%;
overflow: hidden;
position: relative;
}
#apiPopUpList li {
max-width: 500px;
/*text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;*/
}
/*#apiPopUpList li:hover {
background-color: #D8DADC;
}
#apiPopUpList li.selected {
background-color: #7d858c;
color: #fff;
}*/
\ No newline at end of file
}
\ No newline at end of file
......@@ -82,7 +82,7 @@
}
this.isFormula = isFormula;
var item, isFirst, value;
var item, isFirst, value, selectElement = null;
for (var i = 0; i < arrItems.length; ++i) {
item = document.createElement("li");
isFirst = (0 === i);
......@@ -90,10 +90,8 @@
this.firstElement = item;
if (this.isFormula) {
if (isFirst) {
this.selectElement = item;
item.className = "selected";
}
if (isFirst)
selectElement = item;
value = arrItems[i].name;
item.setAttribute("title", arrItems[i].arg);
......@@ -130,6 +128,7 @@
// Для того, чтобы работал scroll
this.selectorListJQ.perfectScrollbar("update");
this._onChangeSelection(selectElement);
};
PopUpSelector.prototype.hide = function () {
if (this.isVisible) {
......@@ -176,11 +175,11 @@
break;
case 38: // Up
this._onChangeSelection(null !== this.selectElement ?
this.selectElement.previousSibling : this.firstElement, -1);
this.selectElement.previousSibling : this.firstElement);
break;
case 40: // Down
this._onChangeSelection(null !== this.selectElement ?
this.selectElement.nextSibling : this.firstElement, +1);
this.selectElement.nextSibling : this.firstElement);
break;
case 16: // Shift
break;
......@@ -200,11 +199,10 @@
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)
......@@ -223,21 +221,28 @@
this._onChangeSelection(event.currentTarget);
};
PopUpSelector.prototype._onChangeSelection = function (newElement, scrollDir) {
if (null === newElement)
PopUpSelector.prototype._onChangeSelection = function (newElement) {
if (null === newElement || null === newElement.getAttribute("val"))
return;
var height = 0;
if (null !== this.selectElement) {
height = this.selectElement.offsetHeight;
if (null !== this.selectElement)
this.selectElement.className = "";
}
this.selectElement = newElement;
this.selectElement.className = "selected";
if (scrollDir && height)
this.selectorListJQ.scrollTop(scrollDir * height);
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);
}
};
/*
......
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