Exemplo n.º 1
0
        // ReSharper disable MemberCanBePrivate.Global
        // ReSharper disable MemberCanBeProtected.Global
        // ReSharper disable UnusedMember.Global
        // ReSharper disable UnusedMethodReturnValue.Global
        // ReSharper disable UnusedAutoPropertyAccessor.Global
        // ReSharper disable UnassignedField.Global

        #endregion ReSharper disable

        public static Control GetAnchors(PageCache cache, string politicianKey)
        {
            var politicianName = cache.Politicians.GetPoliticianName(politicianKey);

            var ul = new HtmlUl();

            ul.Attributes.Add("class", "social-media-anchors");

            foreach (var medium in SocialMediaList)
            {
                var webAddress = medium.GetLink(cache, politicianKey);
                if (string.IsNullOrWhiteSpace(webAddress))
                {
                    continue;
                }
                CreateOneMediumAnchor(ul, webAddress, medium, politicianName);
            }

            // tack on email as a special case
            var email = cache.Politicians.GetPublicEmail(politicianKey);

            if (!string.IsNullOrWhiteSpace(email))
            {
                CreateEmailAnchor(ul, email, politicianName);
            }

            // enclose the <ul> in a div and add a <div style="clear:both">
            // for safety sake

            return(FinishAnchors(ul));
        }
Exemplo n.º 2
0
        public static HtmlContainerControl CreateTabContainer(
            string id, string className)
        {
            var tabs = new HtmlUl {
                EnableViewState = false
            };

            if (id != null)
            {
                tabs.ID = id;
            }
            tabs.AddCssClasses(className);
            return(tabs);
        }
Exemplo n.º 3
0
        public static Control GetAnchors(DataRow row, out int count, bool addClearBoth = true,
                                         bool useLargeIcons = false)
        {
            var politicianName = Politicians.FormatName(row);

            count = 0;

            var ul = new HtmlUl();

            ul.Attributes.Add("class", "social-media-anchors");

            foreach (var medium in SocialMediaList)
            {
                var webAddress = medium.GetLink(row);
                if (IsNullOrWhiteSpace(webAddress))
                {
                    continue;
                }
                count++;
                CreateOneMediumAnchor(ul, webAddress, medium, politicianName, useLargeIcons);
            }

            // tack on email as a special case
            var email = row.PublicEmail();

            if (!IsNullOrWhiteSpace(email))
            {
                count++;
                CreateEmailAnchor(ul, email, politicianName, useLargeIcons);
            }

            // enclose the <ul> in a div and add a <div style="clear:both">
            // for safety sake

            return(FinishAnchors(ul, addClearBoth));
        }
Exemplo n.º 4
0
        public void CreateControls(HtmlContainerControl parent, IList <AnswersViewRow> responses,
                                   MonitorInstance monitor, Dictionary <string, string> alternateHeadings = null)
        {
            var row = responses.First();
            var responsesAsDataRow = responses.Where(r => r.Sequence != null).Cast <DataRow>().ToList();

            parent.AddCssClasses("answer-panel " +
                                 (_Usage == Usage.ForIssues ? "issues-answer-panel " : "intro-answer-panel ") +
                                 (SecurePage.IsPoliticianUser ? "politician-answer-panel" : "master-answer-panel"));

            // The panel title
            var heading     = SecurePage.AddContainer(parent, null, null);
            var headingText = alternateHeadings != null && alternateHeadings.ContainsKey(row.QuestionKey)
        ? alternateHeadings[row.QuestionKey]
        : row.Question;

            SecurePage.AddHeading(heading, 4, null, null, headingText);
            SecurePage.Center(heading, true, true, "heading");
            if (_Usage == Usage.ForIssues)
            {
                heading.Visible = false;
            }

            // Add undo button as next sibling to heading
            var undo = SecurePage.CreateUndoButton("Undo" + row.QuestionKey,
                                                   monitor.GetUndoClass(null),
                                                   $"Revert \"{row.Question}\" to the latest saved version");

            heading.AddAfter(undo);

            // Same for clear button
            var clear = SecurePage.CreateClearButton("Clear" + row.QuestionKey,
                                                     monitor.GetClearClass(null),
                                                     $"Clear \"{row.Question}\"");

            heading.AddAfter(clear);

            var updatePanel = SecurePage.AddAjaxUpdatePanel(parent, "UpdatePanel" + row.QuestionKey);

            var container = SecurePage.AddContainer(updatePanel.ContentTemplateContainer,
                                                    "Container" + row.QuestionKey, monitor.GetContainerClass("update-all updated answer-container"));

            SecurePage.AddHiddenField(container, "Description" + row.QuestionKey,
                                      monitor.GetDescriptionClass(null, "answer"), row.Question);

            SecurePage.AddHiddenField(container, "SubTab" + row.QuestionKey,
                                      "subtab subtab-" + row.QuestionKey);

            var hasNoResponses = row.Sequence == null;

            var sequenceItem = SecurePage.AddHiddenField(container, "Sequence" + row.QuestionKey, "answer-sequence",
                                                         hasNoResponses ? "?" : row.Sequence.Value.ToString(CultureInfo.InvariantCulture));

            SetResponseData(responsesAsDataRow, row, sequenceItem);

            // the action menu
            var menuContainer = SecurePage.AddContainer(container, "Action" + row.QuestionKey,
                                                        "action-menu");

            CreateActionMenu(menuContainer, responsesAsDataRow, row.Sequence == null);

            new HtmlP
            {
                InnerHtml = "To completely delete a response (Text and YouTube), use the Clear button (red <span>X</span> upper right) then Update."
            }.AddTo(container, "delete-message");

            var subTabs = new HtmlDiv
            {
                ID           = "answer-subtabs-" + row.QuestionKey,
                ClientIDMode = ClientIDMode.Static
            }.AddTo(container, "answer-sub-tabs shadow");
            var subTabsTabs = new HtmlUl().AddTo(subTabs, "htabs unselectable");

            var textSubTab = new HtmlLi {
                EnableViewState = false
            }.AddTo(subTabsTabs, "tab htab");

            new HtmlAnchor
            {
                HRef            = "#tab-textanswer-" + row.QuestionKey,
                InnerHtml       = "Text<br />Response",
                EnableViewState = false
            }.AddTo(textSubTab);

            var youTubeSubTab = new HtmlLi {
                EnableViewState = false
            }.AddTo(subTabsTabs, "tab htab");

            new HtmlAnchor
            {
                HRef            = "#tab-youtubeanswer-" + row.QuestionKey,
                InnerHtml       = "YouTube<br />Response",
                EnableViewState = false
            }.AddTo(youTubeSubTab);

            var textSubTabContent = new HtmlDiv
            {
                ID           = "tab-textanswer-" + row.QuestionKey,
                ClientIDMode = ClientIDMode.Static
            }.AddTo(subTabs);
            var youTubeSubTabContent = new HtmlDiv
            {
                ID           = "tab-youtubeanswer-" + row.QuestionKey,
                ClientIDMode = ClientIDMode.Static
            }.AddTo(subTabs);

            string moreClasses;

            switch (_Usage)
            {
            case Usage.ForIntroReasons:
                moreClasses = "mc-mt-reasons";
                break;

            case Usage.ForIntroBio:
                moreClasses = "mc-mt-bio2";
                break;

            default:
                var tabPrefix = MonitorPrefix + "-" + MonitorTabPrefix + "-issue" +
                                row.IssueKey;
                var superTabPrefix = MonitorPrefix + "-" + MonitorSuperTabPrefix + "-igroup" +
                                     row.IssueGroupKey;
                moreClasses = tabPrefix + " " + superTabPrefix;
                break;
            }

            SecurePage.AddHiddenField(container, "HasValue" + row.QuestionKey,
                                      monitor.GetDataClass(moreClasses, "hasvalue"),
                                      string.IsNullOrWhiteSpace(row.Answer) && string.IsNullOrWhiteSpace(row.YouTubeUrl)
          ? string.Empty
          : "Y");

            CreateTextSubTabContent(textSubTabContent, row, moreClasses, monitor);
            CreateYouTubeSubTabContent(youTubeSubTabContent, row, moreClasses, monitor);

            new HtmlHr().AddTo(container);

            // feedback
            AddFeedbackWithIe7Floater(container, "Feedback" + row.QuestionKey,
                                      monitor.GetFeedbackClass(null));

            // update button
            SecurePage.AddUpdateButtonInContainer(container, "Button" + row.QuestionKey,
                                                  "update-button", monitor.GetButtonClass("update-button button-1"),
                                                  $"Update \"{row.Question}\"", ButtonUpdate_OnClick);

            SecurePage.AddClearBoth(container);
        }