|
Modified: jquery/jquery.xsajax.js =================================================================== --- jquery/jquery.xsajax.js 2007-04-12 19:00:35 UTC (rev 29) +++ jquery/jquery.xsajax.js 2007-04-13 08:33:15 UTC (rev 30) @@ -8,6 +8,12 @@ */ (function($){ + if ($.browser.safari || navigator.userAgent.match(/Konqueror/i)) { + $.extend({ + _xsajax$node: [], + _xsajax$nodes: 0 + }); + } $.extend({ getScriptXS: function () { /* determine arguments */ @@ -35,6 +41,7 @@ $(document.createElement('script')) .attr('type', 'text/javascript') .attr('src', arg.url); + var node_helper = null; /* optionally apply on-load handler for garbage collecting <script> node after loading @@ -67,6 +74,22 @@ callback.call(this); }; } + else if ($.browser.safari || navigator.userAgent.match(/Konqueror/i)) { + /* Safari/WebKit and Konqueror/KHTML do not emit + _any_ events at all, but we can exploit the fact + that dynamically generated <script> DOM nodes + are executed in sequence (although the scripts + theirself are still loaded in parallel) */ + $._xsajax$nodes++; + $._xsajax$node[$._xsajax$nodes] = { callback: callback, scope: node }; + var helper = + 'var ctx = jQuery._xsajax$node[' + $._xsajax$nodes + '];' + + 'ctx.callback.call(ctx.scope);'; + node_helper = + $(document.createElement('script')) + .attr('type', 'text/javascript') + .text(helper); + } else { /* use regular "onload" event for all other browsers */ $(node).load(callback); @@ -75,6 +98,14 @@ /* inject <script> node into <head> of document */ $('head', document).append(node); + + /* optionally inject helper <script> node into <head> + (Notice: we have to use a strange indirection via + setTimeout() to insert this second <script> node here or + Konqueror for unknown reasons will not execute the first + <script> node at all) */ + if (node_helper !== null) + setTimeout(function () { $('head', document).append(node_helper) }, 100); } }); })(jQuery);