Skip to content

Commit

Permalink
separate menus into subLayerMenu and menu properties
Browse files Browse the repository at this point in the history
  • Loading branch information
green3g committed Feb 27, 2017
1 parent 2848aad commit a8978a2
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 18 deletions.
25 changes: 14 additions & 11 deletions viewer/js/config/viewer.js
Expand Up @@ -55,16 +55,16 @@ define([
topic.publish('growler/growl', {
title: 'Hello!',
message: event.layer._titleForLegend + ' ' +
(event.subLayer ? event.subLayer.name : '') +
' says hello'
(event.subLayer ? event.subLayer.name : '') +
' says hello'
});
});
topic.subscribe('layerControl/goodbye', function (event) {
topic.publish('growler/growl', {
title: 'Goodbye!',
message: event.layer._titleForLegend + ' ' +
(event.subLayer ? event.subLayer.name : '') +
' says goodbye'
(event.subLayer ? event.subLayer.name : '') +
' says goodbye'
});
});

Expand Down Expand Up @@ -218,7 +218,7 @@ define([
expanded: true,

//override the menu on this particular layer
menu: [{
subLayerMenu: [{
topic: 'hello',
label: 'Say Hello',
iconClass: 'fa fa-smile-o'
Expand Down Expand Up @@ -434,19 +434,22 @@ define([
separated: true,
vectorReorder: true,
overlayReorder: true,

// create a custom menu entry in all of these feature types
// the custom menu item will publish a topic when clicked
menu: {
feature: [{
topic: 'hello',
iconClass: 'fa fa-smile-o',
label: 'Say Hello'
}]
},
//create a example sub layer menu that will
//apply to all layers of type 'dynamic'
subLayerMenu: {
dynamic: [{
topic: 'goodbye',
iconClass: 'fa fa-frown-o',
label: 'Say goodbye'
}],
feature: [{
topic: 'hello',
iconClass: 'fa fa-smile-o',
label: 'Say Hello'
}]
}
}
Expand Down
6 changes: 4 additions & 2 deletions viewer/js/gis/dijit/LayerControl.js
Expand Up @@ -51,6 +51,7 @@ define([
noLegend: null,
noZoom: null,
noTransparency: null,
menu: {},
subLayerMenu: {},
swipe: null,
swiperButtonStyle: 'position:absolute;top:20px;left:120px;z-index:50;',
Expand Down Expand Up @@ -220,7 +221,8 @@ define([
swipe: null,
expanded: false,
sublayers: true,
menu: this.subLayerMenu[layerInfo.type]
menu: this.menu[layerInfo.type],
subLayerMenu: this.subLayerMenu[layerInfo.type]
}, layerInfo.controlOptions)
});
layerControl.startup();
Expand Down Expand Up @@ -487,4 +489,4 @@ define([
}
});
return LayerControl;
});
});
3 changes: 2 additions & 1 deletion viewer/js/gis/dijit/LayerControl/controls/Dynamic.js
Expand Up @@ -91,7 +91,8 @@ define([
_initCustomMenu: function () {
// add custom sublayer menu items if we only have one sublayer
if (!this._hasSublayers) {
array.forEach(this.controlOptions.menu, lang.hitch(this, '_addMenuItem', this.layerMenu));
array.forEach(this.controlOptions.subLayerMenu, lang.hitch(this, '_addCustomMenuItem', this.layerMenu));
this.layerMenu.addChild(new MenuSeparator());
}
},
// toggle all sublayers on/off
Expand Down
2 changes: 1 addition & 1 deletion viewer/js/gis/dijit/LayerControl/controls/Feature.js
Expand Up @@ -28,4 +28,4 @@ define([
}
});
return FeatureControl;
});
});
6 changes: 3 additions & 3 deletions viewer/js/gis/dijit/LayerControl/controls/_DynamicSublayer.js
Expand Up @@ -88,14 +88,14 @@ define([
this._handlers.push(this.control.layer.getMap().on('zoom-end', lang.hitch(this, '_checkboxScaleRange')));
}
//set up menu
if (this.control.controlOptions.menu &&
this.control.controlOptions.menu.length) {
if (this.control.controlOptions.subLayerMenu &&
this.control.controlOptions.subLayerMenu.length) {
this.menu = new Menu({
contextMenuForWindow: false,
targetNodeIds: [this.menuClickNode],
leftClickToOpen: true
});
array.forEach(this.control.controlOptions.menu, lang.hitch(this, '_addMenuItem'));
array.forEach(this.control.controlOptions.subLayerMenu, lang.hitch(this, '_addMenuItem'));
this.menu.startup();
} else {
domClass.add(this.menuClickNode, 'hidden');
Expand Down

0 comments on commit a8978a2

Please sign in to comment.