[Mapbender-commits] r4078 - in trunk/mapbender: http/javascripts lib
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Tue Jun 23 04:27:23 EDT 2009
Author: christoph
Date: 2009-06-23 04:27:23 -0400 (Tue, 23 Jun 2009)
New Revision: 4078
Modified:
trunk/mapbender/http/javascripts/map.js
trunk/mapbender/http/javascripts/map.php
trunk/mapbender/http/javascripts/mapnf.php
trunk/mapbender/http/javascripts/mod_reload.php
trunk/mapbender/http/javascripts/mod_sandclock.php
trunk/mapbender/http/javascripts/mod_zoomIn1.php
trunk/mapbender/lib/core.js
Log:
Mapbender API
Modified: trunk/mapbender/http/javascripts/map.js
===================================================================
--- trunk/mapbender/http/javascripts/map.js 2009-06-23 08:20:27 UTC (rev 4077)
+++ trunk/mapbender/http/javascripts/map.js 2009-06-23 08:27:23 UTC (rev 4078)
@@ -76,7 +76,7 @@
* @deprecated
*/
function mb_registerMapObj(frameName, elementName,wms_index,width, height){
- var newMapObj = new mb_mapObj_const(frameName, elementName, width, height, wms_index);
+ var newMapObj = new Map(frameName, elementName, width, height, wms_index);
mb_mapObj.push(newMapObj);
return newMapObj;
}
@@ -378,7 +378,7 @@
}
/**
- * converts the extent of the mapobject so that the maximum extent will be displayed {@link mb_mapObj_const#calculateExtent}
+ * converts the extent of the mapobject so that the maximum extent will be displayed {@link Map#calculateExtent}
* use: mb_mapObj.calculateExtent
* @deprecated
*
Modified: trunk/mapbender/http/javascripts/map.php
===================================================================
--- trunk/mapbender/http/javascripts/map.php 2009-06-23 08:20:27 UTC (rev 4077)
+++ trunk/mapbender/http/javascripts/map.php 2009-06-23 08:27:23 UTC (rev 4078)
@@ -50,7 +50,6 @@
ob_start();
header('Content-type: application/x-javascript');
-
//
// Define global variables (TODO: move to mapbender object later on)
//
@@ -59,7 +58,6 @@
echo "var mb_myLogin = '".$_SESSION["mb_login"]."';";
echo "var mb_styleID = '".md5($_SESSION["mb_user_name"])."';";
echo "var mb_myBBOX = '".$_SESSION["mb_myBBOX"]."';";
-echo "var Mapbender = {};";
echo "Mapbender.locale = '" . $_SESSION["mb_locale"] . "';";
echo "Mapbender.languageId = '" . $_SESSION["mb_lang"] . "';";
echo "Mapbender.versionNumber = '" . MB_VERSION_NUMBER . "';";
@@ -95,6 +93,20 @@
}
}
+?>
+$(function () {
+ new Mb_notice("new jquery init function");
+ // creates the map objects (mapframe1, overview...)
+ eventInitMap.trigger();
+
+ eventBeforeInit.trigger();
+
+ // initialisation
+ eventInit.trigger();
+
+ eventAfterInit.trigger();
+});
+<?php
//
// Load internal JavaScript libraries
//
@@ -161,6 +173,8 @@
return false;
};
<?php
+$executeJsPluginsArray = array();
+
$mb_sql = "SELECT DISTINCT e_js_file, e_id, e_src, e_target, e_pos, " .
"e_url, e_left, e_top, e_width, e_height, e_requires FROM gui_element WHERE e_public = 1 AND " .
"fkey_gui_id = $1 ORDER BY e_pos";
@@ -186,6 +200,7 @@
die;
}
if (in_array($e_id, $modulesNotRelyingOnGlobalsArray)) {
+ ob_start();
echo "var options = {" .
"id:'$e_id'," .
"target:" . ($e_target[0] != "" ? $json->encode($e_target) : "[]") . "," .
@@ -203,14 +218,18 @@
return this.each(function () {
JS;
- require($currentFile);
+ require($currentFile);
echo <<<JS
});
}
-$("#$e_id").$e_id(options);
JS;
+ echo "$('#$e_id').$e_id(options);";
+ $executeJsPluginsArray[] = ob_get_contents();
+ ob_end_clean();
+ echo "Mapbender.Modules.$e_id = {};\n";
+
}
else {
echo "Mapbender.Modules." . $e_id . " = {\n";
@@ -226,4 +245,5 @@
}
}
}
+echo implode("\n", $executeJsPluginsArray);
?>
\ No newline at end of file
Modified: trunk/mapbender/http/javascripts/mapnf.php
===================================================================
--- trunk/mapbender/http/javascripts/mapnf.php 2009-06-23 08:20:27 UTC (rev 4077)
+++ trunk/mapbender/http/javascripts/mapnf.php 2009-06-23 08:27:23 UTC (rev 4078)
@@ -22,9 +22,10 @@
var lastTimestamp;
var lastScrollPosition;
+ Mapbender.Modules[options.id] = new Map('', options.id, options.width, options.height, null);
+
eventInitMap.register(function () {
- Mapbender.Modules[options.id] = new mb_mapObj_const('', options.id, options.width, options.height, null);
var mapObject = Mapbender.Modules[options.id];
mb_mapObj.push(mapObject);
Modified: trunk/mapbender/http/javascripts/mod_reload.php
===================================================================
--- trunk/mapbender/http/javascripts/mod_reload.php 2009-06-23 08:20:27 UTC (rev 4077)
+++ trunk/mapbender/http/javascripts/mod_reload.php 2009-06-23 08:27:23 UTC (rev 4078)
@@ -16,25 +16,51 @@
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
?>
-var mod_reload_img = new Image();
-mod_reload_img.src = "<?php echo $e_src; ?>";
-var mod_reload_img_over = new Image();
-mod_reload_img_over.src = "<?php echo preg_replace("/_off/","_over",$e_src); ?>";
+/**
+ * Package: Reload
+ *
+ * Description:
+ * A button that reloads the whole window.
+ *
+ * SQL:
+ * > INSERT INTO gui_element (fkey_gui_id, e_id, e_pos, e_public,
+ * > e_comment, e_element, e_src, e_attributes, e_left, e_top, e_width,
+ * > e_height, e_z_index, e_more_styles, e_content, e_closetag, e_js_file,
+ * > e_mb_mod, e_target, e_requires, e_url) VALUES ('<gui_id>', 'reload',
+ * > 2,1,'reload','img','../img/button_blink_red/reload_off.png', '',335,
+ * > 60,24,24,1,'','','','mod_reload.php','','mapframe1','',
+ * > 'http://www.mapbender.org/index.php/Reload');
+ *
+ * Maintainer:
+ * http://www.mapbender.org/User:Vera_Schulze
+ */
+var Reload = function (domElement) {
+
+ var that = this;
+
+ domElement.src = options.src;
+ if (!options.src) {
+ new Mb_exception(options.id + " requires a src.");
+ }
+ else {
+ $(domElement).mouseover(function () {
+ domElement.src = options.src.replace(/_off/,"_over");
+ }).mouseout(function () {
+ domElement.src = options.src;
+ }).click(function () {
+ that.reload();
+ });
+ };
+
+ /**
+ * Method: reload
+ *
+ * Reloads the window.
+ */
+ this.reload = function () {
+ location.reload();
+ };
+};
-function mod_reload(){
- location.reload();
-}
-function mod_reload_init(obj){
- document.getElementById("reload").src = mod_reload_img_over.src;
- obj.onmouseover = new Function("mod_reload_over()");
- obj.onmouseout = new Function("mod_reload_out()");
-}
-function mod_reload_over(){
- document.getElementById("reload").src = mod_reload_img_over.src;
-}
-function mod_reload_out(){
- document.getElementById("reload").src = mod_reload_img.src;
-}
+var reload = new Reload(this);
\ No newline at end of file
Modified: trunk/mapbender/http/javascripts/mod_sandclock.php
===================================================================
--- trunk/mapbender/http/javascripts/mod_sandclock.php 2009-06-23 08:20:27 UTC (rev 4077)
+++ trunk/mapbender/http/javascripts/mod_sandclock.php 2009-06-23 08:27:23 UTC (rev 4078)
@@ -16,76 +16,136 @@
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
-echo "var mod_sandclock_target = '".$e_target[0]."';";
-include '../include/dyn_js.php';
?>
-try{
- if (mod_sandclock_image){}
-}
-catch(e){
- mod_sandclock_image = "../img/sandclock.gif";
-}
+/**
+ * Package: Sandclock
+ *
+ * Description:
+ * Displays an arbitrary sandclock image on a map
+ *
+ * SQL:
+ * > INSERT INTO gui_element (fkey_gui_id, e_id, e_pos, e_public,
+ * > e_comment, e_element, e_src, e_attributes, e_left, e_top, e_width,
+ * > e_height, e_z_index, e_more_styles, e_content, e_closeTag, e_js_file,
+ * > e_mb_mod, e_target, e_requires) VALUES ('<gui_id>', 'sandclock', '0002',
+ * > '1', 'displays a sand clock while waiting for requests', 'div', '',
+ * > '', '', '', '', '', '', '', '', 'div', 'mod_sandclock.php', '',
+ * > 'mapframe1', '');
+ * >
+ * > INSERT INTO gui_element_vars (fkey_gui_id, fkey_e_id, var_name,
+ * > var_value, context, var_type) VALUES ('<gui_id>', 'sandclock',
+ * > 'mod_sandclock_image', '../img/sandclock.gif',
+ * > 'define a sandclock-image', 'var');
+ *
+ * Maintainer:
+ * http://www.mapbender.org/User:Christoph_Baudson
+ *
+ * Parameters:
+ * mod_sandclock_img - *[optional]* the filename and path to the sandclock image
+ */
+
+var Sandclock = function (options) {
+ var that = this;
-var mod_sandclock_img = new Image();
-mod_sandclock_img.src = mod_sandclock_image;
-
-eventAfterMapRequest.register(function (obj) {
- mod_sandclock(true,obj.myMapId);
-});
-
-function mod_sandclock(start,myMapId){
- var ind = getMapObjIndexByName(mod_sandclock_target);
- if(start){
- var temp = "<img src='"+mod_sandclock_img.src+"'>";
-
- var map_el = mb_mapObj[ind].getDomElement();
- if(!map_el.ownerDocument.getElementById(mb_mapObj[ind].elementName+"_sandclock")){
- //create Box Elements
- el_top = map_el.ownerDocument.createElement("div");
- el_top.style.position = "absolute";
- el_top.style.top = "0px";
- el_top.style.left = "0px";
- el_top.style.overflow = "hidden";
- el_top.style.zIndex = "10";
- el_top.style.visibility = "visible";
- el_top.style.cursor = "crosshair";
- el_top.id = mb_mapObj[ind].elementName+"_sandclock";
- map_el.appendChild(el_top);
- }
- writeTag(mb_mapObj[ind].frameName, mb_mapObj[ind].elementName+"_sandclock", temp);
- mb_arrangeElement("", mod_sandclock_target+"_sandclock", (mb_mapObj[ind].width/2 - 16), (mb_mapObj[ind].height/2 - 16));
+ //
+ // check if target is set correctly
+ //
+ if (!options.target) {
+ new Mb_Exception(this.id + "requires a target.");
+ return;
}
+
+ if (!Mapbender.Modules[options.target]) {
+ new Mb_exception("Target " + options.target + " not found by " + this.id)
+ }
+ var map = Mapbender.Modules[options.target];
+
+ //
+ // element vars
+ //
+ if (!options.mod_sandclock_image) {
+ options.mod_sandclock_image = "../img/sandclock.gif";
+ }
+ var mod_sandclock_img = new Image();
+ mod_sandclock_img.src = options.mod_sandclock_image;
+
+
//
- // if myMapId is nopt given, the sandclock has to be turned off manually
- // by calling mod_sandclock_off. Usually this is done in a callback
- // function.
+ // constructor
//
- if (typeof myMapId !== "undefined") {
- aktiv = setTimeout(function () {
- mod_sandclock('',myMapId);
+ eventAfterMapRequest.register(function (obj) {
+ that.show(obj.myMapId);
+ });
+
+ var isInitialised = false;
+
+ var aktiv;
+
+ /**
+ * Method: show
+ *
+ * Displays the sandclock
+ */
+ this.show = function (mapId) {
+ if (!isInitialised) {
+ var temp = "<img src='"+mod_sandclock_img.src+"'>";
+
+ var map_el = map.getDomElement();
+ if(!map_el.ownerDocument.getElementById(map.elementName+"_sandclock")){
+ //create Box Elements
+ el_top = map_el.ownerDocument.createElement("div");
+ el_top.style.position = "absolute";
+ el_top.style.top = "0px";
+ el_top.style.left = "0px";
+ el_top.style.overflow = "hidden";
+ el_top.style.zIndex = "10";
+ el_top.style.visibility = "visible";
+ el_top.style.cursor = "crosshair";
+ el_top.id = map.elementName+"_sandclock";
+ map_el.appendChild(el_top);
+ }
+ writeTag(map.frameName, map.elementName+"_sandclock", temp);
+ mb_arrangeElement("", options.target+"_sandclock", (map.width/2 - 16), (map.height/2 - 16));
+ isInitialised = true;
+ }
+
+ //
+ // if mapId is not given, the sandclock has to be turned off manually
+ // by calling hide(). Usually this is done in a callback
+ // function.
+ //
+ if (typeof mapId !== "undefined") {
+ aktiv = setTimeout(function () {
+ that.show(mapId);
},10);
- var myMapIdArray = myMapId.split(",");
- var complete = true;
- var myMapId;
- for (var i = 0; i < myMapIdArray.length && complete; i++) {
- myMapId = myMapIdArray[i];
- var myDoc = mb_mapObj[ind].getDomElement().ownerDocument;
- if(myDoc.getElementById(myMapId) &&
- !myDoc.getElementById(myMapId).complete) {
- complete = false;
+ var mapIdArray = mapId.split(",");
+ var complete = true;
+ var mapId;
+ for (var i = 0; i < mapIdArray.length && complete; i++) {
+ mapId = mapIdArray[i];
+ var myDoc = map.getDomElement().ownerDocument;
+ if(myDoc.getElementById(mapId) &&
+ !myDoc.getElementById(mapId).complete) {
+ complete = false;
+ }
}
+ if (complete) {
+ clearTimeout(aktiv);
+ that.hide(map);
+ }
}
- if (complete) {
- clearTimeout(aktiv);
- mod_sandclock_off(mb_mapObj[ind]);
- }
- }
+
+ };
+
+ /**
+ * Method: hide
+ *
+ * Hides the sandclock
+ */
+ this.hide = function () {
+ writeTag(map.frameName, map.elementName+"_sandclock", "");
+ };
}
-function mod_sandclock_off() {
- var mapObj = getMapObjByName(mod_sandclock_target);
- writeTag(mapObj.frameName, mapObj.elementName+"_sandclock", "");
-}
+var sandclock = new Sandclock(options);
Modified: trunk/mapbender/http/javascripts/mod_zoomIn1.php
===================================================================
--- trunk/mapbender/http/javascripts/mod_zoomIn1.php 2009-06-23 08:20:27 UTC (rev 4077)
+++ trunk/mapbender/http/javascripts/mod_zoomIn1.php 2009-06-23 08:27:23 UTC (rev 4078)
@@ -17,6 +17,30 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
?>
+/**
+ * Package: ZoomIn1
+ *
+ * Description:
+ * Click button, which minimizes the real world bounding box of the visible map section, doubles the scale (halfes the scale number). Image size is not affected.
+ *
+ * Maintainer:
+ * http://www.mapbender.org/User:Christoph_Baudson
+ *
+ * SQL:
+ * > INSERT INTO gui_element(fkey_gui_id, e_id, e_pos, e_public,
+ * > e_comment, e_title, e_element, e_src, e_attributes, e_left,
+ * > e_top, e_width, e_height, e_z_index, e_more_styles, e_content,
+ * > e_closetag, e_js_file, e_mb_mod, e_target, e_requires, e_url)
+ * > VALUES('gui', 'zoomIn1', 2, 1, 'zoomIn button','Zoom in',
+ * > 'img','../img/button_gray/zoomIn2_off.png','',220,10,24,24,1,
+ * > '','','','mod_zoomIn1.php','','mapframe1','',
+ * > 'http://www.mapbender.org/index.php/ZoomIn');
+ *
+ * Files:
+ * - http/javascripts/mod_zoomIn1.php
+ *
+ *
+ */
$(this).click(function () {
if (!options.target) {
return;
Modified: trunk/mapbender/lib/core.js
===================================================================
--- trunk/mapbender/lib/core.js 2009-06-23 08:20:27 UTC (rev 4077)
+++ trunk/mapbender/lib/core.js 2009-06-23 08:27:23 UTC (rev 4078)
@@ -1,3 +1,7 @@
+var Mapbender = {
+ Event : {}
+};
+
var currentWmcExtensionData = {};
var restoredWmcExtensionData = {};
@@ -39,25 +43,25 @@
/**
* Triggered when Mapbender is loaded and after the map object has been initialised.
*/
-var eventInit = new MapbenderEvent();
+var eventInit = Mapbender.Event.init = new MapbenderEvent();
/**
* Triggered before eventInit.
*/
-var eventBeforeInit = new MapbenderEvent();
+var eventBeforeInit = Mapbender.Event.beforeInit = new MapbenderEvent();
/**
* Triggered after Mapbender is loaded and has been initialised.
* Used to trigger initial map requests
*/
-var eventAfterInit = new MapbenderEvent();
+var eventAfterInit = Mapbender.Event.afterInit = new MapbenderEvent();
/**
* Initializes the map object. Triggered when Mapbender is loaded.
*/
-var eventInitMap = new MapbenderEvent();
+var eventInitMap = Mapbender.Event.initMaps = new MapbenderEvent();
-eventInit.register(function() {
+Mapbender.Event.init.register(function() {
$lm = $("#loading_mapbender");
$cm = $("#complete_mapbender");
$lm.empty();
@@ -67,7 +71,7 @@
/**
* Switches the locale. Triggered by module switch_locale or onload(?)
*/
-var eventLocalize = new MapbenderEvent();
+var eventLocalize = Mapbender.Event.localize = new MapbenderEvent();
/**
* Triggered after the map object has been created.
@@ -172,16 +176,9 @@
/**
* Called in index.php on body onload
*/
-function init() {
- // creates the map objects (mapframe1, overview...)
- eventInitMap.trigger();
- eventBeforeInit.trigger();
-
- // initialisation
- eventInit.trigger();
-
- eventAfterInit.trigger();
+function init(){
+ new Mb_notice("old body onload init");
}
/**
More information about the Mapbender_commits
mailing list