Reusable Accessible Mapping Platform

API Docs for: 5.3.1
Show:

File: src/js/RAMP/RAMP-starter.js

  1. /*global location, $, document */
  2.  
  3. /**
  4. *
  5. *
  6. * @module RAMP
  7. */
  8.  
  9. /**
  10. * RAMPStarter class.
  11. * Performs initial configuration of the dojo config object specifying path to the RAMP modules, detecting locale, and loading the {{#crossLink "Bootstrapper"}}{{/crossLink}} module.
  12. * pipe the locale to dojo.
  13. *
  14. * @class RAMPStarter
  15. * @static
  16. */
  17.  
  18. //required to get draw bar to show in French
  19. var RAMP,
  20. jsFolderPath = "js/",
  21. pathname = location.pathname.replace(/\/[^/]+$/, "") + "/",
  22. jsPrefix = pathname + jsFolderPath,
  23. htmlNode = $("html"),
  24. dojoConfig;
  25.  
  26. /**
  27. * RAMP global class.
  28. * A general globally available class to hold any RAMP global data. Currently houses any plugins which are not loaded via AMD.
  29. *
  30. * @class RAMP
  31. */
  32. RAMP = {
  33. /**
  34. * Contains a URL that points to the application configuration (JSON format) if it's hosted on a web service.
  35. * This is not required if the application has a JSON config file in the website's folder
  36. * @property configServiceURL
  37. * @type String
  38. */
  39. configServiceURL: "http://sncr01wbingsdv1.ncr.int.ec.gc.ca:8000/v1/",
  40. // FIXME move the config service URL out of this file since it is now minified and appended to lib.js in the build
  41.  
  42. /**
  43. * The RAMP application config, it should be treated as read only by all modules other than globalStorage and bootstrapper
  44. *
  45. * @property config
  46. * @type Object
  47. */
  48. config: {},
  49.  
  50. /**
  51. * A registry of plugins for RAMP code to reference, these should be loaded and registered by bootstrapper.js
  52. *
  53. * @property plugins
  54. * @type Object
  55. */
  56. plugins: {
  57. featureInfoParser: {},
  58. projectionLookup: {}
  59. },
  60.  
  61. /**
  62. * A temporary solution to state management. Will be changed
  63. *
  64. * @property state
  65. * @type Object
  66. */
  67. state: {
  68. ui: {
  69. sidePanelOpened: true,
  70. fullscreen: false,
  71. wmsQuery: true
  72. }
  73. },
  74.  
  75. /**
  76. * Store global flags. Should only contain boolean entries.
  77. *
  78. * @property flags
  79. * @type Object
  80. */
  81. flags: {},
  82.  
  83. /**
  84. * Scripts to be loaded after dojo config is prepared. Loaded in order (works around an IE9 issue).
  85. *
  86. * @property scripts
  87. * @type array
  88. */
  89. scripts: ['http://js.arcgis.com/3.13/', jsPrefix + 'lib/wet-boew/js/wet-boew.js', jsPrefix + 'RAMP/bootstrapper.js']
  90. };
  91.  
  92. var importScript = (function (oHead) {
  93. 'use strict';
  94.  
  95. function loadError (oError) {
  96. throw new URIError("The script " + oError.target.src + " is not accessible.");
  97. }
  98.  
  99. return function (sSrc, fOnload) {
  100. var oScript = document.createElement("script");
  101. oScript.type = "text\/javascript";
  102. oScript.onerror = loadError;
  103. if (fOnload) { oScript.onload = fOnload; }
  104. oHead.appendChild(oScript);
  105. oScript.src = sSrc;
  106. };
  107.  
  108. })(document.head || document.getElementsByTagName("head")[0]);
  109.  
  110. dojoConfig = {
  111. parseOnLoad: false,
  112. locale: htmlNode.attr("lang"),
  113. async: true,
  114. packages: [
  115. {
  116. name: "ramp",
  117. location: jsPrefix + "RAMP/Modules"
  118. },
  119. {
  120. name: "utils",
  121. location: jsPrefix + "RAMP/Utils"
  122. },
  123. {
  124. name: "tools",
  125. location: jsPrefix + "RAMP/Tools/"
  126. }
  127. ],
  128. fullPluginPath: jsPrefix + 'plugins/'
  129. };
  130.  
  131. (function loadRampScripts(scripts) {
  132. 'use strict';
  133. if (scripts.length === 0) { return; }
  134. importScript(scripts[0], function () { loadRampScripts(scripts.slice(1)); });
  135. })(RAMP.scripts);
  136.