Moved working file uploader to its own control

This commit is contained in:
Rick Falkvinge
2013-09-21 19:33:13 +00:00
parent c7395dc627
commit bd2c73302e
12 changed files with 88 additions and 56 deletions
+59
View File
@@ -0,0 +1,59 @@
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="FileUpload.ascx.cs" Inherits="Swarmops.Controls.Base.FileUpload" %>
<script type="text/javascript">
// The below weird construct circumvents a mono-server optimization bug that kills the string
var imageFileStart = "\x3Cimg src='";
var imageFileSuccess = "/Images/Icons/iconshock-invoice-greentick-32px.png";
var imageFileFail = "/Images/Icons/iconshock-invoice-redcross-32px.png";
var imageFileEnd = "' /\x3E"; // needs to be separate var rather than inline because of mono-server optimization bug
var imageUploadSuccess = imageFileStart + imageFileSuccess + imageFileEnd;
var imageUploadFail = imageFileStart + imageFileFail + imageFileEnd;
$(document).ready(function() {
$('#ButtonUploadHidden').fileupload({
url: '/Automation/UploadFileHandler.ashx',
dataType: 'json',
done: function(e, data) {
$.each(data.result, function(index, file) {
if (file.error == null || file.error.length < 1) {
$('#DivUploadCount').append(imageUploadSuccess);
} else {
$('#DivUploadCount').append(imageUploadFail); // Assume ERR_NOT_IMAGE
alertify.error('File "' + file.name + '" could not be uploaded. Is it really an image?');
}
});
$('#DivProgressUpload').progressbar({ value: 100 });
$('#DivProgressUpload').fadeOut('400', function() { $('#DivUploadCount').fadeIn(); });
},
progressall: function(e, data) {
var progress = parseInt(data.loaded / data.total * 100, 10);
$("#DivProgressUpload .progressbar-value").animate(
{
width: progress + "%"
}, { queue: false });
},
add: function(e, data) {
$('#DivUploadCount').css('display', 'none');
$('#DivProgressUpload').progressbar({ value: 0 }); // reset in case of previous uploads on this page
$('#DivProgressUpload').fadeIn();
data.submit();
}
});
$('#ButtonUploadVisible').bind("click", function() {
$('#ButtonUploadHidden').click();
});
$('#DivProgressUpload').progressbar({ value: 0, max: 100 });
});
</script>
<div style="height:36px;float:left"><input id="ButtonUploadVisible" type="button" style="width:36px !important; background-image:url('/Images/Icons/iconshock-diskette-upload-32px.png');background-repeat:no-repeat; background-position:top left"/><input id="ButtonUploadHidden" type="file" name="files[]" multiple style="display:none" /></div><div style="height:36px;width:270px;margin-right:10px;float:right;border:none"><div id="DivUploadCount" style="display:none;overflow:hidden;height:64px"></div><div id="DivProgressUpload" style="width:100%;margin-top:8px;display:none"></div></div>&nbsp;<br/>
+18
View File
@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Swarmops.Controls.Base
{
public partial class FileUpload : ControlV5Base
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
}
+2 -1
View File
@@ -1,5 +1,6 @@
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="Master-v5.master.cs" Inherits="Swarmops.MasterV5" %>
<%@ Register Src="~/Controls/v5/Base/LanguageSelector.ascx" TagName="LanguageSelector" TagPrefix="act5" %>
<%@ Register TagPrefix="Swarmops5" TagName="ExternalScripts" Src="~/Controls/v5/UI/ExternalScripts.ascx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
@@ -16,7 +17,7 @@
<link href='https://fonts.googleapis.com/css?family=Permanent+Marker' rel='stylesheet' type='text/css' />
<link href='https://fonts.googleapis.com/css?family=Ubuntu:light,regular,500,bold' rel='stylesheet' type='text/css' />
<link href='https://fonts.googleapis.com/css?family=Arimo:regular,italic,bold,bolditalic' rel='stylesheet' type='text/css' />
<!-- page title -->
<title>Swarmops</title>
+3 -50
View File
@@ -1,5 +1,6 @@
<%@ Page Title="" Language="C#" MasterPageFile="~/Master-v5.master" AutoEventWireup="true" CodeFile="FileExpenseClaim.aspx.cs" Inherits="Swarmops.Frontend.Pages.v5.Financial.FileExpenseClaim" %>
<%@ Register src="~/Controls/v5/UI/ExternalScripts.ascx" tagname="ExternalScripts" tagprefix="Swarmops5" %>
<%@ Register src="~/Controls/v5/Base/FileUpload.ascx" tagname="FileUpload" tagprefix="Swarmops5" %>
<%@ Register TagPrefix="Swarmops5" TagName="ExternalScripts" Src="~/Controls/v5/UI/ExternalScripts.ascx" %>
<asp:Content ID="Content4" ContentPlaceHolderID="PlaceHolderHead" Runat="Server">
<Swarmops5:ExternalScripts ID="ExternalScripts1" Package="easyui" Control="tree" runat="server" />
@@ -11,15 +12,6 @@
<script type="text/javascript">
// The below weird construct circumvents a mono-server optimization bug that kills the string
var imageFileStart = "\x3Cimg src='";
var imageFileSuccess = "/Images/Icons/iconshock-invoice-greentick-32px.png";
var imageFileFail = "/Images/Icons/iconshock-invoice-redcross-32px.png";
var imageFileEnd = "' /\x3E"; // needs to be separate var rather than inline because of mono-server optimization bug
var imageUploadSuccess = imageFileStart + imageFileSuccess + imageFileEnd;
var imageUploadFail = imageFileStart + imageFileFail + imageFileEnd;
$(document).ready(function () {
$('#DropBudgets').combotree({
animate: true,
@@ -40,45 +32,6 @@
});
$('#ButtonUploadHidden').fileupload({
url: '/Automation/UploadFileHandler.ashx',
dataType: 'json',
done: function (e, data) {
$.each(data.result, function(index, file) {
if (file.error == null || file.error.length < 1) {
$('#DivUploadCount').append(imageUploadSuccess);
} else {
$('#DivUploadCount').append(imageUploadFail); // Assume ERR_NOT_IMAGE
alertify.error('File "' + file.name + '" could not be uploaded. Is it really an image?');
}
});
$('#DivProgressUpload').progressbar({ value: 100 });
$('#DivProgressUpload').fadeOut('400', function () { $('#DivUploadCount').fadeIn(); });
},
progressall: function (e, data) {
var progress = parseInt(data.loaded / data.total * 100, 10);
$("#DivProgressUpload .progressbar-value").animate(
{
width: progress + "%"
}, { queue: false });
},
add: function (e, data) {
$('#DivUploadCount').css('display', 'none');
$('#DivProgressUpload').progressbar({ value: 0 }); // reset in case of previous uploads on this page
$('#DivProgressUpload').fadeIn();
data.submit();
}
});
$('#ButtonUploadVisible').bind("click" , function () {
$('#ButtonUploadHidden').click();
});
$('#DivProgressUpload').progressbar({ value: 0, max: 100 });
});
@@ -142,7 +95,7 @@
<!-- file upload begins here -->
<div style="height:36px;float:left"><input id="ButtonUploadVisible" type="button" style="width:36px !important; background-image:url('/Images/Icons/iconshock-diskette-upload-32px.png');background-repeat:no-repeat; background-position:top left"/><input id="ButtonUploadHidden" type="file" name="files[]" multiple style="display:none" /></div><div style="height:36px;width:270px;margin-right:10px;float:right;border:none"><div id="DivUploadCount" style="display:none;overflow:hidden;height:64px"></div><div id="DivProgressUpload" style="width:100%;margin-top:8px;display:none"></div></div>&nbsp;<br/>
<Swarmops5:FileUpload ID="FileUpload" runat="server" />
<!-- file upload ends -->
+1 -1
View File
@@ -1,6 +1,6 @@
<%@ Page Title="" Language="C#" MasterPageFile="~/Master-v5.master" AutoEventWireup="true" CodeFile="AddMotion.aspx.cs" Inherits="Swarmops.Pages.Governance.AddMotion" %>
<%@ Register src="~/Controls/v5/Pirates/ComboPerson.ascx" tagname="ComboPerson" tagprefix="act5" %>
<%@ Register src="~/Controls/v5/Swarm/ComboPerson.ascx" tagname="ComboPerson" tagprefix="act5" %>
<asp:Content ID="Content1" ContentPlaceHolderID="PlaceHolderHead" Runat="Server">
<script type="text/javascript">
@@ -1,5 +1,5 @@
<%@ Page Title="" Language="C#" MasterPageFile="~/Master-v5.master" AutoEventWireup="true" CodeFile="AddMotionAmendment.aspx.cs" Inherits="Swarmops.Pages.Governance.AddMotionAmendment" %>
<%@ Register src="~/Controls/v5/Pirates/ComboPerson.ascx" tagname="ComboPerson" tagprefix="act5" %>
<%@ Register src="~/Controls/v5/Swarm/ComboPerson.ascx" tagname="ComboPerson" tagprefix="act5" %>
<asp:Content ID="Content1" ContentPlaceHolderID="PlaceHolderHead" Runat="Server">
+1 -1
View File
@@ -1,5 +1,5 @@
<%@ Page Title="" Language="C#" MasterPageFile="~/Master-v5.master" AutoEventWireup="true" CodeFile="SetRootBudgets.aspx.cs" Inherits="Pages_v5_Ledgers_SetRootBudgets" %>
<%@ Register src="~/Controls/v5/Pirates/PersonDetailPopup.ascx" tagName="PersonDetailPopup" tagPrefix="act5" %>
<%@ Register src="~/Controls/v5/Swarm/PersonDetailPopup.ascx" tagName="PersonDetailPopup" tagPrefix="act5" %>
<asp:Content ID="Content1" ContentPlaceHolderID="PlaceHolderHead" Runat="Server">
</asp:Content>
@@ -5,6 +5,7 @@ using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Swarmops.Basic.Enums;
using Swarmops.Controls.Swarm;
using Swarmops.Logic.Financial;
using Swarmops.Logic.Swarm;
using Swarmops.Logic.Security;
@@ -178,7 +179,7 @@ public partial class Pages_v5_Ledgers_SetRootBudgets : PageV5Base
RadToolTip toolTip = (RadToolTip)e.Item.FindControl("ToolTip");
Controls_v5_PersonDetailPopup personDetail = (Controls_v5_PersonDetailPopup)toolTip.FindControl("PersonDetail");
Swarmops.Controls.Swarm.PersonDetailPopup personDetail = (PersonDetailPopup)toolTip.FindControl("PersonDetail");
personDetail.PersonChanged += new PersonChangedEventHandler(PersonDetail_PersonChanged);
if (!Page.IsPostBack && this.CurrentAuthority != null)
@@ -267,7 +268,7 @@ public partial class Pages_v5_Ledgers_SetRootBudgets : PageV5Base
FinancialAccount child = FinancialAccount.FromIdentity(Int32.Parse(hiddenAccountId.Value));
RadToolTip toolTip = (RadToolTip)repeaterItem.FindControl("ToolTip");
Controls_v5_PersonDetailPopup personDetail = (Controls_v5_PersonDetailPopup)toolTip.FindControl("PersonDetail");
PersonDetailPopup personDetail = (PersonDetailPopup)toolTip.FindControl("PersonDetail");
FinancialAccount account = FinancialAccount.FromIdentity(Int32.Parse(hiddenAccountId.Value));
personDetail.Person = account.Owner;