gears.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. Copyright (c) 2004-2012, The Dojo Foundation All Rights Reserved.
  3. Available via Academic Free License >= 2.1 OR the modified BSD license.
  4. see: http://dojotoolkit.org/license for details
  5. */
  6. if(!dojo._hasResource["dojo.gears"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
  7. dojo._hasResource["dojo.gears"] = true;
  8. dojo.provide("dojo.gears");
  9. dojo.getObject("gears", true, dojo);
  10. dojo.gears._gearsObject = function(){
  11. // summary:
  12. // factory method to get a Google Gears plugin instance to
  13. // expose in the browser runtime environment, if present
  14. var factory;
  15. var results;
  16. var gearsObj = dojo.getObject("google.gears");
  17. if(gearsObj){ return gearsObj; } // already defined elsewhere
  18. if(typeof GearsFactory != "undefined"){ // Firefox
  19. factory = new GearsFactory();
  20. }else{
  21. if(dojo.isIE){
  22. // IE
  23. try{
  24. factory = new ActiveXObject("Gears.Factory");
  25. }catch(e){
  26. // ok to squelch; there's no gears factory. move on.
  27. }
  28. }else if(navigator.mimeTypes["application/x-googlegears"]){
  29. // Safari?
  30. factory = document.createElement("object");
  31. factory.setAttribute("type", "application/x-googlegears");
  32. factory.setAttribute("width", 0);
  33. factory.setAttribute("height", 0);
  34. factory.style.display = "none";
  35. document.documentElement.appendChild(factory);
  36. }
  37. }
  38. // still nothing?
  39. if(!factory){ return null; }
  40. // define the global objects now; don't overwrite them though if they
  41. // were somehow set internally by the Gears plugin, which is on their
  42. // dev roadmap for the future
  43. dojo.setObject("google.gears.factory", factory);
  44. return dojo.getObject("google.gears");
  45. };
  46. /*=====
  47. dojo.gears.available = {
  48. // summary: True if client is using Google Gears
  49. };
  50. =====*/
  51. // see if we have Google Gears installed, and if
  52. // so, make it available in the runtime environment
  53. // and in the Google standard 'google.gears' global object
  54. dojo.gears.available = (!!dojo.gears._gearsObject())||0;
  55. }