Seperate null and horde geocoder objects into their own js file.
authorMichael J. Rubinsky <mrubinsk@horde.org>
Thu, 4 Mar 2010 17:59:15 +0000 (12:59 -0500)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Thu, 4 Mar 2010 17:59:15 +0000 (12:59 -0500)
Avoid loading javascript we will never use.

horde/js/hordemap/horde.js
horde/js/hordemap/map.js
horde/js/hordemap/null.js [new file with mode: 0644]

index d0f8bb7..940713a 100644 (file)
@@ -224,4 +224,6 @@ OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, {
         this.handler = new OpenLayers.Handler.Click(
             this, { 'click': options.onClick }, this.handlerOptions);
     }
-});
\ No newline at end of file
+});
+
+HordeMap.Geocoder.Horde = Class.create({});
\ No newline at end of file
index db760a3..ff59d00 100644 (file)
@@ -40,7 +40,7 @@ HordeMap = {
         }
         this._addScript(path + this._opts.driver.toLowerCase() + '.js');
 
-        if (this._opts.geocoder && this._opts.geocoder != 'Null') {
+        if (this._opts.geocoder) {
             this._addScript(this._getProviderUrl(this._opts.geocoder));
             this._addScript(path + this._opts.geocoder.toLowerCase() + '.js');
         }
@@ -84,6 +84,9 @@ HordeMap = {
 
     _addScript: function(s)
     {
+        if (s.length == 0) {
+            return;
+        }
         var l = this._includes.length;
         for (var i = 0; i < l; i++) {
             if (this._includes[i] == s) {
@@ -127,6 +130,8 @@ HordeMap = {
             return 'http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.1';
         case 'SAPO':
             return 'http://js.sapo.pt/Bundles/SAPOMapsAPI-1.0.js';
+        default:
+            return '';
         }
     },
 
@@ -142,21 +147,3 @@ HordeMap = {
     Geocoder: {}
 };
 
-HordeMap.Geocoder.Horde = Class.create({});
-HordeMap.Geocoder.Null = Class.create({
-
-    initialize: function(opts)
-    {
-    },
-
-    geocode: function(address, callback, onErrorCallback)
-    {
-        return onErrorCallback('No geocoding support');
-    },
-
-    reverseGeocode: function(lonlat, completeCallback, errorCallback)
-    {
-        var ll = { lon: lonlat.lon, lat: lonlat.lat, address: lonlat.lon + ' ' + lonlat.lat};
-        return completeCallback([ll]);
-    }
-});
diff --git a/horde/js/hordemap/null.js b/horde/js/hordemap/null.js
new file mode 100644 (file)
index 0000000..ca6e1da
--- /dev/null
@@ -0,0 +1,17 @@
+HordeMap.Geocoder.Null = Class.create({
+
+    initialize: function(opts)
+    {
+    },
+
+    geocode: function(address, callback, onErrorCallback)
+    {
+        return onErrorCallback('No geocoding support');
+    },
+
+    reverseGeocode: function(lonlat, completeCallback, errorCallback)
+    {
+        var ll = { lon: lonlat.lon, lat: lonlat.lat, address: lonlat.lon + ' ' + lonlat.lat};
+        return completeCallback([ll]);
+    }
+});