Ox.List: cleanup; trigger copy (add) and cut (add) events
This commit is contained in:
parent
e283ff1053
commit
8383643549
1 changed files with 18 additions and 28 deletions
|
@ -169,6 +169,9 @@ Ox.List = function(options, self) {
|
|||
itemMargin: self.options.type == 'text' ? 0 : 8, // 2 x 4 px margin ... fixme: the 2x should be computed later
|
||||
keyboardEvents: {
|
||||
key_control_c: copyItems,
|
||||
key_shift_control_c: function() {
|
||||
copyItems(true);
|
||||
},
|
||||
key_control_e: editItems,
|
||||
key_control_n: function() {
|
||||
addItem('');
|
||||
|
@ -184,6 +187,9 @@ Ox.List = function(options, self) {
|
|||
},
|
||||
key_control_v: pasteItems,
|
||||
key_control_x: cutItems,
|
||||
key_shift_control_x: function() {
|
||||
cutItems(true);
|
||||
},
|
||||
key_delete: deleteItems,
|
||||
key_end: scrollToLast,
|
||||
key_enter: open,
|
||||
|
@ -374,25 +380,14 @@ Ox.List = function(options, self) {
|
|||
return $page;
|
||||
}
|
||||
|
||||
function copyItems() {
|
||||
// fixme: both copy and paste should just deal with Ox.Clipboard,
|
||||
// and use a "type"
|
||||
self.options.selected.length && that.triggerEvent('copy', {
|
||||
function copyItems(add) {
|
||||
self.options.selected.length && that.triggerEvent('copy' + (add ? 'add': ''), {
|
||||
ids: self.options.selected
|
||||
});
|
||||
/*
|
||||
ids.length && self.options.copy && Ox.Clipboard.copy(
|
||||
self.options.copy(
|
||||
ids.map(function(id) {
|
||||
return that.value(id);
|
||||
})
|
||||
)
|
||||
);
|
||||
*/
|
||||
}
|
||||
|
||||
function cutItems() {
|
||||
copyItems();
|
||||
function cutItems(add) {
|
||||
copyItems(add);
|
||||
deleteItems();
|
||||
}
|
||||
|
||||
|
@ -1005,7 +1000,7 @@ Ox.List = function(options, self) {
|
|||
}
|
||||
|
||||
function pasteItems() {
|
||||
that.triggerEvent('paste', Ox.Clipboard.paste());
|
||||
that.triggerEvent('paste');
|
||||
}
|
||||
|
||||
function preview() {
|
||||
|
@ -1518,11 +1513,16 @@ Ox.List = function(options, self) {
|
|||
|
||||
/*@
|
||||
addItems <f> add item to list
|
||||
(pos, items) -> <u> add items to list at position
|
||||
(items) -> <u> add items at the end of the list
|
||||
(pos, items) -> <u> add items at position
|
||||
pos <n> position to add items
|
||||
items <a> array of items to add
|
||||
@*/
|
||||
that.addItems = function(pos, items) {
|
||||
if (arguments.length == 1) {
|
||||
items = pos;
|
||||
pos = self.listLength;
|
||||
}
|
||||
var $items = [],
|
||||
length = items.length;
|
||||
self.selected.forEach(function(v, i) {
|
||||
|
@ -1586,16 +1586,6 @@ Ox.List = function(options, self) {
|
|||
return that;
|
||||
};
|
||||
|
||||
/*@
|
||||
paste <f> paste data
|
||||
(data) -> <o> the list
|
||||
data <o> paste object
|
||||
@*/
|
||||
that.paste = function(data) {
|
||||
pasteItems(data);
|
||||
return that;
|
||||
};
|
||||
|
||||
/*@
|
||||
reloadList <f> reload list contents
|
||||
() -> <o> the list
|
||||
|
@ -1641,7 +1631,7 @@ Ox.List = function(options, self) {
|
|||
(ids) -> <u> remove items
|
||||
(pos, length) -> <u> remove items
|
||||
ids <a> array of item ids
|
||||
pos <n> delete items starting at this position
|
||||
pos <n> remove items starting at this position
|
||||
length <n> number of items to remove
|
||||
@*/
|
||||
that.removeItems = function(pos, length) {
|
||||
|
|
Loading…
Reference in a new issue