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));
|
||||
},
|
||||
add: function(items, type) {
|
||||
if (type != clipboard.type) {
|
||||
Ox.Clipboard.clear();
|
||||
items = Ox.makeArray(items);
|
||||
if (items.length) {
|
||||
if (type != clipboard.type) {
|
||||
Ox.Clipboard.clear();
|
||||
}
|
||||
clipboard = {items: clipboard.items.concat(items), type: type};
|
||||
$element && $element.triggerEvent('add', clipboard);
|
||||
}
|
||||
clipboard = {
|
||||
items: clipboard.items.concat(Ox.makeArray(items)),
|
||||
type: type
|
||||
};
|
||||
$element && $element.triggerEvent('add', clipboard);
|
||||
return clipboard.items.length;
|
||||
},
|
||||
bindEvent: function() {
|
||||
|
@ -43,8 +43,11 @@ Ox.Clipboard = (function() {
|
|||
return clipboard.items.length;
|
||||
},
|
||||
copy: function(items, type) {
|
||||
clipboard = {items: Ox.makeArray(items), type: type};
|
||||
$element && $element.triggerEvent('copy', clipboard);
|
||||
items = Ox.makeArray(items);
|
||||
if (items.length) {
|
||||
clipboard = {items: items, type: type};
|
||||
$element && $element.triggerEvent('copy', clipboard);
|
||||
}
|
||||
return clipboard.items.length;
|
||||
},
|
||||
items: function(type) {
|
||||
|
|
Loading…
Reference in a new issue