The branch, master has been updated
via dd81bf847ae2d055aabdd24ca379575297eeae41 (commit)
via 9d83d2fc35482424125b065cfac09e7ce04ebb09 (commit)
via 29a8f3f32c50d359496f56da458b68d721ddb6ab (commit)
via c1c81ed80aff6a870aea4fa84e05de79fb2c5836 (commit)
via 1f6bd00b15ef9806820822316765b450f1e885b3 (commit)
via e3bcd9f7cff628841ee158ffeb01b6df9990c900 (commit)
via c3bb40cbce8a3e055fdd0ec98f9468f5d859ee00 (commit)
from 110c1e4a59f1e45f3a4586ed970fc73d9fd8ff0e (commit)
- Log -----------------------------------------------------------------
commit dd81bf847ae2d055aabdd24ca379575297eeae41
Merge: 9d83d2f 110c1e4
Author: Madhura Jayaratne <madhura.cj(a)gmail.com>
Date: Wed Sep 14 10:22:02 2011 +0530
Merge branch 'master' of
ssh://phpmyadmin.git.sourceforge.net/gitroot/phpmyadmin/phpmyadmin
commit 9d83d2fc35482424125b065cfac09e7ce04ebb09
Author: Madhura Jayaratne <madhura.cj(a)gmail.com>
Date: Wed Sep 14 10:06:54 2011 +0530
Load jquery.sprintf.js on demand
commit 29a8f3f32c50d359496f56da458b68d721ddb6ab
Author: Madhura Jayaratne <madhura.cj(a)gmail.com>
Date: Wed Sep 14 07:56:50 2011 +0530
Load scripts from cache when they are available
commit c1c81ed80aff6a870aea4fa84e05de79fb2c5836
Author: Madhura Jayaratne <madhura.cj(a)gmail.com>
Date: Tue Sep 13 21:52:52 2011 +0530
Load OpenLayers.js in a synchronous manner.
commit 1f6bd00b15ef9806820822316765b450f1e885b3
Author: Madhura Jayaratne <madhura.cj(a)gmail.com>
Date: Tue Sep 13 19:03:43 2011 +0530
Revert changes to loadJavascript() method
commit e3bcd9f7cff628841ee158ffeb01b6df9990c900
Author: Madhura Jayaratne <madhura.cj(a)gmail.com>
Date: Tue Sep 13 08:31:10 2011 +0530
JS files for gis_data_editor loaded dynamically
commit c3bb40cbce8a3e055fdd0ec98f9468f5d859ee00
Author: Madhura Jayaratne <madhura.cj(a)gmail.com>
Date: Tue Sep 13 08:28:16 2011 +0530
OpenStreetMaps.js merged into OpenLayers.js
-----------------------------------------------------------------------
Summary of changes:
js/functions.js | 2 +-
js/gis_data_editor.js | 92 ++++++++++++++++++++++++++-----
js/openlayers/OpenLayers.js | 130 ++++++++++++++++++++++++++++++++++++++++++-
js/tbl_change.js | 7 ++-
sql.php | 9 ---
tbl_change.php | 9 ---
tbl_select.php | 9 ---
7 files changed, 214 insertions(+), 44 deletions(-)
diff --git a/js/functions.js b/js/functions.js
index b27dcc4..b0fc717 100644
--- a/js/functions.js
+++ b/js/functions.js
@@ -3325,7 +3325,7 @@ loadJavascript=function(file) {
} else {
$('head').append('<script type="text/javascript"
src="'+file+'"></script>');
}
-}
+};
$(document).ready(function() {
/**
diff --git a/js/gis_data_editor.js b/js/gis_data_editor.js
index 6fb3d7b..f77e286 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('<div id="gis_data_editor"><img
class="ajaxIcon" id="loadingMonitorIcon" src="'
+ + pmaThemeImage + 'ajax_clock_small.gif"
alt=""></div>'
+ );
// 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 43e67e8..66b6188 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>
+ */
+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>
+ */
+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>
+ */
+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 25bc120..099dab9 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 8b8cf12..9695d12 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 5395dda..2fd9394 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 00cecfe..0ad5d25 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);
hooks/post-receive
--
phpMyAdmin