[Mapbender-commits] r4904 - trunk/mapbender/http/javascripts
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Tue Nov 3 05:05:45 EST 2009
Author: christoph
Date: 2009-11-03 05:05:45 -0500 (Tue, 03 Nov 2009)
New Revision: 4904
Modified:
trunk/mapbender/http/javascripts/mod_sandclock.js
Log:
Modified: trunk/mapbender/http/javascripts/mod_sandclock.js
===================================================================
--- trunk/mapbender/http/javascripts/mod_sandclock.js 2009-11-03 10:04:45 UTC (rev 4903)
+++ trunk/mapbender/http/javascripts/mod_sandclock.js 2009-11-03 10:05:45 UTC (rev 4904)
@@ -17,6 +17,10 @@
* > var_value, context, var_type) VALUES ('<gui_id>', 'sandclock',
* > 'mod_sandclock_image', '../img/sandclock.gif',
* > 'define a sandclock-image', 'var');
+ * >
+ * > INSERT INTO gui_element_vars (fkey_gui_id, fkey_e_id, var_name,
+ * > var_value, context, var_type) VALUES('<gui_id>', 'sandclock',
+ * > 'blockElement', '0', '' ,'var');
*
* Help:
* http://www.mapbender.org/Sandclock
@@ -39,19 +43,16 @@
//
// check if target is set correctly
- //
- if (!options.target) {
- new Mb_Exception(this.id + "requires a target.");
- return;
+ for (var i in options.target) {
+ if (!Mapbender.modules[options.target[i]]) {
+ new Mb_exception(
+ "Target " + options.target[i] + " not found by " + options.id
+ );
+ }
}
-
- if (!Mapbender.modules[options.target]) {
- new Mb_exception("Target " + options.target + " not found by " + this.id)
- }
- var map;
-
+
//
- // element vars
+ // sandclock image
//
if (!options.mod_sandclock_image) {
options.mod_sandclock_image = "../img/sandclock.gif";
@@ -60,16 +61,30 @@
var mod_sandclock_img = new Image();
mod_sandclock_img.src = options.mod_sandclock_image;
+ //
+ // block the html element with a css shadow
+ //
+ if (typeof options.blockElement === "undefined") {
+ options.blockElement = 0;
+ }
//
- // constructor
+ // if target objects are maps, bind sandclock to its repaint event
//
- eventAfterMapRequest.register(function (obj) {
- that.show(obj.myMapId);
- });
+ for (var i in options.target) {
+ (function () {
+ var nodeId = options.target[i];
+ if (typeof Mapbender.modules[nodeId].afterMapRequest === "object") {
+ Mapbender.modules[nodeId].afterMapRequest.register(function (obj) {
+ that.show(nodeId, {
+ mapId: obj.myMapId,
+ blockElement: options.blockElement
+ });
+ });
+ }
+ })();
+ }
- var isInitialised = false;
-
var aktiv;
/**
@@ -77,27 +92,33 @@
*
* Displays the sandclock
*/
- this.show = function (mapId) {
- var temp = "<img src='"+mod_sandclock_img.src+"'>";
- if (!isInitialised) {
- map = Mapbender.modules[options.target];
- 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 = "1000";
- el_top.style.visibility = "visible";
- el_top.id = map.elementName+"_sandclock";
- map_el.appendChild(el_top);
- }
- isInitialised = true;
+ this.show = function (nodeId, arg) {
+ var mapId = arg.mapId;
+
+ var $clock = $("#" + nodeId + "_sandclock");
+ if ($clock.size() === 0) {
+ //create Box Elements
+ $(
+ "<div id='" + nodeId + "_sandclock'>"
+ ).css({
+ position: "absolute",
+ top: "0px",
+ left: "0px",
+ width: "100%",
+ height: "100%",
+ overflow: "hidden",
+ zIndex: 1000,
+ visibility: "visible"
+ }).appendTo($("#" + nodeId));
}
- writeTag(map.frameName, map.elementName+"_sandclock", temp);
- mb_arrangeElement("", options.target+"_sandclock", (map.width/2 - 16), (map.height/2 - 16));
+ $clock.html(
+ "<img style='position:absolute; top:50%; left:50%' src='" +
+ mod_sandclock_img.src+"'></div>"
+ );
+
+ if (arg.blockElement) {
+ $clock.addClass("ui-widget-overlay");
+ }
//
// if mapId is not given, the sandclock has to be turned off manually
@@ -106,25 +127,28 @@
//
if (typeof mapId !== "undefined") {
aktiv = setTimeout(function () {
- that.show(mapId);
+ that.show(nodeId, {
+ mapId: mapId,
+ blockElement: arg.blockElement
+ });
},10);
var mapIdArray = mapId.split(",");
var complete = true;
- var mapId;
+ var map = Mapbender.modules[nodeId];
+
for (var i = 0; i < mapIdArray.length && complete; i++) {
- mapId = mapIdArray[i];
+ var currentMapId = mapIdArray[i];
var myDoc = map.getDomElement().ownerDocument;
- if(myDoc.getElementById(mapId) &&
- !myDoc.getElementById(mapId).complete) {
+ if(myDoc.getElementById(currentMapId) &&
+ !myDoc.getElementById(currentMapId).complete) {
complete = false;
}
}
if (complete) {
clearTimeout(aktiv);
- that.hide(map);
+ that.hide(nodeId, map);
}
}
-
};
/**
@@ -132,9 +156,11 @@
*
* Hides the sandclock
*/
- this.hide = function () {
- writeTag(map.frameName, map.elementName+"_sandclock", "");
+ this.hide = function (nodeId) {
+ $("#" + nodeId + "_sandclock").removeClass("ui-widget-overlay").empty();
};
}
-$.extend(Mapbender.modules[options.id], new Sandclock(options));
+Mapbender.events.init.register(function () {
+ $.extend(Mapbender.modules[options.id], new Sandclock(options));
+});
More information about the Mapbender_commits
mailing list