Browse files

Merge pull request #288 from mpriour/multiple-builds

Make the getScriptLocation function work with mobile & light builds
  • Loading branch information...
2 parents 7693c24 + 9e90af9 commit c66371ebf801f1e6a61a6254f2eff209d1445543 Éric Lemoine committed Mar 12, 2012
Showing with 49 additions and 1 deletion.
  1. +1 −1 lib/OpenLayers/SingleFile.js
  2. +15 −0 tests/SingleFile1.html
  3. +15 −0 tests/SingleFile2.html
  4. +15 −0 tests/SingleFile3.html
  5. +3 −0 tests/list-tests.html
View
2 lib/OpenLayers/SingleFile.js
@@ -25,7 +25,7 @@ var OpenLayers = {
* {String} Path to this script
*/
_getScriptLocation: (function() {
- var r = new RegExp("(^|(.*?\\/))(OpenLayers\.js)(\\?|$)"),
+ var r = new RegExp("(^|(.*?\\/))(OpenLayers.*?\\.js)(\\?|$)"),
s = document.getElementsByTagName('script'),
src, m, l = "";
for(var i=0, len=s.length; i<len; i++) {
View
15 tests/SingleFile1.html
@@ -0,0 +1,15 @@
+<html>
+<head>
+ <script src="some/path/OpenLayers.js"></script>
+ <script src="../lib/OpenLayers/SingleFile.js"></script>
+ <script type="text/javascript">
+ function test_OpenLayers(t) {
+ t.plan(1);
+ t.eq(OpenLayers._getScriptLocation(), "some/path/",
+ "Script location correctly detected (OpenLayers.js).");
+ }
+ </script>
+</head>
+<body>
+</body>
+</html>
View
15 tests/SingleFile2.html
@@ -0,0 +1,15 @@
+<html>
+<head>
+ <script src="some/path/OpenLayers.light.js"></script>
+ <script src="../lib/OpenLayers/SingleFile.js"></script>
+ <script type="text/javascript">
+ function test_OpenLayers(t) {
+ t.plan(1);
+ t.eq(OpenLayers._getScriptLocation(), "some/path/",
+ "Script location correctly detected (OpenLayers.light.js) .");
+ }
+ </script>
+</head>
+<body>
+</body>
+</html>
View
15 tests/SingleFile3.html
@@ -0,0 +1,15 @@
+<html>
+<head>
+ <script src="some/path/OpenLayers.light.debug.js"></script>
+ <script src="../lib/OpenLayers/SingleFile.js"></script>
+ <script type="text/javascript">
+ function test_OpenLayers(t) {
+ t.plan(1);
+ t.eq(OpenLayers._getScriptLocation(), "some/path/",
+ "Script location correctly detected (OpenLayers.light.debug.js).");
+ }
+ </script>
+</head>
+<body>
+</body>
+</html>
View
3 tests/list-tests.html
@@ -182,6 +182,9 @@
<li>OpenLayers3.html</li>
<li>OpenLayers4.html</li>
<li>OpenLayersJsFiles.html</li>
+ <li>SingleFile1.html</html>
+ <li>SingleFile2.html</html>
+ <li>SingleFile3.html</html>
<li>Popup.html</li>
<li>Popup/Anchored.html</li>
<li>Popup/AnchoredBubble.html</li>

0 comments on commit c66371e

Please sign in to comment.