Abstracted included jQuery plugin controls

This commit is contained in:
Rick Falkvinge
2014-11-15 05:58:14 +01:00
parent 3d5a61466a
commit 258f5a017a
12 changed files with 119 additions and 11 deletions
+9
View File
@@ -144,3 +144,12 @@ public enum EasyUIControl
ValidateBox = 0x4000000,
Window = 0x8000000
};
[Flags]
public enum IncludedControl
{
Unknown = 0,
FileUpload = 0x00000001,
SwitchButton = 0x00000002
};
+1
View File
@@ -24,6 +24,7 @@ public class MasterV5Base : System.Web.UI.MasterPage
protected Organization _currentOrganization = null;
public EasyUIControl EasyUIControlsUsed { get; set; } // these are set by each page, and called by Master to render in ExternalScripts control
public IncludedControl IncludedControlsUsed { get; set; } // as above with IncludedScripts control
// ReSharper restore InconsistentNaming
public DateTime PermissionCacheTimestamp
+6
View File
@@ -51,6 +51,12 @@ public class PageV5Base : System.Web.UI.Page
set { this.Master.EasyUIControlsUsed = value; }
}
protected IncludedControl IncludedControlsUsed
{
get { return this.Master.IncludedControlsUsed; }
set { this.Master.IncludedControlsUsed = value; }
}
protected Person CurrentUser
{
get { return this.Master.CurrentUser; }
+1 -1
View File
@@ -64,5 +64,5 @@
</script>
<asp:HiddenField runat="server" ID="HiddenGuid"/>
<div style="height:36px;float:left"><input id="<%=this.ClientID %>_ButtonUploadVisible" class="ButtonSwarmopsUpload NoInputFocus" type="button" <%= this.HideTrigger? "style='display:none'" : string.Empty %> /><input id="<%=this.ClientID %>_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="<%=this.ClientID %>_DivUploadCount" style='display:none;overflow:hidden;height:'<%=this.DisplayCount < 9? 32: 64%>px'></div><div id="<%=this.ClientID %>_DivProgressUpload" style="width:100%;margin-top:8px;display:none"></div></div>&#8203;<br/>
<div style="height:36px;padding-top:4px;float:left"><input id="<%=this.ClientID %>_ButtonUploadVisible" class="ButtonSwarmopsUpload NoInputFocus" type="button" <%= this.HideTrigger? "style='display:none'" : string.Empty %> /><input id="<%=this.ClientID %>_ButtonUploadHidden" type="file" name="files[]" multiple style="display:none" /></div><div style="height:36px;padding-top:4px;width:270px;margin-right:10px;float:right;border:none"><div id="<%=this.ClientID %>_DivUploadCount" style='display:none;overflow:hidden;height:'<%=this.DisplayCount < 9? 32: 64%>px'></div><div id="<%=this.ClientID %>_DivProgressUpload" style="width:100%;margin-top:8px;display:none"></div></div>&#8203;<br/>
@@ -0,0 +1,5 @@
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="IncludedScripts.ascx.cs" Inherits="Swarmops.Frontend.Controls.v5.UI.IncludedScripts" %>
<asp:Literal ID="LiteralReference" runat="server" />
@@ -0,0 +1,41 @@
using System;
using System.IO;
using System.Text;
using NBitcoin;
using Swarmops.Logic.Support;
namespace Swarmops.Frontend.Controls.v5.UI
{
public partial class IncludedScripts : ControlV5Base
{
protected void Page_Load(object sender, EventArgs e)
{
StringBuilder scriptRef = new StringBuilder();
string[] controlNames = Controls.Split(',');
foreach (string controlName in controlNames)
{
switch (controlName.Trim().ToLowerInvariant())
{
case "fileupload":
scriptRef.Append(
"<script src=\"/Scripts/jquery.fileupload/jquery.iframe-transport.js\" type=\"text/javascript\" language=\"javascript\"></script>\r\n" +
"<script src=\"/Scripts/jquery.fileupload/jquery.fileupload.js\" type=\"text/javascript\" language=\"javascript\"></script>\r\n");
break;
case "switchbutton":
scriptRef.Append(
"<script src=\"/Scripts/jquery.switchButton.js\" language=\"javascript\" type=\"text/javascript\"></script>\r\n" +
"<link rel=\"stylesheet\" type=\"text/css\" href=\"/Style/jquery.switchButton.css\" />\r\n");
break;
default:
break;
}
}
this.LiteralReference.Text = scriptRef.ToString();
}
public new string Controls { get; set; }
}
}
+3
View File
@@ -1,5 +1,6 @@
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="Master-v5.master.cs" Inherits="Swarmops.MasterV5" %>
<%@ Register TagPrefix="Swarmops5" TagName="ExternalScripts" Src="~/Controls/v5/UI/ExternalScripts.ascx" %>
<%@ Register TagPrefix="Swarmops5" TagName="IncludedScripts" Src="~/Controls/v5/UI/IncludedScripts.ascx" %>
<%@ Register TagPrefix="Swarmops5" TagName="MainMenu" Src="~/Controls/v5/Base/MainMenu.ascx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
@@ -39,6 +40,8 @@
<link href="/Style/v5-easyui-elements.css" rel="stylesheet" type="text/css" />
<!-- additional scripts etc from individual pages -->
<Swarmops5:IncludedScripts ID="IncludedScripts" runat="server" />
<asp:ContentPlaceHolder id="PlaceHolderHead" runat="server" />
<asp:Literal ID="LiteralCrowdinScript" runat="server" Text="" />
+1
View File
@@ -48,6 +48,7 @@ namespace Swarmops
this.Page.Title = "Swarmops - " + this.CurrentPageTitle;
this.ExternalScriptEasyUI.Controls = EasyUIControlsUsed.ToString();
this.IncludedScripts.Controls = IncludedControlsUsed.ToString();
this.LiteralSidebarInfo.Text = this.CurrentPageInfoBoxLiteral;
+33 -5
View File
@@ -1,8 +1,8 @@
<%@ Page Title="" Language="C#" MasterPageFile="~/Master-v5.master" AutoEventWireup="true" CodeFile="EditOrganization.aspx.cs" Inherits="Swarmops.Frontend.Pages.v5.Admin.EditOrganization" %>
<%@ Register tagPrefix="Swarmops5" tagName="FileUpload" src="~/Controls/v5/Base/FileUpload.ascx" %>
<asp:Content ID="Content1" ContentPlaceHolderID="PlaceHolderHead" Runat="Server">
<script src="/Scripts/jquery.switchButton.js" language="javascript" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="/Style/jquery.switchButton.css" />
<script language="javascript" type="text/javascript">
$(document).ready(function () {
@@ -13,6 +13,7 @@
});
});
</script>
<style>
@@ -52,12 +53,39 @@
</div>
</div>
<div title="<img src='/Images/Icons/iconshock-group-diversified-64px.png' />">
<h2>Members policy</h2>
work in progress
<h2>Participant policy</h2>
<div class="entryLabels">
People become members when... [applied, applied+approved, applied+paid, applied+paid+approved, invited+paid, manual only]<br/>
People become members in... [root org only, most local org only, root + local, all on line root-local]<br/>
People churn from membership when... [expiry date hits, not paid final reminder, manual churn only]<br/>
Membership lasts... [1 month, 1 year, 2 years, 5 years, forever]<br/>
Membership costs... [in operating currency]<br/>
Renewals cost... [in operating currency]<br/>
Renewals renew... [all active memberships, one org at a time]<br/>
Remind renewal... [30, 14, 7, 1 day in advance]<br/>
</div>
</div>
<div title="<img src='/Images/Icons/iconshock-colorswatch-64px.png' />">
<h2>Communications profile and branding</h2>
work in progress
<div class="entryFields">
<Swarmops5:FileUpload ID="UploadLogoLandscape" DisplayCount="1" runat="server" />
<Swarmops5:FileUpload ID="UploadLogoSquare" DisplayCount="1" runat="server" />
Bar&nbsp;<br/>
<Swarmops5:FileUpload ID="UploadInvoiceTemplate" DisplayCount="1" runat="server" />
<Swarmops5:FileUpload ID="UploadParticipantMailTemplate" DisplayCount="1" runat="server" />
<Swarmops5:FileUpload ID="UploadOfficerMailTemplate" DisplayCount="1" runat="server" />
<Swarmops5:FileUpload ID="UploadRenewalMailTemplate" DisplayCount="1" runat="server" />
</div>
<div class="entryLabels">
Logo, landscape version [PNG]<br/>
Logo, square version [PNG]<br/>
<h2>MAIL TEMPLATES</h2>
Outbound invoice [SVG]<br/>
Invoice cover letter [TXT]<br/>
Mail to participants [HTML]<br/>
Mail to officers [HTML]<br/>
Renewal letter [HTML]<br/>
</div>
</div>
<div title="<img src='/Images/Icons/iconshock-mail-open-64px.png' />">
<h2>Mail transmission settings</h2>
+17 -1
View File
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.UI;
using System.Web.UI.WebControls;
using Swarmops.Logic.Security;
@@ -19,9 +20,24 @@ namespace Swarmops.Frontend.Pages.v5.Admin
this.PageAccessRequired = new Access(CurrentOrganization, AccessAspect.Administration, AccessType.Write);
this.EasyUIControlsUsed = EasyUIControl.Tabs;
this.IncludedControlsUsed = IncludedControl.FileUpload | IncludedControl.SwitchButton;
}
[WebMethod]
public static CallResult FlickSwitch(string switchName, bool switchOn)
{
// TODO
return new CallResult();
}
public class CallResult
{
public bool Success { get; set; }
public string OpResult { get; set; }
public string DisplayMessage { get; set; }
public string RequiredOn { get; set; }
}
}
@@ -3,10 +3,6 @@
<%@ Register TagPrefix="Swarmops5" TagName="ComboBudgets" Src="~/Controls/v5/Financial/ComboBudgets.ascx" %>
<asp:Content ID="Content4" ContentPlaceHolderID="PlaceHolderHead" Runat="Server">
<!-- The Iframe Transport is required for browsers without support for XHR file uploads -->
<script src="/Scripts/jquery.fileupload/jquery.iframe-transport.js" type="text/javascript" language="javascript"></script>
<!-- The basic File Upload plugin -->
<script src="/Scripts/jquery.fileupload/jquery.fileupload.js" type="text/javascript" language="javascript"></script>
<script type="text/javascript">
@@ -109,6 +109,8 @@ namespace Swarmops.Frontend.Pages.v5.Financial
Localize();
}
IncludedControlsUsed = IncludedControl.FileUpload;
}