Skip to content

Commit

Permalink
Merge branch 'use-inherited-mixins' of https://github.com/roemhildtg/…
Browse files Browse the repository at this point in the history
…cmv-app into HEAD
  • Loading branch information
green3g committed Feb 11, 2017
2 parents 94baf8b + 92dad0a commit 5268fd3
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 90 deletions.
45 changes: 3 additions & 42 deletions viewer/css/cmv-theme-overrides.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,48 +26,9 @@
}

/* icons for the sidebar */

.cmv .dijitTitlePane .dijitTitlePaneTextNode:before,
.cmv .dijitDialogTitleBar:before {
font-family:'FontAwesome';
margin-right: 8px;
}

.cmv #bookmarks_parent .dijitTitlePaneTextNode:before {
content: '\f02e'
}
.cmv #directions_parent .dijitTitlePaneTextNode:before {
content: '\f277'
}
.cmv #draw_parent .dijitTitlePaneTextNode:before {
content: '\f1fc'
}
.cmv #editor_parent .dijitTitlePaneTextNode:before {
content: '\f040'
}
.cmv #find_parent .dijitTitlePaneTextNode:before {
content: '\f002';
}
.cmv #help_parent .dijitTitlePaneTextNode:before {
content: '\f059'
}
.cmv #identify_parent .dijitTitlePaneTextNode:before {
content: '\f05a'
}
.cmv #layerControl_parent .dijitTitlePaneTextNode:before{
content: '\f00b';
}
.cmv #legend_parent .dijitTitlePaneTextNode:before {
content: '\f03e'
}
.cmv #measurement_parent .dijitTitlePaneTextNode:before {
content: '\f065'
}
.cmv #print_parent .dijitTitlePaneTextNode:before {
content: '\f02f';
}
.cmv #streetview_parent .dijitTitlePaneTextNode:before {
content: '\f21d';
.cmv .dijitTitlePane .dijitTitlePaneTitle .titlePaneIcon {
margin: 0 0 0 8px;
padding-top: 2px;
}
/* end custom icons */

Expand Down
2 changes: 1 addition & 1 deletion viewer/js/config/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
_ConfigMixin,
_LayoutMixin,
_MapMixin,
_WidgetsMixin,
_WidgetsMixin

// _WebMapMixin
//_MyCustomMixin
Expand Down
23 changes: 12 additions & 11 deletions viewer/js/config/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ define([
sliderStyle: 'small'
},

webMapId: '880a967872114b44a63c207df10e0a75', // High Cost Mortgage
//webMapId: 'ef9c7fbda731474d98647bebb4b33c20', // High Cost Mortgage
// webMapOptions: {},

// panes: {
Expand Down Expand Up @@ -273,16 +273,6 @@ define([
}],
// set include:true to load. For titlePane type set position the the desired order in the sidebar
widgets: {
// a widget that loads and runs before the app
// loader: {
// type: 'loading',
// path: 'dijit/_WidgetBase',
// options: {
// constructor: function () {
// alert('Preload!');
// }
// }
// },
growler: {
include: true,
id: 'growler',
Expand Down Expand Up @@ -318,6 +308,7 @@ define([
type: 'titlePane',
path: 'gis/dijit/Identify',
title: i18n.viewer.widgets.identify,
iconClass: 'fa-info-circle',
open: false,
position: 3,
options: 'config/identify'
Expand Down Expand Up @@ -409,6 +400,7 @@ define([
type: 'titlePane',
path: 'gis/dijit/Legend',
title: i18n.viewer.widgets.legend,
iconClass: 'fa-picture-o',
open: false,
position: 1,
options: {
Expand All @@ -422,6 +414,7 @@ define([
type: 'titlePane',
path: 'gis/dijit/LayerControl',
title: i18n.viewer.widgets.layerControl,
iconClass: 'fa-th-list',
open: false,
position: 0,
options: {
Expand All @@ -448,6 +441,7 @@ define([
type: 'titlePane',
path: 'gis/dijit/Bookmarks',
title: i18n.viewer.widgets.bookmarks,
iconClass: 'fa-bookmark',
open: false,
position: 2,
options: 'config/bookmarks'
Expand All @@ -459,6 +453,7 @@ define([
canFloat: true,
path: 'gis/dijit/Find',
title: i18n.viewer.widgets.find,
iconClass: 'fa-search',
open: false,
position: 3,
options: 'config/find'
Expand All @@ -470,6 +465,7 @@ define([
canFloat: true,
path: 'gis/dijit/Draw',
title: i18n.viewer.widgets.draw,
iconClass: 'fa-paint-brush',
open: false,
position: 4,
options: {
Expand All @@ -484,6 +480,7 @@ define([
canFloat: true,
path: 'gis/dijit/Measurement',
title: i18n.viewer.widgets.measure,
iconClass: 'fa-expand',
open: false,
position: 5,
options: {
Expand All @@ -500,6 +497,7 @@ define([
canFloat: true,
path: 'gis/dijit/Print',
title: i18n.viewer.widgets.print,
iconClass: 'fa-print',
open: false,
position: 6,
options: {
Expand All @@ -518,6 +516,7 @@ define([
type: 'titlePane',
path: 'gis/dijit/Directions',
title: i18n.viewer.widgets.directions,
iconClass: 'fa-map-signs',
open: false,
position: 7,
options: {
Expand All @@ -539,6 +538,7 @@ define([
type: 'titlePane',
path: 'gis/dijit/Editor',
title: i18n.viewer.widgets.editor,
iconClass: 'fa-pencil',
open: false,
position: 8,
options: {
Expand Down Expand Up @@ -568,6 +568,7 @@ define([
position: 9,
path: 'gis/dijit/StreetView',
title: i18n.viewer.widgets.streetview,
iconClass: 'fa-street-view',
paneOptions: {
resizable: true,
resizeOptions: {
Expand Down
5 changes: 5 additions & 0 deletions viewer/js/gis/dijit/FloatingTitlePane.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ define([
this.createDomNodes();
this.own(on(window, 'resize', lang.hitch(this, '_endDrag')));
}
if (this.iconClass) {
this.iconNode = domConstruct.create('span', {
'class': 'titlePaneIcon fa fa-fw ' + this.iconClass
}, this.titleNode, 'before');
}
this.own(topic.subscribe('titlePane/event', lang.hitch(this, '_updateWidgetSidebarPosition')));
this.own(aspect.after(this, 'toggle', lang.hitch(this, '_afterToggle')));
this.inherited(arguments);
Expand Down
46 changes: 30 additions & 16 deletions viewer/js/gis/dijit/Identify.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ define([
'esri/dijit/PopupTemplate',
'esri/layers/FeatureLayer',
'esri/TimeExtent',
'dojo/Deferred',
'dojo/text!./Identify/templates/Identify.html',
'dojo/i18n!./Identify/nls/resource',
'./Identify/Formatters',

'dijit/form/Form',
'dijit/form/FilteringSelect',
'xstyle/css!./Identify/css/Identify.css'
], function (declare, _WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin, MenuItem, lang, array, all, topic, query, domStyle, domClass, Moveable, Memory, IdentifyTask, IdentifyParameters, PopupTemplate, FeatureLayer, TimeExtent, IdentifyTemplate, i18n, Formatters) {
], function (declare, _WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin, MenuItem, lang, array, all, topic, query, domStyle, domClass, Moveable, Memory, IdentifyTask, IdentifyParameters, PopupTemplate, FeatureLayer, TimeExtent, Deferred, IdentifyTemplate, i18n, Formatters) {

return declare([_WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin], {
widgetsInTemplate: true,
Expand Down Expand Up @@ -133,7 +134,6 @@ define([
if (formatters.length > 0) {
layer.on('graphic-draw', lang.hitch(this, 'getFormattedFeature', layer.infoTemplate));
}
return;
}
}
}
Expand Down Expand Up @@ -203,8 +203,27 @@ define([
}
},
executeIdentifyTask: function (evt) {


var mapPoint = evt.mapPoint;
var identifyParams = this.createIdentifyParams(mapPoint);
var identifies = [];
var identifiedlayers = [];
var selectedLayer = this.getSelectedLayer();


if (!this.checkForGraphicInfoTemplate(evt)) {
return;
// return;
var layer = array.filter(this.layers, function (l) {
return l.ref.id === evt.graphic._layer.id;
})[0];
if (!layer) {
return;
}
identifiedlayers.push(layer);
var d = new Deferred();
identifies.push(d.promise);
d.resolve([{feature: evt.graphic}]);
}

this.map.infoWindow.hide();
Expand All @@ -215,23 +234,18 @@ define([
return;
}

var mapPoint = evt.mapPoint;
var identifyParams = this.createIdentifyParams(mapPoint);
var identifies = [];
var identifiedlayers = [];
var selectedLayer = this.getSelectedLayer();

array.forEach(this.layers, lang.hitch(this, function (layer) {
var layerIds = this.getLayerIds(layer, selectedLayer);
array.forEach(this.layers, lang.hitch(this, function (lyr) {
var layerIds = this.getLayerIds(lyr, selectedLayer);
if (layerIds.length > 0) {
var params = lang.clone(identifyParams);
params.layerDefinitions = layer.ref.layerDefinitions;
params.layerDefinitions = lyr.ref.layerDefinitions;
params.layerIds = layerIds;
if (layer.ref.timeInfo && layer.ref.timeInfo.timeExtent && this.map.timeExtent) {
if (lyr.ref.timeInfo && lyr.ref.timeInfo.timeExtent && this.map.timeExtent) {
params.timeExtent = new TimeExtent(this.map.timeExtent.startTime, this.map.timeExtent.endTime);
}
identifies.push(layer.identifyTask.execute(params));
identifiedlayers.push(layer);
identifies.push(lyr.identifyTask.execute(params));
identifiedlayers.push(lyr);
}
}));

Expand Down Expand Up @@ -383,7 +397,7 @@ define([
getInfoTemplate: function (layer, layerId, result) {
var popup, config;
if (result) {
layerId = result.layerId;
layerId = result.layerId || layer.layerId;
} else if (layerId === null) {
layerId = layer.layerId;
}
Expand Down Expand Up @@ -694,4 +708,4 @@ define([
}, this);
}
});
});
});
41 changes: 25 additions & 16 deletions viewer/js/viewer/_ControllerBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ define([
declare, lang, Deferred
) {
return declare(null, {

/**
* A method run before anything else, can be inherited by mixins to
* load and process the config sync or async
Expand All @@ -22,9 +23,32 @@ define([
* @return {undefined | Deferred} If the operation is async it should return
* a deferred, otherwise it should return the value of `this.inherited(arguments)`
*/
preStartup: function () {
postConfig: function () {
return this.inherited(arguments);
},
/**
* Start the application mixin chain, once the
* startupDeferred is resolved
* @return {undefined}
*/
startup: function () {

// cache the inherited
var inherited = this.getInherited(arguments);

// load config and process it
this.startupDeferred = this.executeSync([
this.loadConfig,
this.postConfig
]);

// wait for any loading to complete
this.startupDeferred.then(lang.hitch(this, function () {

// start up the mixin chain
inherited.apply(this);
}));
},
/**
* executes an array of asynchronous methods synchronously
* @param {Array<function>} methods The array of functions to execute
Expand All @@ -51,21 +75,6 @@ define([
}
return deferred;

},
startup: function () {

var inherited = this.getInherited(arguments);
this.executeSync([
this.loadConfig,
this.preStartup
]).then(lang.hitch(this, function () {
console.log(this);

// start up the mixin chain
inherited.apply(this);
}));


},

//centralized error handler
Expand Down
4 changes: 3 additions & 1 deletion viewer/js/viewer/_LayoutMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ define([
}
},
collapseButtons: {},
preStartup: function () {
postConfig: function () {
this.layoutDeferred = new Deferred();
return this.inherited(arguments);
},
Expand All @@ -76,6 +76,8 @@ define([
this.detectTouchDevices();
this.initPanes();

this.mapDeferred.then(lang.hitch(this, 'createPanes'));

// resolve the layout deferred
this.layoutDeferred.resolve();
this.inherited(arguments);
Expand Down
2 changes: 1 addition & 1 deletion viewer/js/viewer/_MapMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ define([

return declare(null, {

preStartup: function () {
postConfig: function () {
this.mapDeferred = new Deferred();
return this.inherited(arguments);
},
Expand Down
Loading

0 comments on commit 5268fd3

Please sign in to comment.