summaryrefslogtreecommitdiff
path: root/public
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--public/js/index.js35
-rwxr-xr-xpublic/vendor/jquery-textcomplete/jquery.textcomplete.js25
2 files changed, 35 insertions, 25 deletions
diff --git a/public/js/index.js b/public/js/index.js
index 75634cf1..ae3edb28 100644
--- a/public/js/index.js
+++ b/public/js/index.js
@@ -1353,15 +1353,19 @@ function emitUserStatus(force) {
}
function checkCursorTag(coord, ele) {
+ if (!ele) return;
var curosrtagMargin = 60;
- var viewport = editor.getViewport();
- var viewportHeight = (viewport.to - viewport.from) * editor.defaultTextHeight();
+ var cursor = editor.getCursor();
+ //var viewport = editor.getViewport();
+ //var viewportHeight = (viewport.to - viewport.from) * editor.defaultTextHeight();
var editorWidth = ui.area.codemirror.width();
var editorHeight = ui.area.codemirror.height();
var width = ele.width();
var height = ele.height();
+ if (!lineHeightMap)
+ buildMapInner();
var left = coord.left;
- var top = coord.top;
+ var top = lineHeightMap[cursor.line] * defaultTextHeight; //coord.top;
var offsetLeft = -3;
var offsetTop = defaultTextHeight;
var statusBarHeight = 0;
@@ -1371,8 +1375,8 @@ function checkCursorTag(coord, ele) {
if (left + width + offsetLeft > editorWidth - curosrtagMargin) {
offsetLeft = -(width + 10);
}
- offsetTop = -(height);
if (top + height + offsetTop > Math.max(editor.doc.height, editorHeight) + curosrtagMargin - statusBarHeight * 2 && top - height > curosrtagMargin) {
+ offsetTop = -(height + 4);
}
}
ele[0].style.left = offsetLeft + 'px';
@@ -1863,10 +1867,11 @@ if ($('.cursor-menu').length <= 0) {
}
var upSideDown = false;
-var menuMargin = 60;
function checkCursorMenu() {
+ var menuMargin = 60;
var dropdown = $('.cursor-menu .dropdown-menu');
+ if (dropdown.length <= 0) return;
var cursor = editor.getCursor();
var scrollInfo = editor.getScrollInfo();
if (!dropdown.hasClass('other-cursor'))
@@ -1877,14 +1882,16 @@ function checkCursorMenu() {
line: cursor.line,
ch: cursor.ch
}, 'windows');
- var viewport = editor.getViewport();
- var viewportHeight = (viewport.to - viewport.from) * editor.defaultTextHeight();
+ //var viewport = editor.getViewport();
+ //var viewportHeight = (viewport.to - viewport.from) * editor.defaultTextHeight();
var editorWidth = ui.area.codemirror.width();
var editorHeight = ui.area.codemirror.height();
- var width = dropdown.width();
- var height = dropdown.height();
+ var width = dropdown.outerWidth();
+ var height = dropdown.outerHeight();
+ if (!lineHeightMap)
+ buildMapInner();
var left = coord.left;
- var top = coord.top;
+ var top = lineHeightMap[cursor.line] * defaultTextHeight; //coord.top;
var offsetLeft = 0;
var offsetTop = defaultTextHeight;
var statusBarHeight = 0;
@@ -1892,9 +1899,15 @@ function checkCursorMenu() {
statusBarHeight = statusBar.outerHeight();
if (left + width + offsetLeft > editorWidth - menuMargin)
offsetLeft = -(left + width - editorWidth + menuMargin);
- offsetTop = -(height + defaultTextHeight);
if (top + height + offsetTop > Math.max(editor.doc.height, editorHeight) + menuMargin - statusBarHeight * 2 && top - height > menuMargin) {
+ offsetTop = -(height + 4);
upSideDown = true;
+ var items = dropdown.find('.textcomplete-item');
+ items.sort(function (a, b) {
+ return $(b).attr('data-index') - $(a).attr('data-index');
+ });
+ dropdown.html(items);
+ dropdown.scrollTop(dropdown[0].scrollHeight);
} else {
upSideDown = false;
}
diff --git a/public/vendor/jquery-textcomplete/jquery.textcomplete.js b/public/vendor/jquery-textcomplete/jquery.textcomplete.js
index 145e2413..49881ce1 100755
--- a/public/vendor/jquery-textcomplete/jquery.textcomplete.js
+++ b/public/vendor/jquery-textcomplete/jquery.textcomplete.js
@@ -554,10 +554,16 @@ if (typeof jQuery === 'undefined') {
if (!this.shown) { return; }
if (this.isUp(e)) {
e.preventDefault();
- this._up();
+ if(typeof upSideDown != 'undefined' && upSideDown)
+ this._down();
+ else
+ this._up();
} else if (this.isDown(e)) {
e.preventDefault();
- this._down();
+ if(typeof upSideDown != 'undefined' && upSideDown)
+ this._up();
+ else
+ this._down();
} else if (this.isEnter(e)) {
e.preventDefault();
this._enter();
@@ -633,7 +639,7 @@ if (typeof jQuery === 'undefined') {
},
_getActiveElement: function () {
- return this.$el.children('.textcomplete-item:nth(' + this._index + ')');
+ return this.$el.children('.textcomplete-item[data-index=' + this._index + ']');
},
_setScroll: function () {
@@ -661,20 +667,11 @@ if (typeof jQuery === 'undefined') {
this.data.push(datum);
item.push(datum.strategy.template(datum.value));
}
- if(typeof upSideDown != 'undefined' && upSideDown) {
- for (i = item.length - 1; i >= 0; i--) {
- html += '<li class="textcomplete-item" data-index="' + i + '"><a>';
- html += item[i];
- html += '</a></li>';
- }
- this._index = this.data.length - 1;
- } else {
- for (i = 0; i < item.length; i++) {
+ for (i = 0; i < item.length; i++) {
html += '<li class="textcomplete-item" data-index="' + i + '"><a>';
html += item[i];
html += '</a></li>';
- }
- }
+ }
return html;
},