several improvements to autocomplete
This commit is contained in:
parent
7b15d2bb8f
commit
d1477a057a
3 changed files with 33 additions and 17 deletions
|
@ -88,6 +88,8 @@ Ox.load('Geo', function() {
|
||||||
{ id: "", title: "goToOut" },
|
{ id: "", title: "goToOut" },
|
||||||
{ id: "", title: "setIn" },
|
{ id: "", title: "setIn" },
|
||||||
{ id: "", title: "setOut" },
|
{ id: "", title: "setOut" },
|
||||||
|
{ id: "", title: "goToPoster" },
|
||||||
|
{ id: "", title: "setPoster" },
|
||||||
{ id: "", title: "center" },
|
{ id: "", title: "center" },
|
||||||
{ id: "", title: "zoom" },
|
{ id: "", title: "zoom" },
|
||||||
{ id: "", title: "grow" },
|
{ id: "", title: "grow" },
|
||||||
|
@ -109,6 +111,7 @@ Ox.load('Geo', function() {
|
||||||
{ id: "", title: "warning" },
|
{ id: "", title: "warning" },
|
||||||
{ id: "", title: "help" },
|
{ id: "", title: "help" },
|
||||||
{ id: "", title: "check" },
|
{ id: "", title: "check" },
|
||||||
|
{ id: "", title: "embed" },
|
||||||
{ id: "", title: "bracket" },
|
{ id: "", title: "bracket" },
|
||||||
{ id: "", title: "delete" },
|
{ id: "", title: "delete" },
|
||||||
{ id: "", title: "download" },
|
{ id: "", title: "download" },
|
||||||
|
|
|
@ -270,7 +270,7 @@ Ox.Input = function(options, self) {
|
||||||
function autocomplete(oldValue, oldCursor) {
|
function autocomplete(oldValue, oldCursor) {
|
||||||
|
|
||||||
oldValue = Ox.isUndefined(oldValue) ? self.options.value : oldValue;
|
oldValue = Ox.isUndefined(oldValue) ? self.options.value : oldValue;
|
||||||
oldCursor = Ox.isUndefined(oldCursor) ? cursor : oldCursor;
|
oldCursor = Ox.isUndefined(oldCursor) ? cursor() : oldCursor;
|
||||||
|
|
||||||
Ox.print('autocomplete', oldValue, oldCursor)
|
Ox.print('autocomplete', oldValue, oldCursor)
|
||||||
|
|
||||||
|
@ -290,7 +290,12 @@ Ox.Input = function(options, self) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!self.options.value) {
|
if (!self.options.value) {
|
||||||
self.options.autocompleteSelect && self.$autocompleteMenu.hideMenu();
|
if (self.options.autocompleteSelect) {
|
||||||
|
self.$autocompleteMenu
|
||||||
|
.unbindEvent('select')
|
||||||
|
.hideMenu();
|
||||||
|
self.selectEventBound = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function autocompleteFunction() {
|
function autocompleteFunction() {
|
||||||
|
@ -328,6 +333,7 @@ Ox.Input = function(options, self) {
|
||||||
//Ox.print('selectEnd', selectEnd)
|
//Ox.print('selectEnd', selectEnd)
|
||||||
|
|
||||||
if (self.options.autocompleteReplace) {
|
if (self.options.autocompleteReplace) {
|
||||||
|
value = self.options.value;
|
||||||
self.options.value = newValue;
|
self.options.value = newValue;
|
||||||
self.$input.val(self.options.value);
|
self.$input.val(self.options.value);
|
||||||
if (selectEnd) {
|
if (selectEnd) {
|
||||||
|
@ -341,7 +347,7 @@ Ox.Input = function(options, self) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self.options.autocompleteSelect) {
|
if (self.options.autocompleteSelect) {
|
||||||
value = self.options.value.toLowerCase();
|
value = (self.options.autocompleteReplace ? value : self.options.value).toLowerCase();
|
||||||
if (values.length) {
|
if (values.length) {
|
||||||
self.oldCursor = cursor();
|
self.oldCursor = cursor();
|
||||||
self.oldValue = self.options.value;
|
self.oldValue = self.options.value;
|
||||||
|
@ -364,11 +370,20 @@ Ox.Input = function(options, self) {
|
||||||
return ret;
|
return ret;
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
if (!self.selectEventBound) {
|
||||||
|
self.$autocompleteMenu.bindEvent({
|
||||||
|
select: selectMenu,
|
||||||
|
});
|
||||||
|
self.selectEventBound = true;
|
||||||
|
}
|
||||||
self.$autocompleteMenu.options({
|
self.$autocompleteMenu.options({
|
||||||
selected: selected
|
selected: selected
|
||||||
}).showMenu();
|
}).showMenu();
|
||||||
} else {
|
} else {
|
||||||
self.$autocompleteMenu.hideMenu();
|
self.$autocompleteMenu
|
||||||
|
.unbindEvent('select')
|
||||||
|
.hideMenu();
|
||||||
|
self.selectEventBound = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -394,12 +409,6 @@ Ox.Input = function(options, self) {
|
||||||
.bindEvent({
|
.bindEvent({
|
||||||
click: clickMenu
|
click: clickMenu
|
||||||
});
|
});
|
||||||
if (self.options.autocompleteReplace) {
|
|
||||||
menu.bindEvent({
|
|
||||||
deselect: deselectMenu,
|
|
||||||
select: selectMenu,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return menu;
|
return menu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -605,6 +614,8 @@ Ox.Input = function(options, self) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function deselectMenu() {
|
function deselectMenu() {
|
||||||
|
return;
|
||||||
|
Ox.print('deselectMenu')
|
||||||
self.options.value = self.oldValue;
|
self.options.value = self.oldValue;
|
||||||
self.$input.val(self.options.value);
|
self.$input.val(self.options.value);
|
||||||
cursor(self.oldCursor);
|
cursor(self.oldCursor);
|
||||||
|
@ -685,10 +696,12 @@ Ox.Input = function(options, self) {
|
||||||
|
|
||||||
function selectMenu(event, data) {
|
function selectMenu(event, data) {
|
||||||
var pos = cursor();
|
var pos = cursor();
|
||||||
//Ox.print('selectMenu', pos)
|
//if (self.options.value) {
|
||||||
|
Ox.print('selectMenu', pos, data.title)
|
||||||
self.options.value = data.title
|
self.options.value = data.title
|
||||||
self.$input.val(self.options.value);
|
self.$input.val(self.options.value);
|
||||||
cursor(pos[0], self.options.value.length)
|
cursor(pos[0], self.options.value.length);
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setPlaceholder() {
|
function setPlaceholder() {
|
||||||
|
|
|
@ -404,7 +404,7 @@ Ox.print(options)
|
||||||
if (self.options.selected > -1) {
|
if (self.options.selected > -1) {
|
||||||
//Ox.print('s.o.s', self.options.selected, that.items)
|
//Ox.print('s.o.s', self.options.selected, that.items)
|
||||||
item = that.items[self.options.selected]
|
item = that.items[self.options.selected]
|
||||||
item.removeClass('OxSelected');
|
item && item.removeClass('OxSelected');
|
||||||
/* disabled
|
/* disabled
|
||||||
that.triggerEvent('deselect', {
|
that.triggerEvent('deselect', {
|
||||||
id: item.options('id'),
|
id: item.options('id'),
|
||||||
|
@ -422,12 +422,12 @@ Ox.print(options)
|
||||||
});
|
});
|
||||||
item.options('items').length && that.submenus[item.options('id')].showMenu(); // fixme: do we want to switch to this style?
|
item.options('items').length && that.submenus[item.options('id')].showMenu(); // fixme: do we want to switch to this style?
|
||||||
item.addClass('OxSelected');
|
item.addClass('OxSelected');
|
||||||
/* disabled
|
///* disabled
|
||||||
that.triggerEvent('select', {
|
that.triggerEvent('select', {
|
||||||
id: item.options('id'),
|
id: item.options('id'),
|
||||||
title: Ox.stripTags(item.options('title')[0])
|
title: Ox.stripTags(item.options('title')[0])
|
||||||
});
|
});
|
||||||
*/
|
//*/
|
||||||
}
|
}
|
||||||
self.options.selected = position;
|
self.options.selected = position;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue