cesium 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (491) hide show
  1. data/LICENSE.md +259 -0
  2. data/README.rdoc +90 -0
  3. data/Rakefile +40 -0
  4. data/app/assets/javascripts/Assets/Assets.profile.js +8 -0
  5. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_0.json +1 -0
  6. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_1.json +1 -0
  7. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_10.json +1 -0
  8. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_11.json +1 -0
  9. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_12.json +1 -0
  10. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_13.json +1 -0
  11. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_14.json +1 -0
  12. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_15.json +1 -0
  13. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_16.json +1 -0
  14. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_17.json +1 -0
  15. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_18.json +1 -0
  16. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_19.json +1 -0
  17. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_2.json +1 -0
  18. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_20.json +1 -0
  19. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_21.json +1 -0
  20. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_22.json +1 -0
  21. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_23.json +1 -0
  22. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_24.json +1 -0
  23. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_25.json +1 -0
  24. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_26.json +1 -0
  25. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_27.json +1 -0
  26. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_3.json +1 -0
  27. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_4.json +1 -0
  28. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_5.json +1 -0
  29. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_6.json +1 -0
  30. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_7.json +1 -0
  31. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_8.json +1 -0
  32. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_9.json +1 -0
  33. data/app/assets/javascripts/Assets/Textures/NE2_LR_LC_SR_W_DR_2048.jpg +0 -0
  34. data/app/assets/javascripts/Assets/Textures/SkyBox/tycho2t3_80_mx.jpg +0 -0
  35. data/app/assets/javascripts/Assets/Textures/SkyBox/tycho2t3_80_my.jpg +0 -0
  36. data/app/assets/javascripts/Assets/Textures/SkyBox/tycho2t3_80_mz.jpg +0 -0
  37. data/app/assets/javascripts/Assets/Textures/SkyBox/tycho2t3_80_px.jpg +0 -0
  38. data/app/assets/javascripts/Assets/Textures/SkyBox/tycho2t3_80_py.jpg +0 -0
  39. data/app/assets/javascripts/Assets/Textures/SkyBox/tycho2t3_80_pz.jpg +0 -0
  40. data/app/assets/javascripts/Assets/Textures/waterNormals.jpg +0 -0
  41. data/app/assets/javascripts/Assets/package.json +6 -0
  42. data/app/assets/javascripts/Cesium.js +320 -0
  43. data/app/assets/javascripts/Core/AnimationController.js +148 -0
  44. data/app/assets/javascripts/Core/AxisAlignedBoundingBox.js +243 -0
  45. data/app/assets/javascripts/Core/BoundingRectangle.js +364 -0
  46. data/app/assets/javascripts/Core/BoundingSphere.js +819 -0
  47. data/app/assets/javascripts/Core/BoxTessellator.js +93 -0
  48. data/app/assets/javascripts/Core/Cartesian2.js +762 -0
  49. data/app/assets/javascripts/Core/Cartesian3.js +861 -0
  50. data/app/assets/javascripts/Core/Cartesian4.js +762 -0
  51. data/app/assets/javascripts/Core/Cartographic.js +211 -0
  52. data/app/assets/javascripts/Core/CatmullRomSpline.js +232 -0
  53. data/app/assets/javascripts/Core/Clock.js +195 -0
  54. data/app/assets/javascripts/Core/ClockRange.js +37 -0
  55. data/app/assets/javascripts/Core/ClockStep.js +32 -0
  56. data/app/assets/javascripts/Core/Color.js +1629 -0
  57. data/app/assets/javascripts/Core/ComponentDatatype.js +119 -0
  58. data/app/assets/javascripts/Core/Core.profile.js +8 -0
  59. data/app/assets/javascripts/Core/CubeMapEllipsoidTessellator.js +198 -0
  60. data/app/assets/javascripts/Core/CubicRealPolynomial.js +251 -0
  61. data/app/assets/javascripts/Core/DefaultProxy.js +30 -0
  62. data/app/assets/javascripts/Core/DeveloperError.js +60 -0
  63. data/app/assets/javascripts/Core/EarthOrientationParameters.js +383 -0
  64. data/app/assets/javascripts/Core/EarthOrientationParametersSample.js +50 -0
  65. data/app/assets/javascripts/Core/Ellipsoid.js +539 -0
  66. data/app/assets/javascripts/Core/EllipsoidTangentPlane.js +207 -0
  67. data/app/assets/javascripts/Core/EllipsoidalOccluder.js +151 -0
  68. data/app/assets/javascripts/Core/EncodedCartesian3.js +197 -0
  69. data/app/assets/javascripts/Core/Enumeration.js +67 -0
  70. data/app/assets/javascripts/Core/Event.js +122 -0
  71. data/app/assets/javascripts/Core/Extent.js +383 -0
  72. data/app/assets/javascripts/Core/ExtentTessellator.js +384 -0
  73. data/app/assets/javascripts/Core/FAR.js +13 -0
  74. data/app/assets/javascripts/Core/FeatureDetection.js +126 -0
  75. data/app/assets/javascripts/Core/Fullscreen.js +235 -0
  76. data/app/assets/javascripts/Core/GeographicProjection.js +107 -0
  77. data/app/assets/javascripts/Core/HermitePolynomialApproximation.js +176 -0
  78. data/app/assets/javascripts/Core/HermiteSpline.js +234 -0
  79. data/app/assets/javascripts/Core/Iau2006XysData.js +259 -0
  80. data/app/assets/javascripts/Core/Iau2006XysSample.js +36 -0
  81. data/app/assets/javascripts/Core/IndexDatatype.js +28 -0
  82. data/app/assets/javascripts/Core/Intersect.js +40 -0
  83. data/app/assets/javascripts/Core/IntersectionTests.js +359 -0
  84. data/app/assets/javascripts/Core/Interval.js +27 -0
  85. data/app/assets/javascripts/Core/Iso8601.js +46 -0
  86. data/app/assets/javascripts/Core/JulianDate.js +1228 -0
  87. data/app/assets/javascripts/Core/KeyboardEventModifier.js +38 -0
  88. data/app/assets/javascripts/Core/LagrangePolynomialApproximation.js +96 -0
  89. data/app/assets/javascripts/Core/LeapSecond.js +158 -0
  90. data/app/assets/javascripts/Core/LinearApproximation.js +98 -0
  91. data/app/assets/javascripts/Core/Math.js +532 -0
  92. data/app/assets/javascripts/Core/Matrix2.js +833 -0
  93. data/app/assets/javascripts/Core/Matrix3.js +1099 -0
  94. data/app/assets/javascripts/Core/Matrix4.js +2164 -0
  95. data/app/assets/javascripts/Core/MeshFilters.js +568 -0
  96. data/app/assets/javascripts/Core/Occluder.js +474 -0
  97. data/app/assets/javascripts/Core/OrientationInterpolator.js +109 -0
  98. data/app/assets/javascripts/Core/PlaneTessellator.js +74 -0
  99. data/app/assets/javascripts/Core/PolygonPipeline.js +792 -0
  100. data/app/assets/javascripts/Core/PolylinePipeline.js +90 -0
  101. data/app/assets/javascripts/Core/PrimitiveType.js +80 -0
  102. data/app/assets/javascripts/Core/QuadraticRealPolynomial.js +146 -0
  103. data/app/assets/javascripts/Core/QuarticRealPolynomial.js +339 -0
  104. data/app/assets/javascripts/Core/Quaternion.js +947 -0
  105. data/app/assets/javascripts/Core/Queue.js +95 -0
  106. data/app/assets/javascripts/Core/Ray.js +64 -0
  107. data/app/assets/javascripts/Core/ReferenceFrame.js +25 -0
  108. data/app/assets/javascripts/Core/RequestErrorEvent.js +35 -0
  109. data/app/assets/javascripts/Core/RuntimeError.js +59 -0
  110. data/app/assets/javascripts/Core/ScreenSpaceEventHandler.js +658 -0
  111. data/app/assets/javascripts/Core/ScreenSpaceEventType.js +149 -0
  112. data/app/assets/javascripts/Core/Shapes.js +230 -0
  113. data/app/assets/javascripts/Core/Spherical.js +192 -0
  114. data/app/assets/javascripts/Core/TaskProcessor.js +131 -0
  115. data/app/assets/javascripts/Core/TimeConstants.js +85 -0
  116. data/app/assets/javascripts/Core/TimeInterval.js +305 -0
  117. data/app/assets/javascripts/Core/TimeIntervalCollection.js +543 -0
  118. data/app/assets/javascripts/Core/TimeStandard.js +31 -0
  119. data/app/assets/javascripts/Core/Tipsify.js +285 -0
  120. data/app/assets/javascripts/Core/Transforms.js +614 -0
  121. data/app/assets/javascripts/Core/TridiagonalSystemSolver.js +102 -0
  122. data/app/assets/javascripts/Core/Visibility.js +38 -0
  123. data/app/assets/javascripts/Core/WebMercatorProjection.js +154 -0
  124. data/app/assets/javascripts/Core/WindingOrder.js +40 -0
  125. data/app/assets/javascripts/Core/binarySearch.js +69 -0
  126. data/app/assets/javascripts/Core/buildModuleUrl.js +77 -0
  127. data/app/assets/javascripts/Core/clone.js +21 -0
  128. data/app/assets/javascripts/Core/combine.js +81 -0
  129. data/app/assets/javascripts/Core/computeSunPosition.js +116 -0
  130. data/app/assets/javascripts/Core/createGuid.js +25 -0
  131. data/app/assets/javascripts/Core/defaultValue.js +22 -0
  132. data/app/assets/javascripts/Core/destroyObject.js +61 -0
  133. data/app/assets/javascripts/Core/freezeObject.js +20 -0
  134. data/app/assets/javascripts/Core/getImagePixels.js +46 -0
  135. data/app/assets/javascripts/Core/isLeapYear.js +30 -0
  136. data/app/assets/javascripts/Core/jsonp.js +116 -0
  137. data/app/assets/javascripts/Core/loadArrayBuffer.js +76 -0
  138. data/app/assets/javascripts/Core/loadImage.js +85 -0
  139. data/app/assets/javascripts/Core/loadJson.js +54 -0
  140. data/app/assets/javascripts/Core/loadText.js +78 -0
  141. data/app/assets/javascripts/Core/loadXML.js +76 -0
  142. data/app/assets/javascripts/Core/package.json +6 -0
  143. data/app/assets/javascripts/Core/pointInsideTriangle2D.js +41 -0
  144. data/app/assets/javascripts/Core/requestAnimationFrame.js +61 -0
  145. data/app/assets/javascripts/Core/throttleRequestByServer.js +74 -0
  146. data/app/assets/javascripts/Core/writeTextToCanvas.js +92 -0
  147. data/app/assets/javascripts/DynamicScene/CompositeDynamicObjectCollection.js +254 -0
  148. data/app/assets/javascripts/DynamicScene/CzmlBoolean.js +57 -0
  149. data/app/assets/javascripts/DynamicScene/CzmlCartesian2.js +96 -0
  150. data/app/assets/javascripts/DynamicScene/CzmlCartesian3.js +99 -0
  151. data/app/assets/javascripts/DynamicScene/CzmlCartographic.js +125 -0
  152. data/app/assets/javascripts/DynamicScene/CzmlColor.js +127 -0
  153. data/app/assets/javascripts/DynamicScene/CzmlDefaults.js +135 -0
  154. data/app/assets/javascripts/DynamicScene/CzmlHorizontalOrigin.js +59 -0
  155. data/app/assets/javascripts/DynamicScene/CzmlImage.js +61 -0
  156. data/app/assets/javascripts/DynamicScene/CzmlLabelStyle.js +59 -0
  157. data/app/assets/javascripts/DynamicScene/CzmlNumber.js +82 -0
  158. data/app/assets/javascripts/DynamicScene/CzmlString.js +56 -0
  159. data/app/assets/javascripts/DynamicScene/CzmlUnitCartesian3.js +99 -0
  160. data/app/assets/javascripts/DynamicScene/CzmlUnitQuaternion.js +172 -0
  161. data/app/assets/javascripts/DynamicScene/CzmlUnitSpherical.js +98 -0
  162. data/app/assets/javascripts/DynamicScene/CzmlVerticalOrigin.js +59 -0
  163. data/app/assets/javascripts/DynamicScene/DynamicBillboard.js +245 -0
  164. data/app/assets/javascripts/DynamicScene/DynamicBillboardVisualizer.js +347 -0
  165. data/app/assets/javascripts/DynamicScene/DynamicColorMaterial.js +78 -0
  166. data/app/assets/javascripts/DynamicScene/DynamicCone.js +291 -0
  167. data/app/assets/javascripts/DynamicScene/DynamicConeVisualizer.js +350 -0
  168. data/app/assets/javascripts/DynamicScene/DynamicConeVisualizerUsingCustomSensor.js +389 -0
  169. data/app/assets/javascripts/DynamicScene/DynamicDirectionsProperty.js +163 -0
  170. data/app/assets/javascripts/DynamicScene/DynamicEllipsoid.js +158 -0
  171. data/app/assets/javascripts/DynamicScene/DynamicEllipsoidVisualizer.js +277 -0
  172. data/app/assets/javascripts/DynamicScene/DynamicImageMaterial.js +136 -0
  173. data/app/assets/javascripts/DynamicScene/DynamicLabel.js +286 -0
  174. data/app/assets/javascripts/DynamicScene/DynamicLabelVisualizer.js +341 -0
  175. data/app/assets/javascripts/DynamicScene/DynamicMaterialProperty.js +125 -0
  176. data/app/assets/javascripts/DynamicScene/DynamicObject.js +364 -0
  177. data/app/assets/javascripts/DynamicScene/DynamicObjectCollection.js +137 -0
  178. data/app/assets/javascripts/DynamicScene/DynamicObjectView.js +299 -0
  179. data/app/assets/javascripts/DynamicScene/DynamicPath.js +214 -0
  180. data/app/assets/javascripts/DynamicScene/DynamicPathVisualizer.js +402 -0
  181. data/app/assets/javascripts/DynamicScene/DynamicPoint.js +184 -0
  182. data/app/assets/javascripts/DynamicScene/DynamicPointVisualizer.js +323 -0
  183. data/app/assets/javascripts/DynamicScene/DynamicPolygon.js +138 -0
  184. data/app/assets/javascripts/DynamicScene/DynamicPolygonVisualizer.js +251 -0
  185. data/app/assets/javascripts/DynamicScene/DynamicPolyline.js +183 -0
  186. data/app/assets/javascripts/DynamicScene/DynamicPolylineVisualizer.js +268 -0
  187. data/app/assets/javascripts/DynamicScene/DynamicPositionProperty.js +525 -0
  188. data/app/assets/javascripts/DynamicScene/DynamicProperty.js +352 -0
  189. data/app/assets/javascripts/DynamicScene/DynamicPyramid.js +204 -0
  190. data/app/assets/javascripts/DynamicScene/DynamicPyramidVisualizer.js +302 -0
  191. data/app/assets/javascripts/DynamicScene/DynamicScene.profile.js +8 -0
  192. data/app/assets/javascripts/DynamicScene/DynamicVertexPositionsProperty.js +199 -0
  193. data/app/assets/javascripts/DynamicScene/ReferenceProperty.js +155 -0
  194. data/app/assets/javascripts/DynamicScene/VisualizerCollection.js +181 -0
  195. data/app/assets/javascripts/DynamicScene/package.json +6 -0
  196. data/app/assets/javascripts/DynamicScene/processCzml.js +77 -0
  197. data/app/assets/javascripts/Renderer/BlendEquation.js +52 -0
  198. data/app/assets/javascripts/Renderer/BlendFunction.js +158 -0
  199. data/app/assets/javascripts/Renderer/BlendingState.js +64 -0
  200. data/app/assets/javascripts/Renderer/Buffer.js +141 -0
  201. data/app/assets/javascripts/Renderer/BufferUsage.js +48 -0
  202. data/app/assets/javascripts/Renderer/ClearCommand.js +40 -0
  203. data/app/assets/javascripts/Renderer/CommandLists.js +42 -0
  204. data/app/assets/javascripts/Renderer/Context.js +2805 -0
  205. data/app/assets/javascripts/Renderer/CubeMap.js +358 -0
  206. data/app/assets/javascripts/Renderer/CubeMapFace.js +202 -0
  207. data/app/assets/javascripts/Renderer/CullFace.js +50 -0
  208. data/app/assets/javascripts/Renderer/DepthFunction.js +95 -0
  209. data/app/assets/javascripts/Renderer/DrawCommand.js +96 -0
  210. data/app/assets/javascripts/Renderer/Framebuffer.js +435 -0
  211. data/app/assets/javascripts/Renderer/MipmapHint.js +50 -0
  212. data/app/assets/javascripts/Renderer/PickFramebuffer.js +178 -0
  213. data/app/assets/javascripts/Renderer/PixelDatatype.js +86 -0
  214. data/app/assets/javascripts/Renderer/PixelFormat.js +113 -0
  215. data/app/assets/javascripts/Renderer/Renderbuffer.js +102 -0
  216. data/app/assets/javascripts/Renderer/RenderbufferFormat.js +77 -0
  217. data/app/assets/javascripts/Renderer/Renderer.profile.js +8 -0
  218. data/app/assets/javascripts/Renderer/ShaderCache.js +121 -0
  219. data/app/assets/javascripts/Renderer/ShaderProgram.js +2402 -0
  220. data/app/assets/javascripts/Renderer/StencilFunction.js +95 -0
  221. data/app/assets/javascripts/Renderer/StencilOperation.js +95 -0
  222. data/app/assets/javascripts/Renderer/Texture.js +395 -0
  223. data/app/assets/javascripts/Renderer/TextureAtlas.js +472 -0
  224. data/app/assets/javascripts/Renderer/TextureAtlasBuilder.js +133 -0
  225. data/app/assets/javascripts/Renderer/TextureMagnificationFilter.js +41 -0
  226. data/app/assets/javascripts/Renderer/TextureMinificationFilter.js +77 -0
  227. data/app/assets/javascripts/Renderer/TextureWrap.js +50 -0
  228. data/app/assets/javascripts/Renderer/UniformDatatype.js +218 -0
  229. data/app/assets/javascripts/Renderer/UniformState.js +799 -0
  230. data/app/assets/javascripts/Renderer/VertexArray.js +365 -0
  231. data/app/assets/javascripts/Renderer/VertexArrayFacade.js +574 -0
  232. data/app/assets/javascripts/Renderer/VertexLayout.js +49 -0
  233. data/app/assets/javascripts/Renderer/loadCubeMap.js +92 -0
  234. data/app/assets/javascripts/Renderer/package.json +6 -0
  235. data/app/assets/javascripts/Scene/AnimationCollection.js +249 -0
  236. data/app/assets/javascripts/Scene/ArcGisMapServerImageryProvider.js +384 -0
  237. data/app/assets/javascripts/Scene/Billboard.js +680 -0
  238. data/app/assets/javascripts/Scene/BillboardCollection.js +1209 -0
  239. data/app/assets/javascripts/Scene/BingMapsImageryProvider.js +460 -0
  240. data/app/assets/javascripts/Scene/BingMapsStyle.js +55 -0
  241. data/app/assets/javascripts/Scene/Camera.js +358 -0
  242. data/app/assets/javascripts/Scene/CameraColumbusViewMode.js +30 -0
  243. data/app/assets/javascripts/Scene/CameraController.js +1258 -0
  244. data/app/assets/javascripts/Scene/CameraEventAggregator.js +270 -0
  245. data/app/assets/javascripts/Scene/CameraEventType.js +53 -0
  246. data/app/assets/javascripts/Scene/CameraFlightPath.js +495 -0
  247. data/app/assets/javascripts/Scene/CentralBody.js +817 -0
  248. data/app/assets/javascripts/Scene/CentralBodySurface.js +1120 -0
  249. data/app/assets/javascripts/Scene/CentralBodySurfaceShaderSet.js +107 -0
  250. data/app/assets/javascripts/Scene/ComplexConicSensorVolume.js +511 -0
  251. data/app/assets/javascripts/Scene/CompositePrimitive.js +454 -0
  252. data/app/assets/javascripts/Scene/CullingVolume.js +59 -0
  253. data/app/assets/javascripts/Scene/CustomSensorVolume.js +440 -0
  254. data/app/assets/javascripts/Scene/DiscardMissingTileImagePolicy.js +134 -0
  255. data/app/assets/javascripts/Scene/EllipsoidPrimitive.js +412 -0
  256. data/app/assets/javascripts/Scene/EllipsoidTerrainProvider.js +182 -0
  257. data/app/assets/javascripts/Scene/FrameState.js +86 -0
  258. data/app/assets/javascripts/Scene/FrustumCommands.js +32 -0
  259. data/app/assets/javascripts/Scene/GeographicTilingScheme.js +265 -0
  260. data/app/assets/javascripts/Scene/HorizontalOrigin.js +39 -0
  261. data/app/assets/javascripts/Scene/Imagery.js +85 -0
  262. data/app/assets/javascripts/Scene/ImageryLayer.js +876 -0
  263. data/app/assets/javascripts/Scene/ImageryLayerCollection.js +403 -0
  264. data/app/assets/javascripts/Scene/ImageryProvider.js +185 -0
  265. data/app/assets/javascripts/Scene/ImageryProviderError.js +149 -0
  266. data/app/assets/javascripts/Scene/ImageryState.js +20 -0
  267. data/app/assets/javascripts/Scene/Label.js +706 -0
  268. data/app/assets/javascripts/Scene/LabelCollection.js +697 -0
  269. data/app/assets/javascripts/Scene/LabelStyle.js +39 -0
  270. data/app/assets/javascripts/Scene/Material.js +1177 -0
  271. data/app/assets/javascripts/Scene/NeverTileDiscardPolicy.js +38 -0
  272. data/app/assets/javascripts/Scene/OpenStreetMapImageryProvider.js +282 -0
  273. data/app/assets/javascripts/Scene/OrthographicFrustum.js +345 -0
  274. data/app/assets/javascripts/Scene/PerformanceDisplay.js +183 -0
  275. data/app/assets/javascripts/Scene/PerspectiveFrustum.js +239 -0
  276. data/app/assets/javascripts/Scene/PerspectiveOffCenterFrustum.js +394 -0
  277. data/app/assets/javascripts/Scene/Polygon.js +886 -0
  278. data/app/assets/javascripts/Scene/Polyline.js +441 -0
  279. data/app/assets/javascripts/Scene/PolylineCollection.js +1532 -0
  280. data/app/assets/javascripts/Scene/Projections.js +93 -0
  281. data/app/assets/javascripts/Scene/RectangularPyramidSensorVolume.js +224 -0
  282. data/app/assets/javascripts/Scene/Scene.js +632 -0
  283. data/app/assets/javascripts/Scene/Scene.profile.js +8 -0
  284. data/app/assets/javascripts/Scene/SceneMode.js +51 -0
  285. data/app/assets/javascripts/Scene/SceneTransitioner.js +776 -0
  286. data/app/assets/javascripts/Scene/ScreenSpaceCameraController.js +1063 -0
  287. data/app/assets/javascripts/Scene/SensorVolumeCollection.js +192 -0
  288. data/app/assets/javascripts/Scene/SingleTileImageryProvider.js +295 -0
  289. data/app/assets/javascripts/Scene/SkyAtmosphere.js +239 -0
  290. data/app/assets/javascripts/Scene/SkyBox.js +231 -0
  291. data/app/assets/javascripts/Scene/TerrainProvider.js +229 -0
  292. data/app/assets/javascripts/Scene/TexturePool.js +154 -0
  293. data/app/assets/javascripts/Scene/Tile.js +322 -0
  294. data/app/assets/javascripts/Scene/TileDiscardPolicy.js +42 -0
  295. data/app/assets/javascripts/Scene/TileImagery.js +36 -0
  296. data/app/assets/javascripts/Scene/TileLoadQueue.js +123 -0
  297. data/app/assets/javascripts/Scene/TileMapServiceImageryProvider.js +337 -0
  298. data/app/assets/javascripts/Scene/TileReplacementQueue.js +139 -0
  299. data/app/assets/javascripts/Scene/TileState.js +19 -0
  300. data/app/assets/javascripts/Scene/TilingScheme.js +213 -0
  301. data/app/assets/javascripts/Scene/VerticalOrigin.js +39 -0
  302. data/app/assets/javascripts/Scene/ViewportQuad.js +256 -0
  303. data/app/assets/javascripts/Scene/WebMapServiceImageryProvider.js +374 -0
  304. data/app/assets/javascripts/Scene/WebMercatorTilingScheme.js +291 -0
  305. data/app/assets/javascripts/Scene/package.json +6 -0
  306. data/app/assets/javascripts/Shaders/BillboardCollectionFS.glsl +30 -0
  307. data/app/assets/javascripts/Shaders/BillboardCollectionFS.js +31 -0
  308. data/app/assets/javascripts/Shaders/BillboardCollectionVS.glsl +68 -0
  309. data/app/assets/javascripts/Shaders/BillboardCollectionVS.js +54 -0
  310. data/app/assets/javascripts/Shaders/BuiltinFunctions.glsl +927 -0
  311. data/app/assets/javascripts/Shaders/BuiltinFunctions.js +322 -0
  312. data/app/assets/javascripts/Shaders/CentralBodyFS.glsl +106 -0
  313. data/app/assets/javascripts/Shaders/CentralBodyFS.js +82 -0
  314. data/app/assets/javascripts/Shaders/CentralBodyFSDepth.glsl +20 -0
  315. data/app/assets/javascripts/Shaders/CentralBodyFSDepth.js +22 -0
  316. data/app/assets/javascripts/Shaders/CentralBodyFSPole.glsl +29 -0
  317. data/app/assets/javascripts/Shaders/CentralBodyFSPole.js +28 -0
  318. data/app/assets/javascripts/Shaders/CentralBodyVS.glsl +88 -0
  319. data/app/assets/javascripts/Shaders/CentralBodyVS.js +69 -0
  320. data/app/assets/javascripts/Shaders/CentralBodyVSDepth.glsl +9 -0
  321. data/app/assets/javascripts/Shaders/CentralBodyVSDepth.js +13 -0
  322. data/app/assets/javascripts/Shaders/CentralBodyVSPole.glsl +12 -0
  323. data/app/assets/javascripts/Shaders/CentralBodyVSPole.js +15 -0
  324. data/app/assets/javascripts/Shaders/ComplexConicSensorVolumeFS.glsl +448 -0
  325. data/app/assets/javascripts/Shaders/ComplexConicSensorVolumeFS.js +361 -0
  326. data/app/assets/javascripts/Shaders/ComplexConicSensorVolumeVS.glsl +19 -0
  327. data/app/assets/javascripts/Shaders/ComplexConicSensorVolumeVS.js +20 -0
  328. data/app/assets/javascripts/Shaders/ConstructiveSolidGeometry.glsl +886 -0
  329. data/app/assets/javascripts/Shaders/ConstructiveSolidGeometry.js +586 -0
  330. data/app/assets/javascripts/Shaders/CustomSensorVolumeFS.glsl +126 -0
  331. data/app/assets/javascripts/Shaders/CustomSensorVolumeFS.js +95 -0
  332. data/app/assets/javascripts/Shaders/CustomSensorVolumeVS.glsl +14 -0
  333. data/app/assets/javascripts/Shaders/CustomSensorVolumeVS.js +18 -0
  334. data/app/assets/javascripts/Shaders/EllipsoidFS.glsl +40 -0
  335. data/app/assets/javascripts/Shaders/EllipsoidFS.js +38 -0
  336. data/app/assets/javascripts/Shaders/EllipsoidVS.glsl +26 -0
  337. data/app/assets/javascripts/Shaders/EllipsoidVS.js +16 -0
  338. data/app/assets/javascripts/Shaders/Materials/AsphaltMaterial.glsl +25 -0
  339. data/app/assets/javascripts/Shaders/Materials/AsphaltMaterial.js +23 -0
  340. data/app/assets/javascripts/Shaders/Materials/BlobMaterial.glsl +18 -0
  341. data/app/assets/javascripts/Shaders/Materials/BlobMaterial.js +19 -0
  342. data/app/assets/javascripts/Shaders/Materials/BrickMaterial.glsl +42 -0
  343. data/app/assets/javascripts/Shaders/Materials/BrickMaterial.js +36 -0
  344. data/app/assets/javascripts/Shaders/Materials/BumpMapMaterial.glsl +29 -0
  345. data/app/assets/javascripts/Shaders/Materials/BumpMapMaterial.js +27 -0
  346. data/app/assets/javascripts/Shaders/Materials/CementMaterial.glsl +19 -0
  347. data/app/assets/javascripts/Shaders/Materials/CementMaterial.js +20 -0
  348. data/app/assets/javascripts/Shaders/Materials/CheckerboardMaterial.glsl +38 -0
  349. data/app/assets/javascripts/Shaders/Materials/CheckerboardMaterial.js +32 -0
  350. data/app/assets/javascripts/Shaders/Materials/DotMaterial.glsl +17 -0
  351. data/app/assets/javascripts/Shaders/Materials/DotMaterial.js +18 -0
  352. data/app/assets/javascripts/Shaders/Materials/ErosionMaterial.glsl +23 -0
  353. data/app/assets/javascripts/Shaders/Materials/ErosionMaterial.js +24 -0
  354. data/app/assets/javascripts/Shaders/Materials/FacetMaterial.glsl +18 -0
  355. data/app/assets/javascripts/Shaders/Materials/FacetMaterial.js +19 -0
  356. data/app/assets/javascripts/Shaders/Materials/FresnelMaterial.glsl +12 -0
  357. data/app/assets/javascripts/Shaders/Materials/FresnelMaterial.js +15 -0
  358. data/app/assets/javascripts/Shaders/Materials/GrassMaterial.glsl +28 -0
  359. data/app/assets/javascripts/Shaders/Materials/GrassMaterial.js +26 -0
  360. data/app/assets/javascripts/Shaders/Materials/NormalMapMaterial.glsl +19 -0
  361. data/app/assets/javascripts/Shaders/Materials/NormalMapMaterial.js +21 -0
  362. data/app/assets/javascripts/Shaders/Materials/ReflectionMaterial.glsl +13 -0
  363. data/app/assets/javascripts/Shaders/Materials/ReflectionMaterial.js +16 -0
  364. data/app/assets/javascripts/Shaders/Materials/RefractionMaterial.glsl +14 -0
  365. data/app/assets/javascripts/Shaders/Materials/RefractionMaterial.js +17 -0
  366. data/app/assets/javascripts/Shaders/Materials/RimLightingMaterial.glsl +18 -0
  367. data/app/assets/javascripts/Shaders/Materials/RimLightingMaterial.js +19 -0
  368. data/app/assets/javascripts/Shaders/Materials/StripeMaterial.glsl +29 -0
  369. data/app/assets/javascripts/Shaders/Materials/StripeMaterial.js +26 -0
  370. data/app/assets/javascripts/Shaders/Materials/TieDyeMaterial.glsl +17 -0
  371. data/app/assets/javascripts/Shaders/Materials/TieDyeMaterial.js +19 -0
  372. data/app/assets/javascripts/Shaders/Materials/Water.glsl +91 -0
  373. data/app/assets/javascripts/Shaders/Materials/Water.js +60 -0
  374. data/app/assets/javascripts/Shaders/Materials/WoodMaterial.glsl +36 -0
  375. data/app/assets/javascripts/Shaders/Materials/WoodMaterial.js +31 -0
  376. data/app/assets/javascripts/Shaders/Noise.glsl +453 -0
  377. data/app/assets/javascripts/Shaders/Noise.js +242 -0
  378. data/app/assets/javascripts/Shaders/PolygonFS.glsl +27 -0
  379. data/app/assets/javascripts/Shaders/PolygonFS.js +23 -0
  380. data/app/assets/javascripts/Shaders/PolygonFSPick.glsl +6 -0
  381. data/app/assets/javascripts/Shaders/PolygonFSPick.js +11 -0
  382. data/app/assets/javascripts/Shaders/PolygonVS.glsl +38 -0
  383. data/app/assets/javascripts/Shaders/PolygonVS.js +39 -0
  384. data/app/assets/javascripts/Shaders/PolygonVSPick.glsl +30 -0
  385. data/app/assets/javascripts/Shaders/PolygonVSPick.js +32 -0
  386. data/app/assets/javascripts/Shaders/PolylineFS.glsl +6 -0
  387. data/app/assets/javascripts/Shaders/PolylineFS.js +11 -0
  388. data/app/assets/javascripts/Shaders/PolylineVS.glsl +34 -0
  389. data/app/assets/javascripts/Shaders/PolylineVS.js +35 -0
  390. data/app/assets/javascripts/Shaders/Ray.glsl +532 -0
  391. data/app/assets/javascripts/Shaders/Ray.js +357 -0
  392. data/app/assets/javascripts/Shaders/ReprojectWebMercatorFS.glsl +26 -0
  393. data/app/assets/javascripts/Shaders/ReprojectWebMercatorFS.js +22 -0
  394. data/app/assets/javascripts/Shaders/ReprojectWebMercatorVS.glsl +11 -0
  395. data/app/assets/javascripts/Shaders/ReprojectWebMercatorVS.js +14 -0
  396. data/app/assets/javascripts/Shaders/SensorVolume.glsl +43 -0
  397. data/app/assets/javascripts/Shaders/SensorVolume.js +31 -0
  398. data/app/assets/javascripts/Shaders/Shaders.profile.js +8 -0
  399. data/app/assets/javascripts/Shaders/SkyAtmosphereFS.glsl +70 -0
  400. data/app/assets/javascripts/Shaders/SkyAtmosphereFS.js +62 -0
  401. data/app/assets/javascripts/Shaders/SkyAtmosphereVS.glsl +131 -0
  402. data/app/assets/javascripts/Shaders/SkyAtmosphereVS.js +115 -0
  403. data/app/assets/javascripts/Shaders/SkyBoxFS.glsl +10 -0
  404. data/app/assets/javascripts/Shaders/SkyBoxFS.js +14 -0
  405. data/app/assets/javascripts/Shaders/SkyBoxVS.glsl +10 -0
  406. data/app/assets/javascripts/Shaders/SkyBoxVS.js +14 -0
  407. data/app/assets/javascripts/Shaders/ViewportQuadFS.glsl +16 -0
  408. data/app/assets/javascripts/Shaders/ViewportQuadFS.js +17 -0
  409. data/app/assets/javascripts/Shaders/ViewportQuadVS.glsl +10 -0
  410. data/app/assets/javascripts/Shaders/ViewportQuadVS.js +14 -0
  411. data/app/assets/javascripts/Shaders/package.json +6 -0
  412. data/app/assets/javascripts/ThirdParty/ThirdParty.profile.js +8 -0
  413. data/app/assets/javascripts/ThirdParty/Tween.js +678 -0
  414. data/app/assets/javascripts/ThirdParty/Uri.js +277 -0
  415. data/app/assets/javascripts/ThirdParty/measureText.js +197 -0
  416. data/app/assets/javascripts/ThirdParty/package.json +6 -0
  417. data/app/assets/javascripts/ThirdParty/sprintf.js +319 -0
  418. data/app/assets/javascripts/ThirdParty/when.js +748 -0
  419. data/app/assets/javascripts/Widgets/Dojo/CesiumViewerWidget.css +175 -0
  420. data/app/assets/javascripts/Widgets/Dojo/CesiumViewerWidget.html +52 -0
  421. data/app/assets/javascripts/Widgets/Dojo/CesiumViewerWidget.js +1237 -0
  422. data/app/assets/javascripts/Widgets/Dojo/CesiumWidget.html +4 -0
  423. data/app/assets/javascripts/Widgets/Dojo/CesiumWidget.js +349 -0
  424. data/app/assets/javascripts/Widgets/Dojo/TimelineWidget.css +1 -0
  425. data/app/assets/javascripts/Widgets/Dojo/TimelineWidget.js +47 -0
  426. data/app/assets/javascripts/Widgets/Dojo/checkForChromeFrame.js +71 -0
  427. data/app/assets/javascripts/Widgets/Images/Bing_Logo_51x19_White.png +0 -0
  428. data/app/assets/javascripts/Widgets/Images/Cesium_Logo_overlay.png +0 -0
  429. data/app/assets/javascripts/Widgets/Images/TimelineIcons.png +0 -0
  430. data/app/assets/javascripts/Widgets/Images/ajax-loader.gif +0 -0
  431. data/app/assets/javascripts/Widgets/Images/animationBar.png +0 -0
  432. data/app/assets/javascripts/Widgets/Images/viewControlBar.png +0 -0
  433. data/app/assets/javascripts/Widgets/Timeline.css +113 -0
  434. data/app/assets/javascripts/Widgets/Timeline.js +629 -0
  435. data/app/assets/javascripts/Widgets/TimelineHighlightRange.js +51 -0
  436. data/app/assets/javascripts/Widgets/TimelineTrack.js +54 -0
  437. data/app/assets/javascripts/Widgets/Widgets.profile.js +8 -0
  438. data/app/assets/javascripts/Widgets/package.json +6 -0
  439. data/app/assets/javascripts/Workers/Workers.profile.js +8 -0
  440. data/app/assets/javascripts/Workers/cesiumWorkerBootstrapper.js +2015 -0
  441. data/app/assets/javascripts/Workers/createTaskProcessorWorker.js +55 -0
  442. data/app/assets/javascripts/Workers/createVerticesFromExtent.js +24 -0
  443. data/app/assets/javascripts/Workers/package.json +6 -0
  444. data/app/assets/javascripts/copyrightHeader.js +22 -0
  445. data/app/assets/javascripts/main.js +10 -0
  446. data/app/assets/stylesheets/cesium.css +4 -0
  447. data/app/controllers/cesium_controller.rb +4 -0
  448. data/app/helpers/cesium_helper.rb +2 -0
  449. data/app/views/cesium/index.html.erb +3 -0
  450. data/config/routes.rb +3 -0
  451. data/lib/cesium.rb +4 -0
  452. data/lib/cesium/engine.rb +4 -0
  453. data/lib/cesium/version.rb +3 -0
  454. data/lib/tasks/cesium_tasks.rake +4 -0
  455. data/test/cesium_test.rb +7 -0
  456. data/test/dummy/README.rdoc +261 -0
  457. data/test/dummy/Rakefile +7 -0
  458. data/test/dummy/app/assets/javascripts/adapters/jquery-adapter.js.coffee +4 -0
  459. data/test/dummy/app/assets/javascripts/app.js.coffee +11 -0
  460. data/test/dummy/app/assets/javascripts/application.js.coffee +73 -0
  461. data/test/dummy/app/assets/stylesheets/application.css +12 -0
  462. data/test/dummy/app/controllers/application_controller.rb +4 -0
  463. data/test/dummy/app/helpers/application_helper.rb +2 -0
  464. data/test/dummy/app/views/layouts/application.html.erb +21 -0
  465. data/test/dummy/config.ru +4 -0
  466. data/test/dummy/config/application.rb +59 -0
  467. data/test/dummy/config/boot.rb +10 -0
  468. data/test/dummy/config/database.yml +25 -0
  469. data/test/dummy/config/environment.rb +5 -0
  470. data/test/dummy/config/environments/development.rb +37 -0
  471. data/test/dummy/config/environments/production.rb +67 -0
  472. data/test/dummy/config/environments/test.rb +37 -0
  473. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  474. data/test/dummy/config/initializers/inflections.rb +15 -0
  475. data/test/dummy/config/initializers/mime_types.rb +5 -0
  476. data/test/dummy/config/initializers/secret_token.rb +7 -0
  477. data/test/dummy/config/initializers/session_store.rb +8 -0
  478. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  479. data/test/dummy/config/locales/en.yml +5 -0
  480. data/test/dummy/config/requirejs.yml +10 -0
  481. data/test/dummy/config/routes.rb +3 -0
  482. data/test/dummy/public/404.html +26 -0
  483. data/test/dummy/public/422.html +26 -0
  484. data/test/dummy/public/500.html +25 -0
  485. data/test/dummy/public/favicon.ico +0 -0
  486. data/test/dummy/script/rails +6 -0
  487. data/test/functional/cesium_controller_test.rb +9 -0
  488. data/test/integration/navigation_test.rb +10 -0
  489. data/test/test_helper.rb +15 -0
  490. data/test/unit/helpers/cesium_helper_test.rb +4 -0
  491. metadata +641 -0
@@ -0,0 +1,51 @@
1
+ /*global define*/
2
+ define(function() {
3
+ "use strict";
4
+
5
+ function TimelineHighlightRange(color, heightInPx) {
6
+ this._color = color;
7
+ this._height = heightInPx;
8
+ }
9
+
10
+ TimelineHighlightRange.prototype.getHeight = function() {
11
+ return this._height;
12
+ };
13
+
14
+ TimelineHighlightRange.prototype.getStartTime = function() {
15
+ return this._start;
16
+ };
17
+
18
+ TimelineHighlightRange.prototype.getStopTime = function() {
19
+ return this._stop;
20
+ };
21
+
22
+ TimelineHighlightRange.prototype.setRange = function(start, stop) {
23
+ this._start = start;
24
+ this._stop = stop;
25
+ };
26
+
27
+ TimelineHighlightRange.prototype.render = function(renderState) {
28
+ var range = '';
29
+ if (this._start && this._stop && this._color) {
30
+ var highlightStart = renderState.epochJulian.getSecondsDifference(this._start);
31
+ var highlightLeft = Math.round(renderState.timeBarWidth * renderState.getAlpha(highlightStart));
32
+ var highlightStop = renderState.epochJulian.getSecondsDifference(this._stop);
33
+ var highlightWidth = Math.round(renderState.timeBarWidth * renderState.getAlpha(highlightStop)) - highlightLeft;
34
+ if (highlightLeft < 0) {
35
+ highlightWidth += highlightLeft;
36
+ highlightLeft = 0;
37
+ }
38
+ if ((highlightLeft + highlightWidth) > renderState.timeBarWidth) {
39
+ highlightWidth = renderState.timeBarWidth - highlightLeft;
40
+ }
41
+ if (highlightWidth > 0) {
42
+ range = '<span class="timelineHighlight" style="left: ' + highlightLeft.toString() + 'px; width: ' + highlightWidth.toString() + 'px; bottom: ' + renderState.y.toString() +
43
+ 'px; height: ' + this._height + 'px; background-color: ' + this._color + ';"></span>';
44
+ }
45
+ }
46
+ renderState.y += this._height;
47
+ return range;
48
+ };
49
+
50
+ return TimelineHighlightRange;
51
+ });
@@ -0,0 +1,54 @@
1
+ /*global define*/
2
+ define([
3
+ '../Core/Color'
4
+ ],
5
+ function(
6
+ Color) {
7
+ "use strict";
8
+
9
+ function TimelineTrack(interval, pixelHeight, color, backgroundColor) {
10
+ this.interval = interval;
11
+ this.height = pixelHeight;
12
+ this.color = color || new Color(0.5, 0.5, 0.5, 1.0);
13
+ this.backgroundColor = backgroundColor || new Color(0.0, 0.0, 0.0, 0.0);
14
+ }
15
+
16
+ TimelineTrack.prototype.render = function(context, renderState) {
17
+ var startInterval = this.interval.start;
18
+ var stopInterval = this.interval.stop;
19
+
20
+ var spanStart = renderState.startJulian;
21
+ var spanStop = renderState.startJulian.addSeconds(renderState.duration);
22
+
23
+ if (startInterval.lessThan(spanStart) && stopInterval.greaterThan(spanStop)) {
24
+ //The track takes up the entire visible span.
25
+ context.fillStyle = this.color.toCssColorString();
26
+ context.fillRect(0, renderState.y, renderState.timeBarWidth, this.height);
27
+ } else if (startInterval.lessThanOrEquals(spanStop) && stopInterval.greaterThanOrEquals(spanStart)) {
28
+ //The track only takes up some of the visible span, compute that span.
29
+ var x;
30
+ var start, stop;
31
+ for (x = 0; x < renderState.timeBarWidth; ++x) {
32
+ var currentTime = renderState.startJulian.addSeconds((x / renderState.timeBarWidth) * renderState.duration);
33
+ if (typeof start === 'undefined' && currentTime.greaterThanOrEquals(startInterval)) {
34
+ start = x;
35
+ } else if (typeof stop === 'undefined' && currentTime.greaterThanOrEquals(stopInterval)) {
36
+ stop = x;
37
+ }
38
+ }
39
+
40
+ context.fillStyle = this.backgroundColor.toCssColorString();
41
+ context.fillRect(0, renderState.y, renderState.timeBarWidth, this.height);
42
+
43
+ if (typeof start !== 'undefined') {
44
+ if (typeof stop === 'undefined') {
45
+ stop = renderState.timeBarWidth;
46
+ }
47
+ context.fillStyle = this.color.toCssColorString();
48
+ context.fillRect(start, renderState.y, Math.max(stop - start, 1), this.height);
49
+ }
50
+ }
51
+ };
52
+
53
+ return TimelineTrack;
54
+ });
@@ -0,0 +1,8 @@
1
+ var profile = {
2
+ resourceTags : {
3
+ amd : function(filename, mid) {
4
+ "use strict";
5
+ return (/\.js$/).test(filename);
6
+ }
7
+ }
8
+ };
@@ -0,0 +1,6 @@
1
+ {
2
+ "name": "Widgets",
3
+ "description": "Cesium Widgets",
4
+ "version": "0.6.0",
5
+ "dojoBuild": "Widgets.profile.js"
6
+ }
@@ -0,0 +1,8 @@
1
+ var profile = {
2
+ resourceTags : {
3
+ amd : function(filename, mid) {
4
+ "use strict";
5
+ return (/\.js$/).test(filename);
6
+ }
7
+ }
8
+ };
@@ -0,0 +1,2015 @@
1
+ if (typeof self === 'undefined') {
2
+ self = {}; //define self so that the Dojo build can evaluate this file without crashing.
3
+ }
4
+
5
+ self.onmessage = function(event) {
6
+ var data = event.data;
7
+
8
+ require(data.loaderConfig, [data.workerModule], function(workerModule) {
9
+ //replace onmessage with the required-in workerModule
10
+ self.onmessage = workerModule;
11
+ });
12
+ };
13
+
14
+ // replace setTimeout with a function that executes immediately synchronously, which
15
+ // will make the above require synchronous like it used to be, to ensure that we we
16
+ // have the real worker module loaded and installed before receiving any more messages.
17
+ function setTimeout(fn) {
18
+ fn();
19
+ }
20
+
21
+ //below is RequireJS, verbatim
22
+
23
+ /** vim: et:ts=4:sw=4:sts=4
24
+ * @license RequireJS 2.1.2 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
25
+ * Available via the MIT or new BSD license.
26
+ * see: http://github.com/jrburke/requirejs for details
27
+ */
28
+ //Not using strict: uneven strict support in browsers, #392, and causes
29
+ //problems with requirejs.exec()/transpiler plugins that may not be strict.
30
+ /*jslint regexp: true, nomen: true, sloppy: true */
31
+ /*global window, navigator, document, importScripts, jQuery, setTimeout, opera */
32
+
33
+ var requirejs, require, define;
34
+ (function (global) {
35
+ var req, s, head, baseElement, dataMain, src,
36
+ interactiveScript, currentlyAddingScript, mainScript, subPath,
37
+ version = '2.1.2',
38
+ commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,
39
+ cjsRequireRegExp = /[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,
40
+ jsSuffixRegExp = /\.js$/,
41
+ currDirRegExp = /^\.\//,
42
+ op = Object.prototype,
43
+ ostring = op.toString,
44
+ hasOwn = op.hasOwnProperty,
45
+ ap = Array.prototype,
46
+ aps = ap.slice,
47
+ apsp = ap.splice,
48
+ isBrowser = !!(typeof window !== 'undefined' && navigator && document),
49
+ isWebWorker = !isBrowser && typeof importScripts !== 'undefined',
50
+ //PS3 indicates loaded and complete, but need to wait for complete
51
+ //specifically. Sequence is 'loading', 'loaded', execution,
52
+ // then 'complete'. The UA check is unfortunate, but not sure how
53
+ //to feature test w/o causing perf issues.
54
+ readyRegExp = isBrowser && navigator.platform === 'PLAYSTATION 3' ?
55
+ /^complete$/ : /^(complete|loaded)$/,
56
+ defContextName = '_',
57
+ //Oh the tragedy, detecting opera. See the usage of isOpera for reason.
58
+ isOpera = typeof opera !== 'undefined' && opera.toString() === '[object Opera]',
59
+ contexts = {},
60
+ cfg = {},
61
+ globalDefQueue = [],
62
+ useInteractive = false;
63
+
64
+ function isFunction(it) {
65
+ return ostring.call(it) === '[object Function]';
66
+ }
67
+
68
+ function isArray(it) {
69
+ return ostring.call(it) === '[object Array]';
70
+ }
71
+
72
+ /**
73
+ * Helper function for iterating over an array. If the func returns
74
+ * a true value, it will break out of the loop.
75
+ */
76
+ function each(ary, func) {
77
+ if (ary) {
78
+ var i;
79
+ for (i = 0; i < ary.length; i += 1) {
80
+ if (ary[i] && func(ary[i], i, ary)) {
81
+ break;
82
+ }
83
+ }
84
+ }
85
+ }
86
+
87
+ /**
88
+ * Helper function for iterating over an array backwards. If the func
89
+ * returns a true value, it will break out of the loop.
90
+ */
91
+ function eachReverse(ary, func) {
92
+ if (ary) {
93
+ var i;
94
+ for (i = ary.length - 1; i > -1; i -= 1) {
95
+ if (ary[i] && func(ary[i], i, ary)) {
96
+ break;
97
+ }
98
+ }
99
+ }
100
+ }
101
+
102
+ function hasProp(obj, prop) {
103
+ return hasOwn.call(obj, prop);
104
+ }
105
+
106
+ function getOwn(obj, prop) {
107
+ return hasProp(obj, prop) && obj[prop];
108
+ }
109
+
110
+ /**
111
+ * Cycles over properties in an object and calls a function for each
112
+ * property value. If the function returns a truthy value, then the
113
+ * iteration is stopped.
114
+ */
115
+ function eachProp(obj, func) {
116
+ var prop;
117
+ for (prop in obj) {
118
+ if (hasProp(obj, prop)) {
119
+ if (func(obj[prop], prop)) {
120
+ break;
121
+ }
122
+ }
123
+ }
124
+ }
125
+
126
+ /**
127
+ * Simple function to mix in properties from source into target,
128
+ * but only if target does not already have a property of the same name.
129
+ */
130
+ function mixin(target, source, force, deepStringMixin) {
131
+ if (source) {
132
+ eachProp(source, function (value, prop) {
133
+ if (force || !hasProp(target, prop)) {
134
+ if (deepStringMixin && typeof value !== 'string') {
135
+ if (!target[prop]) {
136
+ target[prop] = {};
137
+ }
138
+ mixin(target[prop], value, force, deepStringMixin);
139
+ } else {
140
+ target[prop] = value;
141
+ }
142
+ }
143
+ });
144
+ }
145
+ return target;
146
+ }
147
+
148
+ //Similar to Function.prototype.bind, but the 'this' object is specified
149
+ //first, since it is easier to read/figure out what 'this' will be.
150
+ function bind(obj, fn) {
151
+ return function () {
152
+ return fn.apply(obj, arguments);
153
+ };
154
+ }
155
+
156
+ function scripts() {
157
+ return document.getElementsByTagName('script');
158
+ }
159
+
160
+ //Allow getting a global that expressed in
161
+ //dot notation, like 'a.b.c'.
162
+ function getGlobal(value) {
163
+ if (!value) {
164
+ return value;
165
+ }
166
+ var g = global;
167
+ each(value.split('.'), function (part) {
168
+ g = g[part];
169
+ });
170
+ return g;
171
+ }
172
+
173
+ /**
174
+ * Constructs an error with a pointer to an URL with more information.
175
+ * @param {String} id the error ID that maps to an ID on a web page.
176
+ * @param {String} message human readable error.
177
+ * @param {Error} [err] the original error, if there is one.
178
+ *
179
+ * @returns {Error}
180
+ */
181
+ function makeError(id, msg, err, requireModules) {
182
+ var e = new Error(msg + '\nhttp://requirejs.org/docs/errors.html#' + id);
183
+ e.requireType = id;
184
+ e.requireModules = requireModules;
185
+ if (err) {
186
+ e.originalError = err;
187
+ }
188
+ return e;
189
+ }
190
+
191
+ if (typeof define !== 'undefined') {
192
+ //If a define is already in play via another AMD loader,
193
+ //do not overwrite.
194
+ return;
195
+ }
196
+
197
+ if (typeof requirejs !== 'undefined') {
198
+ if (isFunction(requirejs)) {
199
+ //Do not overwrite and existing requirejs instance.
200
+ return;
201
+ }
202
+ cfg = requirejs;
203
+ requirejs = undefined;
204
+ }
205
+
206
+ //Allow for a require config object
207
+ if (typeof require !== 'undefined' && !isFunction(require)) {
208
+ //assume it is a config object.
209
+ cfg = require;
210
+ require = undefined;
211
+ }
212
+
213
+ function newContext(contextName) {
214
+ var inCheckLoaded, Module, context, handlers,
215
+ checkLoadedTimeoutId,
216
+ config = {
217
+ waitSeconds: 7,
218
+ baseUrl: './',
219
+ paths: {},
220
+ pkgs: {},
221
+ shim: {},
222
+ map: {},
223
+ config: {}
224
+ },
225
+ registry = {},
226
+ undefEvents = {},
227
+ defQueue = [],
228
+ defined = {},
229
+ urlFetched = {},
230
+ requireCounter = 1,
231
+ unnormalizedCounter = 1;
232
+
233
+ /**
234
+ * Trims the . and .. from an array of path segments.
235
+ * It will keep a leading path segment if a .. will become
236
+ * the first path segment, to help with module name lookups,
237
+ * which act like paths, but can be remapped. But the end result,
238
+ * all paths that use this function should look normalized.
239
+ * NOTE: this method MODIFIES the input array.
240
+ * @param {Array} ary the array of path segments.
241
+ */
242
+ function trimDots(ary) {
243
+ var i, part;
244
+ for (i = 0; ary[i]; i += 1) {
245
+ part = ary[i];
246
+ if (part === '.') {
247
+ ary.splice(i, 1);
248
+ i -= 1;
249
+ } else if (part === '..') {
250
+ if (i === 1 && (ary[2] === '..' || ary[0] === '..')) {
251
+ //End of the line. Keep at least one non-dot
252
+ //path segment at the front so it can be mapped
253
+ //correctly to disk. Otherwise, there is likely
254
+ //no path mapping for a path starting with '..'.
255
+ //This can still fail, but catches the most reasonable
256
+ //uses of ..
257
+ break;
258
+ } else if (i > 0) {
259
+ ary.splice(i - 1, 2);
260
+ i -= 2;
261
+ }
262
+ }
263
+ }
264
+ }
265
+
266
+ /**
267
+ * Given a relative module name, like ./something, normalize it to
268
+ * a real name that can be mapped to a path.
269
+ * @param {String} name the relative name
270
+ * @param {String} baseName a real name that the name arg is relative
271
+ * to.
272
+ * @param {Boolean} applyMap apply the map config to the value. Should
273
+ * only be done if this normalization is for a dependency ID.
274
+ * @returns {String} normalized name
275
+ */
276
+ function normalize(name, baseName, applyMap) {
277
+ var pkgName, pkgConfig, mapValue, nameParts, i, j, nameSegment,
278
+ foundMap, foundI, foundStarMap, starI,
279
+ baseParts = baseName && baseName.split('/'),
280
+ normalizedBaseParts = baseParts,
281
+ map = config.map,
282
+ starMap = map && map['*'];
283
+
284
+ //Adjust any relative paths.
285
+ if (name && name.charAt(0) === '.') {
286
+ //If have a base name, try to normalize against it,
287
+ //otherwise, assume it is a top-level require that will
288
+ //be relative to baseUrl in the end.
289
+ if (baseName) {
290
+ if (getOwn(config.pkgs, baseName)) {
291
+ //If the baseName is a package name, then just treat it as one
292
+ //name to concat the name with.
293
+ normalizedBaseParts = baseParts = [baseName];
294
+ } else {
295
+ //Convert baseName to array, and lop off the last part,
296
+ //so that . matches that 'directory' and not name of the baseName's
297
+ //module. For instance, baseName of 'one/two/three', maps to
298
+ //'one/two/three.js', but we want the directory, 'one/two' for
299
+ //this normalization.
300
+ normalizedBaseParts = baseParts.slice(0, baseParts.length - 1);
301
+ }
302
+
303
+ name = normalizedBaseParts.concat(name.split('/'));
304
+ trimDots(name);
305
+
306
+ //Some use of packages may use a . path to reference the
307
+ //'main' module name, so normalize for that.
308
+ pkgConfig = getOwn(config.pkgs, (pkgName = name[0]));
309
+ name = name.join('/');
310
+ if (pkgConfig && name === pkgName + '/' + pkgConfig.main) {
311
+ name = pkgName;
312
+ }
313
+ } else if (name.indexOf('./') === 0) {
314
+ // No baseName, so this is ID is resolved relative
315
+ // to baseUrl, pull off the leading dot.
316
+ name = name.substring(2);
317
+ }
318
+ }
319
+
320
+ //Apply map config if available.
321
+ if (applyMap && (baseParts || starMap) && map) {
322
+ nameParts = name.split('/');
323
+
324
+ for (i = nameParts.length; i > 0; i -= 1) {
325
+ nameSegment = nameParts.slice(0, i).join('/');
326
+
327
+ if (baseParts) {
328
+ //Find the longest baseName segment match in the config.
329
+ //So, do joins on the biggest to smallest lengths of baseParts.
330
+ for (j = baseParts.length; j > 0; j -= 1) {
331
+ mapValue = getOwn(map, baseParts.slice(0, j).join('/'));
332
+
333
+ //baseName segment has config, find if it has one for
334
+ //this name.
335
+ if (mapValue) {
336
+ mapValue = getOwn(mapValue, nameSegment);
337
+ if (mapValue) {
338
+ //Match, update name to the new value.
339
+ foundMap = mapValue;
340
+ foundI = i;
341
+ break;
342
+ }
343
+ }
344
+ }
345
+ }
346
+
347
+ if (foundMap) {
348
+ break;
349
+ }
350
+
351
+ //Check for a star map match, but just hold on to it,
352
+ //if there is a shorter segment match later in a matching
353
+ //config, then favor over this star map.
354
+ if (!foundStarMap && starMap && getOwn(starMap, nameSegment)) {
355
+ foundStarMap = getOwn(starMap, nameSegment);
356
+ starI = i;
357
+ }
358
+ }
359
+
360
+ if (!foundMap && foundStarMap) {
361
+ foundMap = foundStarMap;
362
+ foundI = starI;
363
+ }
364
+
365
+ if (foundMap) {
366
+ nameParts.splice(0, foundI, foundMap);
367
+ name = nameParts.join('/');
368
+ }
369
+ }
370
+
371
+ return name;
372
+ }
373
+
374
+ function removeScript(name) {
375
+ if (isBrowser) {
376
+ each(scripts(), function (scriptNode) {
377
+ if (scriptNode.getAttribute('data-requiremodule') === name &&
378
+ scriptNode.getAttribute('data-requirecontext') === context.contextName) {
379
+ scriptNode.parentNode.removeChild(scriptNode);
380
+ return true;
381
+ }
382
+ });
383
+ }
384
+ }
385
+
386
+ function hasPathFallback(id) {
387
+ var pathConfig = getOwn(config.paths, id);
388
+ if (pathConfig && isArray(pathConfig) && pathConfig.length > 1) {
389
+ removeScript(id);
390
+ //Pop off the first array value, since it failed, and
391
+ //retry
392
+ pathConfig.shift();
393
+ context.require.undef(id);
394
+ context.require([id]);
395
+ return true;
396
+ }
397
+ }
398
+
399
+ //Turns a plugin!resource to [plugin, resource]
400
+ //with the plugin being undefined if the name
401
+ //did not have a plugin prefix.
402
+ function splitPrefix(name) {
403
+ var prefix,
404
+ index = name ? name.indexOf('!') : -1;
405
+ if (index > -1) {
406
+ prefix = name.substring(0, index);
407
+ name = name.substring(index + 1, name.length);
408
+ }
409
+ return [prefix, name];
410
+ }
411
+
412
+ /**
413
+ * Creates a module mapping that includes plugin prefix, module
414
+ * name, and path. If parentModuleMap is provided it will
415
+ * also normalize the name via require.normalize()
416
+ *
417
+ * @param {String} name the module name
418
+ * @param {String} [parentModuleMap] parent module map
419
+ * for the module name, used to resolve relative names.
420
+ * @param {Boolean} isNormalized: is the ID already normalized.
421
+ * This is true if this call is done for a define() module ID.
422
+ * @param {Boolean} applyMap: apply the map config to the ID.
423
+ * Should only be true if this map is for a dependency.
424
+ *
425
+ * @returns {Object}
426
+ */
427
+ function makeModuleMap(name, parentModuleMap, isNormalized, applyMap) {
428
+ var url, pluginModule, suffix, nameParts,
429
+ prefix = null,
430
+ parentName = parentModuleMap ? parentModuleMap.name : null,
431
+ originalName = name,
432
+ isDefine = true,
433
+ normalizedName = '';
434
+
435
+ //If no name, then it means it is a require call, generate an
436
+ //internal name.
437
+ if (!name) {
438
+ isDefine = false;
439
+ name = '_@r' + (requireCounter += 1);
440
+ }
441
+
442
+ nameParts = splitPrefix(name);
443
+ prefix = nameParts[0];
444
+ name = nameParts[1];
445
+
446
+ if (prefix) {
447
+ prefix = normalize(prefix, parentName, applyMap);
448
+ pluginModule = getOwn(defined, prefix);
449
+ }
450
+
451
+ //Account for relative paths if there is a base name.
452
+ if (name) {
453
+ if (prefix) {
454
+ if (pluginModule && pluginModule.normalize) {
455
+ //Plugin is loaded, use its normalize method.
456
+ normalizedName = pluginModule.normalize(name, function (name) {
457
+ return normalize(name, parentName, applyMap);
458
+ });
459
+ } else {
460
+ normalizedName = normalize(name, parentName, applyMap);
461
+ }
462
+ } else {
463
+ //A regular module.
464
+ normalizedName = normalize(name, parentName, applyMap);
465
+
466
+ //Normalized name may be a plugin ID due to map config
467
+ //application in normalize. The map config values must
468
+ //already be normalized, so do not need to redo that part.
469
+ nameParts = splitPrefix(normalizedName);
470
+ prefix = nameParts[0];
471
+ normalizedName = nameParts[1];
472
+ isNormalized = true;
473
+
474
+ url = context.nameToUrl(normalizedName);
475
+ }
476
+ }
477
+
478
+ //If the id is a plugin id that cannot be determined if it needs
479
+ //normalization, stamp it with a unique ID so two matching relative
480
+ //ids that may conflict can be separate.
481
+ suffix = prefix && !pluginModule && !isNormalized ?
482
+ '_unnormalized' + (unnormalizedCounter += 1) :
483
+ '';
484
+
485
+ return {
486
+ prefix: prefix,
487
+ name: normalizedName,
488
+ parentMap: parentModuleMap,
489
+ unnormalized: !!suffix,
490
+ url: url,
491
+ originalName: originalName,
492
+ isDefine: isDefine,
493
+ id: (prefix ?
494
+ prefix + '!' + normalizedName :
495
+ normalizedName) + suffix
496
+ };
497
+ }
498
+
499
+ function getModule(depMap) {
500
+ var id = depMap.id,
501
+ mod = getOwn(registry, id);
502
+
503
+ if (!mod) {
504
+ mod = registry[id] = new context.Module(depMap);
505
+ }
506
+
507
+ return mod;
508
+ }
509
+
510
+ function on(depMap, name, fn) {
511
+ var id = depMap.id,
512
+ mod = getOwn(registry, id);
513
+
514
+ if (hasProp(defined, id) &&
515
+ (!mod || mod.defineEmitComplete)) {
516
+ if (name === 'defined') {
517
+ fn(defined[id]);
518
+ }
519
+ } else {
520
+ getModule(depMap).on(name, fn);
521
+ }
522
+ }
523
+
524
+ function onError(err, errback) {
525
+ var ids = err.requireModules,
526
+ notified = false;
527
+
528
+ if (errback) {
529
+ errback(err);
530
+ } else {
531
+ each(ids, function (id) {
532
+ var mod = getOwn(registry, id);
533
+ if (mod) {
534
+ //Set error on module, so it skips timeout checks.
535
+ mod.error = err;
536
+ if (mod.events.error) {
537
+ notified = true;
538
+ mod.emit('error', err);
539
+ }
540
+ }
541
+ });
542
+
543
+ if (!notified) {
544
+ req.onError(err);
545
+ }
546
+ }
547
+ }
548
+
549
+ /**
550
+ * Internal method to transfer globalQueue items to this context's
551
+ * defQueue.
552
+ */
553
+ function takeGlobalQueue() {
554
+ //Push all the globalDefQueue items into the context's defQueue
555
+ if (globalDefQueue.length) {
556
+ //Array splice in the values since the context code has a
557
+ //local var ref to defQueue, so cannot just reassign the one
558
+ //on context.
559
+ apsp.apply(defQueue,
560
+ [defQueue.length - 1, 0].concat(globalDefQueue));
561
+ globalDefQueue = [];
562
+ }
563
+ }
564
+
565
+ handlers = {
566
+ 'require': function (mod) {
567
+ if (mod.require) {
568
+ return mod.require;
569
+ } else {
570
+ return (mod.require = context.makeRequire(mod.map));
571
+ }
572
+ },
573
+ 'exports': function (mod) {
574
+ mod.usingExports = true;
575
+ if (mod.map.isDefine) {
576
+ if (mod.exports) {
577
+ return mod.exports;
578
+ } else {
579
+ return (mod.exports = defined[mod.map.id] = {});
580
+ }
581
+ }
582
+ },
583
+ 'module': function (mod) {
584
+ if (mod.module) {
585
+ return mod.module;
586
+ } else {
587
+ return (mod.module = {
588
+ id: mod.map.id,
589
+ uri: mod.map.url,
590
+ config: function () {
591
+ return (config.config && getOwn(config.config, mod.map.id)) || {};
592
+ },
593
+ exports: defined[mod.map.id]
594
+ });
595
+ }
596
+ }
597
+ };
598
+
599
+ function cleanRegistry(id) {
600
+ //Clean up machinery used for waiting modules.
601
+ delete registry[id];
602
+ }
603
+
604
+ function breakCycle(mod, traced, processed) {
605
+ var id = mod.map.id;
606
+
607
+ if (mod.error) {
608
+ mod.emit('error', mod.error);
609
+ } else {
610
+ traced[id] = true;
611
+ each(mod.depMaps, function (depMap, i) {
612
+ var depId = depMap.id,
613
+ dep = getOwn(registry, depId);
614
+
615
+ //Only force things that have not completed
616
+ //being defined, so still in the registry,
617
+ //and only if it has not been matched up
618
+ //in the module already.
619
+ if (dep && !mod.depMatched[i] && !processed[depId]) {
620
+ if (getOwn(traced, depId)) {
621
+ mod.defineDep(i, defined[depId]);
622
+ mod.check(); //pass false?
623
+ } else {
624
+ breakCycle(dep, traced, processed);
625
+ }
626
+ }
627
+ });
628
+ processed[id] = true;
629
+ }
630
+ }
631
+
632
+ function checkLoaded() {
633
+ var map, modId, err, usingPathFallback,
634
+ waitInterval = config.waitSeconds * 1000,
635
+ //It is possible to disable the wait interval by using waitSeconds of 0.
636
+ expired = waitInterval && (context.startTime + waitInterval) < new Date().getTime(),
637
+ noLoads = [],
638
+ reqCalls = [],
639
+ stillLoading = false,
640
+ needCycleCheck = true;
641
+
642
+ //Do not bother if this call was a result of a cycle break.
643
+ if (inCheckLoaded) {
644
+ return;
645
+ }
646
+
647
+ inCheckLoaded = true;
648
+
649
+ //Figure out the state of all the modules.
650
+ eachProp(registry, function (mod) {
651
+ map = mod.map;
652
+ modId = map.id;
653
+
654
+ //Skip things that are not enabled or in error state.
655
+ if (!mod.enabled) {
656
+ return;
657
+ }
658
+
659
+ if (!map.isDefine) {
660
+ reqCalls.push(mod);
661
+ }
662
+
663
+ if (!mod.error) {
664
+ //If the module should be executed, and it has not
665
+ //been inited and time is up, remember it.
666
+ if (!mod.inited && expired) {
667
+ if (hasPathFallback(modId)) {
668
+ usingPathFallback = true;
669
+ stillLoading = true;
670
+ } else {
671
+ noLoads.push(modId);
672
+ removeScript(modId);
673
+ }
674
+ } else if (!mod.inited && mod.fetched && map.isDefine) {
675
+ stillLoading = true;
676
+ if (!map.prefix) {
677
+ //No reason to keep looking for unfinished
678
+ //loading. If the only stillLoading is a
679
+ //plugin resource though, keep going,
680
+ //because it may be that a plugin resource
681
+ //is waiting on a non-plugin cycle.
682
+ return (needCycleCheck = false);
683
+ }
684
+ }
685
+ }
686
+ });
687
+
688
+ if (expired && noLoads.length) {
689
+ //If wait time expired, throw error of unloaded modules.
690
+ err = makeError('timeout', 'Load timeout for modules: ' + noLoads, null, noLoads);
691
+ err.contextName = context.contextName;
692
+ return onError(err);
693
+ }
694
+
695
+ //Not expired, check for a cycle.
696
+ if (needCycleCheck) {
697
+ each(reqCalls, function (mod) {
698
+ breakCycle(mod, {}, {});
699
+ });
700
+ }
701
+
702
+ //If still waiting on loads, and the waiting load is something
703
+ //other than a plugin resource, or there are still outstanding
704
+ //scripts, then just try back later.
705
+ if ((!expired || usingPathFallback) && stillLoading) {
706
+ //Something is still waiting to load. Wait for it, but only
707
+ //if a timeout is not already in effect.
708
+ if ((isBrowser || isWebWorker) && !checkLoadedTimeoutId) {
709
+ checkLoadedTimeoutId = setTimeout(function () {
710
+ checkLoadedTimeoutId = 0;
711
+ checkLoaded();
712
+ }, 50);
713
+ }
714
+ }
715
+
716
+ inCheckLoaded = false;
717
+ }
718
+
719
+ Module = function (map) {
720
+ this.events = getOwn(undefEvents, map.id) || {};
721
+ this.map = map;
722
+ this.shim = getOwn(config.shim, map.id);
723
+ this.depExports = [];
724
+ this.depMaps = [];
725
+ this.depMatched = [];
726
+ this.pluginMaps = {};
727
+ this.depCount = 0;
728
+
729
+ /* this.exports this.factory
730
+ this.depMaps = [],
731
+ this.enabled, this.fetched
732
+ */
733
+ };
734
+
735
+ Module.prototype = {
736
+ init: function (depMaps, factory, errback, options) {
737
+ options = options || {};
738
+
739
+ //Do not do more inits if already done. Can happen if there
740
+ //are multiple define calls for the same module. That is not
741
+ //a normal, common case, but it is also not unexpected.
742
+ if (this.inited) {
743
+ return;
744
+ }
745
+
746
+ this.factory = factory;
747
+
748
+ if (errback) {
749
+ //Register for errors on this module.
750
+ this.on('error', errback);
751
+ } else if (this.events.error) {
752
+ //If no errback already, but there are error listeners
753
+ //on this module, set up an errback to pass to the deps.
754
+ errback = bind(this, function (err) {
755
+ this.emit('error', err);
756
+ });
757
+ }
758
+
759
+ //Do a copy of the dependency array, so that
760
+ //source inputs are not modified. For example
761
+ //"shim" deps are passed in here directly, and
762
+ //doing a direct modification of the depMaps array
763
+ //would affect that config.
764
+ this.depMaps = depMaps && depMaps.slice(0);
765
+
766
+ this.errback = errback;
767
+
768
+ //Indicate this module has be initialized
769
+ this.inited = true;
770
+
771
+ this.ignore = options.ignore;
772
+
773
+ //Could have option to init this module in enabled mode,
774
+ //or could have been previously marked as enabled. However,
775
+ //the dependencies are not known until init is called. So
776
+ //if enabled previously, now trigger dependencies as enabled.
777
+ if (options.enabled || this.enabled) {
778
+ //Enable this module and dependencies.
779
+ //Will call this.check()
780
+ this.enable();
781
+ } else {
782
+ this.check();
783
+ }
784
+ },
785
+
786
+ defineDep: function (i, depExports) {
787
+ //Because of cycles, defined callback for a given
788
+ //export can be called more than once.
789
+ if (!this.depMatched[i]) {
790
+ this.depMatched[i] = true;
791
+ this.depCount -= 1;
792
+ this.depExports[i] = depExports;
793
+ }
794
+ },
795
+
796
+ fetch: function () {
797
+ if (this.fetched) {
798
+ return;
799
+ }
800
+ this.fetched = true;
801
+
802
+ context.startTime = (new Date()).getTime();
803
+
804
+ var map = this.map;
805
+
806
+ //If the manager is for a plugin managed resource,
807
+ //ask the plugin to load it now.
808
+ if (this.shim) {
809
+ context.makeRequire(this.map, {
810
+ enableBuildCallback: true
811
+ })(this.shim.deps || [], bind(this, function () {
812
+ return map.prefix ? this.callPlugin() : this.load();
813
+ }));
814
+ } else {
815
+ //Regular dependency.
816
+ return map.prefix ? this.callPlugin() : this.load();
817
+ }
818
+ },
819
+
820
+ load: function () {
821
+ var url = this.map.url;
822
+
823
+ //Regular dependency.
824
+ if (!urlFetched[url]) {
825
+ urlFetched[url] = true;
826
+ context.load(this.map.id, url);
827
+ }
828
+ },
829
+
830
+ /**
831
+ * Checks is the module is ready to define itself, and if so,
832
+ * define it.
833
+ */
834
+ check: function () {
835
+ if (!this.enabled || this.enabling) {
836
+ return;
837
+ }
838
+
839
+ var err, cjsModule,
840
+ id = this.map.id,
841
+ depExports = this.depExports,
842
+ exports = this.exports,
843
+ factory = this.factory;
844
+
845
+ if (!this.inited) {
846
+ this.fetch();
847
+ } else if (this.error) {
848
+ this.emit('error', this.error);
849
+ } else if (!this.defining) {
850
+ //The factory could trigger another require call
851
+ //that would result in checking this module to
852
+ //define itself again. If already in the process
853
+ //of doing that, skip this work.
854
+ this.defining = true;
855
+
856
+ if (this.depCount < 1 && !this.defined) {
857
+ if (isFunction(factory)) {
858
+ //If there is an error listener, favor passing
859
+ //to that instead of throwing an error.
860
+ if (this.events.error) {
861
+ try {
862
+ exports = context.execCb(id, factory, depExports, exports);
863
+ } catch (e) {
864
+ err = e;
865
+ }
866
+ } else {
867
+ exports = context.execCb(id, factory, depExports, exports);
868
+ }
869
+
870
+ if (this.map.isDefine) {
871
+ //If setting exports via 'module' is in play,
872
+ //favor that over return value and exports. After that,
873
+ //favor a non-undefined return value over exports use.
874
+ cjsModule = this.module;
875
+ if (cjsModule &&
876
+ cjsModule.exports !== undefined &&
877
+ //Make sure it is not already the exports value
878
+ cjsModule.exports !== this.exports) {
879
+ exports = cjsModule.exports;
880
+ } else if (exports === undefined && this.usingExports) {
881
+ //exports already set the defined value.
882
+ exports = this.exports;
883
+ }
884
+ }
885
+
886
+ if (err) {
887
+ err.requireMap = this.map;
888
+ err.requireModules = [this.map.id];
889
+ err.requireType = 'define';
890
+ return onError((this.error = err));
891
+ }
892
+
893
+ } else {
894
+ //Just a literal value
895
+ exports = factory;
896
+ }
897
+
898
+ this.exports = exports;
899
+
900
+ if (this.map.isDefine && !this.ignore) {
901
+ defined[id] = exports;
902
+
903
+ if (req.onResourceLoad) {
904
+ req.onResourceLoad(context, this.map, this.depMaps);
905
+ }
906
+ }
907
+
908
+ //Clean up
909
+ delete registry[id];
910
+
911
+ this.defined = true;
912
+ }
913
+
914
+ //Finished the define stage. Allow calling check again
915
+ //to allow define notifications below in the case of a
916
+ //cycle.
917
+ this.defining = false;
918
+
919
+ if (this.defined && !this.defineEmitted) {
920
+ this.defineEmitted = true;
921
+ this.emit('defined', this.exports);
922
+ this.defineEmitComplete = true;
923
+ }
924
+
925
+ }
926
+ },
927
+
928
+ callPlugin: function () {
929
+ var map = this.map,
930
+ id = map.id,
931
+ //Map already normalized the prefix.
932
+ pluginMap = makeModuleMap(map.prefix);
933
+
934
+ //Mark this as a dependency for this plugin, so it
935
+ //can be traced for cycles.
936
+ this.depMaps.push(pluginMap);
937
+
938
+ on(pluginMap, 'defined', bind(this, function (plugin) {
939
+ var load, normalizedMap, normalizedMod,
940
+ name = this.map.name,
941
+ parentName = this.map.parentMap ? this.map.parentMap.name : null,
942
+ localRequire = context.makeRequire(map.parentMap, {
943
+ enableBuildCallback: true,
944
+ skipMap: true
945
+ });
946
+
947
+ //If current map is not normalized, wait for that
948
+ //normalized name to load instead of continuing.
949
+ if (this.map.unnormalized) {
950
+ //Normalize the ID if the plugin allows it.
951
+ if (plugin.normalize) {
952
+ name = plugin.normalize(name, function (name) {
953
+ return normalize(name, parentName, true);
954
+ }) || '';
955
+ }
956
+
957
+ //prefix and name should already be normalized, no need
958
+ //for applying map config again either.
959
+ normalizedMap = makeModuleMap(map.prefix + '!' + name,
960
+ this.map.parentMap);
961
+ on(normalizedMap,
962
+ 'defined', bind(this, function (value) {
963
+ this.init([], function () { return value; }, null, {
964
+ enabled: true,
965
+ ignore: true
966
+ });
967
+ }));
968
+
969
+ normalizedMod = getOwn(registry, normalizedMap.id);
970
+ if (normalizedMod) {
971
+ //Mark this as a dependency for this plugin, so it
972
+ //can be traced for cycles.
973
+ this.depMaps.push(normalizedMap);
974
+
975
+ if (this.events.error) {
976
+ normalizedMod.on('error', bind(this, function (err) {
977
+ this.emit('error', err);
978
+ }));
979
+ }
980
+ normalizedMod.enable();
981
+ }
982
+
983
+ return;
984
+ }
985
+
986
+ load = bind(this, function (value) {
987
+ this.init([], function () { return value; }, null, {
988
+ enabled: true
989
+ });
990
+ });
991
+
992
+ load.error = bind(this, function (err) {
993
+ this.inited = true;
994
+ this.error = err;
995
+ err.requireModules = [id];
996
+
997
+ //Remove temp unnormalized modules for this module,
998
+ //since they will never be resolved otherwise now.
999
+ eachProp(registry, function (mod) {
1000
+ if (mod.map.id.indexOf(id + '_unnormalized') === 0) {
1001
+ cleanRegistry(mod.map.id);
1002
+ }
1003
+ });
1004
+
1005
+ onError(err);
1006
+ });
1007
+
1008
+ //Allow plugins to load other code without having to know the
1009
+ //context or how to 'complete' the load.
1010
+ load.fromText = bind(this, function (text, textAlt) {
1011
+ /*jslint evil: true */
1012
+ var moduleName = map.name,
1013
+ moduleMap = makeModuleMap(moduleName),
1014
+ hasInteractive = useInteractive;
1015
+
1016
+ //As of 2.1.0, support just passing the text, to reinforce
1017
+ //fromText only being called once per resource. Still
1018
+ //support old style of passing moduleName but discard
1019
+ //that moduleName in favor of the internal ref.
1020
+ if (textAlt) {
1021
+ text = textAlt;
1022
+ }
1023
+
1024
+ //Turn off interactive script matching for IE for any define
1025
+ //calls in the text, then turn it back on at the end.
1026
+ if (hasInteractive) {
1027
+ useInteractive = false;
1028
+ }
1029
+
1030
+ //Prime the system by creating a module instance for
1031
+ //it.
1032
+ getModule(moduleMap);
1033
+
1034
+ //Transfer any config to this other module.
1035
+ if (hasProp(config.config, id)) {
1036
+ config.config[moduleName] = config.config[id];
1037
+ }
1038
+
1039
+ try {
1040
+ req.exec(text);
1041
+ } catch (e) {
1042
+ throw new Error('fromText eval for ' + moduleName +
1043
+ ' failed: ' + e);
1044
+ }
1045
+
1046
+ if (hasInteractive) {
1047
+ useInteractive = true;
1048
+ }
1049
+
1050
+ //Mark this as a dependency for the plugin
1051
+ //resource
1052
+ this.depMaps.push(moduleMap);
1053
+
1054
+ //Support anonymous modules.
1055
+ context.completeLoad(moduleName);
1056
+
1057
+ //Bind the value of that module to the value for this
1058
+ //resource ID.
1059
+ localRequire([moduleName], load);
1060
+ });
1061
+
1062
+ //Use parentName here since the plugin's name is not reliable,
1063
+ //could be some weird string with no path that actually wants to
1064
+ //reference the parentName's path.
1065
+ plugin.load(map.name, localRequire, load, config);
1066
+ }));
1067
+
1068
+ context.enable(pluginMap, this);
1069
+ this.pluginMaps[pluginMap.id] = pluginMap;
1070
+ },
1071
+
1072
+ enable: function () {
1073
+ this.enabled = true;
1074
+
1075
+ //Set flag mentioning that the module is enabling,
1076
+ //so that immediate calls to the defined callbacks
1077
+ //for dependencies do not trigger inadvertent load
1078
+ //with the depCount still being zero.
1079
+ this.enabling = true;
1080
+
1081
+ //Enable each dependency
1082
+ each(this.depMaps, bind(this, function (depMap, i) {
1083
+ var id, mod, handler;
1084
+
1085
+ if (typeof depMap === 'string') {
1086
+ //Dependency needs to be converted to a depMap
1087
+ //and wired up to this module.
1088
+ depMap = makeModuleMap(depMap,
1089
+ (this.map.isDefine ? this.map : this.map.parentMap),
1090
+ false,
1091
+ !this.skipMap);
1092
+ this.depMaps[i] = depMap;
1093
+
1094
+ handler = getOwn(handlers, depMap.id);
1095
+
1096
+ if (handler) {
1097
+ this.depExports[i] = handler(this);
1098
+ return;
1099
+ }
1100
+
1101
+ this.depCount += 1;
1102
+
1103
+ on(depMap, 'defined', bind(this, function (depExports) {
1104
+ this.defineDep(i, depExports);
1105
+ this.check();
1106
+ }));
1107
+
1108
+ if (this.errback) {
1109
+ on(depMap, 'error', this.errback);
1110
+ }
1111
+ }
1112
+
1113
+ id = depMap.id;
1114
+ mod = registry[id];
1115
+
1116
+ //Skip special modules like 'require', 'exports', 'module'
1117
+ //Also, don't call enable if it is already enabled,
1118
+ //important in circular dependency cases.
1119
+ if (!hasProp(handlers, id) && mod && !mod.enabled) {
1120
+ context.enable(depMap, this);
1121
+ }
1122
+ }));
1123
+
1124
+ //Enable each plugin that is used in
1125
+ //a dependency
1126
+ eachProp(this.pluginMaps, bind(this, function (pluginMap) {
1127
+ var mod = getOwn(registry, pluginMap.id);
1128
+ if (mod && !mod.enabled) {
1129
+ context.enable(pluginMap, this);
1130
+ }
1131
+ }));
1132
+
1133
+ this.enabling = false;
1134
+
1135
+ this.check();
1136
+ },
1137
+
1138
+ on: function (name, cb) {
1139
+ var cbs = this.events[name];
1140
+ if (!cbs) {
1141
+ cbs = this.events[name] = [];
1142
+ }
1143
+ cbs.push(cb);
1144
+ },
1145
+
1146
+ emit: function (name, evt) {
1147
+ each(this.events[name], function (cb) {
1148
+ cb(evt);
1149
+ });
1150
+ if (name === 'error') {
1151
+ //Now that the error handler was triggered, remove
1152
+ //the listeners, since this broken Module instance
1153
+ //can stay around for a while in the registry.
1154
+ delete this.events[name];
1155
+ }
1156
+ }
1157
+ };
1158
+
1159
+ function callGetModule(args) {
1160
+ //Skip modules already defined.
1161
+ if (!hasProp(defined, args[0])) {
1162
+ getModule(makeModuleMap(args[0], null, true)).init(args[1], args[2]);
1163
+ }
1164
+ }
1165
+
1166
+ function removeListener(node, func, name, ieName) {
1167
+ //Favor detachEvent because of IE9
1168
+ //issue, see attachEvent/addEventListener comment elsewhere
1169
+ //in this file.
1170
+ if (node.detachEvent && !isOpera) {
1171
+ //Probably IE. If not it will throw an error, which will be
1172
+ //useful to know.
1173
+ if (ieName) {
1174
+ node.detachEvent(ieName, func);
1175
+ }
1176
+ } else {
1177
+ node.removeEventListener(name, func, false);
1178
+ }
1179
+ }
1180
+
1181
+ /**
1182
+ * Given an event from a script node, get the requirejs info from it,
1183
+ * and then removes the event listeners on the node.
1184
+ * @param {Event} evt
1185
+ * @returns {Object}
1186
+ */
1187
+ function getScriptData(evt) {
1188
+ //Using currentTarget instead of target for Firefox 2.0's sake. Not
1189
+ //all old browsers will be supported, but this one was easy enough
1190
+ //to support and still makes sense.
1191
+ var node = evt.currentTarget || evt.srcElement;
1192
+
1193
+ //Remove the listeners once here.
1194
+ removeListener(node, context.onScriptLoad, 'load', 'onreadystatechange');
1195
+ removeListener(node, context.onScriptError, 'error');
1196
+
1197
+ return {
1198
+ node: node,
1199
+ id: node && node.getAttribute('data-requiremodule')
1200
+ };
1201
+ }
1202
+
1203
+ function intakeDefines() {
1204
+ var args;
1205
+
1206
+ //Any defined modules in the global queue, intake them now.
1207
+ takeGlobalQueue();
1208
+
1209
+ //Make sure any remaining defQueue items get properly processed.
1210
+ while (defQueue.length) {
1211
+ args = defQueue.shift();
1212
+ if (args[0] === null) {
1213
+ return onError(makeError('mismatch', 'Mismatched anonymous define() module: ' + args[args.length - 1]));
1214
+ } else {
1215
+ //args are id, deps, factory. Should be normalized by the
1216
+ //define() function.
1217
+ callGetModule(args);
1218
+ }
1219
+ }
1220
+ }
1221
+
1222
+ context = {
1223
+ config: config,
1224
+ contextName: contextName,
1225
+ registry: registry,
1226
+ defined: defined,
1227
+ urlFetched: urlFetched,
1228
+ defQueue: defQueue,
1229
+ Module: Module,
1230
+ makeModuleMap: makeModuleMap,
1231
+ nextTick: req.nextTick,
1232
+
1233
+ /**
1234
+ * Set a configuration for the context.
1235
+ * @param {Object} cfg config object to integrate.
1236
+ */
1237
+ configure: function (cfg) {
1238
+ //Make sure the baseUrl ends in a slash.
1239
+ if (cfg.baseUrl) {
1240
+ if (cfg.baseUrl.charAt(cfg.baseUrl.length - 1) !== '/') {
1241
+ cfg.baseUrl += '/';
1242
+ }
1243
+ }
1244
+
1245
+ //Save off the paths and packages since they require special processing,
1246
+ //they are additive.
1247
+ var pkgs = config.pkgs,
1248
+ shim = config.shim,
1249
+ objs = {
1250
+ paths: true,
1251
+ config: true,
1252
+ map: true
1253
+ };
1254
+
1255
+ eachProp(cfg, function (value, prop) {
1256
+ if (objs[prop]) {
1257
+ if (prop === 'map') {
1258
+ mixin(config[prop], value, true, true);
1259
+ } else {
1260
+ mixin(config[prop], value, true);
1261
+ }
1262
+ } else {
1263
+ config[prop] = value;
1264
+ }
1265
+ });
1266
+
1267
+ //Merge shim
1268
+ if (cfg.shim) {
1269
+ eachProp(cfg.shim, function (value, id) {
1270
+ //Normalize the structure
1271
+ if (isArray(value)) {
1272
+ value = {
1273
+ deps: value
1274
+ };
1275
+ }
1276
+ if ((value.exports || value.init) && !value.exportsFn) {
1277
+ value.exportsFn = context.makeShimExports(value);
1278
+ }
1279
+ shim[id] = value;
1280
+ });
1281
+ config.shim = shim;
1282
+ }
1283
+
1284
+ //Adjust packages if necessary.
1285
+ if (cfg.packages) {
1286
+ each(cfg.packages, function (pkgObj) {
1287
+ var location;
1288
+
1289
+ pkgObj = typeof pkgObj === 'string' ? { name: pkgObj } : pkgObj;
1290
+ location = pkgObj.location;
1291
+
1292
+ //Create a brand new object on pkgs, since currentPackages can
1293
+ //be passed in again, and config.pkgs is the internal transformed
1294
+ //state for all package configs.
1295
+ pkgs[pkgObj.name] = {
1296
+ name: pkgObj.name,
1297
+ location: location || pkgObj.name,
1298
+ //Remove leading dot in main, so main paths are normalized,
1299
+ //and remove any trailing .js, since different package
1300
+ //envs have different conventions: some use a module name,
1301
+ //some use a file name.
1302
+ main: (pkgObj.main || 'main')
1303
+ .replace(currDirRegExp, '')
1304
+ .replace(jsSuffixRegExp, '')
1305
+ };
1306
+ });
1307
+
1308
+ //Done with modifications, assing packages back to context config
1309
+ config.pkgs = pkgs;
1310
+ }
1311
+
1312
+ //If there are any "waiting to execute" modules in the registry,
1313
+ //update the maps for them, since their info, like URLs to load,
1314
+ //may have changed.
1315
+ eachProp(registry, function (mod, id) {
1316
+ //If module already has init called, since it is too
1317
+ //late to modify them, and ignore unnormalized ones
1318
+ //since they are transient.
1319
+ if (!mod.inited && !mod.map.unnormalized) {
1320
+ mod.map = makeModuleMap(id);
1321
+ }
1322
+ });
1323
+
1324
+ //If a deps array or a config callback is specified, then call
1325
+ //require with those args. This is useful when require is defined as a
1326
+ //config object before require.js is loaded.
1327
+ if (cfg.deps || cfg.callback) {
1328
+ context.require(cfg.deps || [], cfg.callback);
1329
+ }
1330
+ },
1331
+
1332
+ makeShimExports: function (value) {
1333
+ function fn() {
1334
+ var ret;
1335
+ if (value.init) {
1336
+ ret = value.init.apply(global, arguments);
1337
+ }
1338
+ return ret || (value.exports && getGlobal(value.exports));
1339
+ }
1340
+ return fn;
1341
+ },
1342
+
1343
+ makeRequire: function (relMap, options) {
1344
+ options = options || {};
1345
+
1346
+ function localRequire(deps, callback, errback) {
1347
+ var id, map, requireMod;
1348
+
1349
+ if (options.enableBuildCallback && callback && isFunction(callback)) {
1350
+ callback.__requireJsBuild = true;
1351
+ }
1352
+
1353
+ if (typeof deps === 'string') {
1354
+ if (isFunction(callback)) {
1355
+ //Invalid call
1356
+ return onError(makeError('requireargs', 'Invalid require call'), errback);
1357
+ }
1358
+
1359
+ //If require|exports|module are requested, get the
1360
+ //value for them from the special handlers. Caveat:
1361
+ //this only works while module is being defined.
1362
+ if (relMap && hasProp(handlers, deps)) {
1363
+ return handlers[deps](registry[relMap.id]);
1364
+ }
1365
+
1366
+ //Synchronous access to one module. If require.get is
1367
+ //available (as in the Node adapter), prefer that.
1368
+ if (req.get) {
1369
+ return req.get(context, deps, relMap);
1370
+ }
1371
+
1372
+ //Normalize module name, if it contains . or ..
1373
+ map = makeModuleMap(deps, relMap, false, true);
1374
+ id = map.id;
1375
+
1376
+ if (!hasProp(defined, id)) {
1377
+ return onError(makeError('notloaded', 'Module name "' +
1378
+ id +
1379
+ '" has not been loaded yet for context: ' +
1380
+ contextName +
1381
+ (relMap ? '' : '. Use require([])')));
1382
+ }
1383
+ return defined[id];
1384
+ }
1385
+
1386
+ //Grab defines waiting in the global queue.
1387
+ intakeDefines();
1388
+
1389
+ //Mark all the dependencies as needing to be loaded.
1390
+ context.nextTick(function () {
1391
+ //Some defines could have been added since the
1392
+ //require call, collect them.
1393
+ intakeDefines();
1394
+
1395
+ requireMod = getModule(makeModuleMap(null, relMap));
1396
+
1397
+ //Store if map config should be applied to this require
1398
+ //call for dependencies.
1399
+ requireMod.skipMap = options.skipMap;
1400
+
1401
+ requireMod.init(deps, callback, errback, {
1402
+ enabled: true
1403
+ });
1404
+
1405
+ checkLoaded();
1406
+ });
1407
+
1408
+ return localRequire;
1409
+ }
1410
+
1411
+ mixin(localRequire, {
1412
+ isBrowser: isBrowser,
1413
+
1414
+ /**
1415
+ * Converts a module name + .extension into an URL path.
1416
+ * *Requires* the use of a module name. It does not support using
1417
+ * plain URLs like nameToUrl.
1418
+ */
1419
+ toUrl: function (moduleNamePlusExt) {
1420
+ var index = moduleNamePlusExt.lastIndexOf('.'),
1421
+ ext = null;
1422
+
1423
+ if (index !== -1) {
1424
+ ext = moduleNamePlusExt.substring(index, moduleNamePlusExt.length);
1425
+ moduleNamePlusExt = moduleNamePlusExt.substring(0, index);
1426
+ }
1427
+
1428
+ return context.nameToUrl(normalize(moduleNamePlusExt,
1429
+ relMap && relMap.id, true), ext);
1430
+ },
1431
+
1432
+ defined: function (id) {
1433
+ return hasProp(defined, makeModuleMap(id, relMap, false, true).id);
1434
+ },
1435
+
1436
+ specified: function (id) {
1437
+ id = makeModuleMap(id, relMap, false, true).id;
1438
+ return hasProp(defined, id) || hasProp(registry, id);
1439
+ }
1440
+ });
1441
+
1442
+ //Only allow undef on top level require calls
1443
+ if (!relMap) {
1444
+ localRequire.undef = function (id) {
1445
+ //Bind any waiting define() calls to this context,
1446
+ //fix for #408
1447
+ takeGlobalQueue();
1448
+
1449
+ var map = makeModuleMap(id, relMap, true),
1450
+ mod = getOwn(registry, id);
1451
+
1452
+ delete defined[id];
1453
+ delete urlFetched[map.url];
1454
+ delete undefEvents[id];
1455
+
1456
+ if (mod) {
1457
+ //Hold on to listeners in case the
1458
+ //module will be attempted to be reloaded
1459
+ //using a different config.
1460
+ if (mod.events.defined) {
1461
+ undefEvents[id] = mod.events;
1462
+ }
1463
+
1464
+ cleanRegistry(id);
1465
+ }
1466
+ };
1467
+ }
1468
+
1469
+ return localRequire;
1470
+ },
1471
+
1472
+ /**
1473
+ * Called to enable a module if it is still in the registry
1474
+ * awaiting enablement. parent module is passed in for context,
1475
+ * used by the optimizer.
1476
+ */
1477
+ enable: function (depMap, parent) {
1478
+ var mod = getOwn(registry, depMap.id);
1479
+ if (mod) {
1480
+ getModule(depMap).enable();
1481
+ }
1482
+ },
1483
+
1484
+ /**
1485
+ * Internal method used by environment adapters to complete a load event.
1486
+ * A load event could be a script load or just a load pass from a synchronous
1487
+ * load call.
1488
+ * @param {String} moduleName the name of the module to potentially complete.
1489
+ */
1490
+ completeLoad: function (moduleName) {
1491
+ var found, args, mod,
1492
+ shim = getOwn(config.shim, moduleName) || {},
1493
+ shExports = shim.exports;
1494
+
1495
+ takeGlobalQueue();
1496
+
1497
+ while (defQueue.length) {
1498
+ args = defQueue.shift();
1499
+ if (args[0] === null) {
1500
+ args[0] = moduleName;
1501
+ //If already found an anonymous module and bound it
1502
+ //to this name, then this is some other anon module
1503
+ //waiting for its completeLoad to fire.
1504
+ if (found) {
1505
+ break;
1506
+ }
1507
+ found = true;
1508
+ } else if (args[0] === moduleName) {
1509
+ //Found matching define call for this script!
1510
+ found = true;
1511
+ }
1512
+
1513
+ callGetModule(args);
1514
+ }
1515
+
1516
+ //Do this after the cycle of callGetModule in case the result
1517
+ //of those calls/init calls changes the registry.
1518
+ mod = getOwn(registry, moduleName);
1519
+
1520
+ if (!found && !hasProp(defined, moduleName) && mod && !mod.inited) {
1521
+ if (config.enforceDefine && (!shExports || !getGlobal(shExports))) {
1522
+ if (hasPathFallback(moduleName)) {
1523
+ return;
1524
+ } else {
1525
+ return onError(makeError('nodefine',
1526
+ 'No define call for ' + moduleName,
1527
+ null,
1528
+ [moduleName]));
1529
+ }
1530
+ } else {
1531
+ //A script that does not call define(), so just simulate
1532
+ //the call for it.
1533
+ callGetModule([moduleName, (shim.deps || []), shim.exportsFn]);
1534
+ }
1535
+ }
1536
+
1537
+ checkLoaded();
1538
+ },
1539
+
1540
+ /**
1541
+ * Converts a module name to a file path. Supports cases where
1542
+ * moduleName may actually be just an URL.
1543
+ * Note that it **does not** call normalize on the moduleName,
1544
+ * it is assumed to have already been normalized. This is an
1545
+ * internal API, not a public one. Use toUrl for the public API.
1546
+ */
1547
+ nameToUrl: function (moduleName, ext) {
1548
+ var paths, pkgs, pkg, pkgPath, syms, i, parentModule, url,
1549
+ parentPath;
1550
+
1551
+ //If a colon is in the URL, it indicates a protocol is used and it is just
1552
+ //an URL to a file, or if it starts with a slash, contains a query arg (i.e. ?)
1553
+ //or ends with .js, then assume the user meant to use an url and not a module id.
1554
+ //The slash is important for protocol-less URLs as well as full paths.
1555
+ if (req.jsExtRegExp.test(moduleName)) {
1556
+ //Just a plain path, not module name lookup, so just return it.
1557
+ //Add extension if it is included. This is a bit wonky, only non-.js things pass
1558
+ //an extension, this method probably needs to be reworked.
1559
+ url = moduleName + (ext || '');
1560
+ } else {
1561
+ //A module that needs to be converted to a path.
1562
+ paths = config.paths;
1563
+ pkgs = config.pkgs;
1564
+
1565
+ syms = moduleName.split('/');
1566
+ //For each module name segment, see if there is a path
1567
+ //registered for it. Start with most specific name
1568
+ //and work up from it.
1569
+ for (i = syms.length; i > 0; i -= 1) {
1570
+ parentModule = syms.slice(0, i).join('/');
1571
+ pkg = getOwn(pkgs, parentModule);
1572
+ parentPath = getOwn(paths, parentModule);
1573
+ if (parentPath) {
1574
+ //If an array, it means there are a few choices,
1575
+ //Choose the one that is desired
1576
+ if (isArray(parentPath)) {
1577
+ parentPath = parentPath[0];
1578
+ }
1579
+ syms.splice(0, i, parentPath);
1580
+ break;
1581
+ } else if (pkg) {
1582
+ //If module name is just the package name, then looking
1583
+ //for the main module.
1584
+ if (moduleName === pkg.name) {
1585
+ pkgPath = pkg.location + '/' + pkg.main;
1586
+ } else {
1587
+ pkgPath = pkg.location;
1588
+ }
1589
+ syms.splice(0, i, pkgPath);
1590
+ break;
1591
+ }
1592
+ }
1593
+
1594
+ //Join the path parts together, then figure out if baseUrl is needed.
1595
+ url = syms.join('/');
1596
+ url += (ext || (/\?/.test(url) ? '' : '.js'));
1597
+ url = (url.charAt(0) === '/' || url.match(/^[\w\+\.\-]+:/) ? '' : config.baseUrl) + url;
1598
+ }
1599
+
1600
+ return config.urlArgs ? url +
1601
+ ((url.indexOf('?') === -1 ? '?' : '&') +
1602
+ config.urlArgs) : url;
1603
+ },
1604
+
1605
+ //Delegates to req.load. Broken out as a separate function to
1606
+ //allow overriding in the optimizer.
1607
+ load: function (id, url) {
1608
+ req.load(context, id, url);
1609
+ },
1610
+
1611
+ /**
1612
+ * Executes a module callack function. Broken out as a separate function
1613
+ * solely to allow the build system to sequence the files in the built
1614
+ * layer in the right sequence.
1615
+ *
1616
+ * @private
1617
+ */
1618
+ execCb: function (name, callback, args, exports) {
1619
+ return callback.apply(exports, args);
1620
+ },
1621
+
1622
+ /**
1623
+ * callback for script loads, used to check status of loading.
1624
+ *
1625
+ * @param {Event} evt the event from the browser for the script
1626
+ * that was loaded.
1627
+ */
1628
+ onScriptLoad: function (evt) {
1629
+ //Using currentTarget instead of target for Firefox 2.0's sake. Not
1630
+ //all old browsers will be supported, but this one was easy enough
1631
+ //to support and still makes sense.
1632
+ if (evt.type === 'load' ||
1633
+ (readyRegExp.test((evt.currentTarget || evt.srcElement).readyState))) {
1634
+ //Reset interactive script so a script node is not held onto for
1635
+ //to long.
1636
+ interactiveScript = null;
1637
+
1638
+ //Pull out the name of the module and the context.
1639
+ var data = getScriptData(evt);
1640
+ context.completeLoad(data.id);
1641
+ }
1642
+ },
1643
+
1644
+ /**
1645
+ * Callback for script errors.
1646
+ */
1647
+ onScriptError: function (evt) {
1648
+ var data = getScriptData(evt);
1649
+ if (!hasPathFallback(data.id)) {
1650
+ return onError(makeError('scripterror', 'Script error', evt, [data.id]));
1651
+ }
1652
+ }
1653
+ };
1654
+
1655
+ context.require = context.makeRequire();
1656
+ return context;
1657
+ }
1658
+
1659
+ /**
1660
+ * Main entry point.
1661
+ *
1662
+ * If the only argument to require is a string, then the module that
1663
+ * is represented by that string is fetched for the appropriate context.
1664
+ *
1665
+ * If the first argument is an array, then it will be treated as an array
1666
+ * of dependency string names to fetch. An optional function callback can
1667
+ * be specified to execute when all of those dependencies are available.
1668
+ *
1669
+ * Make a local req variable to help Caja compliance (it assumes things
1670
+ * on a require that are not standardized), and to give a short
1671
+ * name for minification/local scope use.
1672
+ */
1673
+ req = requirejs = function (deps, callback, errback, optional) {
1674
+
1675
+ //Find the right context, use default
1676
+ var context, config,
1677
+ contextName = defContextName;
1678
+
1679
+ // Determine if have config object in the call.
1680
+ if (!isArray(deps) && typeof deps !== 'string') {
1681
+ // deps is a config object
1682
+ config = deps;
1683
+ if (isArray(callback)) {
1684
+ // Adjust args if there are dependencies
1685
+ deps = callback;
1686
+ callback = errback;
1687
+ errback = optional;
1688
+ } else {
1689
+ deps = [];
1690
+ }
1691
+ }
1692
+
1693
+ if (config && config.context) {
1694
+ contextName = config.context;
1695
+ }
1696
+
1697
+ context = getOwn(contexts, contextName);
1698
+ if (!context) {
1699
+ context = contexts[contextName] = req.s.newContext(contextName);
1700
+ }
1701
+
1702
+ if (config) {
1703
+ context.configure(config);
1704
+ }
1705
+
1706
+ return context.require(deps, callback, errback);
1707
+ };
1708
+
1709
+ /**
1710
+ * Support require.config() to make it easier to cooperate with other
1711
+ * AMD loaders on globally agreed names.
1712
+ */
1713
+ req.config = function (config) {
1714
+ return req(config);
1715
+ };
1716
+
1717
+ /**
1718
+ * Execute something after the current tick
1719
+ * of the event loop. Override for other envs
1720
+ * that have a better solution than setTimeout.
1721
+ * @param {Function} fn function to execute later.
1722
+ */
1723
+ req.nextTick = typeof setTimeout !== 'undefined' ? function (fn) {
1724
+ setTimeout(fn, 4);
1725
+ } : function (fn) { fn(); };
1726
+
1727
+ /**
1728
+ * Export require as a global, but only if it does not already exist.
1729
+ */
1730
+ if (!require) {
1731
+ require = req;
1732
+ }
1733
+
1734
+ req.version = version;
1735
+
1736
+ //Used to filter out dependencies that are already paths.
1737
+ req.jsExtRegExp = /^\/|:|\?|\.js$/;
1738
+ req.isBrowser = isBrowser;
1739
+ s = req.s = {
1740
+ contexts: contexts,
1741
+ newContext: newContext
1742
+ };
1743
+
1744
+ //Create default context.
1745
+ req({});
1746
+
1747
+ //Exports some context-sensitive methods on global require.
1748
+ each([
1749
+ 'toUrl',
1750
+ 'undef',
1751
+ 'defined',
1752
+ 'specified'
1753
+ ], function (prop) {
1754
+ //Reference from contexts instead of early binding to default context,
1755
+ //so that during builds, the latest instance of the default context
1756
+ //with its config gets used.
1757
+ req[prop] = function () {
1758
+ var ctx = contexts[defContextName];
1759
+ return ctx.require[prop].apply(ctx, arguments);
1760
+ };
1761
+ });
1762
+
1763
+ if (isBrowser) {
1764
+ head = s.head = document.getElementsByTagName('head')[0];
1765
+ //If BASE tag is in play, using appendChild is a problem for IE6.
1766
+ //When that browser dies, this can be removed. Details in this jQuery bug:
1767
+ //http://dev.jquery.com/ticket/2709
1768
+ baseElement = document.getElementsByTagName('base')[0];
1769
+ if (baseElement) {
1770
+ head = s.head = baseElement.parentNode;
1771
+ }
1772
+ }
1773
+
1774
+ /**
1775
+ * Any errors that require explicitly generates will be passed to this
1776
+ * function. Intercept/override it if you want custom error handling.
1777
+ * @param {Error} err the error object.
1778
+ */
1779
+ req.onError = function (err) {
1780
+ throw err;
1781
+ };
1782
+
1783
+ /**
1784
+ * Does the request to load a module for the browser case.
1785
+ * Make this a separate function to allow other environments
1786
+ * to override it.
1787
+ *
1788
+ * @param {Object} context the require context to find state.
1789
+ * @param {String} moduleName the name of the module.
1790
+ * @param {Object} url the URL to the module.
1791
+ */
1792
+ req.load = function (context, moduleName, url) {
1793
+ var config = (context && context.config) || {},
1794
+ node;
1795
+ if (isBrowser) {
1796
+ //In the browser so use a script tag
1797
+ node = config.xhtml ?
1798
+ document.createElementNS('http://www.w3.org/1999/xhtml', 'html:script') :
1799
+ document.createElement('script');
1800
+ node.type = config.scriptType || 'text/javascript';
1801
+ node.charset = 'utf-8';
1802
+ node.async = true;
1803
+
1804
+ node.setAttribute('data-requirecontext', context.contextName);
1805
+ node.setAttribute('data-requiremodule', moduleName);
1806
+
1807
+ //Set up load listener. Test attachEvent first because IE9 has
1808
+ //a subtle issue in its addEventListener and script onload firings
1809
+ //that do not match the behavior of all other browsers with
1810
+ //addEventListener support, which fire the onload event for a
1811
+ //script right after the script execution. See:
1812
+ //https://connect.microsoft.com/IE/feedback/details/648057/script-onload-event-is-not-fired-immediately-after-script-execution
1813
+ //UNFORTUNATELY Opera implements attachEvent but does not follow the script
1814
+ //script execution mode.
1815
+ if (node.attachEvent &&
1816
+ //Check if node.attachEvent is artificially added by custom script or
1817
+ //natively supported by browser
1818
+ //read https://github.com/jrburke/requirejs/issues/187
1819
+ //if we can NOT find [native code] then it must NOT natively supported.
1820
+ //in IE8, node.attachEvent does not have toString()
1821
+ //Note the test for "[native code" with no closing brace, see:
1822
+ //https://github.com/jrburke/requirejs/issues/273
1823
+ !(node.attachEvent.toString && node.attachEvent.toString().indexOf('[native code') < 0) &&
1824
+ !isOpera) {
1825
+ //Probably IE. IE (at least 6-8) do not fire
1826
+ //script onload right after executing the script, so
1827
+ //we cannot tie the anonymous define call to a name.
1828
+ //However, IE reports the script as being in 'interactive'
1829
+ //readyState at the time of the define call.
1830
+ useInteractive = true;
1831
+
1832
+ node.attachEvent('onreadystatechange', context.onScriptLoad);
1833
+ //It would be great to add an error handler here to catch
1834
+ //404s in IE9+. However, onreadystatechange will fire before
1835
+ //the error handler, so that does not help. If addEvenListener
1836
+ //is used, then IE will fire error before load, but we cannot
1837
+ //use that pathway given the connect.microsoft.com issue
1838
+ //mentioned above about not doing the 'script execute,
1839
+ //then fire the script load event listener before execute
1840
+ //next script' that other browsers do.
1841
+ //Best hope: IE10 fixes the issues,
1842
+ //and then destroys all installs of IE 6-9.
1843
+ //node.attachEvent('onerror', context.onScriptError);
1844
+ } else {
1845
+ node.addEventListener('load', context.onScriptLoad, false);
1846
+ node.addEventListener('error', context.onScriptError, false);
1847
+ }
1848
+ node.src = url;
1849
+
1850
+ //For some cache cases in IE 6-8, the script executes before the end
1851
+ //of the appendChild execution, so to tie an anonymous define
1852
+ //call to the module name (which is stored on the node), hold on
1853
+ //to a reference to this node, but clear after the DOM insertion.
1854
+ currentlyAddingScript = node;
1855
+ if (baseElement) {
1856
+ head.insertBefore(node, baseElement);
1857
+ } else {
1858
+ head.appendChild(node);
1859
+ }
1860
+ currentlyAddingScript = null;
1861
+
1862
+ return node;
1863
+ } else if (isWebWorker) {
1864
+ //In a web worker, use importScripts. This is not a very
1865
+ //efficient use of importScripts, importScripts will block until
1866
+ //its script is downloaded and evaluated. However, if web workers
1867
+ //are in play, the expectation that a build has been done so that
1868
+ //only one script needs to be loaded anyway. This may need to be
1869
+ //reevaluated if other use cases become common.
1870
+ importScripts(url);
1871
+
1872
+ //Account for anonymous modules
1873
+ context.completeLoad(moduleName);
1874
+ }
1875
+ };
1876
+
1877
+ function getInteractiveScript() {
1878
+ if (interactiveScript && interactiveScript.readyState === 'interactive') {
1879
+ return interactiveScript;
1880
+ }
1881
+
1882
+ eachReverse(scripts(), function (script) {
1883
+ if (script.readyState === 'interactive') {
1884
+ return (interactiveScript = script);
1885
+ }
1886
+ });
1887
+ return interactiveScript;
1888
+ }
1889
+
1890
+ //Look for a data-main script attribute, which could also adjust the baseUrl.
1891
+ if (isBrowser) {
1892
+ //Figure out baseUrl. Get it from the script tag with require.js in it.
1893
+ eachReverse(scripts(), function (script) {
1894
+ //Set the 'head' where we can append children by
1895
+ //using the script's parent.
1896
+ if (!head) {
1897
+ head = script.parentNode;
1898
+ }
1899
+
1900
+ //Look for a data-main attribute to set main script for the page
1901
+ //to load. If it is there, the path to data main becomes the
1902
+ //baseUrl, if it is not already set.
1903
+ dataMain = script.getAttribute('data-main');
1904
+ if (dataMain) {
1905
+ //Set final baseUrl if there is not already an explicit one.
1906
+ if (!cfg.baseUrl) {
1907
+ //Pull off the directory of data-main for use as the
1908
+ //baseUrl.
1909
+ src = dataMain.split('/');
1910
+ mainScript = src.pop();
1911
+ subPath = src.length ? src.join('/') + '/' : './';
1912
+
1913
+ cfg.baseUrl = subPath;
1914
+ dataMain = mainScript;
1915
+ }
1916
+
1917
+ //Strip off any trailing .js since dataMain is now
1918
+ //like a module name.
1919
+ dataMain = dataMain.replace(jsSuffixRegExp, '');
1920
+
1921
+ //Put the data-main script in the files to load.
1922
+ cfg.deps = cfg.deps ? cfg.deps.concat(dataMain) : [dataMain];
1923
+
1924
+ return true;
1925
+ }
1926
+ });
1927
+ }
1928
+
1929
+ /**
1930
+ * The function that handles definitions of modules. Differs from
1931
+ * require() in that a string for the module should be the first argument,
1932
+ * and the function to execute after dependencies are loaded should
1933
+ * return a value to define the module corresponding to the first argument's
1934
+ * name.
1935
+ */
1936
+ define = function (name, deps, callback) {
1937
+ var node, context;
1938
+
1939
+ //Allow for anonymous modules
1940
+ if (typeof name !== 'string') {
1941
+ //Adjust args appropriately
1942
+ callback = deps;
1943
+ deps = name;
1944
+ name = null;
1945
+ }
1946
+
1947
+ //This module may not have dependencies
1948
+ if (!isArray(deps)) {
1949
+ callback = deps;
1950
+ deps = [];
1951
+ }
1952
+
1953
+ //If no name, and callback is a function, then figure out if it a
1954
+ //CommonJS thing with dependencies.
1955
+ if (!deps.length && isFunction(callback)) {
1956
+ //Remove comments from the callback string,
1957
+ //look for require calls, and pull them into the dependencies,
1958
+ //but only if there are function args.
1959
+ if (callback.length) {
1960
+ callback
1961
+ .toString()
1962
+ .replace(commentRegExp, '')
1963
+ .replace(cjsRequireRegExp, function (match, dep) {
1964
+ deps.push(dep);
1965
+ });
1966
+
1967
+ //May be a CommonJS thing even without require calls, but still
1968
+ //could use exports, and module. Avoid doing exports and module
1969
+ //work though if it just needs require.
1970
+ //REQUIRES the function to expect the CommonJS variables in the
1971
+ //order listed below.
1972
+ deps = (callback.length === 1 ? ['require'] : ['require', 'exports', 'module']).concat(deps);
1973
+ }
1974
+ }
1975
+
1976
+ //If in IE 6-8 and hit an anonymous define() call, do the interactive
1977
+ //work.
1978
+ if (useInteractive) {
1979
+ node = currentlyAddingScript || getInteractiveScript();
1980
+ if (node) {
1981
+ if (!name) {
1982
+ name = node.getAttribute('data-requiremodule');
1983
+ }
1984
+ context = contexts[node.getAttribute('data-requirecontext')];
1985
+ }
1986
+ }
1987
+
1988
+ //Always save off evaluating the def call until the script onload handler.
1989
+ //This allows multiple modules to be in a file without prematurely
1990
+ //tracing dependencies, and allows for anonymous module support,
1991
+ //where the module name is not known until the script onload event
1992
+ //occurs. If no context, use the global queue, and get it processed
1993
+ //in the onscript load callback.
1994
+ (context ? context.defQueue : globalDefQueue).push([name, deps, callback]);
1995
+ };
1996
+
1997
+ define.amd = {
1998
+ jQuery: true
1999
+ };
2000
+
2001
+
2002
+ /**
2003
+ * Executes the text. Normally just uses eval, but can be modified
2004
+ * to use a better, environment-specific call. Only used for transpiling
2005
+ * loader plugins, not for plain JS modules.
2006
+ * @param {String} text the text to execute/evaluate.
2007
+ */
2008
+ req.exec = function (text) {
2009
+ /*jslint evil: true */
2010
+ return eval(text);
2011
+ };
2012
+
2013
+ //Set up with config info.
2014
+ req(cfg);
2015
+ }(this));