Ox.Clipboard: ignore copy/add in case zero items get passed

This commit is contained in:
rlx 2013-08-02 16:41:08 +00:00
parent 8273b8654a
commit e6541b2b32

View file

@ -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) {