Skip to content

Commit

Permalink
Merge pull request #547 from roemhildtg/fix/fix-dojo-build-issues
Browse files Browse the repository at this point in the history
Fix dojo build issues
  • Loading branch information
DavidSpriggs authored Jul 14, 2016
2 parents f421d77 + 90ee802 commit f229b6e
Show file tree
Hide file tree
Showing 7 changed files with 361 additions and 51 deletions.
75 changes: 75 additions & 0 deletions package.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/**
* This file is referenced by the `dojoBuild` key in `package.json` and provides extra hinting specific to the Dojo
* build system about how certain files in the package need to be handled at build time. Build profiles for the
* application itself are stored in the `profiles` directory.
*/

var profile = (function () {
//only copy files matching these expressions
//this prevents them from being evaluated as amd modules
var reCopyOnly = [
/Gruntfile/,
/package/,
/app\.js/
];
//exclude from builds completely
var reMiniExclude = [
/Gruntfile/,
/package/
];
//non-amd modules
var reNonAmd = [
/plugins\/Google/
];
return {
// Resource tags are functions that provide hints to the build system about the way files should be processed.
// Each of these functions is called once for every file in the package directory. The first argument passed to
// the function is the filename of the file, and the second argument is the computed AMD module ID of the file.
resourceTags: {
// Files that contain test code and should be excluded when the `copyTests` build flag exists and is `false`.
// It is strongly recommended that the `mini` build flag be used instead of `copyTests`. Therefore, no files
// are marked with the `test` tag here.
test: function (filename, mid) {
return false;
},

// Files that should be copied as-is without being modified by the build system.
// All files in the `app/resources` directory that are not CSS files are marked as copy-only, since these files
// are typically binaries (images, etc.) and may be corrupted by the build system if it attempts to process
// them and naively assumes they are scripts.
copyOnly: function (filename, mid) {
for (var i = 0; i < reCopyOnly.length; i++) {
if (reCopyOnly[i].test(filename)) {
return true;
}
}
return (/\/(images)\//.test(mid) && !/\.css$/.test(filename)) ||
/\/node_modules\//.test(mid);
},

// Files that are AMD modules.
// All JavaScript in this package should be AMD modules if you are starting a new project. If you are copying
// any legacy scripts from an existing project, those legacy scripts should not be given the `amd` tag.
amd: function (filename, mid) {
for (var i = 0; i < reNonAmd.length; i++) {
if (reNonAmd[i].test(filename)) {
return false;
}
}
return !this.copyOnly(filename, mid) && /\.js$/.test(filename);
},

// Files that should not be copied when the `mini` build flag is set to true.
// In this case, we are excluding this package configuration file which is not necessary in a built copy of
// the application.
miniExclude: function (filename, mid) {
for (var i = 0; i < reMiniExclude.length; i++) {
if (reMiniExclude[i].test(filename)) {
return true;
}
}
return false;
}
}
};
})();
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@
"grunt-contrib-compress": "1.2.x",
"proxypage": "*"
},
"engine": "node >= 4"
}
"engine": "node >= 4",
"dojoBuild": "package.js"
}
5 changes: 4 additions & 1 deletion viewer/js/config/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
name: 'xstyle',
main: 'css',
location: 'https://cdn.rawgit.com/kriszyp/xstyle/v0.3.2'
}, {
name: 'proj4js',
location: '//cdnjs.cloudflare.com/ajax/libs/proj4js/2.3.12'
}
]
};
Expand Down Expand Up @@ -61,4 +64,4 @@
]))();
controller.startup();
});
})();
})();
19 changes: 11 additions & 8 deletions viewer/js/gis/dijit/Directions.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ define([
'esri/geometry/Point',
'esri/SpatialReference',
'dojo/topic',
'dojo/i18n!./Directions/nls/resource'
], function (declare, _WidgetBase, _TemplatedMixin, Directions, template, lang, Menu, MenuItem, PopupMenuItem, MenuSeparator, Point, SpatialReference, topic, i18n) {
'dojo/i18n!./Directions/nls/resource',
'dojo/dom-style'
], function (declare, _WidgetBase, _TemplatedMixin, Directions, template, lang, Menu, MenuItem, PopupMenuItem, MenuSeparator, Point, SpatialReference, topic, i18n, domStyle) {

return declare([_WidgetBase, _TemplatedMixin], {
templateString: template,
Expand All @@ -27,12 +28,14 @@ define([

//temp fix for 3.12 and 3.13 map click button.
if (this.directions._activateButton) {
this.directions._activateButton.style.display = 'none';
domStyle.set(this.directions._activateButton, 'display', 'none');
} else if (this.directions._activateButtonNode) {
this.directions._activateButtonNode.style.display = 'none';
this.directions._addDestinationNode.style.float = 'inherit';
this.directions._optionsButtonNode.style.float = 'inherit';
this.directions._optionsButtonNode.style.marginRight = '5px';
domStyle.set(this.directions._activateButtonNode, 'display', 'none');
domStyle.set(this.directions._addDestinationNode, 'float', 'inherit');
domStyle.set(this.directions._optionsButtonNode, {
'float': 'inherit',
marginRight: '5px'
});
}

if (this.mapRightClickMenu) {
Expand Down Expand Up @@ -130,4 +133,4 @@ define([
});
}
});
});
});
4 changes: 2 additions & 2 deletions viewer/js/gis/dijit/MapInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ define([
'dojo/dom-style',
'dojo/number',
'dojo/topic',
'//cdnjs.cloudflare.com/ajax/libs/proj4js/2.3.12/proj4.js',
'proj4js/proj4',
'xstyle/css!./MapInfo/css/MapInfo.css'
], function (
declare,
Expand Down Expand Up @@ -217,4 +217,4 @@ define([
return deg + '&deg;' + minIntTxt + '\'' + secTxt + '"&nbsp;' + dir;
}
});
});
});
83 changes: 45 additions & 38 deletions viewer/js/gis/dijit/StreetView.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/*global google */
define([
'dojo/_base/declare',
'dijit/_WidgetBase',
Expand All @@ -17,31 +16,21 @@ define([
'esri/geometry/Point',
'esri/SpatialReference',
'dijit/MenuItem',
'//cdnjs.cloudflare.com/ajax/libs/proj4js/2.3.12/proj4.js',
'proj4js/proj4',
'dojo/i18n!./StreetView/nls/resource',

'gis/plugins/Google',
'dijit/form/ToggleButton',
'xstyle/css!./StreetView/css/StreetView.css',
'gis/plugins/async!//maps.google.com/maps/api/js?v=3'
], function (declare, _WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin, lang, aspect, topic, GraphicsLayer, Graphic, SimpleRenderer, template, PictureMarkerSymbol, domStyle, domGeom, Point, SpatialReference, MenuItem, proj4, i18n) {

'xstyle/css!./StreetView/css/StreetView.css'
], function (declare, _WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin, lang, aspect, topic, GraphicsLayer, Graphic, SimpleRenderer, template, PictureMarkerSymbol, domStyle, domGeom, Point, SpatialReference, MenuItem, proj4, i18n, Google) {
//cache google so
var google;
return declare([_WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin], {
widgetsInTemplate: true,
templateString: template,
i18n: i18n,
mapClickMode: null,

panoOptions: {
addressControlOptions: {
position: google.maps.ControlPosition.TOP_RIGHT
},
linksControl: false,
panControl: false,
zoomControlOptions: {
style: google.maps.ZoomControlStyle.SMALL
},
enableCloseButton: false
},
panoOptions: null,

// in case this changes some day
proj4BaseURL: 'http://spatialreference.org/',
Expand All @@ -57,29 +46,47 @@ define([

postCreate: function () {
this.inherited(arguments);
this.createGraphicsLayer();
this.map.on('click', lang.hitch(this, 'getStreetView'));
//load the google api asynchronously
Google.load(lang.hitch(this, function (g) {
//store a reference to google
google = g;

this.own(topic.subscribe('mapClickMode/currentSet', lang.hitch(this, 'setMapClickMode')));
//init our panoOptions since they depend on google
this.panoOptions = {
addressControlOptions: {
position: google.maps.ControlPosition.TOP_RIGHT
},
linksControl: false,
panControl: false,
zoomControlOptions: {
style: google.maps.ZoomControlStyle.SMALL
},
enableCloseButton: false
};
this.createGraphicsLayer();
this.map.on('click', lang.hitch(this, 'getStreetView'));

if (this.parentWidget) {
if (this.parentWidget.toggleable) {
this.own(aspect.after(this.parentWidget, 'toggle', lang.hitch(this, function () {
this.onLayoutChange(this.parentWidget.open);
})));
this.own(topic.subscribe('mapClickMode/currentSet', lang.hitch(this, 'setMapClickMode')));

if (this.parentWidget) {
if (this.parentWidget.toggleable) {
this.own(aspect.after(this.parentWidget, 'toggle', lang.hitch(this, function () {
this.onLayoutChange(this.parentWidget.open);
})));
}
this.own(aspect.after(this.parentWidget, 'resize', lang.hitch(this, 'resize')));
this.own(topic.subscribe(this.parentWidget.id + '/resize/resize', lang.hitch(this, 'resize')));
}
this.own(aspect.after(this.parentWidget, 'resize', lang.hitch(this, 'resize')));
this.own(topic.subscribe(this.parentWidget.id + '/resize/resize', lang.hitch(this, 'resize')));
}

// spatialreference.org uses the old
// Proj4js style so we need an alias
// https://github.com/proj4js/proj4js/issues/23
window.Proj4js = proj4;
// spatialreference.org uses the old
// Proj4js style so we need an alias
// https://github.com/proj4js/proj4js/issues/23
window.Proj4js = proj4;

if (this.mapRightClickMenu) {
this.addRightClickMenu();
}
if (this.mapRightClickMenu) {
this.addRightClickMenu();
}
}));
},
createGraphicsLayer: function () {
this.pointSymbol = new PictureMarkerSymbol(require.toUrl('gis/dijit/StreetView/images/blueArrow.png'), 30, 30);
Expand Down Expand Up @@ -129,7 +136,7 @@ define([
} else {
this.connectMapClick();
}
//get map click, set up listener in post create
//get map click, set up listener in post create
},
disconnectMapClick: function () {
this.streetViewButtonDijit.set('checked', true);
Expand Down Expand Up @@ -302,4 +309,4 @@ define([
this.mapClickMode = mode;
}
});
});
});
Loading

0 comments on commit f229b6e

Please sign in to comment.