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