allow custom jsfiles array, r=tschaub (closes #2947)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@11136 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Éric Lemoine
2011-02-17 19:54:11 +00:00
parent 1f042af289
commit 95380a512c
3 changed files with 291 additions and 260 deletions
+32 -6
View File
@@ -30,6 +30,27 @@
*/
var scriptName = (!singleFile) ? "lib/OpenLayers.js" : "OpenLayers.js";
/*
* If window.OpenLayers isn't set when this script (OpenLayers.js) is
* evaluated (and if singleFile is false) then this script will load
* *all* OpenLayers scripts. If window.OpenLayers is set to an array
* then this script will attempt to load scripts for each string of
* the array, using the string as the src of the script.
*
* Example:
* (code)
* <script type="text/javascript">
* window.OpenLayers = [
* "OpenLayers/Util.js",
* "OpenLayers/BaseTypes.js"
* ];
* </script>
* <script type="text/javascript" src="../lib/OpenLayers.js"></script>
* (end)
* In this example OpenLayers.js will load Util.js and BaseTypes.js only.
*/
var jsFiles = window.OpenLayers;
/**
* Namespace: OpenLayers
* The OpenLayers object provides a namespace for all things OpenLayers
@@ -60,6 +81,7 @@
return (function() { return l; });
})()
};
/**
* OpenLayers.singleFile is a flag indicating this file is being included
* in a Single File Library build of the OpenLayers Library.
@@ -71,7 +93,8 @@
* OpenLayers library code as it will be appended at the end of this file.
*/
if(!singleFile) {
var jsfiles = new Array(
if (!jsFiles) {
jsFiles = [
"OpenLayers/BaseTypes/Class.js",
"OpenLayers/Util.js",
"OpenLayers/BaseTypes.js",
@@ -314,17 +337,20 @@
"OpenLayers/Symbolizer/Raster.js",
"OpenLayers/Lang.js",
"OpenLayers/Lang/en.js"
); // etc.
]; // etc.
}
// use "parser-inserted scripts" for guaranteed execution order
// http://hsivonen.iki.fi/script-execution/
var allScriptTags = new Array(jsfiles.length);
var scriptTags = new Array(jsFiles.length);
var host = OpenLayers._getScriptLocation() + "lib/";
for (var i=0, len=jsfiles.length; i<len; i++) {
allScriptTags[i] = "<script src='" + host + jsfiles[i] +
for (var i=0, len=jsFiles.length; i<len; i++) {
scriptTags[i] = "<script src='" + host + jsFiles[i] +
"'></script>";
}
document.write(allScriptTags.join(""));
if (scriptTags.length > 0) {
document.write(scriptTags.join(""));
}
}
})();
+14 -10
View File
@@ -5,16 +5,20 @@
var custom$ = function() {};
window.$ = custom$;
</script>
<script src="../lib/OpenLayers/SingleFile.js"></script>
<script src="../lib/OpenLayers/BaseTypes/Class.js"></script>
<script src="../lib/OpenLayers/Util.js"></script>
<script src="../lib/OpenLayers/BaseTypes.js"></script>
<script src="../lib/OpenLayers/BaseTypes/Element.js"></script>
<script src="../lib/OpenLayers/BaseTypes/LonLat.js"></script>
<script src="../lib/OpenLayers/BaseTypes/Pixel.js"></script>
<script src="../lib/OpenLayers/BaseTypes/Size.js"></script>
<script src="../lib/OpenLayers/Lang.js"></script>
<script src="../lib/OpenLayers/Console.js"></script>
<script>
var OpenLayers = [
"OpenLayers/BaseTypes/Class.js",
"OpenLayers/Util.js",
"OpenLayers/BaseTypes.js",
"OpenLayers/BaseTypes/Element.js",
"OpenLayers/BaseTypes/LonLat.js",
"OpenLayers/BaseTypes/Pixel.js",
"OpenLayers/BaseTypes/Size.js",
"OpenLayers/Lang.js",
"OpenLayers/Console.js"
];
</script>
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript">
var isMozilla = (navigator.userAgent.indexOf("compatible") == -1);
var map;
+1
View File
@@ -163,6 +163,7 @@
<li>OpenLayers2.html</li>
<li>OpenLayers3.html</li>
<li>OpenLayers4.html</li>
<li>OpenLayersJsFiles.html</li>
<li>Popup.html</li>
<li>Popup/Anchored.html</li>
<li>Popup/AnchoredBubble.html</li>