Ox.Clipboard: ignore copy/add in case zero items get passed
This commit is contained in:
parent
8273b8654a
commit
e6541b2b32
1 changed files with 12 additions and 9 deletions
|
@ -21,14 +21,14 @@ Ox.Clipboard = (function() {
|
||||||
Ox.print(JSON.stringify(clipboard));
|
Ox.print(JSON.stringify(clipboard));
|
||||||
},
|
},
|
||||||
add: function(items, type) {
|
add: function(items, type) {
|
||||||
|
items = Ox.makeArray(items);
|
||||||
|
if (items.length) {
|
||||||
if (type != clipboard.type) {
|
if (type != clipboard.type) {
|
||||||
Ox.Clipboard.clear();
|
Ox.Clipboard.clear();
|
||||||
}
|
}
|
||||||
clipboard = {
|
clipboard = {items: clipboard.items.concat(items), type: type};
|
||||||
items: clipboard.items.concat(Ox.makeArray(items)),
|
|
||||||
type: type
|
|
||||||
};
|
|
||||||
$element && $element.triggerEvent('add', clipboard);
|
$element && $element.triggerEvent('add', clipboard);
|
||||||
|
}
|
||||||
return clipboard.items.length;
|
return clipboard.items.length;
|
||||||
},
|
},
|
||||||
bindEvent: function() {
|
bindEvent: function() {
|
||||||
|
@ -43,8 +43,11 @@ Ox.Clipboard = (function() {
|
||||||
return clipboard.items.length;
|
return clipboard.items.length;
|
||||||
},
|
},
|
||||||
copy: function(items, type) {
|
copy: function(items, type) {
|
||||||
clipboard = {items: Ox.makeArray(items), type: type};
|
items = Ox.makeArray(items);
|
||||||
|
if (items.length) {
|
||||||
|
clipboard = {items: items, type: type};
|
||||||
$element && $element.triggerEvent('copy', clipboard);
|
$element && $element.triggerEvent('copy', clipboard);
|
||||||
|
}
|
||||||
return clipboard.items.length;
|
return clipboard.items.length;
|
||||||
},
|
},
|
||||||
items: function(type) {
|
items: function(type) {
|
||||||
|
|
Loading…
Reference in a new issue