[mapguide-commits] r7114 - trunk/MgDev/Web/src/viewerfiles
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Mon Oct 15 23:08:32 PDT 2012
Author: jng
Date: 2012-10-15 23:08:31 -0700 (Mon, 15 Oct 2012)
New Revision: 7114
Modified:
trunk/MgDev/Web/src/viewerfiles/legendui.templ
Log:
#2146: Add context menu item in AJAX Viewer legend to toggle display of invisible layers. Patch by Bruno Scott.
Modified: trunk/MgDev/Web/src/viewerfiles/legendui.templ
===================================================================
--- trunk/MgDev/Web/src/viewerfiles/legendui.templ 2012-10-16 06:02:00 UTC (rev 7113)
+++ trunk/MgDev/Web/src/viewerfiles/legendui.templ 2012-10-16 06:08:31 UTC (rev 7114)
@@ -80,6 +80,7 @@
var clientAgent = 'Ajax Viewer';
var legendTextNoWrap = true;
+var showInvisibleLayers = false;
if(legendTextNoWrap)
{
iconExpand = "../stdicons/lc_expand_16.gif";
@@ -227,12 +228,26 @@
function RequestSymbolizationIconImg(layer, scale, iconId)
{
- return BuildDelayedLoadIconImg(layer.layerRes, scale, -1, -1, iconId);
+ if(showInvisibleLayers && layer.willDisplayAtScale)
+ {
+ return BuildDelayedLoadIconImg(layer.layerRes, layer.willDisplayAtScale, -1, -1, iconId);
+ }
+ else
+ {
+ return BuildDelayedLoadIconImg(layer.layerRes, scale, -1, -1, iconId);
+ }
}
function RequestThemeStyleIconImg(layer, scale, themeIndex, geomtype, iconId)
{
- return BuildDelayedLoadIconImg(layer.layerRes, scale, themeIndex, geomtype, iconId);
+ if(showInvisibleLayers && layer.willDisplayAtScale)
+ {
+ return BuildDelayedLoadIconImg(layer.layerRes, layer.willDisplayAtScale, themeIndex, geomtype, iconId);
+ }
+ else
+ {
+ return BuildDelayedLoadIconImg(layer.layerRes, scale, themeIndex, geomtype, iconId);
+ }
}
function BuildIconRequest(layerDef, scale, themeIndex, geomtype)
@@ -287,7 +302,8 @@
{
var layerChildren = document.getElementById('ChildrenOf_' + layer.objectId);
var code = "";
- var sc = layer.children[layer.curScale];
+ var layerCurScale = layer.curScale != -1 ? layer.curScale:0;
+ var sc = layer.children[layerCurScale];
var styles = sc.children;
var hasThemes = styles.length > 1;
var layerIconImg = "";
@@ -295,10 +311,17 @@
{
if(layer.expanded && !sc.iconWasRequested)
{
+ var textStyle = "";
+ if(showInvisibleLayers && layer.willDisplayAtScale)
+ {
+ textStyle = "font-style:italic;color:#C0C0C0";
+ }
+
+
for(var j=0; j < styles.length; j++)
{
var node = styles[j];
- var iconId = GetIconId(layer) + '_Scl_' + layer.curScale + '_Th_' + j;
+ var iconId = GetIconId(layer) + '_Scl_' + layerCurScale + '_Th_' + j;
var iconImg = RequestThemeStyleIconImg(layer, scale, node.catindex, node.geomtype, iconId);
code += '<table border=0 cellspacing="0" cellpadding="0"><tr height=17>';
@@ -308,14 +331,14 @@
code += '<td width=16 id="' + iconId + '">' + iconImg + '</td>';
//legend text
code += '<td width=7><img width=7 height=16 src="../stdicons/transparentpixel.gif"></td>';
- code += '<td style="white-space:nowrap">' + node.legend + '</td>';
+ code += '<td style="white-space:nowrap;' + textStyle +'">' + node.legend + '</td>';
}
else
{
//icon
code += '<td width=23 id="' + iconId + '">' + iconImg + '</td>';
//legend text
- code += '<td>' + node.legend + '</td>';
+ code += '<td style="' + textStyle + '">' + node.legend + '</td>';
}
code += '</tr></table>';
@@ -348,7 +371,7 @@
layerIconImg = iconRasterLayer;
else if(layer.lyrtype == 2)
layerIconImg = iconDrawingLayer;
- else if(layer.curScale == -1)
+ else if(layerCurScale == -1)
layerIconImg = iconBrokenLayer;
else
{
@@ -357,6 +380,10 @@
}
SetLayerIcon(layer, layerIconImg);
SetLayerExpandBox(layer, hasThemes);
+ if(showInvisibleLayers)
+ {
+ SetLayerTextStyle(layer);
+ }
}
function SetLayerIcon(layer, layerIconImg)
@@ -365,7 +392,23 @@
if(icElt != null)
icElt.innerHTML = layerIconImg;
}
-
+function SetLayerTextStyle(layer)
+{
+ var textElt = document.getElementById("Lg_" + layer.objectId);
+ if(textElt != null)
+ {
+ if(layer.willDisplayAtScale)
+ {
+ textElt.style.fontStyle = "italic";
+ textElt.style.color = "#C0C0C0";
+ }
+ else
+ {
+ textElt.style.fontStyle = "normal";
+ textElt.style.color = "#000000";
+ }
+ }
+}
function GetIconId(node)
{
return 'Ic_' + node.objectId;
@@ -672,6 +715,16 @@
addMenuOption(ctxMenu, "__#ALLSELECTABLE#__", 7, 1, "", "", cmdState[7] = true);
addMenuOption(ctxMenu, "__#ALLUNSELECTABLE#__", 8, 1, "", "", cmdState[8] = true);
+ addMenuOption(ctxMenu, "", 0, 2, "", "", false);
+ if(showInvisibleLayers)
+ {
+ addMenuOption(ctxMenu, "__#HIDEINVISIBLELAYERS#__", 9, 1, "", "", cmdState[9] = true);
+ }
+ else
+ {
+ addMenuOption(ctxMenu, "__#SHOWINVISIBLELAYERS#__", 10, 1, "", "", cmdState[10] = true);
+ }
+
endBuildMenuContent(ctxMenu);
showPopup(ctxMenu, true, x, y);
}
@@ -713,6 +766,12 @@
case 8:
SetSelectability(tree,false)
break;
+ case 9:
+ SetShowInvisibleLayers(false);
+ break;
+ case 10:
+ SetShowInvisibleLayers(true);
+ break;
}
}
@@ -834,7 +893,10 @@
if(tree == null)
return;
UpdateScaleRanges(tree);
- ShowHideNodes(tree);
+ if(showInvisibleLayers == false)
+ {
+ ShowHideNodes(tree);
+ }
iconsToLoad.reverse();
LoadNextIcon();
}
@@ -895,6 +957,8 @@
var rangeIndex = node.curScale;
var scaleRanges = node.children;
node.curScale = -1;
+
+ node.willDisplayAtScale = null;
for(var j=0; j < scaleRanges.length; j++)
{
var scaleRange = scaleRanges[j];
@@ -904,33 +968,63 @@
break;
}
}
+ if(showInvisibleLayers && node.curScale == -1)
+ {
+ var minScale = 1000000000;
+ var maxScale = 0;
+ for(var j=0; j < scaleRanges.length; j++)
+ {
+ var scaleRange = scaleRanges[j];
+ minScale = Math.min(minScale,scaleRange.min);
+ maxScale = Math.max(maxScale,scaleRange.max);
+ }
+ if(scale > maxScale)
+ {
+ node.willDisplayAtScale = maxScale-1;
+ }
+ else if(scale < minScale)
+ {
+ node.willDisplayAtScale = minScale;
+ }
+ }
+ var nodeCurScale= -1;
+ if(node.curScale != -1)
+ {
+ nodeCurScale = node.curScale;
+ }
+ else if(node.willDisplayAtScale)
+ {
+ nodeCurScale = 0;
+ }
- if(node.displayInLegend && node.curScale != -1)
{
- // scale changed
- if(rangeIndex != node.curScale)
- {
- // the layer's theme will be changed on demand
- node.children[node.curScale].iconWasRequested = false;
+ if(node.displayInLegend && nodeCurScale != -1)
+ {
+ // scale changed
+ if(rangeIndex != nodeCurScale || node.willDisplayAtScale)
+ {
+ // the layer's theme will be changed on demand
+ node.children[nodeCurScale].iconWasRequested = false;
- // the layer's legend image will be changed immediately
- if(!HasCollapsedParent(node))
- {
- SetLayerStyles(node);
- node.iconWasRequested = true;
- }
- // the layer's legend image will be changed on demand
- else
- {
- node.iconWasRequested = false;
- }
- }
- // parent group expanded
- else if(!node.iconWasRequested && !HasCollapsedParent(node))
- {
- SetLayerStyles(node);
- node.iconWasRequested = true;
- }
+ // the layer's legend image will be changed immediately
+ if(!HasCollapsedParent(node))
+ {
+ SetLayerStyles(node);
+ node.iconWasRequested = true;
+ }
+ // the layer's legend image will be changed on demand
+ else
+ {
+ node.iconWasRequested = false;
+ }
+ }
+ // parent group expanded
+ else if(!node.iconWasRequested && !HasCollapsedParent(node))
+ {
+ SetLayerStyles(node);
+ node.iconWasRequested = true;
+ }
+ }
}
node.isDisplayed = node.displayInLegend && node.curScale != -1;
@@ -1126,6 +1220,12 @@
return groups;
}
+function SetShowInvisibleLayers(isInvisibleLayersVisible)
+{
+ showInvisibleLayers = isInvisibleLayersVisible;
+ GetMainFrame().Refresh();
+}
+
</script>
</head>
More information about the mapguide-commits
mailing list