2011-11-05 16:46:53 +00:00
|
|
|
'use strict';
|
2012-05-21 10:38:18 +00:00
|
|
|
|
2011-05-16 08:24:46 +00:00
|
|
|
/*@
|
2011-05-16 10:49:48 +00:00
|
|
|
Ox.Clipboard <o> Basic clipboard handler
|
2013-07-13 21:03:29 +00:00
|
|
|
add <f> Add items to clipboard
|
|
|
|
(items[, type]) -> <n> Number of items
|
|
|
|
clear <f> Clear clipboard
|
|
|
|
() -> <n> Number of items
|
|
|
|
copy <f> Copy items to clipboard
|
|
|
|
(items[, type]) -> <n> Number of items
|
|
|
|
paste <f> Paste items from clipboard
|
|
|
|
() -> <a> Items
|
|
|
|
type <f> Get item type
|
|
|
|
() -> <s|undefined> Item type
|
2011-05-16 08:24:46 +00:00
|
|
|
@*/
|
2012-05-22 13:14:40 +00:00
|
|
|
Ox.Clipboard = (function() {
|
2013-07-13 21:03:29 +00:00
|
|
|
var clipboard = {items: [], type: void 0};
|
2011-04-22 22:03:10 +00:00
|
|
|
return {
|
|
|
|
_print: function() {
|
2013-07-13 21:03:29 +00:00
|
|
|
Ox.print(JSON.stringify(clipboard));
|
2011-04-22 22:03:10 +00:00
|
|
|
},
|
2013-07-13 21:03:29 +00:00
|
|
|
add: function(items, type) {
|
|
|
|
if (type != clipboard.type) {
|
|
|
|
Ox.Clipboard.clear();
|
|
|
|
}
|
|
|
|
clipboard = {items: clipboard.items.concat(items), type: type};
|
|
|
|
return clipboard.items.length;
|
|
|
|
},
|
|
|
|
clear: function() {
|
|
|
|
clipboard = {items: [], type: void 0};
|
|
|
|
return clipboard.items.length;
|
|
|
|
},
|
|
|
|
copy: function(items, type) {
|
|
|
|
clipboard = {items: items, type: type};
|
|
|
|
return clipboard.items.length;
|
2011-04-22 22:03:10 +00:00
|
|
|
},
|
|
|
|
paste: function(type) {
|
2013-07-13 21:03:29 +00:00
|
|
|
return !type || type == clipboard.type ? clipboard.items : [];
|
2011-09-20 21:50:00 +00:00
|
|
|
},
|
2013-07-13 21:03:29 +00:00
|
|
|
type: function() {
|
|
|
|
return clipboard.type;
|
2011-04-22 22:03:10 +00:00
|
|
|
}
|
|
|
|
};
|
2012-05-26 12:38:45 +00:00
|
|
|
}());
|