From e8ef1830c8aa1a8de8f15ee6028f8e8e20a034aa Mon Sep 17 00:00:00 2001 From: roemhildtg Date: Tue, 19 Apr 2016 15:21:00 -0500 Subject: [PATCH 01/19] Move proj4 to the app config to allow developers to use offline version of proj4. --- viewer/js/config/app.js | 4 +++- viewer/js/gis/dijit/MapInfo.js | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/viewer/js/config/app.js b/viewer/js/config/app.js index e8084d7c7..7a4a11cc4 100644 --- a/viewer/js/config/app.js +++ b/viewer/js/config/app.js @@ -15,6 +15,8 @@ }, { name: 'put-selector', main: 'put', + name: 'proj4js', + location: '//cdnjs.cloudflare.com/ajax/libs/proj4js/2.3.12' location: 'https://cdn.rawgit.com/kriszyp/put-selector/v0.3.6' }, { name: 'xstyle', @@ -61,4 +63,4 @@ ]))(); controller.startup(); }); -})(); \ No newline at end of file +})(); diff --git a/viewer/js/gis/dijit/MapInfo.js b/viewer/js/gis/dijit/MapInfo.js index 07c238bea..6f674e665 100644 --- a/viewer/js/gis/dijit/MapInfo.js +++ b/viewer/js/gis/dijit/MapInfo.js @@ -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, @@ -217,4 +217,4 @@ define([ return deg + '°' + minIntTxt + '\'' + secTxt + '" ' + dir; } }); -}); \ No newline at end of file +}); From c5eeb40796cd0e10f65fc17307c6646f16d5d38f Mon Sep 17 00:00:00 2001 From: roemhildtg Date: Tue, 19 Apr 2016 15:26:53 -0500 Subject: [PATCH 02/19] Remove proj4 cdn path from streetview --- viewer/js/gis/dijit/StreetView.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/viewer/js/gis/dijit/StreetView.js b/viewer/js/gis/dijit/StreetView.js index 057332415..51cb49719 100644 --- a/viewer/js/gis/dijit/StreetView.js +++ b/viewer/js/gis/dijit/StreetView.js @@ -17,9 +17,8 @@ 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', - 'dijit/form/ToggleButton', 'xstyle/css!./StreetView/css/StreetView.css', 'gis/plugins/async!//maps.google.com/maps/api/js?v=3' @@ -302,4 +301,4 @@ define([ this.mapClickMode = mode; } }); -}); \ No newline at end of file +}); From 35e8d8db7f5c51be1aed5ef90cb7956d6a5cb47f Mon Sep 17 00:00:00 2001 From: roemhildtg Date: Wed, 20 Apr 2016 07:54:41 -0500 Subject: [PATCH 03/19] Add a package.js build descriptor file --- package.js | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 package.js diff --git a/package.js b/package.js new file mode 100644 index 000000000..e24076f02 --- /dev/null +++ b/package.js @@ -0,0 +1,43 @@ +/** + * 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 = { + // 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) { + return (/^app\/resources\//.test(mid) && !/\.css$/.test(filename)); + }, + + // 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) { + 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) { + return mid in { + 'cmv/package': 1 + }; + } + } +}; From becb23c4accd7f4481924b9505e4c99bc370c06c Mon Sep 17 00:00:00 2001 From: roemhildtg Date: Thu, 21 Apr 2016 11:17:19 -0500 Subject: [PATCH 04/19] Switch to the bower version of google maps loader. --- viewer/js/gis/dijit/StreetView.js | 77 ++++++----- viewer/js/gis/plugins/Google.js | 219 ++++++++++++++++++++++++++++++ 2 files changed, 262 insertions(+), 34 deletions(-) create mode 100644 viewer/js/gis/plugins/Google.js diff --git a/viewer/js/gis/dijit/StreetView.js b/viewer/js/gis/dijit/StreetView.js index 51cb49719..403b526e2 100644 --- a/viewer/js/gis/dijit/StreetView.js +++ b/viewer/js/gis/dijit/StreetView.js @@ -19,28 +19,19 @@ define([ 'dijit/MenuItem', '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' + // '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, Google) { + 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/', @@ -56,29 +47,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(aspect.after(this.parentWidget, 'resize', lang.hitch(this, 'resize'))); - this.own(topic.subscribe(this.parentWidget.id + '/resize/resize', lang.hitch(this, 'resize'))); - } + this.own(topic.subscribe('mapClickMode/currentSet', lang.hitch(this, 'setMapClickMode'))); - // spatialreference.org uses the old - // Proj4js style so we need an alias - // https://github.com/proj4js/proj4js/issues/23 - window.Proj4js = proj4; + 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'))); + } - if (this.mapRightClickMenu) { - this.addRightClickMenu(); - } + // 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(); + } + })); }, createGraphicsLayer: function () { this.pointSymbol = new PictureMarkerSymbol(require.toUrl('gis/dijit/StreetView/images/blueArrow.png'), 30, 30); diff --git a/viewer/js/gis/plugins/Google.js b/viewer/js/gis/plugins/Google.js new file mode 100644 index 000000000..3d9435c82 --- /dev/null +++ b/viewer/js/gis/plugins/Google.js @@ -0,0 +1,219 @@ +(function(root, factory) { + + if (root === null) { + throw new Error('Google-maps package can be used only in browser'); + } + + if (typeof define === 'function' && define.amd) { + define(factory); + } else if (typeof exports === 'object') { + module.exports = factory(); + } else { + root.GoogleMapsLoader = factory(); + } + +})(typeof window !== 'undefined' ? window : null, function() { + + + 'use strict'; + + + var googleVersion = '3.18'; + + var script = null; + + var google = null; + + var loading = false; + + var callbacks = []; + + var onLoadEvents = []; + + var originalCreateLoaderMethod = null; + + + var GoogleMapsLoader = {}; + + + GoogleMapsLoader.URL = 'https://maps.googleapis.com/maps/api/js'; + + GoogleMapsLoader.KEY = null; + + GoogleMapsLoader.LIBRARIES = []; + + GoogleMapsLoader.CLIENT = null; + + GoogleMapsLoader.CHANNEL = null; + + GoogleMapsLoader.LANGUAGE = null; + + GoogleMapsLoader.REGION = null; + + GoogleMapsLoader.VERSION = googleVersion; + + GoogleMapsLoader.WINDOW_CALLBACK_NAME = '__google_maps_api_provider_initializator__'; + + + GoogleMapsLoader._googleMockApiObject = {}; + + + GoogleMapsLoader.load = function(fn) { + if (google === null) { + if (loading === true) { + if (fn) { + callbacks.push(fn); + } + } else { + loading = true; + + window[GoogleMapsLoader.WINDOW_CALLBACK_NAME] = function() { + ready(fn); + }; + + GoogleMapsLoader.createLoader(); + } + } else if (fn) { + fn(google); + } + }; + + + GoogleMapsLoader.createLoader = function() { + script = document.createElement('script'); + script.type = 'text/javascript'; + script.src = GoogleMapsLoader.createUrl(); + + document.body.appendChild(script); + }; + + + GoogleMapsLoader.isLoaded = function() { + return google !== null; + }; + + + GoogleMapsLoader.createUrl = function() { + var url = GoogleMapsLoader.URL; + + url += '?callback=' + GoogleMapsLoader.WINDOW_CALLBACK_NAME; + + if (GoogleMapsLoader.KEY) { + url += '&key=' + GoogleMapsLoader.KEY; + } + + if (GoogleMapsLoader.LIBRARIES.length > 0) { + url += '&libraries=' + GoogleMapsLoader.LIBRARIES.join(','); + } + + if (GoogleMapsLoader.CLIENT) { + url += '&client=' + GoogleMapsLoader.CLIENT + '&v=' + GoogleMapsLoader.VERSION; + } + + if (GoogleMapsLoader.CHANNEL) { + url += '&channel=' + GoogleMapsLoader.CHANNEL; + } + + if (GoogleMapsLoader.LANGUAGE) { + url += '&language=' + GoogleMapsLoader.LANGUAGE; + } + + if (GoogleMapsLoader.REGION) { + url += '®ion=' + GoogleMapsLoader.REGION; + } + + return url; + }; + + + GoogleMapsLoader.release = function(fn) { + var release = function() { + GoogleMapsLoader.KEY = null; + GoogleMapsLoader.LIBRARIES = []; + GoogleMapsLoader.CLIENT = null; + GoogleMapsLoader.CHANNEL = null; + GoogleMapsLoader.LANGUAGE = null; + GoogleMapsLoader.REGION = null; + GoogleMapsLoader.VERSION = googleVersion; + + google = null; + loading = false; + callbacks = []; + onLoadEvents = []; + + if (typeof window.google !== 'undefined') { + delete window.google; + } + + if (typeof window[GoogleMapsLoader.WINDOW_CALLBACK_NAME] !== 'undefined') { + delete window[GoogleMapsLoader.WINDOW_CALLBACK_NAME]; + } + + if (originalCreateLoaderMethod !== null) { + GoogleMapsLoader.createLoader = originalCreateLoaderMethod; + originalCreateLoaderMethod = null; + } + + if (script !== null) { + script.parentElement.removeChild(script); + script = null; + } + + if (fn) { + fn(); + } + }; + + if (loading) { + GoogleMapsLoader.load(function() { + release(); + }); + } else { + release(); + } + }; + + + GoogleMapsLoader.onLoad = function(fn) { + onLoadEvents.push(fn); + }; + + + GoogleMapsLoader.makeMock = function() { + originalCreateLoaderMethod = GoogleMapsLoader.createLoader; + + GoogleMapsLoader.createLoader = function() { + window.google = GoogleMapsLoader._googleMockApiObject; + window[GoogleMapsLoader.WINDOW_CALLBACK_NAME](); + }; + }; + + + var ready = function(fn) { + var i; + + loading = false; + + if (google === null) { + google = window.google; + } + + for (i = 0; i < onLoadEvents.length; i++) { + onLoadEvents[i](google); + } + + if (fn) { + fn(google); + } + + for (i = 0; i < callbacks.length; i++) { + callbacks[i](google); + } + + callbacks = []; + }; + + + return GoogleMapsLoader; + +}); From ec2b69105ce55ba8cbffa7a33efa17769dff157d Mon Sep 17 00:00:00 2001 From: roemhildtg Date: Thu, 21 Apr 2016 11:17:48 -0500 Subject: [PATCH 05/19] Use quotes around reserved property 'float' --- viewer/js/gis/dijit/Directions.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/viewer/js/gis/dijit/Directions.js b/viewer/js/gis/dijit/Directions.js index 524c9cf37..9ae0f36fe 100644 --- a/viewer/js/gis/dijit/Directions.js +++ b/viewer/js/gis/dijit/Directions.js @@ -30,8 +30,8 @@ define([ this.directions._activateButton.style.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._addDestinationNode.style['float'] = 'inherit'; + this.directions._optionsButtonNode.style['float'] = 'inherit'; this.directions._optionsButtonNode.style.marginRight = '5px'; } @@ -130,4 +130,4 @@ define([ }); } }); -}); \ No newline at end of file +}); From 2e74d2174019e919c26b95758001b54b6d4a985c Mon Sep 17 00:00:00 2001 From: roemhildtg Date: Thu, 21 Apr 2016 13:00:34 -0500 Subject: [PATCH 06/19] Update package descriptor to only copy the image files --- package.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.js b/package.js index e24076f02..765d02464 100644 --- a/package.js +++ b/package.js @@ -21,7 +21,7 @@ var profile = { // 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) { - return (/^app\/resources\//.test(mid) && !/\.css$/.test(filename)); + return (/^cmv\/(images)\//.test(mid) && !/\.css$/.test(filename)); }, // Files that are AMD modules. From 683f5debe5ca39e4fbc4c3e21114d59990dcb9e9 Mon Sep 17 00:00:00 2001 From: roemhildtg Date: Thu, 21 Apr 2016 13:17:31 -0500 Subject: [PATCH 07/19] Remove old plugin import --- viewer/js/gis/dijit/StreetView.js | 1 - 1 file changed, 1 deletion(-) diff --git a/viewer/js/gis/dijit/StreetView.js b/viewer/js/gis/dijit/StreetView.js index 403b526e2..9edce2e4d 100644 --- a/viewer/js/gis/dijit/StreetView.js +++ b/viewer/js/gis/dijit/StreetView.js @@ -22,7 +22,6 @@ define([ '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, Google) { var google; return declare([_WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin], { From 66a73bdd516b87b02335984f1e0964e1026bf6f5 Mon Sep 17 00:00:00 2001 From: roemhildtg Date: Mon, 25 Apr 2016 08:44:57 -0500 Subject: [PATCH 08/19] Fix indentation --- viewer/js/config/app.js | 4 +- viewer/js/gis/dijit/StreetView.js | 74 +++++++++++++++---------------- 2 files changed, 39 insertions(+), 39 deletions(-) diff --git a/viewer/js/config/app.js b/viewer/js/config/app.js index 7a4a11cc4..f8183b401 100644 --- a/viewer/js/config/app.js +++ b/viewer/js/config/app.js @@ -15,8 +15,8 @@ }, { name: 'put-selector', main: 'put', - name: 'proj4js', - location: '//cdnjs.cloudflare.com/ajax/libs/proj4js/2.3.12' + name: 'proj4js', + location: '//cdnjs.cloudflare.com/ajax/libs/proj4js/2.3.12' location: 'https://cdn.rawgit.com/kriszyp/put-selector/v0.3.6' }, { name: 'xstyle', diff --git a/viewer/js/gis/dijit/StreetView.js b/viewer/js/gis/dijit/StreetView.js index 9edce2e4d..9dba0c8ec 100644 --- a/viewer/js/gis/dijit/StreetView.js +++ b/viewer/js/gis/dijit/StreetView.js @@ -1,4 +1,3 @@ -/*global google */ define([ 'dojo/_base/declare', 'dijit/_WidgetBase', @@ -23,6 +22,7 @@ define([ 'dijit/form/ToggleButton', '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, @@ -47,46 +47,46 @@ define([ postCreate: function () { this.inherited(arguments); //load the google api asynchronously - Google.load(lang.hitch(this, function(g){ - //store a reference to google - google = g; + Google.load(lang.hitch(this, function (g) { + //store a reference to google + google = g; - //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')); + //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')); - this.own(topic.subscribe('mapClickMode/currentSet', lang.hitch(this, 'setMapClickMode'))); + 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'))); - } + 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'))); + } - // 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); @@ -136,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); From 580347d26f09472b67b88b84f3b29ed2df0b8745 Mon Sep 17 00:00:00 2001 From: roemhildtg Date: Mon, 25 Apr 2016 08:46:02 -0500 Subject: [PATCH 09/19] Disable eslint on vendor google-maps loader --- viewer/js/gis/plugins/Google.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/viewer/js/gis/plugins/Google.js b/viewer/js/gis/plugins/Google.js index 3d9435c82..c6ebf3190 100644 --- a/viewer/js/gis/plugins/Google.js +++ b/viewer/js/gis/plugins/Google.js @@ -1,3 +1,5 @@ +//https://www.npmjs.com/package/google-maps +/* eslint-disable */ (function(root, factory) { if (root === null) { From 6a83281e2a2bcd96814635fa11971e82f14ae0d4 Mon Sep 17 00:00:00 2001 From: roemhildtg Date: Mon, 25 Apr 2016 08:46:27 -0500 Subject: [PATCH 10/19] Switch style setter to use dojo/dom-style --- viewer/js/gis/dijit/Directions.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/viewer/js/gis/dijit/Directions.js b/viewer/js/gis/dijit/Directions.js index 9ae0f36fe..88fcbac5d 100644 --- a/viewer/js/gis/dijit/Directions.js +++ b/viewer/js/gis/dijit/Directions.js @@ -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, @@ -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) { From 8ced6d28d7e25d344066091e083c32ee4cc90785 Mon Sep 17 00:00:00 2001 From: roemhildtg Date: Fri, 29 Apr 2016 12:45:50 -0500 Subject: [PATCH 11/19] Exclude node_modules from amd search --- package.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.js b/package.js index 765d02464..61756af6e 100644 --- a/package.js +++ b/package.js @@ -21,7 +21,8 @@ var profile = { // 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) { - return (/^cmv\/(images)\//.test(mid) && !/\.css$/.test(filename)); + return (/^cmv\/(images)\//.test(mid) && !/\.css$/.test(filename)) || + /\/node_modules\//.test(mid); }, // Files that are AMD modules. From 0e1ba877217266e7e51c7f9dea6db32abaa28d39 Mon Sep 17 00:00:00 2001 From: roemhildtg Date: Fri, 29 Apr 2016 13:17:45 -0500 Subject: [PATCH 12/19] Tell dojo to use the package.js build file --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 58ad7b674..5e060cb08 100644 --- a/package.json +++ b/package.json @@ -25,5 +25,6 @@ "grunt-contrib-compress": "1.2.x", "proxypage": "*" }, - "engine": "node >= 4" -} \ No newline at end of file + "engine": "node >= 4", + "dojoBuild": "package.js" +} From 1cf77500aaa9539f2fff87968a11ad26cc2285d1 Mon Sep 17 00:00:00 2001 From: roemhildtg Date: Fri, 29 Apr 2016 13:18:18 -0500 Subject: [PATCH 13/19] Exclude node_modules and other non-amd files from being tagged as amd --- package.js | 75 +++++++++++++++++++++++++++++------------------------- 1 file changed, 40 insertions(+), 35 deletions(-) diff --git a/package.js b/package.js index 61756af6e..03a9a6abf 100644 --- a/package.js +++ b/package.js @@ -4,41 +4,46 @@ * application itself are stored in the `profiles` directory. */ -var profile = { - // 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; - }, +var profile = (function() { + var excludes = { + 'Gruntfile': 1, + 'package': 1 + }; + 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) { - return (/^cmv\/(images)\//.test(mid) && !/\.css$/.test(filename)) || - /\/node_modules\//.test(mid); - }, + // 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) { + return (/\/(images)\//.test(mid) && !/\.css$/.test(filename)) || + /\/node_modules\//.test(mid) || + filename in excludes; + }, - // 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) { - return !this.copyOnly(filename, mid) && /\.js$/.test(filename); - }, + // 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) { + 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) { - return mid in { - 'cmv/package': 1 - }; - } - } -}; + // 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) { + return filename in excludes; + } + } + }; +})(); From 059b3aca789102c00755a2a17290626725f5ad87 Mon Sep 17 00:00:00 2001 From: roemhildtg Date: Mon, 2 May 2016 10:35:37 -0500 Subject: [PATCH 14/19] Remove troublesome error from Google Loader --- viewer/js/gis/plugins/Google.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/viewer/js/gis/plugins/Google.js b/viewer/js/gis/plugins/Google.js index c6ebf3190..4155ef7c4 100644 --- a/viewer/js/gis/plugins/Google.js +++ b/viewer/js/gis/plugins/Google.js @@ -3,7 +3,7 @@ (function(root, factory) { if (root === null) { - throw new Error('Google-maps package can be used only in browser'); + //throw new Error('Google-maps package can be used only in browser'); } if (typeof define === 'function' && define.amd) { From a62df6af544006027aca1d6cf09a8712f66a25e4 Mon Sep 17 00:00:00 2001 From: roemhildtg Date: Mon, 2 May 2016 12:27:56 -0500 Subject: [PATCH 15/19] Add more rules to the package.js --- package.js | 39 ++++++++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/package.js b/package.js index 03a9a6abf..2e973bdb7 100644 --- a/package.js +++ b/package.js @@ -5,10 +5,21 @@ */ var profile = (function() { - var excludes = { - 'Gruntfile': 1, - 'package': 1 - }; + //only copy files matching these expressions + //this prevents them from being evaluated as amd modules + var reCopyOnly = [ + /Gruntfile/, + /package/ + ]; + //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 @@ -26,15 +37,24 @@ var profile = (function() { // 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) || - filename in excludes; + /\/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); }, @@ -42,7 +62,12 @@ var profile = (function() { // 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) { - return filename in excludes; + for (var i = 0; i < reMiniExclude.length; i++) { + if (reMiniExclude[i].test(filename)) { + return true; + } + } + return false; } } }; From 95ed51ceb4bcdac23e8df4edcd64bcf105fb6be8 Mon Sep 17 00:00:00 2001 From: roemhildtg Date: Thu, 12 May 2016 11:00:29 -0500 Subject: [PATCH 16/19] Makes config/app dojo-build friendly --- viewer/js/config/app.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/viewer/js/config/app.js b/viewer/js/config/app.js index f8183b401..aca56e23c 100644 --- a/viewer/js/config/app.js +++ b/viewer/js/config/app.js @@ -1,6 +1,7 @@ -(function () { - var path = location.pathname.replace(/[^\/]+$/, ''); - window.dojoConfig = { +define(['dojo/_base/window'], function(window){ + + var path = window.global.location.pathname.replace(/[^\/]+$/, ''); + var dojoConfig = window.global.dojoConfig = { async: true, packages: [ { @@ -26,7 +27,7 @@ ] }; - require(window.dojoConfig, [ + require(dojoConfig, [ 'dojo/_base/declare', // minimal Base Controller @@ -63,4 +64,6 @@ ]))(); controller.startup(); }); -})(); + //we have to return something + return dojoConfig; +}); From 1e916e6c17a2c22db3e4b9187e1fc0e9daecc30a Mon Sep 17 00:00:00 2001 From: roemhildtg Date: Thu, 12 May 2016 11:14:35 -0500 Subject: [PATCH 17/19] Fix proj4js path merge --- viewer/js/config/app.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/viewer/js/config/app.js b/viewer/js/config/app.js index aca56e23c..22de0cc3a 100644 --- a/viewer/js/config/app.js +++ b/viewer/js/config/app.js @@ -13,11 +13,12 @@ define(['dojo/_base/window'], function(window){ }, { name: 'config', location: path + 'js/config' + }, { + name: 'proj4js', + location: '//cdnjs.cloudflare.com/ajax/libs/proj4js/2.3.12' }, { name: 'put-selector', main: 'put', - name: 'proj4js', - location: '//cdnjs.cloudflare.com/ajax/libs/proj4js/2.3.12' location: 'https://cdn.rawgit.com/kriszyp/put-selector/v0.3.6' }, { name: 'xstyle', From 3f89efc35e5afcf21301dc8b611b9af658831a14 Mon Sep 17 00:00:00 2001 From: roemhildtg Date: Thu, 12 May 2016 11:57:56 -0500 Subject: [PATCH 18/19] Fix eslint errors (again) --- package.js | 56 ++++++++++++++++++++--------------------- viewer/js/config/app.js | 6 ++--- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/package.js b/package.js index 2e973bdb7..3aed5bf83 100644 --- a/package.js +++ b/package.js @@ -4,70 +4,70 @@ * application itself are stored in the `profiles` directory. */ -var profile = (function() { +var profile = (function () { //only copy files matching these expressions //this prevents them from being evaluated as amd modules - var reCopyOnly = [ - /Gruntfile/, - /package/ + var reCopyOnly = [ + /Gruntfile/, + /package/ ]; //exclude from builds completely - var reMiniExclude = [ - /Gruntfile/, - /package/ + var reMiniExclude = [ + /Gruntfile/, + /package/ ]; //non-amd modules - var reNonAmd = [ - /plugins\/Google/ + var reNonAmd = [ + /plugins\/Google/ ]; - return { + 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: { + 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; + 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; + 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)) || + 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; + 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); + 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; + miniExclude: function (filename, mid) { + for (var i = 0; i < reMiniExclude.length; i++) { + if (reMiniExclude[i].test(filename)) { + return true; } } - return false; + return false; } } }; diff --git a/viewer/js/config/app.js b/viewer/js/config/app.js index 22de0cc3a..62171b609 100644 --- a/viewer/js/config/app.js +++ b/viewer/js/config/app.js @@ -1,4 +1,4 @@ -define(['dojo/_base/window'], function(window){ +define(['dojo/_base/window'], function (window) { var path = window.global.location.pathname.replace(/[^\/]+$/, ''); var dojoConfig = window.global.dojoConfig = { @@ -14,8 +14,8 @@ define(['dojo/_base/window'], function(window){ name: 'config', location: path + 'js/config' }, { - name: 'proj4js', - location: '//cdnjs.cloudflare.com/ajax/libs/proj4js/2.3.12' + name: 'proj4js', + location: '//cdnjs.cloudflare.com/ajax/libs/proj4js/2.3.12' }, { name: 'put-selector', main: 'put', From 0e5224f739bee6f8c6c591d98591c156dd382823 Mon Sep 17 00:00:00 2001 From: roemhildtg Date: Thu, 12 May 2016 15:17:59 -0500 Subject: [PATCH 19/19] Revert app.js back to cmv default and ignore app.js via the profile. --- package.js | 67 +++++++++++++++++++++-------------------- viewer/js/config/app.js | 19 +++++------- 2 files changed, 42 insertions(+), 44 deletions(-) diff --git a/package.js b/package.js index 3aed5bf83..ca310ab6a 100644 --- a/package.js +++ b/package.js @@ -8,67 +8,68 @@ var profile = (function () { //only copy files matching these expressions //this prevents them from being evaluated as amd modules var reCopyOnly = [ - /Gruntfile/, - /package/ - ]; + /Gruntfile/, + /package/, + /app\.js/ + ]; //exclude from builds completely - var reMiniExclude = [ - /Gruntfile/, - /package/ + var reMiniExclude = [ + /Gruntfile/, + /package/ ]; //non-amd modules var reNonAmd = [ - /plugins\/Google/ - ]; + /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: { + 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; - }, + 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; + 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)) || + 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; + 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); - }, + 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; + miniExclude: function (filename, mid) { + for (var i = 0; i < reMiniExclude.length; i++) { + if (reMiniExclude[i].test(filename)) { + return true; } } - return false; + return false; + } } - } - }; + }; })(); diff --git a/viewer/js/config/app.js b/viewer/js/config/app.js index 62171b609..b2b71c050 100644 --- a/viewer/js/config/app.js +++ b/viewer/js/config/app.js @@ -1,7 +1,6 @@ -define(['dojo/_base/window'], function (window) { - - var path = window.global.location.pathname.replace(/[^\/]+$/, ''); - var dojoConfig = window.global.dojoConfig = { +(function () { + var path = location.pathname.replace(/[^\/]+$/, ''); + window.dojoConfig = { async: true, packages: [ { @@ -13,9 +12,6 @@ define(['dojo/_base/window'], function (window) { }, { name: 'config', location: path + 'js/config' - }, { - name: 'proj4js', - location: '//cdnjs.cloudflare.com/ajax/libs/proj4js/2.3.12' }, { name: 'put-selector', main: 'put', @@ -24,11 +20,14 @@ define(['dojo/_base/window'], function (window) { 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' } ] }; - require(dojoConfig, [ + require(window.dojoConfig, [ 'dojo/_base/declare', // minimal Base Controller @@ -65,6 +64,4 @@ define(['dojo/_base/window'], function (window) { ]))(); controller.startup(); }); - //we have to return something - return dojoConfig; -}); +})();