commit extjs-2.2.1
[extjs.git] / air / src / Clipboard.js
1 /*\r
2  * Ext JS Library 0.30\r
3  * Copyright(c) 2006-2009, Ext JS, LLC.\r
4  * licensing@extjs.com\r
5  * \r
6  * http://extjs.com/license\r
7  */\r
8 \r
9 /**
10  * @class Ext.air.Clipboard
11  * @singleton
12  * Allows you to manipulate the native system clipboard and handle various formats.
13  * This class is essentially a passthrough to air.Clipboard.generalClipboard at this
14  * time, but may get more Ext-like functions in the future.
15  *
16  * The Clipboard has different types which it can hold:
17  * CONSTANT - value
18  * air.ClipboardFormats.TEXT_FORMAT - air:text
19  * air.ClipboardFormats.HTML_FORMAT - air:html
20  * air.ClipboardFormats.RICH_TEXT_FORMAT - air:rtf
21  * air.ClipboardFormats.URL_FORMAT - air:url
22  * air.ClipboardFormats.FILE_LIST_FORMAT - air:file list
23  * air.ClipboardFormats.BITMAP_FORMAT - air:bitmap
24  */
25 Ext.air.Clipboard = function() {
26     var clipboard = air.Clipboard.generalClipboard;
27     
28     return {
29         /**
30          * Determine if there is any data in a particular format clipboard.
31          * @param {String} format Use the air.ClipboardFormats CONSTANT or the string value
32          */
33         hasData: function(format) {
34             return clipboard.hasFormat(format);
35         },
36         /**
37          * Set the data for a particular format clipboard.
38          * @param {String} format Use the air.ClipboardFormats CONSTANT or the string value
39          * @param {Mixed} data Data to set 
40          */
41         setData: function(format, data) {
42             clipboard.setData(format, data);
43         },
44         /**
45          * Set the data handler for a particular format clipboard.
46          * @param {String} format Use the air.ClipboardFormats CONSTANT or the string value
47          * @param {Function} fn The function to evaluate when getting the clipboard data
48          */
49         setDataHandler: function(format, fn) {
50             clipboard.setDataHandler(format, fn);
51         },
52         /**
53          * Get the data for a particular format.
54          * @param {String} format Use the air.ClipboardFormats CONSTANT or the string value
55          * @param {String} transferMode 
56          */
57         getData: function(format, transferMode) {
58             clipboard.getData(format, transferMode);
59         },
60         /**
61          * Clear the clipboard for all formats.
62          */
63         clear: function() {
64             clipboard.clear();
65         },
66         /**
67          * Clear the data for a particular format.
68          * @param {String} format Use the air.ClipboardFormats CONSTANT or the string value
69          */
70         clearData: function(format) {
71             clipboard.clearData(format);
72         }
73     };
74 }();