change semantics of shift+arrow in one-dimensional lists to always mean 'move cursor' (like in grid lists); make shift+click on selected item move that item to the first position in the selection

This commit is contained in:
rolux 2014-02-02 13:15:09 +00:00
parent e069f11c9a
commit 382f9fce79

View file

@ -244,15 +244,10 @@ Ox.List = function(options, self) {
] = selectNext;
if (self.options.max == -1) {
self.keyboardEvents[
'key_' + (
self.options.orientation == 'vertical'
? 'shift_up' : 'shift_left'
)
'key_shift_' + (self.options.orientation == 'vertical' ? 'up' : 'left')
] = addPreviousToSelection;
self.keyboardEvents[
'key_' + (
self.options.orientation == 'vertical'
? 'shift_down' : 'shift_right'
'key_shift_' + (self.options.orientation == 'vertical' ? 'down' : 'right'
)
] = addNextToSelection;
}
@ -607,11 +602,7 @@ Ox.List = function(options, self) {
function getNext() {
var pos = -1;
if (self.selected.length) {
pos = (
self.options.orientation == 'both'
? self.selected[0]
: Ox.max(self.selected)
) + 1;
pos = self.selected[0] + 1;
if (pos == self.$items.length) {
pos = -1;
}
@ -721,11 +712,7 @@ Ox.List = function(options, self) {
function getPrevious() {
var pos = -1;
if (self.selected.length) {
pos = (
self.options.orientation == 'both'
? self.selected[0]
: Ox.min(self.selected)
) - 1;
pos = self.selected[0] - 1;
}
return pos;
}
@ -918,9 +905,12 @@ Ox.List = function(options, self) {
deselect(pos);
}
} else if (data.shiftKey) {
if (self.options.max == -1) {
// shift-click on item
if (!isSelected(pos) && self.options.max == -1) {
// shift-click on unselected item
addAllToSelection(pos);
} else if (isSelected(pos)) {
// shift-click on selected item
addToSelection(pos);
}
} else if (!isSelected(pos) && self.options.max != 0) {
// click on unselected item