function getTextContent(graphic) { require (["dojox/xml/DomParser", "dojox/xml/parser", "dojo/date/locale", "dijit/layout/ContentPane", "dijit/layout/TabContainer"], function (DomParser,parser,locale, ContentPane,TabContainer) { if(dijit.byId('wscontpane')){ dijit.byId('wscontpane').destroy(); } var partners = graphic.attributes.KNOWN_PARTNERS; var estCompDate; var estCost; if (!graphic.attributes.ESTIMATED_COMPLETION_DATE == '') { estCompDate = new Date(graphic.attributes.ESTIMATED_COMPLETION_DATE); estCompDate = locale.format(estCompDate, { selector: 'date', datePattern: 'MMMM d, y' }); } else { estCompDate = ''; } if (!graphic.attributes.ESSENTIAL_PROJECT_EST_COST == '') { estCost = '$' + dojo.number.format(graphic.attributes.ESSENTIAL_PROJECT_EST_COST) } else { estCost = ''; } var jsdom = DomParser.parse(partners); //console.debug(jsdom); var docNode = jsdom.documentElement; partners = ""; if (docNode) { var nodestoprocess = docNode.childNodes; for (var i = 0; i < nodestoprocess.length; i++) { partners += parser.textContent(docNode.childNodes.childNodes[0]) + "<br/>" ; } } lscapp.cp = new ContentPane({ id: 'wscontpane', isContainer:true, content:'<b>' + graphic.attributes.FOREST_NAME + '</b><br />' + '<b>' + graphic.attributes.WATERSHED_NAME + '<hr>'}, dojo.create('div')); var tc = new TabContainer({ id:'wsTabCont', style: 'width:350px;height:264px;line-height:150%;' + 'font-family: Verdana,Arial,Helvetica,sans-serif;'}, dojo.create('div')); var pane1 = new ContentPane({ title:'Abstract', id:'wstab1', content:'<b>Watershed Code: </b>' + graphic.attributes.WATERSHED_CODE + '<br />' + '<b>Total Acres: </b>' + dojo.number.format(graphic.attributes.TOTAL_WATERSHED_AREA_ACRES, {places:0}) + '<br />' + '<b>Forest Service Ownership: </b>' + graphic.attributes.FS_OWNERSHIP_PERCENT + '%<br />' + '<b>Condition - Forest Service Area: </b>' + graphic.attributes.WATERSHED_CONDITION_FS_AREA + '<br />' + '<b>Year Identified: </b>' + graphic.attributes.YEAR_PRIORITY_IDENTIFIED + '<br />' + '<b>Estimated Completion Date: </b>' + estCompDate + '<br />' + '<b>Estimated Cost: </b>' + estCost }); dojo.addClass(pane1.domNode, "wstab"); var pane2 = new ContentPane({ title:'Conditions', id:'wstab2', content:'<b>Aquatic Habitat: </b>' + graphic.attributes.AQUATIC_HABITAT_CONDITION + '<br />' + '<b>Aquatic Biota: </b>' + graphic.attributes.AQUATIC_BIOTA_CONDITION + '<br />' + '<b>Water Quality: </b>' + graphic.attributes.WATER_QUALITY_CONDITION + '<br />' + '<b>Water Quantity: </b>' + graphic.attributes.WATER_QUANTITY_CONDITION + '<br />' + '<b>Wetland Vegetation: </b>' + graphic.attributes.RIPARIAN_WETLAND_VEG_CONDITION + '<br />' + '<b>Forest Cover: </b>' + graphic.attributes.FOREST_COVER_CONDITION + '<br />' + '<b>Forest Health: </b>' + graphic.attributes.FOREST_HEALTH_CONDITION + '<br />' + '<b>Soil: </b>' + graphic.attributes.SOIL_CONDITION + '<br />' + '<b>Roads and Trails: </b>' + graphic.attributes.ROADS_AND_TRAILS_CONDITION }); dojo.addClass(pane2.domNode, "wstab"); var pane3 = new ContentPane({ title:'Justification', id:'wstab3', style:'line-height:125%; margin:10px', content: graphic.attributes.SELECTION_NARRATIVE }); dojo.addClass(pane3.domNode, "wstab"); var pane4 = new ContentPane({ title:'Partners', id:'wstab4', content: partners }); dojo.addClass(pane4.domNode, "wstab"); tc.addChild(pane1); tc.addChild(pane2); tc.addChild(pane3); tc.addChild(pane4); tc.startup(); lscapp.cp.addChild(tc); lscapp.cp.startup(); }); return lscapp.cp.domNode;
Solved! Go to Solution.
var content = getTextContent(evt.graphic); wsDialog.setContent(content); dojo.style(wsDialog.domNode, "opacity", 1.0); dijit.popup.open({ popup: wsDialog, x:evt.pageX, y:evt.pageY });
getTextContent(evt.graphic,function() { wsDialog.setContent(lscapp.cp.domNode); dojo.style(wsDialog.domNode, "opacity", 1.0); dijit.popup.open({ popup: wsDialog, x:evt.pageX, y:evt.pageY }); });
function getTextContent(graphic,callback) { require (["dojox/xml/DomParser", "dojox/xml/parser", "dojo/date/locale", "dijit/layout/ContentPane", "dijit/layout/TabContainer"], function (DomParser,parser,locale, ContentPane,TabContainer) { ... /* content pane and tab container building code removed */ ... lscapp.cp.startup(); callback(); }); }
function getTextContent(graphic) { require (["dojox/xml/DomParser", "dojox/xml/parser", "dojo/date/locale", "dijit/layout/ContentPane", "dijit/layout/TabContainer"], function (DomParser,parser,locale, ContentPane,TabContainer) { if(dijit.byId('wscontpane')){ dijit.byId('wscontpane').destroy(); } var partners = graphic.attributes.KNOWN_PARTNERS; var estCompDate; var estCost; if (!graphic.attributes.ESTIMATED_COMPLETION_DATE == '') { estCompDate = new Date(graphic.attributes.ESTIMATED_COMPLETION_DATE); estCompDate = locale.format(estCompDate, { selector: 'date', datePattern: 'MMMM d, y' }); } else { estCompDate = ''; } if (!graphic.attributes.ESSENTIAL_PROJECT_EST_COST == '') { estCost = '$' + dojo.number.format(graphic.attributes.ESSENTIAL_PROJECT_EST_COST) } else { estCost = ''; } var jsdom = DomParser.parse(partners); //console.debug(jsdom); var docNode = jsdom.documentElement; partners = ""; if (docNode) { var nodestoprocess = docNode.childNodes; for (var i = 0; i < nodestoprocess.length; i++) { partners += parser.textContent(docNode.childNodes.childNodes[0]) + "<br/>" ; } } lscapp.cp = new ContentPane({ id: 'wscontpane', isContainer:true, content:'<b>' + graphic.attributes.FOREST_NAME + '</b><br />' + '<b>' + graphic.attributes.WATERSHED_NAME + '<hr>'}, dojo.create('div')); var tc = new TabContainer({ id:'wsTabCont', style: 'width:350px;height:264px;line-height:150%;' + 'font-family: Verdana,Arial,Helvetica,sans-serif;'}, dojo.create('div')); var pane1 = new ContentPane({ title:'Abstract', id:'wstab1', content:'<b>Watershed Code: </b>' + graphic.attributes.WATERSHED_CODE + '<br />' + '<b>Total Acres: </b>' + dojo.number.format(graphic.attributes.TOTAL_WATERSHED_AREA_ACRES, {places:0}) + '<br />' + '<b>Forest Service Ownership: </b>' + graphic.attributes.FS_OWNERSHIP_PERCENT + '%<br />' + '<b>Condition - Forest Service Area: </b>' + graphic.attributes.WATERSHED_CONDITION_FS_AREA + '<br />' + '<b>Year Identified: </b>' + graphic.attributes.YEAR_PRIORITY_IDENTIFIED + '<br />' + '<b>Estimated Completion Date: </b>' + estCompDate + '<br />' + '<b>Estimated Cost: </b>' + estCost }); dojo.addClass(pane1.domNode, "wstab"); var pane2 = new ContentPane({ title:'Conditions', id:'wstab2', content:'<b>Aquatic Habitat: </b>' + graphic.attributes.AQUATIC_HABITAT_CONDITION + '<br />' + '<b>Aquatic Biota: </b>' + graphic.attributes.AQUATIC_BIOTA_CONDITION + '<br />' + '<b>Water Quality: </b>' + graphic.attributes.WATER_QUALITY_CONDITION + '<br />' + '<b>Water Quantity: </b>' + graphic.attributes.WATER_QUANTITY_CONDITION + '<br />' + '<b>Wetland Vegetation: </b>' + graphic.attributes.RIPARIAN_WETLAND_VEG_CONDITION + '<br />' + '<b>Forest Cover: </b>' + graphic.attributes.FOREST_COVER_CONDITION + '<br />' + '<b>Forest Health: </b>' + graphic.attributes.FOREST_HEALTH_CONDITION + '<br />' + '<b>Soil: </b>' + graphic.attributes.SOIL_CONDITION + '<br />' + '<b>Roads and Trails: </b>' + graphic.attributes.ROADS_AND_TRAILS_CONDITION }); dojo.addClass(pane2.domNode, "wstab"); var pane3 = new ContentPane({ title:'Justification', id:'wstab3', style:'line-height:125%; margin:10px', content: graphic.attributes.SELECTION_NARRATIVE }); dojo.addClass(pane3.domNode, "wstab"); var pane4 = new ContentPane({ title:'Partners', id:'wstab4', content: partners }); dojo.addClass(pane4.domNode, "wstab"); tc.addChild(pane1); tc.addChild(pane2); tc.addChild(pane3); tc.addChild(pane4); tc.startup(); lscapp.cp.addChild(tc); lscapp.cp.startup(); return lscapp.cp.domNode; //Move return inside the function }); }
var content = getTextContent(evt.graphic); wsDialog.setContent(content); dojo.style(wsDialog.domNode, "opacity", 1.0); dijit.popup.open({ popup: wsDialog, x:evt.pageX, y:evt.pageY });
getTextContent(evt.graphic,function() { wsDialog.setContent(lscapp.cp.domNode); dojo.style(wsDialog.domNode, "opacity", 1.0); dijit.popup.open({ popup: wsDialog, x:evt.pageX, y:evt.pageY }); });
function getTextContent(graphic,callback) { require (["dojox/xml/DomParser", "dojox/xml/parser", "dojo/date/locale", "dijit/layout/ContentPane", "dijit/layout/TabContainer"], function (DomParser,parser,locale, ContentPane,TabContainer) { ... /* content pane and tab container building code removed */ ... lscapp.cp.startup(); callback(); }); }