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