Fix textcomplete up side down option not set properly

This commit is contained in:
Wu Cheng-Han 2016-12-07 01:34:42 +08:00
parent bbaf697687
commit dd284a7bd0
2 changed files with 8 additions and 9 deletions

View file

@ -3651,9 +3651,6 @@ function reverseSortCursorMenu(dropdown) {
return items; return items;
} }
var lastUpSideDown = false;
var upSideDown = false;
var checkCursorMenu = _.throttle(checkCursorMenuInner, cursorMenuThrottle); var checkCursorMenu = _.throttle(checkCursorMenuInner, cursorMenuThrottle);
function checkCursorMenuInner() { function checkCursorMenuInner() {
@ -3692,6 +3689,8 @@ function checkCursorMenuInner() {
// set offset // set offset
var offsetLeft = 0; var offsetLeft = 0;
var offsetTop = defaultTextHeight; var offsetTop = defaultTextHeight;
// set up side down
var lastUpSideDown = upSideDown = false;
// only do when have width and height // only do when have width and height
if (width > 0 && height > 0) { if (width > 0 && height > 0) {
// make element right bound not larger than doc width // make element right bound not larger than doc width
@ -3703,12 +3702,11 @@ function checkCursorMenuInner() {
offsetTop = -(height + menuBottomMargin); offsetTop = -(height + menuBottomMargin);
// reverse sort menu because upSideDown // reverse sort menu because upSideDown
dropdown.html(reverseSortCursorMenu(dropdown)); dropdown.html(reverseSortCursorMenu(dropdown));
lastUpSideDown = upSideDown;
upSideDown = true; upSideDown = true;
} else {
lastUpSideDown = upSideDown;
upSideDown = false;
} }
var textCompleteDropdown = $(editor.getInputField()).data('textComplete').dropdown;
lastUpSideDown = textCompleteDropdown.upSideDown;
textCompleteDropdown.upSideDown = upSideDown;
} }
// make menu scroll top only if upSideDown changed // make menu scroll top only if upSideDown changed
if (upSideDown !== lastUpSideDown) if (upSideDown !== lastUpSideDown)

5
public/vendor/jquery-textcomplete/jquery.textcomplete.js vendored Normal file → Executable file
View file

@ -167,6 +167,7 @@ if (typeof jQuery === 'undefined') {
var element = this.$el.get(0); var element = this.$el.get(0);
// Initialize view objects. // Initialize view objects.
this.dropdown = new $.fn.textcomplete.Dropdown(element, this, this.option); this.dropdown = new $.fn.textcomplete.Dropdown(element, this, this.option);
this.dropdown.upSideDown = false;
var Adapter, viewName; var Adapter, viewName;
if (this.option.adapter) { if (this.option.adapter) {
Adapter = this.option.adapter; Adapter = this.option.adapter;
@ -556,13 +557,13 @@ if (typeof jQuery === 'undefined') {
if (!this.shown) { return; } if (!this.shown) { return; }
if (this.isUp(e)) { if (this.isUp(e)) {
e.preventDefault(); e.preventDefault();
if(typeof upSideDown != 'undefined' && upSideDown) if(this.upSideDown)
this._down(); this._down();
else else
this._up(); this._up();
} else if (this.isDown(e)) { } else if (this.isDown(e)) {
e.preventDefault(); e.preventDefault();
if(typeof upSideDown != 'undefined' && upSideDown) if(this.upSideDown)
this._up(); this._up();
else else
this._down(); this._down();