From 318d47b730769f538dbc24800b9ad67ff8e73ea9 Mon Sep 17 00:00:00 2001 From: jaubourg Date: Wed, 7 Mar 2012 09:54:25 +0100 Subject: [PATCH] No more php/js logic duplication. Ensures modules are still loaded separately when using "file:" protocol (makes debugging much easier, /kiss @rwaldron). Ensures test iframes will use the same jquery as specified in the main document. Known issue: chrome will cringe at cross-frame access using file: protocol, apparently chrome sees this as cross-domain... go figure. --- test/data/include_js.php | 156 ++++++++++++++------------------------- 1 file changed, 56 insertions(+), 100 deletions(-) diff --git a/test/data/include_js.php b/test/data/include_js.php index 23207a9d9..1e12588eb 100644 --- a/test/data/include_js.php +++ b/test/data/include_js.php @@ -1,106 +1,62 @@ -/* - */; -// extract vars from referrer to determine version -if(isset($_SERVER['HTTP_REFERER'])){ - $referrer = $_SERVER['HTTP_REFERER']; - $referrer_query_string = parse_url($_SERVER['HTTP_REFERER'], PHP_URL_QUERY ); - parse_str($referrer_query_string, $referrer_params); +if ( !window.top.jQueryIncludes ) { + + window.top.jQueryIncludes = (function() { + + var location = window.top.document.location.href, + baseURL = location.replace( /\/test\/.+/, "/"), + version = /(?:&|\?)jquery=([^&]+?)(?:$|&)/.exec( location ), + includes, i; - if(isset($referrer_params['jquery'])){ - $version = $referrer_params['jquery']; - } + if ( version ) { + version = version[ 1 ]; + if( version === "min" ) { + includes = [ baseURL + "dist/jquery.min.js" ]; + } else if( version === "dist" ) { + includes = [ baseURL + "dist/jquery.js" ]; + } else { + includes = [ "http://code.jquery.com/jquery-" + version + ".js" ]; + } + } else { + includes = [ + "core", + "callbacks", + "deferred", + "support", + "data", + "queue", + "attributes", + "event", + "sizzle/sizzle", + "sizzle-jquery", + "traversing", + "manipulation", + "css", + "ajax", + "ajax/jsonp", + "ajax/script", + "ajax/xhr", + "effects", + "offset", + "dimensions", + "exports" + ]; + for ( i = includes.length; i--; ) { + includes[ i ] = baseURL + "src/" + includes[ i ] + ".js"; + } + } + + for ( i = includes.length; i--; ) { + includes[ i ] = "