Lists: add public 'selectAll' and 'invertSelection' methods
This commit is contained in:
parent
43502c42a1
commit
1fc0a0191b
5 changed files with 73 additions and 18 deletions
|
@ -108,6 +108,11 @@ Ox.CustomList = function(options, self) {
|
|||
return self.$list.hasFocus();
|
||||
};
|
||||
|
||||
that.invertSelection = function() {
|
||||
self.$list.invertSelection();
|
||||
return that;
|
||||
};
|
||||
|
||||
/*@
|
||||
loseFocus <f> lose Focus
|
||||
@*/
|
||||
|
@ -116,6 +121,11 @@ Ox.CustomList = function(options, self) {
|
|||
return that;
|
||||
};
|
||||
|
||||
that.selectAll = function() {
|
||||
self.$list.selectAll();
|
||||
return that;
|
||||
};
|
||||
|
||||
/*@
|
||||
selectPosition <f> select position
|
||||
@*/
|
||||
|
|
|
@ -184,6 +184,11 @@ Ox.IconList = function(options, self) {
|
|||
return that.$element.hasFocus();
|
||||
};
|
||||
|
||||
that.invertSelection = function() {
|
||||
that.$element.invertSelection();
|
||||
return that;
|
||||
};
|
||||
|
||||
/*@
|
||||
loseFocus <f> loseFocus
|
||||
@*/
|
||||
|
@ -210,6 +215,11 @@ Ox.IconList = function(options, self) {
|
|||
return that;
|
||||
};
|
||||
|
||||
that.selectAll = function() {
|
||||
that.$element.selectAll();
|
||||
return that;
|
||||
};
|
||||
|
||||
/*@
|
||||
size <f> get size of list
|
||||
() -> <n> size
|
||||
|
|
|
@ -205,6 +205,11 @@ Ox.InfoList = function(options, self) {
|
|||
return that.$element.hasFocus();
|
||||
};
|
||||
|
||||
that.invertSelection = function() {
|
||||
that.$element.invertSelection();
|
||||
return that;
|
||||
};
|
||||
|
||||
/*@
|
||||
loseFocus <f> loseFocus
|
||||
@*/
|
||||
|
@ -229,6 +234,11 @@ Ox.InfoList = function(options, self) {
|
|||
return that;
|
||||
};
|
||||
|
||||
that.selectAll = function() {
|
||||
that.$element.selectAll();
|
||||
return that;
|
||||
};
|
||||
|
||||
/*@
|
||||
size <f> size
|
||||
@*/
|
||||
|
|
|
@ -36,6 +36,9 @@ Ox.List <f> List constructor
|
|||
([options[, self]]) -> <o:Ox.Container> List object
|
||||
init <!> init
|
||||
add <!> item added
|
||||
closepreview <!> preview closed
|
||||
copy <!> copy and replace clipboard
|
||||
copyadd <!> copy and add to clipboard
|
||||
delete <!> item removed
|
||||
draganddrop <!> Fires during drag
|
||||
draganddropend <!> Fires on drop
|
||||
|
@ -43,12 +46,10 @@ Ox.List <f> List constructor
|
|||
draganddropleave <!> Fires when leaving an item during drag
|
||||
draganddroppause <!> Fires when the mouse stops during drag
|
||||
draganddropstart <!> Fires when drag starts
|
||||
copy <!> copy
|
||||
paste <!> paste
|
||||
move <!> move item
|
||||
load <!> list loaded
|
||||
move <!> move item
|
||||
openpreview <!> preview of selected item opened
|
||||
closepreview <!> preview closed
|
||||
select <!> select item
|
||||
selectnext <!> selectnext
|
||||
selectprevious <!> selectprevious
|
||||
|
@ -219,8 +220,12 @@ Ox.List = function(options, self) {
|
|||
});
|
||||
}
|
||||
self.options.max == -1 && Ox.extend(self.keyboardEvents, {
|
||||
key_alt_control_a: invertSelection,
|
||||
key_control_a: selectAll
|
||||
key_alt_control_a: function() {
|
||||
that.invertSelection();
|
||||
},
|
||||
key_control_a: function() {
|
||||
that.selectAll();
|
||||
}
|
||||
});
|
||||
self.options.min == 0 && Ox.extend(self.keyboardEvents, {
|
||||
key_control_shift_a: selectNone
|
||||
|
@ -782,14 +787,6 @@ Ox.List = function(options, self) {
|
|||
);
|
||||
}
|
||||
|
||||
function invertSelection() {
|
||||
var arr = Ox.range(self.listLength).filter(function(pos) {
|
||||
return !isSelected(pos);
|
||||
});
|
||||
selectNone();
|
||||
addToSelection(arr);
|
||||
}
|
||||
|
||||
function isSelected(pos) {
|
||||
return self.selected.indexOf(pos) > -1;
|
||||
}
|
||||
|
@ -1161,10 +1158,6 @@ Ox.List = function(options, self) {
|
|||
}
|
||||
}
|
||||
|
||||
function selectAll() {
|
||||
addToSelection(Ox.range(self.listLength));
|
||||
}
|
||||
|
||||
function selectAsYouType(data) {
|
||||
self.options.items({
|
||||
keys: [self.options.unique],
|
||||
|
@ -1589,7 +1582,7 @@ Ox.List = function(options, self) {
|
|||
|
||||
/*@
|
||||
closePreview <f> to be called when preview is closed externally
|
||||
() -> <o> the list
|
||||
() -> <o> the list
|
||||
@*/
|
||||
that.closePreview = function() {
|
||||
self.preview = false;
|
||||
|
@ -1606,6 +1599,19 @@ Ox.List = function(options, self) {
|
|||
return that;
|
||||
};
|
||||
|
||||
/*@
|
||||
invertSelection <f> Invert selection
|
||||
() -> <o> The list
|
||||
@*/
|
||||
that.invertSelection = function() {
|
||||
var arr = Ox.range(self.listLength).filter(function(pos) {
|
||||
return !isSelected(pos);
|
||||
});
|
||||
selectNone();
|
||||
addToSelection(arr);
|
||||
return that;
|
||||
};
|
||||
|
||||
/*@
|
||||
openPreview <f> to be called when preview is opened externally
|
||||
() -> <o> the list
|
||||
|
@ -1699,6 +1705,15 @@ Ox.List = function(options, self) {
|
|||
return that;
|
||||
};
|
||||
|
||||
/*@
|
||||
selectAll <f> Select all
|
||||
() -> <o> The list
|
||||
@*/
|
||||
that.selectAll = function() {
|
||||
addToSelection(Ox.range(self.listLength));
|
||||
return that;
|
||||
};
|
||||
|
||||
/*@
|
||||
selectPosition <f> select position
|
||||
(pos) -> <o> List Object
|
||||
|
|
|
@ -1081,6 +1081,11 @@ Ox.TableList = function(options, self) {
|
|||
return that.$body.hasFocus();
|
||||
};
|
||||
|
||||
that.invertSelection = function() {
|
||||
that.$body.invertSelection();
|
||||
return that;
|
||||
};
|
||||
|
||||
/*@
|
||||
loseFocus <f> loseFocus
|
||||
@*/
|
||||
|
@ -1111,6 +1116,11 @@ Ox.TableList = function(options, self) {
|
|||
return that;
|
||||
};
|
||||
|
||||
that.selectAll = function() {
|
||||
that.$body.selectAll();
|
||||
return that;
|
||||
};
|
||||
|
||||
that.selectPosition = function(pos) {
|
||||
that.$body.selectPosition(pos);
|
||||
return that;
|
||||
|
|
Loading…
Reference in a new issue