/// <summary> /// Creates the control(s) necessary for prompting user for a new value /// </summary> /// <param name="configurationValues">The configuration values.</param> /// <param name="id">The id.</param> /// <returns> /// The control /// </returns> public override System.Web.UI.Control EditControl(Dictionary <string, ConfigurationValue> configurationValues, string id) { var editControl = new MediaElementPicker { ID = id, Label = "Media" }; if (configurationValues?.ContainsKey(CONFIG_MEDIA_PICKER_LABEL) == true) { editControl.MediaElementLabel = configurationValues[CONFIG_MEDIA_PICKER_LABEL].Value; } if (configurationValues?.ContainsKey(CONFIG_ALLOW_REFRESH) == true) { editControl.IsRefreshAllowed = configurationValues[CONFIG_ALLOW_REFRESH].Value.AsBoolean(true); } if (configurationValues?.ContainsKey(CONFIG_ALLOW_REFRESH) == true) { editControl.EnhanceForLongListsThreshold = configurationValues[CONFIG_ENHANCE_FOR_LONG_LISTS_THRESHOLD].Value.AsIntegerOrNull() ?? 20; } SetAccountAndFolderValues(editControl, configurationValues); return(editControl); }
/// <summary> /// Creates the HTML controls required to configure this type of field /// </summary> /// <returns></returns> public override List <Control> ConfigurationControls() { List <Control> controls = new List <Control>(); var mpMedia = new MediaElementPicker(); mpMedia.Label = "Media"; mpMedia.Help = "The media file that will be watched by the individual."; mpMedia.Required = true; controls.Add(mpMedia); var nbCompletionPercentage = new NumberBox(); nbCompletionPercentage.NumberType = System.Web.UI.WebControls.ValidationDataType.Double; nbCompletionPercentage.Label = "Completion Percentage"; nbCompletionPercentage.Help = "The percentage of the video that the individual must view in order for the video to be considered watched. Instead of setting this to 100% you probably want a few points below that."; nbCompletionPercentage.AppendText = "%"; nbCompletionPercentage.MaximumValue = 100.ToString(); nbCompletionPercentage.MinimumValue = 0.ToString(); nbCompletionPercentage.CssClass = "input-width-sm"; controls.Add(nbCompletionPercentage); var nbAutoResume = new NumberBox(); nbAutoResume.NumberType = System.Web.UI.WebControls.ValidationDataType.Integer; nbAutoResume.Label = "Auto Resume In Days"; nbAutoResume.Help = "The video player will look back this many days for a previous watch session and attempt to auto-resume from that point."; nbAutoResume.MaximumValue = 3650.ToString(); nbAutoResume.MinimumValue = (-1).ToString(); nbAutoResume.CssClass = "input-width-sm"; controls.Add(nbAutoResume); var tbMaxWidth = new RockTextBox(); tbMaxWidth.Label = "Maximum Video Width"; tbMaxWidth.Help = "The maximum width of the video. This unit can be expressed in pixels (e.g. 250px) or percent (e.g. 75%). If no unit is provided pixels is assumed."; tbMaxWidth.CssClass = "input-width-sm"; controls.Add(tbMaxWidth); var tbValidationMessage = new RockTextBox(); tbValidationMessage.Label = "Validation Message"; tbValidationMessage.Help = "The message that should be show when the individual does not watch the required amount of the video."; tbValidationMessage.TextMode = System.Web.UI.WebControls.TextBoxMode.MultiLine; tbValidationMessage.Rows = 3; controls.Add(tbValidationMessage); return(controls); }
/// <summary> /// Creates the HTML controls required to configure this type of field /// </summary> /// <returns></returns> public override List <Control> ConfigurationControls() { List <Control> controls = new List <Control>(); var tbMediaElementPickerLabel = new RockTextBox(); tbMediaElementPickerLabel.Label = "Media Element Picker Label"; tbMediaElementPickerLabel.Help = "The label for the media element picker"; tbMediaElementPickerLabel.Text = "Media"; tbMediaElementPickerLabel.AutoPostBack = true; tbMediaElementPickerLabel.TextChanged += OnQualifierUpdated; controls.Add(tbMediaElementPickerLabel); var nbEnhanceForLongListsThreshold = new NumberBox(); nbEnhanceForLongListsThreshold.Label = "Enhance For Long Lists Threshold"; nbEnhanceForLongListsThreshold.Help = "When the number of items exceed this value then the picker will turn on enhanced for long lists."; nbEnhanceForLongListsThreshold.Text = "20"; nbEnhanceForLongListsThreshold.MinimumValue = "0"; nbEnhanceForLongListsThreshold.AutoPostBack = true; nbEnhanceForLongListsThreshold.NumberType = System.Web.UI.WebControls.ValidationDataType.Integer; nbEnhanceForLongListsThreshold.TextChanged += OnQualifierUpdated; controls.Add(nbEnhanceForLongListsThreshold); var mpLimits = new MediaElementPicker(); mpLimits.Label = "Limit To"; mpLimits.Help = "Enforces the account or folder selections and hides them from the user."; mpLimits.ShowMediaPicker = false; controls.Add(mpLimits); var cbAllowRefresh = new RockCheckBox(); cbAllowRefresh.Label = "Allow Refresh"; cbAllowRefresh.Help = "If enabled the user will be allowed to request a refresh of the folders and media items."; cbAllowRefresh.Checked = true; cbAllowRefresh.AutoPostBack = true; cbAllowRefresh.CheckedChanged += OnQualifierUpdated; controls.Add(cbAllowRefresh); return(controls); }
/// <summary> /// Sets the account and folder values if they were provided in the /// configuration. /// </summary> /// <param name="mediaElementPicker">The media element picker.</param> /// <param name="configurationValues">The configuration values.</param> private void SetAccountAndFolderValues(MediaElementPicker mediaElementPicker, Dictionary <string, ConfigurationValue> configurationValues) { // Determine if we have limit values for either account or folder. var accountId = GetLimitToAccountId(configurationValues); var folderId = GetLimitToFolderId(configurationValues); // Set defaults for picker visibility. mediaElementPicker.ShowAccountPicker = true; mediaElementPicker.ShowFolderPicker = true; // Set default values and hide the controls we don't need. if (folderId.IsNotNullOrZero()) { mediaElementPicker.MediaFolderId = folderId; mediaElementPicker.ShowFolderPicker = false; mediaElementPicker.ShowAccountPicker = false; } else if (accountId.IsNotNullOrZero()) { mediaElementPicker.MediaAccountId = accountId; mediaElementPicker.ShowAccountPicker = false; } }