codesite-noreply at google.com
2009-Sep-03 12:10 UTC
[Mapstraction] [mapstraction] r25 committed - - A bit more verbose documentation...
Revision: 25
Author: freyfogle
Date: Thu Sep 3 05:06:14 2009
Log: - A bit more verbose documentation
- Allow for the parameter ''none'' to be passed in to turn off
autoloading of
other libraries. It is then the application developer''s responsibility
to
ensure the relevant libraries are loaded. Useful as a workaround for the
problems of certain browsers (Safari, I''m looking at you) that proceed
with
execution before dependent libraries are loaded leading to an error.
http://code.google.com/p/mapstraction/source/detail?r=25
Modified:
/trunk/source/mxn.js
======================================--- /trunk/source/mxn.js Sun Aug 16
17:18:10 2009
+++ /trunk/source/mxn.js Thu Sep 3 05:06:14 2009
@@ -461,8 +461,18 @@
})();
-
// Auto-load scripts
+//
+// specify which map providers to load by using
+// <script
src="mxn.js?(provider1,[module1],provider2,[module2],provider3)" ...
+// in your HTML
+//
+// for each provider mxn.provider.module.js and mxn.module.js will be
loaded
+// by default module is ''core''
+//
+// NOTE: if you specify ''none'' as the provider no scripts
will be loaded
at all.
+// it is then up to you to load the scripts independently
+//
(function() {
// Defaults
@@ -470,7 +480,8 @@
var modules = ''core'';
var scriptBase;
var scripts = document.getElementsByTagName(''script'');
-
+
+ // determine which scripts we need to load
for (var i = 0; i < scripts.length; i++) {
var match =
scripts[i].src.replace(/%20/g ,
'''').match(/^(.*?)mxn\.js(\?\(\[?(.*?)\]?\))?$/);
if (match !== null) {
@@ -485,8 +496,13 @@
break;
}
}
+ if (providers == ''none''){ // bail out if we
don''t want to load
anything
+ return;
+ }
providers = providers.replace(/ /g,
'''').split('','');
modules = modules.replace(/ /g,
'''').split('','');
+
+ // actually load the scripts
for (i = 0; i < modules.length; i++) {
mxn.util.loadScript(scriptBase + ''mxn.'' + modules[i] +
''.js'');
for (var j = 0; j < providers.length; j++){