mirror of
https://github.com/jquery/jquery.git
synced 2024-12-09 08:04:24 +00:00
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.
This commit is contained in:
parent
92a92be10f
commit
318d47b730
@ -1,106 +1,62 @@
|
|||||||
/*
|
(function() {
|
||||||
<?php
|
|
||||||
// if php is available, close the comment so PHP can echo the appropriate JS
|
|
||||||
echo "*" . "/";
|
|
||||||
|
|
||||||
// initialize vars
|
window.hasPHP = false /* <?php echo "*" + "/ || true /*"; ?> */;
|
||||||
$output = "";
|
|
||||||
$version = "";
|
|
||||||
|
|
||||||
// extract vars from referrer to determine version
|
if ( !window.top.jQueryIncludes ) {
|
||||||
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(isset($referrer_params['jquery'])){
|
window.top.jQueryIncludes = (function() {
|
||||||
$version = $referrer_params['jquery'];
|
|
||||||
}
|
var location = window.top.document.location.href,
|
||||||
|
baseURL = location.replace( /\/test\/.+/, "/"),
|
||||||
|
version = /(?:&|\?)jquery=([^&]+?)(?:$|&)/.exec( location ),
|
||||||
|
includes, i;
|
||||||
|
|
||||||
|
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 ] = "<script src='" + includes[ i ] + "'><" + "/script>";
|
||||||
|
}
|
||||||
|
|
||||||
|
return includes.join( "\n" );
|
||||||
|
})();
|
||||||
}
|
}
|
||||||
|
|
||||||
// load up built versions of jquery
|
document.write( window.top.jQueryIncludes );
|
||||||
if( $version === "min" ) {
|
|
||||||
$output = @file_get_contents("../../dist/jquery.min.js");
|
|
||||||
}elseif( $version === "dist" ) {
|
|
||||||
$output = @file_get_contents("../../dist/jquery.js");
|
|
||||||
}elseif( ctype_digit( substr( $version, 0, 1 )) || $version === "git" ) {
|
|
||||||
$output = "document.write('<script src=\"http://code.jquery.com/jquery-" . $version . ".js\"><'+'/script>');";
|
|
||||||
}
|
|
||||||
|
|
||||||
// the concatenated version of the the src files is both the default and the fallback
|
})();
|
||||||
// because it does not require you to "make" jquery for it to update
|
|
||||||
if( $output === "" ) {
|
|
||||||
$files = array(
|
|
||||||
"intro",
|
|
||||||
"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",
|
|
||||||
"outro"
|
|
||||||
);
|
|
||||||
|
|
||||||
foreach ( $files as $file ) {
|
|
||||||
$output .= file_get_contents( "../../src/" . $file . ".js" );
|
|
||||||
}
|
|
||||||
|
|
||||||
$output = str_replace( "(function( jQuery ) {", "", $output );
|
|
||||||
$output = str_replace( "})( jQuery );", "", $output );
|
|
||||||
}
|
|
||||||
|
|
||||||
echo $output;
|
|
||||||
die();
|
|
||||||
?>
|
|
||||||
*/
|
|
||||||
|
|
||||||
hasPHP = false;
|
|
||||||
|
|
||||||
// javascript fallback using src files in case this is not run on a PHP server!
|
|
||||||
// please note that this fallback is for convenience only, and is not fully supported
|
|
||||||
// i.e. don't expect all of the tests to work properly
|
|
||||||
var baseURL = document.location.href.replace( /\/test\/.+/, "/"),
|
|
||||||
files = [
|
|
||||||
"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"
|
|
||||||
],
|
|
||||||
len = files.length,
|
|
||||||
i = 0;
|
|
||||||
|
|
||||||
for ( ; i < len; i++ ) {
|
|
||||||
document.write("<script src=\"" + baseURL + "src/" + files[ i ] + ".js\"><"+"/script>");
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user