diff --git a/Site5/Pages/v5/Governance/AddMotion.aspx b/Site5/Pages/v5/Governance/AddMotion.aspx new file mode 100644 index 00000000..77c58d65 --- /dev/null +++ b/Site5/Pages/v5/Governance/AddMotion.aspx @@ -0,0 +1,70 @@ +<%@ Page Title="" Language="C#" MasterPageFile="~/Master-v5.master" AutoEventWireup="true" CodeFile="AddMotion.aspx.cs" Inherits="Activizr.Pages.Governance.AddMotion" %> + +<%@ Register src="~/Controls/v5/Pirates/ComboPerson.ascx" tagname="ComboPerson" tagprefix="act5" %> + + + + + + + +
+
+
+
+ +
+
+
+
+  
+  
+
+ +
+
+
+
+  
+  
+
+ +
+
+
+ + +

+ +
+
+ . +
+
+ +

+ +
+
+ +
+
+ +

+ +
+
+ +
+
+ +
+ diff --git a/Site5/Pages/v5/Governance/AddMotion.aspx.cs b/Site5/Pages/v5/Governance/AddMotion.aspx.cs new file mode 100644 index 00000000..dc8f4c80 --- /dev/null +++ b/Site5/Pages/v5/Governance/AddMotion.aspx.cs @@ -0,0 +1,119 @@ +using System; +using System.Collections.Generic; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; +using Activizr.Logic.Governance; +using Activizr.Logic.Pirates; + +namespace Activizr.Pages.Governance +{ + + public partial class AddMotion : PageV5Base + { + private Meeting _meeting = Meeting.FromIdentity(1); + + protected void Page_Load(object sender, EventArgs e) + { + // Stylize + + this.PageIcon = "iconshock-motion-add"; + this.TextTitle.Style[HtmlTextWriterStyle.Width] = "300px"; + this.PersonSubmitter.Width = 304; // !? + this.TextMotionText.Style[HtmlTextWriterStyle.Width] = "300px"; + this.TextDecisionPoints.Style[HtmlTextWriterStyle.Width] = "300px"; + this.TextMotionText.Style[HtmlTextWriterStyle.Height] = "200px"; + + // Localize + + this.PageTitle = Resources.Pages.Governance.AddMotion_PageTitle; + + this.LabelMeetingName.Text = _meeting.Name; + this.LabelWrongMeeting.Text = Resources.Pages.Governance.AddMotion_WrongMeeting; + this.LabelSubmittingMotionInfo.Text = Resources.Pages.Governance.AddMotion_SubmittingMotionInfo; + this.LabelTitle.Text = Resources.Pages.Governance.AddMotion_Title; + this.LabelSubmitter.Text = Resources.Pages.Governance.AddMotion_Submitter; + this.LabelText.Text = Resources.Pages.Governance.AddMotion_Text; + this.LabelDecisions.Text = Resources.Pages.Governance.AddMotion_Decisions; + + this.LabelSidebarInfo.Text = Resources.Pages.Global.Sidebar_Information; + this.LabelSidebarActions.Text = Resources.Pages.Global.Sidebar_Actions; + this.LabelSidebarTodo.Text = Resources.Pages.Global.Sidebar_Todo; + this.LabelActionItemsHere.Text = Resources.Pages.Global.Sidebar_Actions_Placeholder; + + this.ButtonAddMotion.Text = Resources.Pages.Governance.AddMotion_SubmitMotion; + + this.LabelActionListMotions.Text = Resources.Pages.Governance.ListMotions_PageTitle; + + if (!Page.IsPostBack) + { + this.PersonSubmitter.SelectedPerson = _currentUser; + + // HACK: Hardcode the presidency of this meeting + + bool isPresidency = false; + + switch (_currentUser.Identity) + { + case 1681: // Nils Agnesson + case 15719: // Andreas Bjärnemalm + case 1185: // Jonatan Kindh + case 7838: // Jörgen Lindell + case 16761: // Mikael Holm + case 14843: // Staffan Jonsson + case 71888: // Henrik Brändén + { + isPresidency = true; + break; + } + default: + { + break; + } + } + + this.PersonSubmitter.Enabled = isPresidency; + + this.TextTitle.Focus(); + } + } + + protected void ButtonAddMotion_Click(object sender, EventArgs e) + { + if (!Page.IsValid) + { + this.LabelMotionSaved.Text = string.Empty; + return; // Do nothing if validators fail the page + } + + Motion newMotion = Motion.Create(_meeting, this.PersonSubmitter.SelectedPerson, _currentUser, + this.TextTitle.Text, this.TextMotionText.Text, this.TextDecisionPoints.Text); + + this.LabelMotionSaved.Text = String.Format(Resources.Pages.Governance.AddMotion_MotionSubmittedAs, + newMotion.SequenceNumber); + + this.TextDecisionPoints.Text = string.Empty; + this.TextMotionText.Text = string.Empty; + this.TextTitle.Text = string.Empty; + + if (this.PersonSubmitter.Enabled) + { + this.PersonSubmitter.SelectedPerson = null; + } + + this.TextTitle.Focus(); + } + + protected void ValidatorSubmitterRequired_Validate(object source, ServerValidateEventArgs args) + { + if (this.PersonSubmitter.SelectedPerson == null) + { + args.IsValid = false; + } + else + { + args.IsValid = true; + } + } + } +} \ No newline at end of file diff --git a/Site5/Pages/v5/Governance/AddMotionAmendment.aspx b/Site5/Pages/v5/Governance/AddMotionAmendment.aspx new file mode 100644 index 00000000..c63fcaf4 --- /dev/null +++ b/Site5/Pages/v5/Governance/AddMotionAmendment.aspx @@ -0,0 +1,70 @@ +<%@ Page Title="" Language="C#" MasterPageFile="~/Master-v5.master" AutoEventWireup="true" CodeFile="AddMotionAmendment.aspx.cs" Inherits="Activizr.Pages.Governance.AddMotionAmendment" %> +<%@ Register src="~/Controls/v5/Pirates/ComboPerson.ascx" tagname="ComboPerson" tagprefix="act5" %> + + + + + + + + +
+
+
+
+ +
+
+
+
+  
+  
+
+ +
+
+
+
+  
+  
+
+ +
+
+
+ + +

+ +
+
+ . +
+
+ +

+ +
+
+ +
+
+ +

+ +
+
+ +
+
+ +
+ diff --git a/Site5/Pages/v5/Governance/AddMotionAmendment.aspx.cs b/Site5/Pages/v5/Governance/AddMotionAmendment.aspx.cs new file mode 100644 index 00000000..82c85aa2 --- /dev/null +++ b/Site5/Pages/v5/Governance/AddMotionAmendment.aspx.cs @@ -0,0 +1,121 @@ +using System; +using System.Collections.Generic; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; +using Activizr.Logic.Governance; + +namespace Activizr.Pages.Governance +{ + public partial class AddMotionAmendment : PageV5Base + { + private Motion _motion; + + protected void Page_Load(object sender, EventArgs e) + { + string motionIdString = Request.QueryString["MotionId"]; + int motionId = Int32.Parse(motionIdString); + _motion = Motion.FromIdentity(motionId); + + // Stylize + + this.PageIcon = "iconshock-motion-amendment-add"; + this.TextTitle.Style[HtmlTextWriterStyle.Width] = "300px"; + this.PersonSubmitter.Width = 304; // !? + this.TextAmendmentText.Style[HtmlTextWriterStyle.Width] = "300px"; + this.TextDecisionPoint.Style[HtmlTextWriterStyle.Width] = "300px"; + this.TextAmendmentText.Style[HtmlTextWriterStyle.Height] = "200px"; + + // Localize + + this.PageTitle = Resources.Pages.Governance.AddMotionAmendment_PageTitle; + + this.LabelMotionName.Text = _motion.Title; + this.LabelSubmittingAmendmentInfo.Text = Resources.Pages.Governance.AddMotionAmendment_SubmittingAmendmentInfo; + this.LabelTitle.Text = Resources.Pages.Governance.AddMotionAmendment_Title; + this.LabelSubmitter.Text = Resources.Pages.Governance.AddMotionAmendment_Submitter; + this.LabelText.Text = Resources.Pages.Governance.AddMotionAmendment_Text; + this.LabelDecision.Text = Resources.Pages.Governance.AddMotionAmendment_Decision; + + this.LabelSidebarInfo.Text = Resources.Pages.Global.Sidebar_Information; + this.LabelSidebarActions.Text = Resources.Pages.Global.Sidebar_Actions; + this.LabelSidebarTodo.Text = Resources.Pages.Global.Sidebar_Todo; + this.LabelActionItemsHere.Text = Resources.Pages.Global.Sidebar_Actions_Placeholder; + + this.ButtonAddMotionAmendment.Text = Resources.Pages.Governance.AddMotionAmendment_SubmitAmendment; + + this.LabelActionListMotions.Text = Resources.Pages.Governance.ListMotions_PageTitle; + + if (!Page.IsPostBack) + { + this.PersonSubmitter.SelectedPerson = _currentUser; + + // HACK: Hardcode the presidency of this meeting + + bool isPresidency = false; + + switch (_currentUser.Identity) + { + case 1681: // Nils Agnesson + case 15719: // Andreas Bjärnemalm + case 1185: // Jonatan Kindh + case 7838: // Jörgen Lindell + case 16761: // Mikael Holm + case 14843: // Staffan Jonsson + case 71888: // Henrik Brändén + { + isPresidency = true; + break; + } + default: + { + break; + } + } + + this.PersonSubmitter.Enabled = isPresidency; + + this.TextTitle.Focus(); + } + } + + protected void ValidatorSubmitterRequired_Validate(object source, ServerValidateEventArgs args) + { + if (this.PersonSubmitter.SelectedPerson == null) + { + args.IsValid = false; + } + else + { + args.IsValid = true; + } + } + + protected void ButtonAddAmendment_Click(object sender, EventArgs e) + { + if (!Page.IsValid) + { + this.LabelAmendmentSaved.Text = string.Empty; + return; // Do nothing if validators fail the page + } + + MotionAmendment newAmendment = MotionAmendment.Create(_motion, this.TextTitle.Text, this.TextAmendmentText.Text, + this.TextDecisionPoint.Text, + this.PersonSubmitter.SelectedPerson, _currentUser); + + this.LabelAmendmentSaved.Text = String.Format(Resources.Pages.Governance.AddMotionAmendment_AmendmentSubmittedAs, + _motion.SequenceNumber, (char) ((int)('A') + newAmendment.SequenceNumber - 1)); + + this.TextDecisionPoint.Text = string.Empty; + this.TextAmendmentText.Text = string.Empty; + this.TextTitle.Text = string.Empty; + + if (this.PersonSubmitter.Enabled) + { + this.PersonSubmitter.SelectedPerson = null; + } + + this.TextTitle.Focus(); + } + } +} \ No newline at end of file diff --git a/Site5/Pages/v5/Governance/ListMotions.aspx b/Site5/Pages/v5/Governance/ListMotions.aspx new file mode 100644 index 00000000..19e8cce4 --- /dev/null +++ b/Site5/Pages/v5/Governance/ListMotions.aspx @@ -0,0 +1,66 @@ +<%@ Page Title="" Language="C#" MasterPageFile="~/Master-v5.master" AutoEventWireup="true" CodeFile="ListMotions.aspx.cs" Inherits="Activizr.Pages.Governance.ListMotions" %> + + + + + + + + + + + + + + + + + + + + + – + + + + + – + + + + + + + +

+ +
+
+ . +
+
+ +

+ +
+
+ + +
+
+ +

+ +
+
+ +
+
+
+ diff --git a/Site5/Pages/v5/Governance/ListMotions.aspx.cs b/Site5/Pages/v5/Governance/ListMotions.aspx.cs new file mode 100644 index 00000000..2891998c --- /dev/null +++ b/Site5/Pages/v5/Governance/ListMotions.aspx.cs @@ -0,0 +1,213 @@ +using System; +using System.Collections.Generic; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; +using Activizr.Logic.Governance; +using Telerik.Web.UI; + +namespace Activizr.Pages.Governance +{ + public partial class ListMotions : PageV5Base + { + private Meeting _meeting = Meeting.FromIdentity(1); + private Dictionary _amendmentLookup; + + public ListMotions() + { + } + + protected void Page_Load(object sender, EventArgs e) + { + this.PageTitle = Resources.Pages.Governance.ListMotions_PageTitle; + this.PageIcon = "iconshock-motions"; + + this.LabelActionAddMotion.Text = Resources.Pages.Governance.AddMotion_PageTitle; + this.LabelActionVote.Text = Resources.Pages.Governance.Vote_PageTitle; + + Localize(); + + if (!this.IsPostBack) + { + PopulateGrid(); + this.GridMotions.DataBind(); + } + + ((Activizr.MasterV5) Master).LanguageChanged += new EventHandler(Master_LanguageChanged); + + } + + private void Master_LanguageChanged(object sender, EventArgs e) + { + // Grid must be re-localized + + LocalizeGrid(); + PopulateGrid(); + this.GridMotions.DataBind(); + } + + + private void Localize() + { + this.LabelSidebarInfo.Text = Resources.Pages.Global.Sidebar_Information; + this.LabelSidebarActions.Text = Resources.Pages.Global.Sidebar_Actions; + this.LabelSidebarTodo.Text = Resources.Pages.Global.Sidebar_Todo; + this.LabelActionItemsHere.Text = Resources.Pages.Global.Sidebar_Actions_Placeholder; + + this.LabelSidebarLookingAt.Text = Resources.Pages.Governance.ListMotions_Sidebar_Info; + this.LabelMeetingName.Text = _meeting.Name; + this.LabelChangeMeeting.Text = Resources.Pages.Global.Global_Change; + + LocalizeGrid(); + } + + + private void LocalizeGrid() + { + TreeListColumnsCollection columns = this.GridMotions.Columns; + + foreach (TreeListColumn column in columns) + { + column.HeaderText = GetGlobalResourceObject("Pages.Governance", column.UniqueName).ToString(); + } + } + + private void PopulateGrid() + { + Motions motions = Motions.ForMeeting(_meeting); + MotionListRows rows = new MotionListRows(); + + MotionAmendments amendments = MotionAmendments.ForMeeting(_meeting); + + _amendmentLookup = new Dictionary(); + + foreach (Motion motion in motions) + { + MotionListRow newRow = new MotionListRow(motion.Identity, 0, motion.SequenceNumber.ToString(), motion.Title, + 0, false, false); + rows.Add(newRow); + } + + foreach (MotionAmendment amendment in amendments) + { + if (!_amendmentLookup.ContainsKey(amendment.MotionId)) + { + _amendmentLookup[amendment.MotionId] = new MotionAmendments(); + } + + _amendmentLookup[amendment.MotionId].Add(amendment); + + MotionListRow newRow = new MotionListRow(-amendment.Identity, amendment.MotionId, amendment.Designation, amendment.Title, 0, false, amendment.Carried); + + rows.Add(newRow); + } + + // TODO: Sort rows by identity + + this.GridMotions.DataSource = rows; + + // TODO: Store in session var to enable paging + } + + + protected void GridMotions_ItemCreated(object sender, TreeListItemCreatedEventArgs e) + { + MotionListRow row = null; + + if (!(e.Item is TreeListDataItem)) + { + return; + } + + row = ((TreeListDataItem) e.Item).DataItem as MotionListRow; + + if (row == null) + { + return; + } + + Literal literalAmendments = (Literal)e.Item.FindControl("LiteralAmendments"); + Literal literalTitle = (Literal)e.Item.FindControl("LiteralTitle"); + + if (row.Identity > 0) + { + int amendmentCount = 0; + + if (_amendmentLookup.ContainsKey(row.Identity)) + { + amendmentCount = _amendmentLookup[row.Identity].Count; + } + + literalAmendments.Text = String.Format("{0} ({2})", + amendmentCount, row.Identity, + Resources.Pages.Governance.ListMotions_SubmitAmendment); + + literalTitle.Text = String.Format("{1}", row.Identity, + HttpUtility.HtmlEncode(row.Title)); + } + else + { + literalAmendments.Text = string.Empty; + literalTitle.Text = HttpUtility.HtmlEncode(row.Title); + } + + // 0 (">Submit...) + // "><%# Eval("Title") %> + + } + + + public class MotionListRow + { + public MotionListRow (int identity, int parentIdentity, string designation, string title, int amendmentCount, bool amended, bool carried) + { + this.identity = identity; + this.parentIdentity = parentIdentity; + this.designation = designation; + this.title = title; + this.amendmentCount = amendmentCount; + this.amended = amended; + this.carried = carried; + } + + private int identity; + private int parentIdentity; + private string designation; + private string title; + private int amendmentCount; + private bool amended; + private bool carried; + + public int ParentIdentity + { + get { return this.parentIdentity; } + } + + public int Identity + { + get { return this.identity; } + } + + public string Designation + { + get { return this.designation; } + } + + public string Title + { + get { return this.title; } + } + } + + public class MotionListRows: List + { + // empty class; we just want the name + } + + protected void GridMotions_NeedDataSource(object sender, TreeListNeedDataSourceEventArgs e) + { + LocalizeGrid(); + PopulateGrid(); // read this from session var instead, later + } + } +} \ No newline at end of file diff --git a/Site5/Pages/v5/Governance/ViewMotion.aspx b/Site5/Pages/v5/Governance/ViewMotion.aspx new file mode 100644 index 00000000..ff6ccaf7 --- /dev/null +++ b/Site5/Pages/v5/Governance/ViewMotion.aspx @@ -0,0 +1,79 @@ +<%@ Page Title="" Language="C#" MasterPageFile="~/Master-v5.master" AutoEventWireup="true" CodeFile="ViewMotion.aspx.cs" Inherits="Activizr.Pages.Governance.ViewMotion" %> + + + + + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + + +
+
+
<%=GetGlobalResourceObject("Pages.Governance", "ViewMotion_Amendment").ToString() %> #<%# Eval("Designation") %>
<%# Eval("Title") %>
+
+
+
+
<%=GetGlobalResourceObject("Pages.Governance", "ViewMotion_AmendmentText").ToString() %>
<%# Eval("Text") %>
+
+
+
+
<%=GetGlobalResourceObject("Pages.Governance", "ViewMotion_AmendmentProposedChange").ToString() %>
<%# Eval("DecisionPoint") %>
+
+
+
+
+ +
+ +
+
+
+
+ +
+ + +

+ +
+
+ . +
+
+ +

+ +
+
+ +
+
+ +

+ +
+
+ +
+
+
+ diff --git a/Site5/Pages/v5/Governance/ViewMotion.aspx.cs b/Site5/Pages/v5/Governance/ViewMotion.aspx.cs new file mode 100644 index 00000000..55d823c9 --- /dev/null +++ b/Site5/Pages/v5/Governance/ViewMotion.aspx.cs @@ -0,0 +1,95 @@ +using System; +using System.Collections.Generic; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; +using Activizr.Logic.Governance; + +namespace Activizr.Pages.Governance +{ + public partial class ViewMotion : PageV5Base + { + private Motion _motion; + private Meeting _meeting; + + protected void Page_Load(object sender, EventArgs e) + { + string motionIdString = Request.QueryString["MotionId"]; + int motionId = Int32.Parse(motionIdString); + _motion = Motion.FromIdentity(motionId); + _meeting = _motion.Meeting; + + // TODO: Authorize + + // TODO: Get # of posts in discussion thread + + int discussionPostCount = 0; + + // Localize + + this.PageTitle = Resources.Pages.Governance.ViewMotion_PageTitle; + this.PageIcon = "iconshock-motion"; + + this.LabelActionListMotions.Text = Resources.Pages.Governance.ListMotions_PageTitle; + + this.LabelDiscussLabel.Text = Resources.Pages.Governance.ViewMotion_Discuss; + this.LabelMotionDecisionsLabel.Text = Resources.Pages.Governance.ViewMotion_DecisionPoints; + this.LabelMotionDesignation.Text = String.Format(Resources.Pages.Governance.ViewMotion_MotionDesignation, _motion.SequenceNumber); + this.LabelMotionTextLabel.Text = Resources.Pages.Governance.ViewMotion_Text; + this.LabelViewingMotionInfo.Text = Resources.Pages.Governance.ViewMotion_ViewingMotionInfo; + + this.LabelSidebarInfo.Text = Resources.Pages.Global.Sidebar_Information; + this.LabelSidebarActions.Text = Resources.Pages.Global.Sidebar_Actions; + this.LabelSidebarTodo.Text = Resources.Pages.Global.Sidebar_Todo; + this.LabelActionItemsHere.Text = Resources.Pages.Global.Sidebar_Actions_Placeholder; + + + // Fill in fields + + this.LabelMeetingName.Text = _meeting.Name; + this.LabelMotionText.Text = _motion.Text; + this.LabelMotionTitle.Text = _motion.Title; + this.LinkDiscussion.Text = String.Format(Resources.Pages.Governance.ViewMotion_DiscussLink, discussionPostCount); + + // construct motion text field (a literal, we make it an OL field, need to take care to HTML encode text) + + string[] decisionPoints = _motion.DecisionPoints.Split('\r', '\n'); + + string literal = "
    "; + foreach (string decisionPoint in decisionPoints) + { + string proposedDecision = decisionPoint.Trim(); + + if (proposedDecision.Length > 0) + { + literal += "
  1. " + HttpUtility.HtmlEncode(proposedDecision) + "
  2. "; + } + } + literal += "
"; + + this.LiteralMotionDecisions.Text = literal; + + MotionAmendments amendments = _motion.Amendments; + + this.RepeaterAmendments.DataSource = amendments; + this.RepeaterAmendments.DataBind(); + + if (amendments.Count > 1) + { + this.LabelAmendmentCount.Text = String.Format(Resources.Pages.Governance.ViewMotion_AmendmentCountTwoPlus, + amendments.Count); + } + else if (amendments.Count == 1) + { + this.LabelAmendmentCount.Text = Resources.Pages.Governance.ViewMotion_AmendmentCountOne; + } + else // zero + { + this.LabelAmendmentCount.Text = Resources.Pages.Governance.ViewMotion_AmendmentCountZero; + } + + this.LinkAddAmendment.NavigateUrl = "AddMotionAmendment.aspx?MotionId=" + _motion.Identity.ToString(); + this.LinkAddAmendment.Text = Resources.Pages.Governance.ViewMotion_AddAmendment; + } + } +} \ No newline at end of file diff --git a/Site5/Pages/v5/Governance/Vote.aspx b/Site5/Pages/v5/Governance/Vote.aspx new file mode 100644 index 00000000..aa141d0b --- /dev/null +++ b/Site5/Pages/v5/Governance/Vote.aspx @@ -0,0 +1,60 @@ +<%@ Page Title="" Language="C#" MasterPageFile="~/Master-v5.master" AutoEventWireup="true" CodeFile="Vote.aspx.cs" Inherits="Activizr.Pages.Governance.Vote" %> + + + + + + +

SIMULERAT VÅRMÖTE 2011

+ +

+ +

+ +

+ +

+

Öppnar 2011-04-25
+
 
 
+
+ +

+ +

+ +
Styrelsens sammankallande
Styrelsen t.o.m. 2013
Styrelsen t.o.m. 2012 (fyllnadsval)
Mötespresidium
+
Öppnar 2011-05-03
Öppnar 2011-05-03
Öppnar 2011-05-03
Öppnar 2011-05-03
+
 
 
+
+ +
+ + + +

+ +
+
+ +
+
+ +

+ +
+
+ +
+
+ +

+ +
+
+ +
+
+
diff --git a/Site5/Pages/v5/Governance/Vote.aspx.cs b/Site5/Pages/v5/Governance/Vote.aspx.cs new file mode 100644 index 00000000..c02be587 --- /dev/null +++ b/Site5/Pages/v5/Governance/Vote.aspx.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; +using Activizr.Logic.Governance; + +namespace Activizr.Pages.Governance +{ + + public partial class Vote : PageV5Base + { + protected void Page_Load(object sender, EventArgs e) + { + int motionCount = Motions.ForMeeting(Meeting.FromIdentity(1)).Count; + int amendmentCount = MotionAmendments.ForMeeting(Meeting.FromIdentity(1)).Count; + + this.PageTitle = Resources.Pages.Governance.Vote_PageTitle; + this.PageIcon = "iconshock-vote"; + + this.LabelSidebarInfo.Text = Resources.Pages.Global.Sidebar_Information; + this.LabelSidebarActions.Text = Resources.Pages.Global.Sidebar_Actions; + this.LabelSidebarTodo.Text = Resources.Pages.Global.Sidebar_Todo; + this.LabelActionItemsHere.Text = Resources.Pages.Global.Sidebar_Actions_Placeholder; + + this.LabelActionListMotions.Text = Resources.Pages.Governance.ListMotions_PageTitle; + this.LabelVotingInfo.Text = String.Format(Resources.Pages.Governance.Vote_Info, _currentOrganization.Name); + + this.LabelPointsOfOrderHeader.Text = Resources.Pages.Governance.Vote_PointsOfOrder; + this.LabelPointsOfOrderTemp.Text = Resources.Pages.Governance.Vote_PointsOfOrderTemp; + + this.LabelVoteAmendmentsLabel.Text = String.Format(Resources.Pages.Governance.Vote_VoteOnAmendments, + amendmentCount); + this.LabelVoteMotionsLabel.Text = String.Format(Resources.Pages.Governance.Vote_VoteOnMotions, motionCount); + + this.LabelCreateVotingList.Text = Resources.Pages.Governance.Vote_CreateVotingList; + this.LabelVoteHere.Text = Resources.Pages.Governance.Vote_VoteHere; + + this.LabelElectionsHeader.Text = Resources.Pages.Governance.Vote_MeetingElections; + this.LabelMotionsHeader.Text = Resources.Pages.Governance.Vote_Motions; + } + } +} \ No newline at end of file diff --git a/Site5/Pages/v5/Governance/VoteAmendments.aspx b/Site5/Pages/v5/Governance/VoteAmendments.aspx new file mode 100644 index 00000000..29d8d7b3 --- /dev/null +++ b/Site5/Pages/v5/Governance/VoteAmendments.aspx @@ -0,0 +1,70 @@ +<%@ Page Title="" Language="C#" MasterPageFile="~/Master-v5.master" EnableEventValidation="false" AutoEventWireup="true" CodeFile="VoteAmendments.aspx.cs" Inherits="Activizr.Pages.Governance.VoteAmendments" %> + + + + + + +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+ + +

+ +
+
+ +
+
+ +

+ +
+
+ +
+
+ +

+ +
+
+ +
+
+
+ diff --git a/Site5/Pages/v5/Governance/VoteAmendments.aspx.cs b/Site5/Pages/v5/Governance/VoteAmendments.aspx.cs new file mode 100644 index 00000000..ade6164b --- /dev/null +++ b/Site5/Pages/v5/Governance/VoteAmendments.aspx.cs @@ -0,0 +1,262 @@ +using System; +using System.Collections.Generic; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; +using Activizr.Logic.Governance; +using Activizr.Logic.Pirates; +using Telerik.Web.UI; + +namespace Activizr.Pages.Governance +{ + public partial class VoteAmendments : PageV5Base + { + private Meeting _meeting; + private string _selectedRecommendation; + + protected void Page_Init (object sender, EventArgs e) + { + _selectedRecommendation = Request.Form["ctl00$PlaceHolderMain$DropRecommendations"]; + if (String.IsNullOrEmpty(_selectedRecommendation)) + { + _selectedRecommendation = "0"; + } + + /* + PopulateGrid(); + this.GridAmendmentsVote.DataBind();*/ + } + + protected void Page_Load(object sender, EventArgs e) + { + string motionIdString = Request.QueryString["MeetingId"]; + int meetingId = Int32.Parse(motionIdString); + _meeting = Meeting.FromIdentity(meetingId); + + // TODO: Authorize + + // Localize + + this.PageTitle = Resources.Pages.Governance.VoteAmendments_PageTitle; + this.PageIcon = "iconshock-motion-amendments-vote"; + + this.LabelActionListMotions.Text = Resources.Pages.Governance.ListMotions_PageTitle; + + // Fill in fields + + LocalizeGrid(); + Localize(); + + if (!Page.IsPostBack) + { + PopulateGrid(); + PopulateRecommendations(); + } + + this.DropRecommendations.Style[HtmlTextWriterStyle.Position] = "relative"; + this.DropRecommendations.Style[HtmlTextWriterStyle.Top] = "3px"; + } + + private void LocalizeGrid() + { + TreeListColumnsCollection columns = this.GridAmendmentsVote.Columns; + + foreach (TreeListColumn column in columns) + { + column.HeaderText = GetGlobalResourceObject("Pages.Governance", column.UniqueName).ToString(); + } + } + + private void Localize() + { + this.LabelActionListMotions.Text = Resources.Pages.Governance.ListMotions_PageTitle; + this.LabelActionItemsHere.Text = Resources.Pages.Global.Sidebar_Actions_Placeholder; + this.LabelAmendmentsForMeeting.Text = _meeting.Name; + this.LabelSidebarInfo.Text = Resources.Pages.Global.Sidebar_Information; + this.LabelSidebarActions.Text = Resources.Pages.Global.Sidebar_Actions; + this.LabelSidebarTodo.Text = Resources.Pages.Global.Sidebar_Todo; + this.ButtonSaveVote.Text = Resources.Pages.Governance.VoteAmendments_SaveVote_Temp; + + this.LabelInfo.Text = Resources.Pages.Governance.VoteAmendments_Info; + } + + private void PopulateRecommendations() + { + this.DropRecommendations.Items.Clear(); + this.DropRecommendations.Items.Add(new ListItem(Resources.Pages.Governance.VoteAmendments_SelectRecommendation, "0")); + this.DropRecommendations.Items.Add(new ListItem(Resources.Pages.Governance.VoteAmendments_BoardRecommendation, "-1")); + this.DropRecommendations.Items.Add(new ListItem("DinLista - " + _currentUser.Canonical, "3")); + this.DropRecommendations.Items.Add(new ListItem("TestList - Rick Falkvinge (#1)", "1")); + } + + + private void PopulateGrid() + { + // Use lazy method. This can be optimized plenty. + + List items = new List(); + Motions motions = Motions.ForMeeting(_meeting); + + foreach (Motion motion in motions) + { + items.Add(new GridRowItem(String.Format(Resources.Pages.Governance.ViewMotion_MotionDesignation, motion.SequenceNumber), motion.Title, motion.Submitter, -motion.Identity, 0)); + items.Add(new GridRowItem(Resources.Pages.Governance.VoteAmendments_Grid_Text, motion.Text, null, -motion.Identity + 210000, -motion.Identity)); + items.Add(new GridRowItem(Resources.Pages.Governance.VoteAmendments_Grid_Decision, motion.DecisionPoints, null, -motion.Identity + 220000, -motion.Identity)); + + MotionAmendments amendments = MotionAmendments.ForMotion(motion); + + foreach (MotionAmendment amendment in amendments) + { + items.Add(new GridRowItem("#" + amendment.Designation, amendment.Title, amendment.Submitter, amendment.Identity, 0)); + items.Add(new GridRowItem(Resources.Pages.Governance.VoteAmendments_Grid_Rationale, amendment.Text, null, + amendment.Identity + 100000, amendment.Identity)); + items.Add(new GridRowItem(Resources.Pages.Governance.VoteAmendments_Grid_Change, + amendment.DecisionPoint, null, amendment.Identity + 200000, amendment.Identity)); + } + } + + this.GridAmendmentsVote.DataSource = items; + } + + + public class GridRowItem + { + public GridRowItem(string designation, string text, Person submitter, int identity, int parentIdentity) + { + this.TextField = text; + this.DesignationField = designation; + this.Submitter = submitter; + this.IdentityField = identity; + this.ParentIdentityField = parentIdentity; + } + + public string Title; + public string TextField; + public string DesignationField; + public Person Submitter; + public int IdentityField; + public int ParentIdentityField; + + public int Identity + { + get { return this.IdentityField; } + } + + public int ParentIdentity + { + get { return this.ParentIdentityField; } + } + + public string Designation + { + get { return this.DesignationField;} + } + + public string Text + { + get { return this.TextField; } + } + } + + protected void GridAmendments_NeedDataSource(object sender, TreeListNeedDataSourceEventArgs e) + { + PopulateGrid(); + } + + protected void GridAmendmentsVote_ItemCreated(object sender, TreeListItemCreatedEventArgs e) + { + GridRowItem row = null; + + if (!(e.Item is TreeListDataItem)) + { + return; + } + + row = ((TreeListDataItem)e.Item).DataItem as GridRowItem; + + if (row == null) + { + return; + } + + RadioButton radioYes = (RadioButton)e.Item.FindControl("RadioYes"); + RadioButton radioNo = (RadioButton)e.Item.FindControl("RadioNo"); + RadioButton radioAbstain = (RadioButton)e.Item.FindControl("RadioAbstain"); + Label labelRecommendation = (Label)e.Item.FindControl("LabelRecommendation"); + + labelRecommendation.Style[HtmlTextWriterStyle.FontWeight] = "700"; + labelRecommendation.Style[HtmlTextWriterStyle.Color] = "#880"; + + bool showButtons = false; + + if (row.Identity > 0 && row.Identity < 100000) + { + showButtons = true; + + string recommendation = Resources.Pages.Governance.VoteAmendments_Recommend_Abstain; + + radioYes.GroupName = + radioNo.GroupName = + radioAbstain.GroupName = "Amendment" + row.Identity.ToString(); + + if (_selectedRecommendation != "0") + { + switch ((Convert.ToInt32(_selectedRecommendation) + row.Identity) % 3) + { + case 1: + recommendation = Resources.Pages.Governance.VoteAmendments_Recommend_Yes; + labelRecommendation.Style[HtmlTextWriterStyle.Color] = "#080"; + break; + case 2: + recommendation = Resources.Pages.Governance.VoteAmendments_Recommend_No; + labelRecommendation.Style[HtmlTextWriterStyle.Color] = "#800"; + break; + default: + break; + } + } + + labelRecommendation.Text = recommendation; + + // Repopulate the state directly from the form + + string previousState = null; + + foreach (string key in Request.Form.AllKeys) + { + if (key.EndsWith(radioYes.GroupName)) + { + previousState = Request.Form[key]; + } + } + + if (!String.IsNullOrEmpty(previousState)) + { + if (previousState == "RadioYes") + { + radioYes.Checked = true; + } + else if (previousState == "RadioNo") + { + radioNo.Checked = true; + } + else if (previousState == "RadioAbstain") + { + radioAbstain.Checked = true; + } + } + } + + radioYes.Visible = showButtons; + radioNo.Visible = showButtons; + radioAbstain.Visible = showButtons; + labelRecommendation.Visible = showButtons; + } + + protected void DropRecommendations_SelectedIndexChanged(object sender, EventArgs e) + { + PopulateGrid(); + this.GridAmendmentsVote.DataBind(); + } + } +} \ No newline at end of file diff --git a/Site5/Scripts/crowdin-jipt.js b/Site5/Scripts/crowdin-jipt.js new file mode 100644 index 00000000..76699d10 --- /dev/null +++ b/Site5/Scripts/crowdin-jipt.js @@ -0,0 +1 @@ +Crowdin = window.Crowdin ? Crowdin : { phrases: null, htmlPhrases: [], entryPoint: "http://crowdin.net/", jiptCDN: "http://jipt.crowdin.net/", editor: { currentTranslation: null, currentTranslations: [], currentElement: null, showTranslations: false, marker: "border", skipApproved: false, files: false, customPlaceholders: [], mergeDuplicates: true, currentPhraseId: null, traversePage: true }, suggestions: { tm: [], google: [], microsoft: [] }, language: { code: null, id: 0 }, source_language: { code: null }, project: { id: 0, identifier: null, name: null }, user: { is_leader: false, is_logged_in: true }, previewTranslations: false, _preloadCallbacks: [], is_first_run: false, matchType: { any: 0, text: 1, textRegExp: 2, html: 3, htmlRegExp: 4, htmlOuter: 5, title: 6 }, placeholders: [{ template: "((?:%%|%(?:[0-9]+\\$)?[+-]?(?:[ 0]|'.)?-?[0-9]*(?:\\.[0-9]+)?[bcdeufFosxX]))", replacement: "(.*)" }, { template: "(\\{0\\})", replacement: "(.*)" }, { template: "(\\{1\\})", replacement: "(.*)" }, { template: "(\\{2\\})", replacement: "(.*)" }, { template: "(\\{3\\})", replacement: "(.*)" }, { template: "(\\{4\\})", replacement: "(.*)" }, { template: "(\\{5\\})", replacement: "(.*)" }, { template: "(%1)", replacement: "(.*)" }, { template: "(%2)", replacement: "(.*)" }, { template: "(%3)", replacement: "(.*)" }, { template: "(%4)", replacement: "(.*)" }, { template: "(%5)", replacement: "(.*)" }, { template: "(%6)", replacement: "(.*)"}], init: function() { Crowdin.self = this; this.self_configure(); this.init_google_jsapi(); return this }, ready: function(a) { Crowdin._preloadCallbacks.push(a) }, get_instance: function() { return Crowdin.self }, start_translation: function() { if ($JIPT("#crowdin-translation-panel").length) { this.just_show_panel() } else { this.init_editor().init_translation_panel().init_help_dialog(); this.loader.create().hide() } }, self_configure: function() { if (this.check_first_run()) { this.is_first_run = true } else { this.is_first_run = false } if (!Crowdin.cookies.has("crowdin_language_code" + this.get_project_identifier()) || !Crowdin.cookies.has("crowdin_language_id" + this.get_project_identifier()) || !Crowdin.cookies.has("crowdin_project_id" + this.get_project_identifier()) || !Crowdin.cookies.has("crowdin_project_name" + this.get_project_identifier()) || !Crowdin.cookies.has("crowdin_source_language_code" + this.get_project_identifier())) { this.logout() } this.language.code = Crowdin.cookies.get("crowdin_language_code" + this.get_project_identifier()); this.language.id = Crowdin.cookies.get("crowdin_language_id" + this.get_project_identifier()); this.project.id = Crowdin.cookies.get("crowdin_project_id" + this.get_project_identifier()); this.project.name = Crowdin.cookies.get("crowdin_project_name" + this.get_project_identifier()); this.user.is_leader = Crowdin.cookies.get("crowdin_is_leader" + this.get_project_identifier()); if (Crowdin.cookies.has("crowdin_marker" + this.get_project_identifier())) { this.editor.marker = Crowdin.cookies.get("crowdin_marker" + this.get_project_identifier()) } if (Crowdin.cookies.has("crowdin_merge_duplicates" + this.get_project_identifier())) { this.editor.mergeDuplicates = (Crowdin.cookies.get("crowdin_merge_duplicates" + this.get_project_identifier()) == "true") } else { this.editor.mergeDuplicates = true } if (Crowdin.cookies.has("crowdin_show_translations" + this.get_project_identifier())) { this.editor.showTranslations = (Crowdin.cookies.get("crowdin_show_translations" + this.get_project_identifier()) == "true"); this.previewTranslations = this.editor.showTranslations } this.source_language.code = Crowdin.cookies.get("crowdin_source_language_code" + this.get_project_identifier()) }, check_first_run: function() { if (!Crowdin.cookies.pattern_has("crowdin_marker") && !Crowdin.cookies.pattern_has("crowdin_merge_duplicates") && !Crowdin.cookies.pattern_has("crowdin_show_translations")) { return true } else { return false } }, show_quick_start: function() { $JIPT("#crowdin-help-container").attr("src", this.jiptCDN + "help/quick-start.html"); $JIPT("#crowdin-help").dialog("open") }, set_element_marker: function(c, a) { if (this.previewTranslations) { return } c = $JIPT(c); var e = c.attr("class").split(/\s+/); var f = /^crowdin-jipt-/; for (var b = 0; b < e.length; b++) { var d = e[b]; if (d.match(f)) { c.removeClass(d) } } $JIPT(c).addClass(a + "-" + this.editor.marker) }, _get_editor_buttons: function() { var a = {}; if (this.editor.currentPhraseId) { a["Translate and Open Next"] = this._suggest_translation_and_open_next; a.Skip = this._proceed_to_next_phrase } if (this.editor.currentTranslations && this.editor.currentTranslations.length > 0) { a["Translate All"] = this._suggest_translation } else { a.Translate = this._suggest_translation } a.Cancel = function() { $JIPT("#crowdin-editor").dialog("close"); if (Crowdin.self.editor.currentElement != null) { } }; return a }, init_editor: function() { if ($JIPT("#crowdin-editor").length) { return this } $JIPT($JIPT("
").attr("id", "crowdin-editor").attr("title", "Crowdin Editor").css("display", "none").html(this.get_editor_markup())).appendTo("body"); $JIPT("#crowdin-editor").dialog({ autoOpen: false, height: "auto", zIndex: 16777260, width: 600, dialogClass: "cjipt", beforeClose: function() { $JIPT(".crowdin-active-element").removeClass("crowdin-active-element") }, buttons: this._get_editor_buttons() }); this.dialog_ui_help($JIPT("#crowdin-editor"), this.jiptCDN + "help/crowdin-editor.html"); $JIPT("#crowdin-show-hide-context").click(function() { $JIPT("#crowdin-context-header").slideToggle(); $JIPT(".crowdin-phrase-context").slideToggle() }); $JIPT("#crowdin-copy-source").click(function() { var a = Crowdin.self.editor.currentTranslation.html ? Crowdin.self.editor.currentTranslation.html : Crowdin.self.editor.currentTranslation.text; $JIPT(".crowdin-editor-translation").val(a).focus(); Crowdin.self.place_translation_preview(a) }); $JIPT("#crowdin-edit-context").click(function() { $JIPT("#crowdin-context-editor-current-context").html(Crowdin.self.editor.currentTranslation.context.replace(/(\r\n|\n\r|\r|\n)/g, "
")); $JIPT("#crowdin-context-editor").dialog("open"); Crowdin.self.fix_dialogs() }); $JIPT(".crowdin-editor-translation").keyup(function(a) { if ($JIPT(this).val().length == 0) { return } if (a.keyCode != 27) { Crowdin.self.place_translation_preview($JIPT(this).val()) } if ((a.ctrlKey) && ((a.keyCode == 10) || (a.keyCode == 13))) { if (Crowdin.self.editor.currentPhraseId) { Crowdin.self._suggest_translation_and_open_next() } else { Crowdin.self._suggest_translation() } } if ((a.altKey) && ((a.keyCode == 10) || (a.keyCode == 13))) { if (Crowdin.self.editor.currentPhraseId) { Crowdin.self._proceed_to_next_phrase() } } }); this.init_context_editor(); this.init_functions_proxy(); return this }, _suggest_translation_and_open_next: function() { if (Crowdin.self._suggest_translation()) { Crowdin.self._proceed_to_next_phrase() } }, _proceed_to_next_phrase: function() { if (Crowdin.self.editor.currentPhraseId && Crowdin.self.phrases[Crowdin.self.editor.currentPhraseId + 1]) { Crowdin.self.editor.currentPhraseId++; Crowdin.self.editor.currentTranslation = Crowdin.self.phrases[Crowdin.self.editor.currentPhraseId]; Crowdin.self.editor.currentTranslations = []; Crowdin.self.editor.currentElement = null; Crowdin.self.editor.currentPhraseId = Crowdin.self.editor.currentPhraseId; Crowdin.self.show_editor() } else { Crowdin.self.loader.notify("You reached the end of file.") } }, _suggest_translation: function() { if (!Crowdin.self._validate_translation()) { return false } else { Crowdin.self._force_suggest_translation(); return true } }, trigger_suggestion_added: function() { if (this.editor.currentElement != null) { for (var a = this.editor.currentTranslation.elements.length; a--; ) { this.set_element_marker(this.editor.currentTranslation.elements[a], "crowdin-jipt-translated") } } var c = null; for (var b = this.phrases.length; b--; ) { if (this.phrases[b].id == this.editor.currentTranslation.id) { this.phrases[b].suggestions_count++; c = b; break } } $JIPT(".jipt-phrases-to-translate li a[rel=" + c + "]").removeClass("crowdin-untranslated-item").addClass("crowdin-translated-item") }, trigger_suggestion_approved: function() { if (this.editor.currentElement != null) { for (var a = this.editor.currentTranslation.elements.length; a--; ) { this.set_element_marker(this.editor.currentTranslation.elements[a], "crowdin-jipt-approved") } } var c = null; for (var b = this.phrases.length; b--; ) { if (this.phrases[b].id == this.editor.currentTranslation.id) { this.phrases[b].approved = true; c = b; break } } $JIPT(".jipt-phrases-to-translate li a[rel=" + c + "]").removeClass("crowdin-translated-item").addClass("crowdin-approved-item") }, _force_suggest_translation: function() { $JIPT("#crowdin-editor").dialog("close"); this.trigger_suggestion_added(); if (this.editor.currentTranslations.length) { for (var a = 0; a < this.editor.currentTranslations.length; a++) { this.suggest(this.editor.currentTranslations[a].translation, $JIPT(".crowdin-editor-translation").val()) } } else { this.suggest(this.editor.currentTranslation, $JIPT(".crowdin-editor-translation").val()) } }, _validate_translation: function() { var a = $JIPT(".crowdin-editor-translation").val(); if (!a.length) { this.loader.notify("Translation can not be empty string"); $JIPT(".crowdin-editor-translation").focus(); return false } var p = this.editor.currentTranslation.text.match(/^\s*/g)[0].length; var b = a.match(/^\s*/g)[0].length; var c = this.editor.currentTranslation.text.match(/\s*$/g)[0].length; var d = a.match(/\s*$/g)[0].length; if (p != b && p == 0) { this.validation_message_with_action("Original text doesn't have any leading spaces, but your suggestion begins with " + b + " spaces"); return false } if (c != d && c == 0) { this.validation_message_with_action("Original text doesn't have any trailing spaces, but your suggestion ends with " + d + " spaces"); return false } if (p != b && b == 0) { this.validation_message_with_action("Original text begins with " + p + " leading spaces, but your suggestion haven't at all"); return false } if (c != d && d == 0) { this.validation_message_with_action("Original text ends with " + c + " trailing spaces, but your suggestion haven't at all"); return false } if (p != b && c != d) { this.validation_message_with_action("The original text has " + p + " leading spaces and " + c + " trailing spaces, your suggestion has " + b + " leading spaces and " + d + " trailing"); return false } if (p != b) { this.validation_message_with_action("The original text has " + p + " leading spaces, your suggestion has " + b); return false } if (c != d) { this.validation_message_with_action("The original text has " + c + " trailing spaces, your suggestion has " + d); return false } var l = this.editor.currentTranslation.text.match(/[\.\!\?\:]+\s*$/g); var h = a.match(/[\.\!\?\:]+\s*$/g); if (!this.is_eq(l, h) && l == null) { this.validation_message_with_action("The original text does not end with: " + h.join(", ") + ""); return false } if (!this.is_eq(l, h) && h == null) { this.validation_message_with_action('Probably you forgot the ending: "' + l.join(", ") + '"'); return false } if (!this.is_eq(l, h) && l != null && h != null) { this.validation_message_with_action('The original text ends with "' + l.join(", ") + '", but your suggestion ends with "' + h.join(", ") + '"'); return false } var n = []; var i = []; var m = []; var g, e, q = null, o = null, f = null; for (g = 0; g < this.placeholders.length; g++) { q = new RegExp(this.placeholders[g].template, "g"); o = this.editor.currentTranslation.text.match(q); f = a.match(q); if (o && o.length) { for (e = 0; e < o.length; e++) { i.push(o[e]) } } if (f && f.length) { for (e = 0; e < f.length; e++) { m.push(f[e]) } } } for (g = 0; g < this.editor.customPlaceholders.length; g++) { q = new RegExp(this.editor.customPlaceholders[g], "g"); o = this.editor.currentTranslation.text.match(q); f = a.match(q); if (o && o.length) { for (e = 0; e < o.length; e++) { i.push(o[e]) } } if (f && f.length) { for (e = 0; e < f.length; e++) { m.push(f[e]) } } } for (e = 0; e < i.length; e++) { if (m.indexOf(i[e]) == -1) { n.push(i[e]) } } if (n.length > 0) { this.validation_message_with_action("You translated or forgot some variables that should have been left as they were: " + n.join(", ") + ""); return false } return true }, validation_message_with_action: function(a) { this.loader.update(a + ' Continue anyway!') }, init_functions_proxy: function() { var b = window.alert; window.alert = function() { if (arguments[0]) { Crowdin.self.process_abstract_text(arguments[0]) } return b.apply(this, arguments) }; var a = window.confirm; window.confirm = function() { if (arguments[0]) { Crowdin.self.process_abstract_text(arguments[0]) } return a.apply(this, arguments) } }, process_abstract_text: function(b) { if (!b.length || !this.phrases) { return false } for (var a = this.phrases.length; a--; ) { if (this.fuzzy_trim(b) == this.phrases[a].textCleared) { this.editor.currentTranslation = this.phrases[a]; this.editor.currentTranslations = []; this.editor.currentElement = null; this.editor.currentPhraseId = null; this.show_editor(); return true } if (this.phrases[a].regexp) { if (b.match(this.phrases[a].regexp)) { this.editor.currentTranslation = this.phrases[a]; this.editor.currentTranslations = []; this.editor.currentElement = null; this.editor.currentPhraseId = null; this.show_editor(); return true } } } return false }, init_context_editor: function() { if ($JIPT("#crowdin-context-editor").length) { return } $JIPT($JIPT("
").attr("id", "crowdin-context-editor").attr("title", "Context Editor").css("display", "none").html(this.get_context_editor_markup())).appendTo("body"); $JIPT("#crowdin-context-editor").dialog({ autoOpen: false, height: "auto", width: 500, zIndex: 16777270, dialogClass: "cjipt", resizable: false, modal: true, buttons: this.get_context_editor_buttons() }); $JIPT("#crowdin-context-editor-current-context").hover(function() { $JIPT(this).css("background-color", "#fffed4") }, function() { $JIPT(this).css("background-color", "#fff") }); $JIPT("#crowdin-context-editor-current-context").click(function() { $JIPT("#crowdin-context-editor-context").val(Crowdin.self.editor.currentTranslation.context).focus() }) }, init_help_dialog: function() { if ($JIPT("#crowdin-help").length) { return this } $JIPT($JIPT("
").attr("id", "crowdin-help").attr("title", "Crowdin Help").css("display", "none").html('')).appendTo("body"); $JIPT("#crowdin-help").dialog({ autoOpen: false, height: 500, width: 700, zIndex: 16777271, dialogClass: "cjipt", resizable: true, modal: true }); return this }, get_context_editor_buttons: function() { var a = {}; a["Update context"] = function() { var c = $JIPT("#crowdin-context-editor-context").val(); Crowdin.self.editor.currentTranslation.context = c; var b = "File: " + Crowdin.self.editor.currentTranslation.file + "
Context:
" + c + "
"; $JIPT(".crowdin-phrase-context").html(b); $JIPT.ajax({ url: Crowdin.self.entryPoint + "jipt/update_context?callback=?", dataType: "json", data: { id: Crowdin.self.editor.currentTranslation.id, project: Crowdin.self.get_project_identifier(), context: c }, success: function(d) { if (!d.success) { alert(d.msg) } else { $JIPT("#crowdin-context-editor").dialog("close"); Crowdin.self.loader.notify("Context has been updated...") } } }) }; a.Cancel = function() { $JIPT("#crowdin-context-editor").dialog("close") }; return a }, get_match_type_text: function(a) { switch (a) { default: case this.matchType.text: case this.matchType.textRegExp: case this.matchType.html: case this.matchType.htmlRegExp: case this.matchType.htmlOuter: return "Text on page"; case this.matchType.title: return "Element title" } }, init_translation_panel: function() { if (!$JIPT("#crowdin-translation-panel").length) { $JIPT($JIPT("
").attr("id", "crowdin-translation-panel").attr("title", "Crowdin JIPT").css("display", "none").html(this.get_translation_panel_markup())).prependTo("body"); $JIPT("#crowdin-translation-panel").dialog({ autoOpen: false, height: "auto", zIndex: 16777260, dialogClass: "cjipt", width: 500, height: 380, position: ["right", "bottom"] }); this.dialog_ui_minimization($JIPT("#crowdin-translation-panel")); this.dialog_ui_help($JIPT("#crowdin-translation-panel"), this.jiptCDN + "help/translations-panel.html"); this.bind_auto_search() } else { this.just_show_panel() } if (!this.user.is_logged_in) { this.init_login_panel() } else { this.init_translation_panel_phrases(); this.configure_translation_panel() } return this }, configure_translation_panel: function() { $JIPT("#jipt-options #jipt-show-actual-translations").get(0).checked = this.editor.showTranslations; $JIPT("#jipt-options #jipt-group-matches").get(0).checked = this.editor.mergeDuplicates; $JIPT("#jipt-options #jipt-marker").val(this.editor.marker); if (!this.editor.traversePage) { $JIPT("#jipt-options .inline-table").hide(); $JIPT("#jipt-preview-translations").hide(); $JIPT("#jipt-marker").parents("tr").remove() } }, init_translation_panel_phrases: function() { $JIPT(".crowdin-translation-panel-container").tabs(); $JIPT.ajax({ url: this.entryPoint + "jipt/project_languages?callback=?", dataType: "json", data: { project: this.get_project_identifier() }, success: function(c) { if (!Crowdin.self.check_auth(c)) { return } for (var a = 0; a < c.length; a++) { var b = $JIPT("
' }, get_context_editor_markup: function() { return '

Note: Your comment will be visible for translators into other languages

' }, get_signup_panel_markup: function() { return '' }, set_project_identifier: function(a) { this.project.identifier = a }, set_target_language: function(a) { this.language.code = a; Crowdin.cookies.set("crowdin_language_code" + this.get_project_identifier(), a) }, set_marker: function(a) { this.editor.marker = a; Crowdin.cookies.set("crowdin_marker" + this.get_project_identifier(), a) }, set_target_language_id: function(a) { this.language.id = a; Crowdin.cookies.set("crowdin_language_id" + this.get_project_identifier(), a) }, set_project_id: function(a) { this.project.id = a; Crowdin.cookies.set("crowdin_project_id" + this.get_project_identifier(), a) }, mark_translatable_phrases: function(a) { this.editor.traversePage = a }, set_project_name: function(a) { this.project.name = a; Crowdin.cookies.set("crowdin_project_name" + this.get_project_identifier(), a) }, set_is_leader: function(a) { this.user.is_leader = a; Crowdin.cookies.set("crowdin_is_leader" + this.get_project_identifier(), a) }, set_translations_panel_state: function(a) { Crowdin.cookies.set("crowdin_is_tp_min" + this.get_project_identifier(), a) }, set_source_language: function(a) { this.source_language.code = a; Crowdin.cookies.set("crowdin_source_language_code" + this.get_project_identifier(), a) }, set_show_translations: function(a) { this.editor.showTranslations = a; Crowdin.cookies.set("crowdin_show_translations" + this.get_project_identifier(), a) }, set_files: function(a) { this.editor.files = a }, set_skip_approved: function(a) { this.editor.skipApproved = a }, set_custom_placeholders: function(a) { this.editor.customPlaceholders = a }, set_merge_duplicates: function(a) { this.editor.mergeDuplicates = a; Crowdin.cookies.set("crowdin_merge_duplicates" + this.get_project_identifier(), a) }, login: function(a, b, c) { $JIPT.ajax({ url: this.entryPoint + "jipt/login?callback=?", dataType: "json", data: { login: a, password: b, language_code: this.language.code, project: this.get_project_identifier() }, success: function(d) { Crowdin.self.login_success(d); if (c) { c(d.success) } } }) }, logout: function() { $JIPT.ajax({ url: this.entryPoint + "jipt/logout?callback=?", dataType: "json", data: { project: this.get_project_identifier() }, success: function(a) { Crowdin.self.user.is_logged_in = false; $JIPT("#crowdin-translation-panel").html(Crowdin.self.get_translation_panel_markup()); Crowdin.self.init_login_panel(); $JIPT("#crowdin-editor").dialog("close") } }) }, preview_translations: function() { this.overlay.create(); this.previewTranslations = true; this.drop_element_translation_relations(document.body); this.proceed_phrases_with_html(document.body); this.each_element(document.body, this.phrases); this.clear_markers($JIPT("body")); $JIPT("#crowdin-editor").dialog("close"); this.overlay.destroy() }, clear_markers: function(a) { a.find(".crowdin-jipt-approved-border").removeClass("crowdin-jipt-approved-border"); a.find(".crowdin-jipt-translated-border").removeClass("crowdin-jipt-translated-border"); a.find(".crowdin-jipt-untranslated-border").removeClass("crowdin-jipt-untranslated-border"); a.find(".crowdin-jipt-has-many-border").removeClass("crowdin-jipt-has-many-border"); a.find(".crowdin-jipt-approved-bg").removeClass("crowdin-jipt-approved-bg"); a.find(".crowdin-jipt-translated-bg").removeClass("crowdin-jipt-translated-bg"); a.find(".crowdin-jipt-untranslated-bg").removeClass("crowdin-jipt-untranslated-bg"); a.find(".crowdin-jipt-has-many-bg").removeClass("crowdin-jipt-has-many-bg"); a.find(".crowdin-jipt-approved-underline").removeClass("crowdin-jipt-approved-underline"); a.find(".crowdin-jipt-translated-underline").removeClass("crowdin-jipt-translated-underline"); a.find(".crowdin-jipt-untranslated-underline").removeClass("crowdin-jipt-untranslated-underline"); a.find(".crowdin-jipt-has-many-underline").removeClass("crowdin-jipt-has-many-underline"); a.find(".crowdin-jipt-approved-none").removeClass("crowdin-jipt-approved-none"); a.find(".crowdin-jipt-translated-none").removeClass("crowdin-jipt-translated-none"); a.find(".crowdin-jipt-untranslated-none").removeClass("crowdin-jipt-untranslated-none"); a.find(".crowdin-jipt-has-many-none").removeClass("crowdin-jipt-has-many-none") }, get_login_panel_markup: function() { return '' }, get_translation_panel_markup: function() { if (!this.user.is_logged_in) { return this.get_login_panel_markup() } else { return '
  • Loading...
   
' } }, get_project_identifier: function() { if (this.project.identifier != null) { return this.project.identifier } else { return document.domain } }, check_auth: function(a) { if (a.jipt_error) { $JIPT("#crowdin-editor").dialog("close"); $JIPT("#crowdin-translation-panel").dialog("close"); alert(a.message); this.user.is_logged_in = false; return false } if (a.auth_error) { this.user.is_logged_in = false; $JIPT("#crowdin-translation-panel").html(this.get_translation_panel_markup()); this.init_login_panel(); return false } else { return true } }, fix_dialogs: function() { this.clear_markers($JIPT("#crowdin-editor").parents(".ui-dialog")); $JIPT("#crowdin-editor").parents(".ui-dialog").css("height", "auto"); $JIPT("#crowdin-editor").css("height", "auto"); $JIPT("#crowdin-context-editor").parents(".ui-dialog").css("height", "auto") }, fuzzy_trim: function(a) { return a.replace(/^[\s:.()*-]+|[\s:.()*-]+$/g, "").replace(/\\t/g, "").replace(/\\n/g, "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"') }, fuzzy_trimmed: function(c) { c = c.replace(/^[\s]+|[\s]+$/g, ""); var b = c.match(/^([:.()*-]+)/g); var a = c.match(/([:.()*-]+)$/g); return { l: b ? b[0] : "", r: a ? a[0] : ""} }, htmlspecialchars: function(a) { return a.replace(/&/g, "&").replace(//g, ">").replace(/"/g, """) }, unhtmlspecialchars: function(a) { return a.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"') }, just_show_panel: function() { $JIPT("#crowdin-translation-panel").dialog("open") }, is_eq: function(c, b) { if (c == b) { return true } else { if (c == null || b == null) { return false } else { if (c.length != b.length) { return false } } } for (var a = 0; a < c.length; a++) { if (c[a] != b[a]) { return false } } return true }, load_external_resource: function(b, a) { if (a == "js") { var c = document.createElement("script"); c.setAttribute("type", "text/javascript"); c.setAttribute("src", b) } else { if (a == "css") { var c = document.createElement("link"); c.setAttribute("rel", "stylesheet"); c.setAttribute("type", "text/css"); c.setAttribute("href", b) } } if (typeof c != "undefined") { document.getElementsByTagName("head")[0].appendChild(c) } return c }, loader: { create: function() { var a = $JIPT("
").appendTo(document.body).attr("id", "crowdin-load-indicator"); return a }, hide: function() { $JIPT("#crowdin-load-indicator").hide(); return this }, fadeOut: function() { $JIPT("#crowdin-load-indicator").fadeOut(); return this }, show: function() { $JIPT("#crowdin-load-indicator").show(); return this }, update: function(a) { $JIPT("#crowdin-load-indicator").html(a).show(); Crowdin.self.loader.center(); return this }, notify: function(a) { Crowdin.self.loader.update(a); setTimeout(function() { Crowdin.self.loader.fadeOut() }, 2000); return this }, center: function() { var a = $JIPT("#crowdin-load-indicator"); a.css("left", ($JIPT(window).width() - a.width()) / 2 + $JIPT(window).scrollLeft() + "px"); return this } }, overlay: { create: function() { var a = $JIPT("
").appendTo(document.body).addClass("ui-widget-overlay").css({ width: $JIPT.ui.dialog.overlay.width(), height: $JIPT.ui.dialog.overlay.height(), zIndex: 16777271 }); return a }, destroy: function() { $JIPT(".ui-widget-overlay").remove() } }, cookies: { set: function(a, b) { var c = new Date((new Date()).getTime() + (365 * 1000 * 60 * 60 * 24)); document.cookie = a + "=" + escape(b) + ";expires=" + c.toGMTString() + ";path=/" }, get: function(a) { var e = document.cookie.split(";"); var c = ""; var f = ""; var d = ""; for (var b = 0; b < e.length; b++) { c = e[b].split("="); f = c[0].replace(/^\s+|\s+$/g, ""); if (f == a) { if (c.length > 1) { d = unescape(c[1].replace(/^\s+|\s+$/g, "")) } return d } c = null; f = "" } return null }, has: function(a) { return Crowdin.cookies.get(a) }, pattern_has: function(a) { var c = document.cookie.split(";"); var d = ""; for (var b = 0; b < c.length; b++) { d = c[b].split("=")[0].replace(/^\s+|\s+$/g, ""); if (d.indexOf(a)) { return true } } return false } }, dialog_ui_help: function(e, b) { var a = e.parents(".cjipt"); var d = a.find(".ui-dialog-titlebar:first"); var c = $JIPT("").addClass("ui-icon").addClass("ui-icon-help"); var f = $JIPT('').append(c); f.click(function(g) { $JIPT("#crowdin-help-container").attr("src", b); $JIPT("#crowdin-help").dialog("open"); g.stopPropagation(); return false }); d.append(f) }, dialog_ui_minimization: function(e) { var a = e.parents(".cjipt"); var d = a.find(".ui-dialog-titlebar"); var c = $JIPT("").addClass("ui-icon").addClass("ui-icon-minusthick").data("state", true); var b = $JIPT('').append(c); a.get(0).jipt_minimize = function() { c.removeClass("ui-icon-minusthick").addClass("ui-icon-newwin").data("height", a.height()).data("width", a.width()).data("position", a.position()).data("state", false); e.hide(); $JIPT(e).dialog("option", "resizable", false); $JIPT(e).dialog("option", "draggable", false); a.height("auto").width(250); a.css({ position: "fixed", top: "auto", left: "auto", bottom: 0, right: 0 }) }; var f = function(g) { if (c.data("state")) { a.get(0).jipt_minimize(); Crowdin.self.set_translations_panel_state(true) } else { c.removeClass("ui-icon-minusthick").addClass("ui-icon-minusthick").data("state", true); $JIPT(e).dialog("option", "resizable", true); $JIPT(e).dialog("option", "draggable", true); a.height(c.data("height")).width(c.data("width")).position(c.data("position")); e.show(); Crowdin.self.set_translations_panel_state(false) } g.stopPropagation(); return false }; b.click(f); d.dblclick(f); d.append(b) } }; if (!("$JIPT" in window)) { Crowdin.load_external_resource(Crowdin.jiptCDN + "jipt.css", "css"); Crowdin.load_external_resource(Crowdin.jiptCDN + "lib/jquery-ui/jquery-ui.css", "css"); Crowdin.load_external_resource("http://www.google.com/jsapi", "js"); Crowdin.load_external_resource("http://api.microsofttranslator.com/v1/Ajax.svc/Embed?appId=5jsjk2lJyATpvoTvhmrzFt2WCkcFHsWH", "js"); Crowdin.load_external_resource(Crowdin.jiptCDN + "lib/jquery.js", "js").onload = function() { Crowdin.load_external_resource(Crowdin.jiptCDN + "lib/jquery-ui/jquery-ui.js", "js").onload = function() { window.$JIPT = $.noConflict(true); var a = Crowdin.init(); if ($JIPT("script[jipt=api]").length) { $JIPT(document).ready(function() { for (var b = 0; b < Crowdin._preloadCallbacks.length; b++) { Crowdin._preloadCallbacks[b](a) } }) } else { if ($JIPT("script[jipt=bml]").length) { a.start_translation() } else { if ($JIPT.isReady) { a.start_translation() } else { $JIPT(document).ready(function() { a.start_translation() }) } } } } } }; \ No newline at end of file