diff --git a/js/functions.js b/js/functions.js
index b27dcc46b1..b0fc717652 100644
--- a/js/functions.js
+++ b/js/functions.js
@@ -3325,7 +3325,7 @@ loadJavascript=function(file) {
} else {
$('head').append('');
}
-}
+};
$(document).ready(function() {
/**
diff --git a/js/gis_data_editor.js b/js/gis_data_editor.js
index 6fb3d7bb68..f77e286c25 100644
--- a/js/gis_data_editor.js
+++ b/js/gis_data_editor.js
@@ -5,6 +5,8 @@
*
*/
+var gisEditorLoaded = false;
+
/**
* Closes the GIS data editor and perform necessary clean up work.
*/
@@ -78,7 +80,7 @@ function initGISEditorVisualization() {
}
/**
- * Opens up the GIS data editor.
+ * Loads JavaScript files and the GIS editor.
*
* @param value current value of the geometry field
* @param field field name
@@ -86,17 +88,56 @@ function initGISEditorVisualization() {
* @param input_name name of the input field
* @param token token
*/
-function openGISEditor(value, field, type, input_name, token) {
- // Center the popup
- var windowWidth = document.documentElement.clientWidth;
- var windowHeight = document.documentElement.clientHeight;
- var popupWidth = windowWidth * 0.9;
- var popupHeight = windowHeight * 0.9;
- var popupOffsetTop = windowHeight / 2 - popupHeight / 2;
- var popupOffsetLeft = windowWidth / 2 - popupWidth / 2;
- var $gis_editor = $("#gis_editor");
- $gis_editor.css({"top": popupOffsetTop, "left": popupOffsetLeft, "width": popupWidth, "height": popupHeight});
+function loadJSAndGISEditor(value, field, type, input_name, token) {
+ var head = document.getElementsByTagName('head')[0];
+ var script;
+ // Loads a set of small JS file needed for the GIS editor
+ var smallScripts = [ 'js/jquery/jquery.svg.js',
+ 'js/jquery/jquery.sprintf.js',
+ 'js/jquery/jquery.mousewheel.js',
+ 'js/jquery/jquery.event.drag-2.0.min.js',
+ 'js/tbl_gis_visualization.js' ];
+
+ for (i = 0; i < smallScripts.length; i++) {
+ script = document.createElement('script');
+ script.type = 'text/javascript';
+ script.src = smallScripts[i];
+ head.appendChild(script);
+ }
+
+ // OpenLayers.js is BIG and takes time. So asynchronous loading would not work.
+ // Load the JS and do a callback to load the content for the GIS Editor.
+ script = document.createElement('script');
+ script.type = 'text/javascript';
+
+ script.onreadystatechange = function() {
+ if (this.readyState == 'complete') {
+ loadGISEditor(value, field, type, input_name, token);
+ }
+ };
+ script.onload = function() {
+ loadGISEditor(value, field, type, input_name, token);
+ };
+
+ script.src = 'js/openlayers/OpenLayers.js';
+ head.appendChild(script);
+
+ gisEditorLoaded = true;
+}
+
+/**
+ * Loads the GIS editor via AJAX
+ *
+ * @param value current value of the geometry field
+ * @param field field name
+ * @param type geometry type
+ * @param input_name name of the input field
+ * @param token token
+ */
+function loadGISEditor(value, field, type, input_name, token) {
+
+ var $gis_editor = $("#gis_editor");
$.post('gis_data_editor.php', {
'field' : field,
'value' : value,
@@ -105,7 +146,7 @@ function openGISEditor(value, field, type, input_name, token) {
'get_gis_editor' : true,
'token' : token
}, function(data) {
- if(data.success == true) {
+ if (data.success == true) {
$gis_editor.html(data.gis_editor);
initGISEditorVisualization();
prepareJSVersion();
@@ -113,10 +154,33 @@ function openGISEditor(value, field, type, input_name, token) {
PMA_ajaxShowMessage(data.error);
}
}, 'json');
+}
+
+/**
+ * Opens up the dialog for the GIS data editor.
+ */
+function openGISEditor() {
+
+ // Center the popup
+ var windowWidth = document.documentElement.clientWidth;
+ var windowHeight = document.documentElement.clientHeight;
+ var popupWidth = windowWidth * 0.9;
+ var popupHeight = windowHeight * 0.9;
+ var popupOffsetTop = windowHeight / 2 - popupHeight / 2;
+ var popupOffsetLeft = windowWidth / 2 - popupWidth / 2;
+
+ var $gis_editor = $("#gis_editor");
+ var $backgrouond = $("#popup_background");
+
+ $gis_editor.css({"top": popupOffsetTop, "left": popupOffsetLeft, "width": popupWidth, "height": popupHeight});
+ $backgrouond.css({"opacity":"0.7"});
+
+ $gis_editor.append('

'
+ );
// Make it appear
- $("#popup_background").css({"opacity":"0.7"});
- $("#popup_background").fadeIn("fast");
+ $backgrouond.fadeIn("fast");
$gis_editor.fadeIn("fast");
}
diff --git a/js/openlayers/OpenLayers.js b/js/openlayers/OpenLayers.js
index 43e67e8195..66b61887ba 100644
--- a/js/openlayers/OpenLayers.js
+++ b/js/openlayers/OpenLayers.js
@@ -2550,4 +2550,132 @@ return node;},"_Layer":function(options){var layer,subPaths,node,title;layer=opt
options.subPaths.shift();this.writeNode("_Layer",options,node);return node;}else{if(layer instanceof OpenLayers.Layer.WMS){node=this.writeNode("_WMS",layer);}else if(layer instanceof OpenLayers.Layer.Vector){if(layer.protocol instanceof OpenLayers.Protocol.WFS.v1){node=this.writeNode("_WFS",layer);}else if(layer.protocol instanceof OpenLayers.Protocol.HTTP){if(layer.protocol.format instanceof OpenLayers.Format.GML){layer.protocol.format.version="2.1.2";node=this.writeNode("_GML",layer);}else if(layer.protocol.format instanceof OpenLayers.Format.KML){layer.protocol.format.version="2.2";node=this.writeNode("_KML",layer);}}else{this.setNamespace("feature",this.featureNS);node=this.writeNode("_InlineGeometry",layer);}}
if(layer.options.maxScale){this.writeNode("sld:MinScaleDenominator",layer.options.maxScale,node);}
if(layer.options.minScale){this.writeNode("sld:MaxScaleDenominator",layer.options.minScale,node);}
-this.nestingLayerLookup[layer.name]=node;return node;}},"_WFS":function(layer){var node=this.createElementNSPlus("Layer",{attributes:{name:layer.protocol.featurePrefix+":"+layer.protocol.featureType,hidden:layer.visibility?"0":"1"}});this.writeNode("ows:Title",layer.name,node);this.writeNode("Server",{service:OpenLayers.Format.Context.serviceTypes.WFS,version:layer.protocol.version,url:layer.protocol.url},node);return node;},"_InlineGeometry":function(layer){var node=this.createElementNSPlus("Layer",{attributes:{name:this.featureType,hidden:layer.visibility?"0":"1"}});this.writeNode("ows:Title",layer.name,node);this.writeNode("InlineGeometry",layer,node);return node;},"_GML":function(layer){var node=this.createElementNSPlus("Layer");this.writeNode("ows:Title",layer.name,node);this.writeNode("Server",{service:OpenLayers.Format.Context.serviceTypes.GML,url:layer.protocol.url,version:layer.protocol.format.version},node);return node;},"_KML":function(layer){var node=this.createElementNSPlus("Layer");this.writeNode("ows:Title",layer.name,node);this.writeNode("Server",{service:OpenLayers.Format.Context.serviceTypes.KML,version:layer.protocol.format.version,url:layer.protocol.url},node);return node;}},"gml":OpenLayers.Util.applyDefaults({"boundedBy":function(bounds){var node=this.createElementNSPlus("gml:boundedBy");this.writeNode("gml:Box",bounds,node);return node;}},OpenLayers.Format.GML.v2.prototype.writers.gml),"ows":OpenLayers.Format.OWSCommon.v1_0_0.prototype.writers.ows,"sld":OpenLayers.Format.SLD.v1_0_0.prototype.writers.sld,"feature":OpenLayers.Format.GML.v2.prototype.writers.feature},CLASS_NAME:"OpenLayers.Format.OWSContext.v0_3_1"});
\ No newline at end of file
+this.nestingLayerLookup[layer.name]=node;return node;}},"_WFS":function(layer){var node=this.createElementNSPlus("Layer",{attributes:{name:layer.protocol.featurePrefix+":"+layer.protocol.featureType,hidden:layer.visibility?"0":"1"}});this.writeNode("ows:Title",layer.name,node);this.writeNode("Server",{service:OpenLayers.Format.Context.serviceTypes.WFS,version:layer.protocol.version,url:layer.protocol.url},node);return node;},"_InlineGeometry":function(layer){var node=this.createElementNSPlus("Layer",{attributes:{name:this.featureType,hidden:layer.visibility?"0":"1"}});this.writeNode("ows:Title",layer.name,node);this.writeNode("InlineGeometry",layer,node);return node;},"_GML":function(layer){var node=this.createElementNSPlus("Layer");this.writeNode("ows:Title",layer.name,node);this.writeNode("Server",{service:OpenLayers.Format.Context.serviceTypes.GML,url:layer.protocol.url,version:layer.protocol.format.version},node);return node;},"_KML":function(layer){var node=this.createElementNSPlus("Layer");this.writeNode("ows:Title",layer.name,node);this.writeNode("Server",{service:OpenLayers.Format.Context.serviceTypes.KML,version:layer.protocol.format.version,url:layer.protocol.url},node);return node;}},"gml":OpenLayers.Util.applyDefaults({"boundedBy":function(bounds){var node=this.createElementNSPlus("gml:boundedBy");this.writeNode("gml:Box",bounds,node);return node;}},OpenLayers.Format.GML.v2.prototype.writers.gml),"ows":OpenLayers.Format.OWSCommon.v1_0_0.prototype.writers.ows,"sld":OpenLayers.Format.SLD.v1_0_0.prototype.writers.sld,"feature":OpenLayers.Format.GML.v2.prototype.writers.feature},CLASS_NAME:"OpenLayers.Format.OWSContext.v0_3_1"});
+
+// OpenStreetMaps.js merged
+
+/**
+ * Namespace: Util.OSM
+ */
+OpenLayers.Util.OSM = {};
+
+/**
+ * Constant: MISSING_TILE_URL
+ * {String} URL of image to display for missing tiles
+ */
+OpenLayers.Util.OSM.MISSING_TILE_URL = "http://www.openstreetmap.org/openlayers/img/404.png";
+
+/**
+ * Property: originalOnImageLoadError
+ * {Function} Original onImageLoadError function.
+ */
+OpenLayers.Util.OSM.originalOnImageLoadError = OpenLayers.Util.onImageLoadError;
+
+/**
+ * Function: onImageLoadError
+ */
+OpenLayers.Util.onImageLoadError = function() {
+ if (this.src.match(/^http:\/\/[abc]\.[a-z]+\.openstreetmap\.org\//)) {
+ this.src = OpenLayers.Util.OSM.MISSING_TILE_URL;
+ } else if (this.src.match(/^http:\/\/[def]\.tah\.openstreetmap\.org\//)) {
+ // do nothing - this layer is transparent
+ } else {
+ OpenLayers.Util.OSM.originalOnImageLoadError;
+ }
+};
+
+/**
+ * Class: OpenLayers.Layer.OSM.Mapnik
+ *
+ * Inherits from:
+ * -
+ */
+OpenLayers.Layer.OSM.Mapnik = OpenLayers.Class(OpenLayers.Layer.OSM, {
+ /**
+ * Constructor: OpenLayers.Layer.OSM.Mapnik
+ *
+ * Parameters:
+ * name - {String}
+ * options - {Object} Hashtable of extra options to tag onto the layer
+ */
+ initialize: function(name, options) {
+ var url = [
+ "http://a.tile.openstreetmap.org/${z}/${x}/${y}.png",
+ "http://b.tile.openstreetmap.org/${z}/${x}/${y}.png",
+ "http://c.tile.openstreetmap.org/${z}/${x}/${y}.png"
+ ];
+ options = OpenLayers.Util.extend({
+ numZoomLevels: 19,
+ buffer: 0,
+ transitionEffect: "resize"
+ }, options);
+ var newArguments = [name, url, options];
+ OpenLayers.Layer.OSM.prototype.initialize.apply(this, newArguments);
+ },
+
+ CLASS_NAME: "OpenLayers.Layer.OSM.Mapnik"
+});
+
+/**
+ * Class: OpenLayers.Layer.OSM.Osmarender
+ *
+ * Inherits from:
+ * -
+ */
+OpenLayers.Layer.OSM.Osmarender = OpenLayers.Class(OpenLayers.Layer.OSM, {
+ /**
+ * Constructor: OpenLayers.Layer.OSM.Osmarender
+ *
+ * Parameters:
+ * name - {String}
+ * options - {Object} Hashtable of extra options to tag onto the layer
+ */
+ initialize: function(name, options) {
+ var url = [
+ "http://a.tah.openstreetmap.org/Tiles/tile/${z}/${x}/${y}.png",
+ "http://b.tah.openstreetmap.org/Tiles/tile/${z}/${x}/${y}.png",
+ "http://c.tah.openstreetmap.org/Tiles/tile/${z}/${x}/${y}.png"
+ ];
+ options = OpenLayers.Util.extend({
+ numZoomLevels: 18,
+ buffer: 0,
+ transitionEffect: "resize"
+ }, options);
+ var newArguments = [name, url, options];
+ OpenLayers.Layer.OSM.prototype.initialize.apply(this, newArguments);
+ },
+
+ CLASS_NAME: "OpenLayers.Layer.OSM.Osmarender"
+});
+
+/**
+ * Class: OpenLayers.Layer.OSM.CycleMap
+ *
+ * Inherits from:
+ * -
+ */
+OpenLayers.Layer.OSM.CycleMap = OpenLayers.Class(OpenLayers.Layer.OSM, {
+ /**
+ * Constructor: OpenLayers.Layer.OSM.CycleMap
+ *
+ * Parameters:
+ * name - {String}
+ * options - {Object} Hashtable of extra options to tag onto the layer
+ */
+ initialize: function(name, options) {
+ var url = [
+ "http://a.tile.opencyclemap.org/cycle/${z}/${x}/${y}.png",
+ "http://b.tile.opencyclemap.org/cycle/${z}/${x}/${y}.png",
+ "http://c.tile.opencyclemap.org/cycle/${z}/${x}/${y}.png"
+ ];
+ options = OpenLayers.Util.extend({
+ numZoomLevels: 19,
+ buffer: 0,
+ transitionEffect: "resize"
+ }, options);
+ var newArguments = [name, url, options];
+ OpenLayers.Layer.OSM.prototype.initialize.apply(this, newArguments);
+ },
+
+ CLASS_NAME: "OpenLayers.Layer.OSM.CycleMap"
+});
\ No newline at end of file
diff --git a/js/tbl_change.js b/js/tbl_change.js
index 25bc120349..099dab99b7 100644
--- a/js/tbl_change.js
+++ b/js/tbl_change.js
@@ -238,7 +238,12 @@ $(document).ready(function() {
//Token
var token = $("input[name='token']").val();
- openGISEditor(value, field, type, input_name, token);
+ openGISEditor();
+ if (!gisEditorLoaded) {
+ loadJSAndGISEditor(value, field, type, input_name, token);
+ } else {
+ loadGISEditor(value, field, type, input_name, token);
+ }
});
/**
diff --git a/sql.php b/sql.php
index 8b8cf12838..9695d12601 100644
--- a/sql.php
+++ b/sql.php
@@ -17,16 +17,7 @@ require_once './libraries/bookmark.lib.php';
$GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.custom.js';
$GLOBALS['js_include'][] = 'jquery/timepicker.js';
$GLOBALS['js_include'][] = 'tbl_change.js';
-
-// required for GIS editor loaded via AJAX
$GLOBALS['js_include'][] = 'gis_data_editor.js';
-$GLOBALS['js_include'][] = 'jquery/jquery.sprintf.js';
-$GLOBALS['js_include'][] = 'jquery/jquery.svg.js';
-$GLOBALS['js_include'][] = 'jquery/jquery.mousewheel.js';
-$GLOBALS['js_include'][] = 'jquery/jquery.event.drag-2.0.min.js';
-$GLOBALS['js_include'][] = 'tbl_gis_visualization.js';
-$GLOBALS['js_include'][] = 'openlayers/OpenLayers.js';
-$GLOBALS['js_include'][] = 'OpenStreetMap.js';
if (isset($_SESSION['profiling'])) {
$GLOBALS['js_include'][] = 'highcharts/highcharts.js';
diff --git a/tbl_change.php b/tbl_change.php
index 5395ddabde..2fd9394605 100644
--- a/tbl_change.php
+++ b/tbl_change.php
@@ -122,16 +122,7 @@ $GLOBALS['js_include'][] = 'functions.js';
$GLOBALS['js_include'][] = 'tbl_change.js';
$GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.custom.js';
$GLOBALS['js_include'][] = 'jquery/timepicker.js';
-
-// required for GIS editor
$GLOBALS['js_include'][] = 'gis_data_editor.js';
-$GLOBALS['js_include'][] = 'jquery/jquery.sprintf.js';
-$GLOBALS['js_include'][] = 'jquery/jquery.svg.js';
-$GLOBALS['js_include'][] = 'jquery/jquery.mousewheel.js';
-$GLOBALS['js_include'][] = 'jquery/jquery.event.drag-2.0.min.js';
-$GLOBALS['js_include'][] = 'tbl_gis_visualization.js';
-$GLOBALS['js_include'][] = 'openlayers/OpenLayers.js';
-$GLOBALS['js_include'][] = 'OpenStreetMap.js';
/**
* HTTP and HTML headers
diff --git a/tbl_select.php b/tbl_select.php
index 00cecfe70c..0ad5d2530b 100644
--- a/tbl_select.php
+++ b/tbl_select.php
@@ -23,16 +23,7 @@ $GLOBALS['js_include'][] = 'tbl_select.js';
$GLOBALS['js_include'][] = 'tbl_change.js';
$GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.custom.js';
$GLOBALS['js_include'][] = 'jquery/timepicker.js';
-
-// required for GIS editor loaded via AJAX
$GLOBALS['js_include'][] = 'gis_data_editor.js';
-$GLOBALS['js_include'][] = 'jquery/jquery.sprintf.js';
-$GLOBALS['js_include'][] = 'jquery/jquery.svg.js';
-$GLOBALS['js_include'][] = 'jquery/jquery.mousewheel.js';
-$GLOBALS['js_include'][] = 'jquery/jquery.event.drag-2.0.min.js';
-$GLOBALS['js_include'][] = 'tbl_gis_visualization.js';
-$GLOBALS['js_include'][] = 'openlayers/OpenLayers.js';
-$GLOBALS['js_include'][] = 'OpenStreetMap.js';
$titles['Browse'] = PMA_tbl_setTitle($GLOBALS['cfg']['PropertiesIconic'], $pmaThemeImage);