[Commits] r1616 - in sandbox/cmoullet/ux/LayerManager: examples ux/data ux/widgets
commits at geoext.org
commits at geoext.org
Sun Dec 27 01:54:46 CET 2009
Author: cmoullet
Date: 2009-12-27 01:54:46 +0100 (Sun, 27 Dec 2009)
New Revision: 1616
Modified:
sandbox/cmoullet/ux/LayerManager/examples/LayerManagerExample.html
sandbox/cmoullet/ux/LayerManager/examples/LayerManagerExample.js
sandbox/cmoullet/ux/LayerManager/ux/data/Export.js
sandbox/cmoullet/ux/LayerManager/ux/widgets/LayerManagerExportPanel.js
sandbox/cmoullet/ux/LayerManager/ux/widgets/LayerManagerTabPanel.js
sandbox/cmoullet/ux/LayerManager/ux/widgets/LayerManagerWindow.js
Log:
Support IE and FF download.
Provide downloadService capabilities
Modified: sandbox/cmoullet/ux/LayerManager/examples/LayerManagerExample.html
===================================================================
--- sandbox/cmoullet/ux/LayerManager/examples/LayerManagerExample.html 2009-12-26 07:10:43 UTC (rev 1615)
+++ sandbox/cmoullet/ux/LayerManager/examples/LayerManagerExample.html 2009-12-27 00:54:46 UTC (rev 1616)
@@ -10,6 +10,7 @@
<script type="text/javascript" src="../ux/form/FileUploadField.js"></script>
<script type="text/javascript" src="../ux/data/FormatStore.js"></script>
<script type="text/javascript" src="../ux/data/Export.js"></script>
+ <script type="text/javascript" src="../ux/widgets/DownloadComponent.js"></script>
<script type="text/javascript" src="../ux/widgets/LayerManagerExportPanel.js"></script>
<script type="text/javascript" src="../ux/widgets/LayerManagerTabPanel.js"></script>
<script type="text/javascript" src="../ux/widgets/LayerManagerWindow.js"></script>
Modified: sandbox/cmoullet/ux/LayerManager/examples/LayerManagerExample.js
===================================================================
--- sandbox/cmoullet/ux/LayerManager/examples/LayerManagerExample.js 2009-12-26 07:10:43 UTC (rev 1615)
+++ sandbox/cmoullet/ux/LayerManager/examples/LayerManagerExample.js 2009-12-27 00:54:46 UTC (rev 1616)
@@ -34,6 +34,7 @@
handler: function() {
var layerManagerWindow = new GeoExt.ux.LayerManagerWindow({
map: map
+ //,downloadService: 'http://localhost:5000/filemanager/download'
});
layerManagerWindow.show();
}
Modified: sandbox/cmoullet/ux/LayerManager/ux/data/Export.js
===================================================================
--- sandbox/cmoullet/ux/LayerManager/ux/data/Export.js 2009-12-26 07:10:43 UTC (rev 1615)
+++ sandbox/cmoullet/ux/LayerManager/ux/data/Export.js 2009-12-27 00:54:46 UTC (rev 1616)
@@ -26,15 +26,15 @@
}
}
}
-
+
if (features) {
- exportFeatures = features;
+ exportFeatures = features;
} else {
for (var j = 0; j < exportLayers.length; j++) {
var exportLayer = exportLayers[j];
if (exportLayer.features) {
for (var k = 0; k < exportLayer.features.length; k++) {
- exportFeatures.push(exportLayer.features[k]);
+ exportFeatures.push(exportLayer.features[k]);
}
}
}
@@ -58,10 +58,19 @@
return false;
};
-GeoExt.ux.data.Export.OpenWindowIE = function(content) {
- alert('hello');
+GeoExt.ux.data.Export.OpenWindowIE = function(format) {
+ var exportWindow = window.open("", "exportWindow", "location=1,status=1,scrollbars=1,width=100,height=100");
+ var content = GeoExt.ux.data.Export.content;
+ if (format == 'KML') {
+ exportWindow.document.open("text/xml");
+ exportWindow.document.write(content.replace(/</g,'<').replace(/>/g,'>'));
+ exportWindow.document.execCommand('SaveAs', true, ' ');
+ }
+ exportWindow.document.close();
+ exportWindow.close();
};
+GeoExt.ux.data.Export.content = null;
GeoExt.ux.data.Export.SupportedLayerType = [
['OpenLayers.Layer.Vector'],
Modified: sandbox/cmoullet/ux/LayerManager/ux/widgets/LayerManagerExportPanel.js
===================================================================
--- sandbox/cmoullet/ux/LayerManager/ux/widgets/LayerManagerExportPanel.js 2009-12-26 07:10:43 UTC (rev 1615)
+++ sandbox/cmoullet/ux/LayerManager/ux/widgets/LayerManagerExportPanel.js 2009-12-27 00:54:46 UTC (rev 1616)
@@ -13,6 +13,7 @@
formatCombo: null,
exportLinkBox: null,
defaultFormat: 'KML',
+ downloadService: null,
initComponent: function() {
@@ -83,16 +84,42 @@
text: OpenLayers.i18n('Export'),
handler: function() {
var exportContent = GeoExt.ux.data.Export(this.map, this.formatCombo.getValue(), null, null);
+ // Create a global variable GeoExt.ux.data.Export.content
+ GeoExt.ux.data.Export.content = exportContent;
+ if (this.downloadService) {
+ var form = document.createElement("form");
+ form.setAttribute("method", 'POST');
+ form.setAttribute("action", this.downloadService);
- if (Ext.isIE) {
- // TODO this.exportLinkBox.getEl().dom.innerHTML = '<a href="javascript:GeoExt.ux.data.Export.OpenWindowIE(\''+exportContent+'\');">Save file</a>';
- return;
+ var formatField = document.createElement("input");
+ formatField.setAttribute("type", "hidden");
+ formatField.setAttribute("name", "format");
+ formatField.setAttribute("value", this.formatCombo.getValue());
+
+ var contentField = document.createElement("input");
+ contentField.setAttribute("type", "hidden");
+ contentField.setAttribute("name", "content");
+ contentField.setAttribute("value", exportContent.replace(/</g,'<').replace(/>/g,'>'));
+
+ form.appendChild(formatField);
+ form.appendChild(contentField);
+
+ document.body.appendChild(form);
+ form.submit();
+
+ } else {
+ if (Ext.isIE) {
+ this.exportLinkBox.getEl().dom.innerHTML = '<a href="javascript:GeoExt.ux.data.Export.OpenWindowIE(\'' + this.formatCombo.getValue() + '\');">Save file</a>';
+ return;
+ }
+ if (Ext.isGecko) {
+ if (this.formatCombo.getValue() == 'KML') {
+ this.exportLinkBox.getEl().dom.innerHTML = '<a href="data:text/kml,' + exportContent.replace(/"/g, '\'') + '" target="new">Right mouse click, Save As...</a>';
+ }
+ return;
+ }
+ this.exportLinkBox.getEl().dom.innerHTML = OpenLayers.i18n('Your browser is not supported. Please use IE or Firefox.');
}
- if (Ext.isGecko) {
- this.exportLinkBox.getEl().dom.innerHTML = '<a href="data:text/xml,'+exportContent.replace(/"/g,'\'')+'" target="new">Right mouse click, Save As...</a>';
- return;
- }
- this.exportLinkBox.getEl().dom.innerHTML = 'Your browser is not supported';
},
scope: this
}
@@ -113,19 +140,15 @@
columnWidth: 1,
bodyCfg: {tag:'center'},
items: [
- this.exportLinkBox
+ this.exportLinkBox
]
}
]
}
-
];
GeoExt.ux.LayerManagerExportPanel.superclass.initComponent.call(this);
},
-
-
onRender: function(container, position) {
- this.expand(false);
GeoExt.ux.LayerManagerExportPanel.superclass.onRender.apply(this, arguments);
}
});
\ No newline at end of file
Modified: sandbox/cmoullet/ux/LayerManager/ux/widgets/LayerManagerTabPanel.js
===================================================================
--- sandbox/cmoullet/ux/LayerManager/ux/widgets/LayerManagerTabPanel.js 2009-12-26 07:10:43 UTC (rev 1615)
+++ sandbox/cmoullet/ux/LayerManager/ux/widgets/LayerManagerTabPanel.js 2009-12-27 00:54:46 UTC (rev 1616)
@@ -13,10 +13,13 @@
importPanel: null,
exportPanel: null,
deferredRender: false,
+ downloadService: null,
initComponent: function() {
this.exportPanel = new GeoExt.ux.LayerManagerExportPanel({
map: this.map,
+ downloadService: this.downloadService,
+ uploadService: this.uploadService,
defaultFormat: 'KML'
});
Modified: sandbox/cmoullet/ux/LayerManager/ux/widgets/LayerManagerWindow.js
===================================================================
--- sandbox/cmoullet/ux/LayerManager/ux/widgets/LayerManagerWindow.js 2009-12-26 07:10:43 UTC (rev 1615)
+++ sandbox/cmoullet/ux/LayerManager/ux/widgets/LayerManagerWindow.js 2009-12-27 00:54:46 UTC (rev 1616)
@@ -14,10 +14,13 @@
height: 300,
width: 400,
layerManagerTabPanel: null,
+ downloadService: null,
initComponent: function() {
this.layerManagerTabPanel = new GeoExt.ux.LayerManagerTabPanel({
- map: this.map
+ map: this.map,
+ downloadService: this.downloadService,
+ uploadService: this.uploadService
});
this.items = this.layerManagerTabPanel;
GeoExt.ux.LayerManagerWindow.superclass.initComponent.call(this);
More information about the Commits
mailing list