From e6541b2b32956c14045b9bc4e30af46f0b760a24 Mon Sep 17 00:00:00 2001 From: rlx <0x0073@0x2620.org> Date: Fri, 2 Aug 2013 16:41:08 +0000 Subject: [PATCH] Ox.Clipboard: ignore copy/add in case zero items get passed --- source/Ox.UI/js/Core/Clipboard.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/source/Ox.UI/js/Core/Clipboard.js b/source/Ox.UI/js/Core/Clipboard.js index 3d9afbcf..918e5d1c 100644 --- a/source/Ox.UI/js/Core/Clipboard.js +++ b/source/Ox.UI/js/Core/Clipboard.js @@ -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) {