From 382f9fce79304cb790be43dd29aa1e5b7cf1807c Mon Sep 17 00:00:00 2001 From: rolux Date: Sun, 2 Feb 2014 13:15:09 +0000 Subject: [PATCH] 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 --- source/Ox.UI/js/List/List.js | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/source/Ox.UI/js/List/List.js b/source/Ox.UI/js/List/List.js index b338e5d2..cc6b9627 100644 --- a/source/Ox.UI/js/List/List.js +++ b/source/Ox.UI/js/List/List.js @@ -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