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