rewrite clipboard controller
This commit is contained in:
parent
861dabfb43
commit
18d100f978
1 changed files with 29 additions and 12 deletions
|
@ -2,26 +2,43 @@
|
|||
|
||||
/*@
|
||||
Ox.Clipboard <o> Basic clipboard handler
|
||||
copy <f> Copy data to clipboard
|
||||
(data) -> <u> undefined
|
||||
paste <f> Paste data from clipboard
|
||||
() -> <*> Clipboard data
|
||||
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
|
||||
@*/
|
||||
Ox.Clipboard = (function() {
|
||||
var clipboard = {};
|
||||
var clipboard = {items: [], type: void 0};
|
||||
return {
|
||||
_print: function() {
|
||||
Ox.Log('Core', JSON.stringify(clipboard));
|
||||
Ox.print(JSON.stringify(clipboard));
|
||||
},
|
||||
copy: function(data) {
|
||||
clipboard = data;
|
||||
Ox.Log('Core', 'copy', JSON.stringify(clipboard));
|
||||
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;
|
||||
},
|
||||
paste: function(type) {
|
||||
return type ? clipboard.type : clipboard;
|
||||
return !type || type == clipboard.type ? clipboard.items : [];
|
||||
},
|
||||
type: function(type) {
|
||||
return type in clipboard;
|
||||
type: function() {
|
||||
return clipboard.type;
|
||||
}
|
||||
};
|
||||
}());
|
||||
|
|
Loading…
Reference in a new issue