Created
February 24, 2013 22:42
-
-
Save dbouwman/5026063 to your computer and use it in GitHub Desktop.
LayerList Controller Initialize is where all the orchestration happens because we never change the collections at runtime.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//================================== | |
//Controller for the LayerList Module | |
//================================== | |
var Controller = Backbone.Marionette.Controller.extend({ | |
initialize: function (options) { | |
_.bindAll(); | |
console.log('LayerListMobule:Controller:initialize'); | |
this.region = options.region; | |
//The layer list has two collections | |
// 1) the list of basemaps | |
// 2) list of operational layers | |
this.basemapCollection = new LayerCollection(options.mapConfig.basemaps); | |
this.layerCollection = new LayerCollection(options.mapConfig.operationalLayers); | |
//create the views - these are Marionette.CollectionViews that render ItemViews | |
this.basemapView = new BasemapListView({collection:this.basemapCollection}); | |
this.layersView = new LayerListView({collection:this.layerCollection}); | |
//create our layout that will hold the child views | |
this.layout = new LayerListLayoutView(); | |
//We have to render the layout before we can | |
//call show() on the layout's regions | |
this.region.show(this.layout); | |
this.layout.layerListRegion.show(this.layersView); | |
this.layout.basemapRegion.show(this.basemapView); | |
//hook up App events to show/hide the panel | |
Viewer.vent.on('View:LayerList', function (name) { | |
console.log('LayerListController caught View:LayerList'); | |
$('#layer-list-region').show(); | |
}); | |
Viewer.vent.on('View:LayerList:Hide',function(){ | |
$('#layer-list-region').hide(); | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment