commit extjs-2.2.1
[extjs.git] / examples / tasks / gears.js
1 /*\r
2  * Ext JS Library 2.2.1\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 // Copyright 2007 Google Inc. All Rights Reserved.\r
10 //\r
11 // Sets up google.gears.*, which is *the only* supported way to access Gears.\r
12 //\r
13 // Circumvent this file at your own risk!\r
14 //\r
15 // In the future, Gears may automatically define google.gears.* without this\r
16 // file. Gears may use these objects to transparently fix bugs and compatibility\r
17 // issues. Applications that use the code below will continue to work seamlessly\r
18 // when that happens.\r
19 \r
20 (function() {\r
21   // We are already defined. Hooray!\r
22   if (window.google && google.gears) {\r
23     return;\r
24   }\r
25 \r
26   var factory = null;\r
27 \r
28   // Firefox\r
29   if (typeof GearsFactory != 'undefined') {\r
30     factory = new GearsFactory();\r
31   } else {\r
32     // IE\r
33     try {\r
34       factory = new ActiveXObject('Gears.Factory');\r
35     } catch (e) {\r
36       // Safari\r
37       if (navigator.mimeTypes["application/x-googlegears"]) {\r
38         factory = document.createElement("object");\r
39         factory.style.display = "none";\r
40         factory.width = 0;\r
41         factory.height = 0;\r
42         factory.type = "application/x-googlegears";\r
43         document.documentElement.appendChild(factory);\r
44       }\r
45     }\r
46   }\r
47 \r
48   // *Do not* define any objects if Gears is not installed. This mimics the\r
49   // behavior of Gears defining the objects in the future.\r
50   if (!factory) {\r
51     return;\r
52   }\r
53 \r
54   // Now set up the objects, being careful not to overwrite anything.\r
55   if (!window.google) {\r
56     window.google = {};\r
57   }\r
58 \r
59   if (!google.gears) {\r
60     google.gears = {factory: factory};\r
61   }\r
62 })();\r
63 \r
64 if (!window.google || !google.gears) {\r
65     location.href = "http://gears.google.com/?action=install&message=Google%20Gears%20is%20required%20for%20this%20application" +\r
66                 "&return="+window.location.href;\r
67 }