/**
* Controller module for loading sidebar widgets
* @module app/SidebarController
* @author David Kristiansen <david.kristiansen@nscc.ca>
* @copyright Nova Scotia Community College 2017
*/
define([
"dojo/_base/declare",
"dojo/topic",
"dijit/_WidgetBase",
"dijit/layout/ContentPane",
"dijit/TitlePane",
"dojox/layout/GridContainerLite",
"app/widget/LayerWidget",
"app/widget/BasemapWidget",
"app/widget/TextWidget",
"app/widget/TideSurgeWidget",
"app/widget/LegendWidget",
"app/widget/LCAWidget",
"app/widget/ToolWidget"
],
function (
declare,
topic,
_WidgetBase,
ContentPane,
TitlePane,
GridContainer,
LayerWidget,
BasemapWidget,
TextWidget,
TideSurgeWidget,
LegendWidget,
LCA,
ToolWidget
) {
return declare("app.SidebarController", [_WidgetBase], {
gc: null,
cp1: null,
cp2: null,
cp3: null,
cp4: null,
cp5: null,
cp6: null,
options: {
map: null,
data: null
},
/** @constructor
* @param {object} param Object of properties to mixin
* @param {object} srcRefNode Dom node for the widget to attach to
**/
constructor: function (param, srcRefNode) {
/** mix in settings and defaults
* @mixin args
*/
declare.safeMixin(this.options, param);
/** Dom widget node */
this.domNode = srcRefNode;
// store localized strings
this.set("map", this.options.map);
this.set("data", this.options.data);
},
/**
* Calls createGridContainer after widget constructor finishes and before startup is called.
* @public
*
**/
postCreate: function () {
// console.log("SidebarController::postCreate");
this.createGridContainer();
},
/**
* Starts the widget after it has been constructed
* @public
*
**/
startup: function () {
// console.log("SidebarController::startup");
this._init();
},
/**
* Tells the grid container to start and begins adding widgets to the dom.
* @private
*
**/
_init: function () {
// console.log("SidebarController::init");
this.gc.startup();
this.addSidebarWidgets();
},
/**
* Constructs the grid container and inserts content panes.
* @todo create content panes dynamically based on an array or object of widgets.
*
**/
createGridContainer: function () {
this.gc = new GridContainer({
nbZones: 1,
dragHandleClass: 'dijitTitlePaneTitle',
style: {
width: '100%'
},
doLayout: false
}, "sidebarToolbar");
this.cp0 = new ContentPane();
this.gc.addChild(this.cp0);
this.cp1 = new TitlePane({
open: false
});
this.gc.addChild(this.cp1);
this.cp2 = new TitlePane({
open: false
});
this.gc.addChild(this.cp2);
this.cp3 = new TitlePane({
open: false
});
this.gc.addChild(this.cp3);
this.cp4 = new TitlePane({
open: false
});
this.gc.addChild(this.cp4);
this.cp5 = new TitlePane({
open: false
});
this.gc.addChild(this.cp5);
this.cp6 = new ContentPane();
this.gc.addChild(this.cp6);
},
/**
* Adds the widgets to the side bar.
*
**/
addSidebarWidgets: function () {
var lcaChooser = new LCA({
title: "Coverage Area",
pane: this.cp0,
dataStore: this.data
});
lcaChooser.startup();
var basemaps = new BasemapWidget({
title: "Basemaps",
map: this.map,
pane: this.cp1
});
basemaps.startup();
var tpLayers = new LayerWidget({
title: "Layers",
map: this.map,
pane: this.cp2
});
tpLayers.startup();
var floodlvl = new TideSurgeWidget({
title: "Tide & Storm Surge",
map: this.map,
pane: this.cp3,
data: this.data
});
floodlvl.startup();
var legend = new LegendWidget({
title: "Legend",
map: this.map,
pane: this.cp4
});
legend.startup();
var tools = new ToolWidget({
title: "Tools",
map: this.map,
pane: this.cp5
});
tools.startup();
var text = new TextWidget({
title: "Instructions",
pane: this.cp6
});
text.startup();
this.resize();
topic.publish("Sidebar/Loaded");
},
/**
* NOT IMPLEMENTED
* @todo resize grid container externally
*/
resize: function () {
this.gc.resize();
}
});
});