/// <summary> /// Renders appropriate view depending on the <see cref="TemplateName" /> /// </summary> /// <returns> /// The <see cref="ActionResult" />. /// </returns> public ActionResult Index() { var viewModel = this.Model.GetViewModel(); var page = this.GetHttpContext().CurrentHandler.GetPageHandler(); if (page != null && !this.IsEdit) { if (this.Model.Position == Models.EmbedPosition.Head) { page.Header.Controls.Add(new LiteralControl(viewModel.JavaScriptCode)); } if (this.Model.Position == Models.EmbedPosition.BeforeBodyEndTag) { page.PreRenderComplete += PagePreRenderCompleteHandler; } } if (this.IsEdit) { string result = null; if (!string.IsNullOrEmpty(this.Model.Description)) { result = this.Model.Description; } else if (Model.Mode == ResourceMode.Inline && !string.IsNullOrEmpty(viewModel.JavaScriptCode)) { result = EmbedCodeHelper.GetShortEmbededCode(viewModel.JavaScriptCode); } else { result = viewModel.JavaScriptCode; } if (!this.IsEmpty) { viewModel.DesignModeContent = result; } if (!string.IsNullOrEmpty(result) && string.IsNullOrEmpty(this.Model.Description)) { var includedIn = this.GetIncludeInResource(viewModel.Position); viewModel.DesignModeContent = viewModel.DesignModeContent + Environment.NewLine + includedIn; } } return(this.View("Index", viewModel)); }
private void SetDesignModeContent(EmbedCodeViewModel viewModel) { if (!string.IsNullOrWhiteSpace(viewModel.Description)) { this.ViewBag.DesignModeContent = viewModel.Description; } else { var result = EmbedCodeHelper.GetShortEmbededCode(viewModel.EmbedCode); if (!string.IsNullOrWhiteSpace(result)) { this.ViewBag.DesignModeContent = result + Environment.NewLine + this.GetResource <EmbedCodeResources>("IncludedWhereDropped"); } } }
/// <summary> /// Handles CSS referencing on the page. /// </summary> /// <returns></returns> public ActionResult Index() { var cssMarkup = this.Model.GetMarkup(); if (!cssMarkup.IsNullOrEmpty()) { this.AddCssInHead(cssMarkup); } if (this.ShouldDisplayContent()) { string markup = null; var hasDescription = !string.IsNullOrEmpty(this.Model.Description); this.ViewBag.HasDescription = hasDescription; if (hasDescription) { markup = this.Model.Description; } else if (this.Model.Mode == Models.ResourceMode.Inline) { markup = EmbedCodeHelper.GetShortEmbededCode(this.Model.InlineStyles); } else if (this.Model.Mode == Models.ResourceMode.Reference) { markup = cssMarkup; } if (!string.IsNullOrEmpty(markup)) { this.ViewBag.DesignModeContent = markup; return(this.View()); } } return(new EmptyResult()); }