[76] | 1 | /** |
---|
| 2 | * Copyright (c) 2008-2010 The Open Source Geospatial Foundation |
---|
| 3 | * |
---|
| 4 | * Published under the BSD license. |
---|
| 5 | * See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text |
---|
| 6 | * of the license. |
---|
| 7 | */ |
---|
| 8 | |
---|
| 9 | /* |
---|
| 10 | * The code in this file is based on code taken from OpenLayers. |
---|
| 11 | * |
---|
| 12 | * Copyright (c) 2006-2007 MetaCarta, Inc., published under the Clear BSD |
---|
| 13 | * license. See http://svn.openlayers.org/trunk/openlayers/license.txt for the |
---|
| 14 | * full text of the license. |
---|
| 15 | */ |
---|
| 16 | |
---|
| 17 | (function() { |
---|
| 18 | |
---|
| 19 | /** |
---|
| 20 | * Check to see if GeoExt.singleFile is true. It is true if the |
---|
| 21 | * GeoExt/SingleFile.js is included before this one, as it is |
---|
| 22 | * the case in single file builds. |
---|
| 23 | */ |
---|
| 24 | var singleFile = (typeof GeoExt == "object" && GeoExt.singleFile); |
---|
| 25 | |
---|
| 26 | /** |
---|
| 27 | * The relative path of this script. |
---|
| 28 | */ |
---|
| 29 | var scriptName = singleFile ? "GeoExt.js" : "lib/GeoExt.js"; |
---|
| 30 | |
---|
| 31 | /** |
---|
| 32 | * Function returning the path of this script. |
---|
| 33 | */ |
---|
| 34 | var getScriptLocation = function() { |
---|
| 35 | var scriptLocation = ""; |
---|
| 36 | // If we load other scripts right before GeoExt using the same |
---|
| 37 | // mechanism to add script resources dynamically (e.g. OpenLayers), |
---|
| 38 | // document.getElementsByTagName will not find the GeoExt script tag |
---|
| 39 | // in FF2. Using document.documentElement.getElementsByTagName instead |
---|
| 40 | // works around this issue. |
---|
| 41 | var scripts = document.documentElement.getElementsByTagName('script'); |
---|
| 42 | for(var i=0, len=scripts.length; i<len; i++) { |
---|
| 43 | var src = scripts[i].getAttribute('src'); |
---|
| 44 | if(src) { |
---|
| 45 | var index = src.lastIndexOf(scriptName); |
---|
| 46 | // set path length for src up to a query string |
---|
| 47 | var pathLength = src.lastIndexOf('?'); |
---|
| 48 | if(pathLength < 0) { |
---|
| 49 | pathLength = src.length; |
---|
| 50 | } |
---|
| 51 | // is it found, at the end of the URL? |
---|
| 52 | if((index > -1) && (index + scriptName.length == pathLength)) { |
---|
| 53 | scriptLocation = src.slice(0, pathLength - scriptName.length); |
---|
| 54 | break; |
---|
| 55 | } |
---|
| 56 | } |
---|
| 57 | } |
---|
| 58 | return scriptLocation; |
---|
| 59 | }; |
---|
| 60 | |
---|
| 61 | /** |
---|
| 62 | * If GeoExt.singleFile is false then the JavaScript files in the jsfiles |
---|
| 63 | * array are autoloaded. |
---|
| 64 | */ |
---|
| 65 | if(!singleFile) { |
---|
| 66 | var jsfiles = new Array( |
---|
| 67 | "GeoExt/data/AttributeReader.js", |
---|
| 68 | "GeoExt/data/AttributeStore.js", |
---|
| 69 | "GeoExt/data/FeatureRecord.js", |
---|
| 70 | "GeoExt/data/FeatureReader.js", |
---|
| 71 | "GeoExt/data/FeatureStore.js", |
---|
| 72 | "GeoExt/data/LayerRecord.js", |
---|
| 73 | "GeoExt/data/LayerReader.js", |
---|
| 74 | "GeoExt/data/LayerStore.js", |
---|
| 75 | "GeoExt/data/ScaleStore.js", |
---|
| 76 | "GeoExt/data/WMSCapabilitiesReader.js", |
---|
| 77 | "GeoExt/data/WMSCapabilitiesStore.js", |
---|
| 78 | "GeoExt/data/WFSCapabilitiesReader.js", |
---|
| 79 | "GeoExt/data/WFSCapabilitiesStore.js", |
---|
| 80 | "GeoExt/data/WMSDescribeLayerReader.js", |
---|
| 81 | "GeoExt/data/WMSDescribeLayerStore.js", |
---|
| 82 | "GeoExt/data/WMCReader.js", |
---|
| 83 | "GeoExt/widgets/Action.js", |
---|
| 84 | "GeoExt/data/ProtocolProxy.js", |
---|
| 85 | "GeoExt/widgets/FeatureRenderer.js", |
---|
| 86 | "GeoExt/widgets/MapPanel.js", |
---|
| 87 | "GeoExt/widgets/Popup.js", |
---|
| 88 | "GeoExt/widgets/form.js", |
---|
| 89 | "GeoExt/widgets/form/SearchAction.js", |
---|
| 90 | "GeoExt/widgets/form/BasicForm.js", |
---|
| 91 | "GeoExt/widgets/form/FormPanel.js", |
---|
| 92 | "GeoExt/widgets/tips/SliderTip.js", |
---|
| 93 | "GeoExt/widgets/tips/LayerOpacitySliderTip.js", |
---|
| 94 | "GeoExt/widgets/tips/ZoomSliderTip.js", |
---|
| 95 | "GeoExt/widgets/tree/LayerNode.js", |
---|
| 96 | "GeoExt/widgets/tree/TreeNodeUIEventMixin.js", |
---|
| 97 | "GeoExt/plugins/TreeNodeComponent.js", |
---|
| 98 | "GeoExt/plugins/TreeNodeRadioButton.js", |
---|
| 99 | "GeoExt/widgets/tree/LayerLoader.js", |
---|
| 100 | "GeoExt/widgets/tree/LayerContainer.js", |
---|
| 101 | "GeoExt/widgets/tree/BaseLayerContainer.js", |
---|
| 102 | "GeoExt/widgets/tree/OverlayLayerContainer.js", |
---|
| 103 | "GeoExt/widgets/tree/LayerParamNode.js", |
---|
| 104 | "GeoExt/widgets/tree/LayerParamLoader.js", |
---|
| 105 | "GeoExt/widgets/tree/WMSCapabilitiesLoader.js", |
---|
| 106 | "GeoExt/widgets/LayerOpacitySlider.js", |
---|
| 107 | "GeoExt/widgets/LayerLegend.js", |
---|
| 108 | "GeoExt/widgets/LegendImage.js", |
---|
| 109 | "GeoExt/widgets/UrlLegend.js", |
---|
| 110 | "GeoExt/widgets/WMSLegend.js", |
---|
| 111 | "GeoExt/widgets/VectorLegend.js", |
---|
| 112 | "GeoExt/widgets/LegendPanel.js", |
---|
| 113 | "GeoExt/widgets/ZoomSlider.js", |
---|
| 114 | "GeoExt/widgets/grid/FeatureSelectionModel.js", |
---|
| 115 | "GeoExt/data/PrintPage.js", |
---|
| 116 | "GeoExt/data/PrintProvider.js", |
---|
| 117 | "GeoExt/plugins/PrintPageField.js", |
---|
| 118 | "GeoExt/plugins/PrintProviderField.js", |
---|
| 119 | "GeoExt/plugins/PrintExtent.js", |
---|
| 120 | "GeoExt/plugins/AttributeForm.js", |
---|
| 121 | "GeoExt/widgets/PrintMapPanel.js", |
---|
| 122 | "GeoExt/state/PermalinkProvider.js" |
---|
| 123 | ); |
---|
| 124 | |
---|
| 125 | var agent = navigator.userAgent; |
---|
| 126 | var docWrite = (agent.match("MSIE") || agent.match("Safari")); |
---|
| 127 | if(docWrite) { |
---|
| 128 | var allScriptTags = new Array(jsfiles.length); |
---|
| 129 | } |
---|
| 130 | var host = getScriptLocation() + "lib/"; |
---|
| 131 | for (var i=0, len=jsfiles.length; i<len; i++) { |
---|
| 132 | if (docWrite) { |
---|
| 133 | allScriptTags[i] = "<script src='" + host + jsfiles[i] + |
---|
| 134 | "'></script>"; |
---|
| 135 | } else { |
---|
| 136 | var s = document.createElement("script"); |
---|
| 137 | s.src = host + jsfiles[i]; |
---|
| 138 | var h = document.getElementsByTagName("head").length ? |
---|
| 139 | document.getElementsByTagName("head")[0] : |
---|
| 140 | document.body; |
---|
| 141 | h.appendChild(s); |
---|
| 142 | } |
---|
| 143 | } |
---|
| 144 | if (docWrite) { |
---|
| 145 | document.write(allScriptTags.join("")); |
---|
| 146 | } |
---|
| 147 | } |
---|
| 148 | })(); |
---|