private static void CreateYouTubeSubTabContent(HtmlControl parent, AnswersViewRow row, string moreClasses, MonitorInstance monitor) { var wasUploadedByCandidate = !string.IsNullOrWhiteSpace(row.YouTubeUrl) && row.YouTubeSource == YouTubeInfo.VideoUploadedByCandidateMessage; var wasUploadedByVoteUsa = !string.IsNullOrWhiteSpace(row.YouTubeUrl) && row.YouTubeSource != YouTubeInfo.VideoUploadedByCandidateMessage; // the Source heading and Uploaded by candidate checkbox (only for master users) if (!SecurePage.IsPoliticianUser) { var heading = new HtmlDiv().AddTo(parent, "category-heading"); new HtmlSpan { InnerText = "Select Type of Video to be Shown" }.AddTo(heading); SecurePage.AddCheckboxInputElement(parent, "YouTubeFromCandidate" + row.QuestionKey, monitor.GetDataClass("youtubefrom-checkbox youtubefromcandidate-checkbox " + moreClasses, "youtubefromcandidate"), null, wasUploadedByCandidate, "Complete Video on YouTube (not created by Vote USA)", "fromcandidate clearfix", null, null, null, string.Empty); SecurePage.AddCheckboxInputElement(parent, "YouTubeFromVoteUSA" + row.QuestionKey, monitor.GetDataClass("youtubefrom-checkbox youtubefromvoteusa-checkbox " + moreClasses, "youtubefromvoteusa"), null, wasUploadedByVoteUsa, "Shortened Video Extracted from an Existing Video (on Vote USA or other Private Channel)", "fromvoteusa clearfix", null, null, null, string.Empty); } // the Vote-USA heading (only for master users) //if (!SecurePage.IsPoliticianUser) //{ // var heading = new HtmlDiv().AddTo(parent, "category-heading"); // new HtmlSpan {InnerText = "Uploaded Vote USA YouTube Video"}.AddTo(heading); //} var youTubeSourceFields = new HtmlDiv().AddTo(parent, "youtube-source-fields"); if (!SecurePage.IsPoliticianUser) { SecurePage.AddTextInputElement(youTubeSourceFields, "YouTubeSourceUrl" + row.QuestionKey, monitor.GetDataClass("shadow-2 youtubesourceurl-textbox " + moreClasses, "youtubesourceurl"), row.YouTubeSourceUrl, "Enter the url (with or without http://) of the source video.", false, "Url of Longer Video Used to Extract Shortened Video (on Vote USA or Private Channel)", "youtubeurl wide", null, null, null); } var youTubeSourceAndDateDiv = new HtmlDiv().AddTo(youTubeSourceFields, "youtube-source-and-date-container source-and-date-container"); if (wasUploadedByCandidate) { youTubeSourceFields.AddCssClasses("hidden"); } else { youTubeSourceFields.RemoveCssClass("hidden"); } if (!SecurePage.IsPoliticianUser) { var youTubeSourceDiv = new HtmlDiv().AddTo(youTubeSourceAndDateDiv, "youtube-source-container source-container"); SecurePage.AddTextAreaInputElement(youTubeSourceDiv, "YouTubeSource" + row.QuestionKey, monitor.GetDataClass("shadow youtubesource-textbox " + moreClasses, "youtube-source source"), row.YouTubeSource, "Enter a description of the source video into this box.", false, "Enter a description of the source video into this box.", true, "Source Description of Longer Video", "source", null, null, null); var youTubeDateDiv = new HtmlDiv().AddTo(youTubeSourceAndDateDiv, "youtube-date-container date-container"); SecurePage.AddTextInputElement(youTubeDateDiv, "YouTubeDate" + row.QuestionKey, monitor.GetDataClass("shadow-2 youtubedate-textbox date-picker " + moreClasses, "youtubedate sourcedate"), row.YouTubeDate.DbDateToShortDate(), "Enter the date of the video if today is not an appropriate date.", false, "Source Date", "youtubedate", null, null, null); SecurePage.AddButtonInputElement(youTubeDateDiv, null, "today-button for-youtubedate button-1 button-smallest", "Today", "today for-youtubedate"); } SecurePage.AddTextInputElement(parent, "YouTubeUrl" + row.QuestionKey, monitor.GetDataClass("shadow-2 youtubeurl-textbox for-star " + moreClasses, "youtubeurl"), row.YouTubeUrl, SecurePage.IsPoliticianUser ? "Enter a YouTube url that addresses the question." : "Enter the YouTube url of the Vote-USA video.", false, //SecurePage.IsPoliticianUser // ? "YouTube Url" // : "Url Provided by YouTube", "YouTube Url to be Shown", "youtubeurl wide", null, null, null); new HtmlP { InnerText = "When you Update, the Video Description and Running Time will be automatically retrieved from YouTube." }.AddTo(parent, "url-message"); var displayYouTubeDescription = row.YouTubeDescription.SafeString(); var displayYouTubeRunningTime = row.YouTubeRunningTime.FormatRunningTime(); if (!string.IsNullOrWhiteSpace(row.YouTubeAutoDisable)) { displayYouTubeDescription = ">>> This video has been temporarily disabled on Vote-USA: " + row.YouTubeAutoDisable; displayYouTubeRunningTime = string.Empty; } var youTubeDescriptionAndTimeDiv = new HtmlDiv().AddTo(parent, "youtube-description-and-time-container"); var youTubeDescriptionDiv = new HtmlDiv().AddTo(youTubeDescriptionAndTimeDiv, "youtube-description-container"); SecurePage.AddTextAreaInputElement(youTubeDescriptionDiv, "YouTubeDescription" + row.QuestionKey, monitor.GetDataClass("shadow youtubedescription-textbox " + moreClasses, "youtubedescription"), displayYouTubeDescription, null, false, null, false, "Video Description", "youtubedescription wide", null, null, null, true); var youTubeTimeDiv = new HtmlDiv().AddTo(youTubeDescriptionAndTimeDiv, "youtube-time-container"); SecurePage.AddTextInputElement(youTubeTimeDiv, "YouTubeRunningTime" + row.QuestionKey, monitor.GetDataClass("shadow-2 youtuberunningtime-textbox " + moreClasses, "youtuberunningtime"), displayYouTubeRunningTime, null, false, "Running Time", "youtuberunningtime", null, null, null, true); }
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); }