[fusion-commits] r1863 - in trunk/widgets: . Redline

svn_fusion at osgeo.org svn_fusion at osgeo.org
Thu May 21 16:21:44 EDT 2009


Author: aboudreault
Date: 2009-05-21 16:21:44 -0400 (Thu, 21 May 2009)
New Revision: 1863

Modified:
   trunk/widgets/Redline.js
   trunk/widgets/Redline/Redline.php
Log:
Fixed bugs for IE 7 and 8

Modified: trunk/widgets/Redline/Redline.php
===================================================================
--- trunk/widgets/Redline/Redline.php	2009-05-20 19:55:01 UTC (rev 1862)
+++ trunk/widgets/Redline/Redline.php	2009-05-21 20:21:44 UTC (rev 1863)
@@ -29,7 +29,6 @@
  *  The max file size should be setted in the php5.ini.
  *****************************************************************************/
 
-
 $fileUpload = false;
 
 $action = $_POST['action'];
@@ -53,6 +52,7 @@
             $fileUpload = false;
         }
     }
+    else if (isset($action)){ echo "--> ".$_FILES['uploadedfile']['error']; exit(1);}
 }
 
 ?>
@@ -118,7 +118,14 @@
         </td>
       </tr>
       <tr>
-        <td id="RedlineWidgetUploadTd" colspan="2"/>
+        <td id="RedlineWidgetUploadTd" colspan="2">
+          <form id="RedlineWidgetUploadForm" enctype="multipart/form-data" action="Redline.php" method="post">
+             <input type="file" name="uploadedfile"/>
+             <input type="hidden" name="action" value="upload"/>
+             <br/>
+             <input id="RedlineWidgetUploadButton" type="submit" name="submit_element" value="Upload" />
+          </form>
+    </td>
       </tr>
       <tr><td><!-- dummy col --></td></tr>
       <tr>

Modified: trunk/widgets/Redline.js
===================================================================
--- trunk/widgets/Redline.js	2009-05-20 19:55:01 UTC (rev 1862)
+++ trunk/widgets/Redline.js	2009-05-21 20:21:44 UTC (rev 1863)
@@ -70,7 +70,6 @@
 
     // the hidden html form for the save action
     saveForm: null,
-    uploadForm: null,
 
     initializeWidget: function(widgetTag) {
         var json = widgetTag.extension;
@@ -114,7 +113,6 @@
         }
 
         this.createSaveForm();
-        this.createUploadForm();
     },
 
     createDrawControls: function() {
@@ -168,7 +166,7 @@
 
     },    
 
-    createSaveForm: function() {
+    createSaveForm: function(panelDocument) {
         /* Create a hidden form for the Save action */
         var sl = Fusion.getScriptLanguage();
         var scriptURL = Fusion.getFusionURL() + 'layers/Generic/' + sl + '/save.' + sl;
@@ -200,33 +198,6 @@
         document.body.appendChild(div);
     },
 
-    createUploadForm: function() {
-        /* Create a hidden form for the Upload action ,
-           this form will be placed the the TaskPane manager */
-        var sl = Fusion.getScriptLanguage();
-        var scriptURL = Fusion.getFusionURL() + 'widgets/Redline/Redline.php';
-        var file = document.createElement("input");
-        var submit = document.createElement("input");
-        var action = document.createElement("input");
-
-        this.uploadForm = document.createElement("form");
-        submit.type="submit";
-        submit.name="submit_element";
-        submit.value="Upload";
-        action.type = "hidden";
-        action.name = "action";
-        action.value = "upload";
-        this.uploadForm.enctype = "multipart/form-data";
-        this.uploadForm.action = scriptURL;
-        this.uploadForm.method = "POST";
-        file.name="uploadedfile";
-        file.type="file";
-        this.uploadForm.appendChild(file);
-        this.uploadForm.appendChild(action);
-        this.uploadForm.appendChild(document.createElement("br"));
-        this.uploadForm.appendChild(submit);
-    },
-
     // activate the redline widget
     activate: function() {
         if (this.taskPane) {
@@ -354,13 +325,7 @@
         // select the default control
         var radioName = this.widget.defaultControl.charAt(0).toUpperCase() + this.widget.defaultControl.substr(1);
         this.taskPaneWin.document.getElementById("RedlineWidget"+radioName+"Radio").checked = true;
-        // wrapper around the original upload button of the form
-        var uploadButton = document.createElement("button");
-        uploadButton.id = "RedlineWidgetUploadButton";
-        uploadButton.innerHTML = "Upload";
-        this.widget.uploadForm.elements[2].style.display = "none";
-        this.taskPaneWin.document.getElementById("RedlineWidgetUploadTd").appendChild(this.widget.uploadForm);
-        this.taskPaneWin.document.getElementById("RedlineWidgetUploadTd").appendChild(uploadButton);
+
         // do we have an uploaded file ?
         if (this.taskPaneWin.document.getElementById("uploadedFileName")) {
             this.widget.activateControl(this.widget.defaultControl,0); //hack to reset the right control/radio
@@ -402,7 +367,7 @@
     removeLayer: function() {
         var i = this.taskPaneWin.document.getElementById("RedlineWidgetLayerList").selectedIndex;
         this.widget.removeLayer(i);
-        this.updateLayerList();
+        this.updateLayerList(); 
         this.updateFeatureList();
     },
 
@@ -426,7 +391,6 @@
     },
 
     uploadFile: function() {
-        this.widget.uploadForm.submit();
         var initFunction = OpenLayers.Function.bind(this.initPanel, this);
         setTimeout(initFunction,300);
     },
@@ -441,7 +405,14 @@
             opt.text = this.widget.vectorLayers[i].name;
             if (i == selectedIndex)
                 opt.selected = true;
-            select.add(opt,null);
+            try
+            {
+                select.add(opt,null); // standards compliant
+            }
+            catch(ex)
+            {
+                select.add(opt); // IE only
+            }
         }
     },
 
@@ -449,7 +420,14 @@
         var select = this.taskPaneWin.document.getElementById('RedlineWidgetFeatureList');
         var opt = document.createElement('option');
         opt.text = feature.id;
-        select.add(opt,null);
+        try
+        {
+            select.add(opt,null); // standards compliant
+        }
+        catch(ex)
+        {
+            select.add(opt); // IE only
+        }
     },
 
     removeFeature: function() {
@@ -481,7 +459,14 @@
         {
             var opt = document.createElement('option');
             opt.text = this.widget.activeLayer.features[i].id;
-            select.add(opt,null);
+            try
+            {
+                select.add(opt,null); // standards compliant
+            }
+            catch(ex)
+            {
+                select.add(opt); // IE only
+            }
         }
     },
 



More information about the fusion-commits mailing list