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
|
Ox.Clipboard <o> Basic clipboard handler
|
||||||
copy <f> Copy data to clipboard
|
add <f> Add items to clipboard
|
||||||
(data) -> <u> undefined
|
(items[, type]) -> <n> Number of items
|
||||||
paste <f> Paste data from clipboard
|
clear <f> Clear clipboard
|
||||||
() -> <*> Clipboard data
|
() -> <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() {
|
Ox.Clipboard = (function() {
|
||||||
var clipboard = {};
|
var clipboard = {items: [], type: void 0};
|
||||||
return {
|
return {
|
||||||
_print: function() {
|
_print: function() {
|
||||||
Ox.Log('Core', JSON.stringify(clipboard));
|
Ox.print(JSON.stringify(clipboard));
|
||||||
},
|
},
|
||||||
copy: function(data) {
|
add: function(items, type) {
|
||||||
clipboard = data;
|
if (type != clipboard.type) {
|
||||||
Ox.Log('Core', 'copy', JSON.stringify(clipboard));
|
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) {
|
paste: function(type) {
|
||||||
return type ? clipboard.type : clipboard;
|
return !type || type == clipboard.type ? clipboard.items : [];
|
||||||
},
|
},
|
||||||
type: function(type) {
|
type: function() {
|
||||||
return type in clipboard;
|
return clipboard.type;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}());
|
}());
|
||||||
|
|
Loading…
Reference in a new issue