[Jifty-commit] r4823 - jifty/branches/jquery/share/web/static/js

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Fri Jan 11 13:11:35 EST 2008


Author: gugod
Date: Fri Jan 11 13:11:34 2008
New Revision: 4823

Modified:
   jifty/branches/jquery/share/web/static/js/jifty.js

Log:
Provide an alternative function to Ajax.getTransport() that tests if
current JS engine is capable for doing ajax. It's a property named
"Jifty.hasAjaxTransport".


Modified: jifty/branches/jquery/share/web/static/js/jifty.js
==============================================================================
--- jifty/branches/jquery/share/web/static/js/jifty.js	(original)
+++ jifty/branches/jquery/share/web/static/js/jifty.js	Fri Jan 11 13:11:34 2008
@@ -7,6 +7,23 @@
     return id;
 }
 
+Jifty.hasAjaxTransport = function() {
+    var r = false;
+    jQuery.each(
+        [
+            function() {return new XMLHttpRequest()},
+            function() {return new ActiveXObject('Msxml2.XMLHTTP')},
+            function() {return new ActiveXObject('Microsoft.XMLHTTP')}
+        ],
+        function(i, v) {
+            try {
+                r = v();
+                if (r) return false;
+            } catch(e) {}
+        })
+    return r ? true : false;
+}();
+
 Jifty.Web = {};
 Jifty.Web.current_actions = [];
 Jifty.Web.new_action = function() {
@@ -1018,7 +1035,7 @@
 //     - 'effect' is the name of a Prototype Effect
 Jifty.update = function () {
     // loads
-    if(!Ajax.getTransport()) return true;
+    if (!Jifty.hasAjaxTransport) return true;
     // XXX: prevent default behavior in IE
     if(window.event) {
         window.event.returnValue = false;


More information about the Jifty-commit mailing list