public IHttpHandler GetHttpHandler(RequestContext requestContext) { CssManager handler = new CssManager(); HttpContext.Current.Items["s"] = requestContext.RouteData.Values["s"]; return(handler); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); CssManager.AddStyleSheet(this, GetStylesheetUrl(), string.Empty); JSManager.AddExternalScript(this, "/JS/imgEvents.js"); JSManager.AddExternalScript(this, "/JS/popEvents.js"); }
private void PreviewButtonOnClick(object sender, RoutedEventArgs e) { try { PreviewWebView.NavigateToString(CssManager.WrapWithCss(BBCode.BBCode.ToHtml(ContentBox.Text))); } catch (Exception) { //bbcode parsing } }
public MobileBridge(Control bridgeTo) { _bridgeTo = bridgeTo; _cssManager = new CssManager(bridgeTo); _bridgeTo.PreRender += delegate(object sender, EventArgs e) { this.PreRender(); }; _bridgeTo.Load += delegate(object sender, EventArgs e) { _bridgeTo.Page.Unload += delegate(object s, EventArgs ea) { this.RenderMeta(); }; }; this.SetDefaults(); }
private void SetupStyle() { if (MenuStyle != ContextMenuStyle.None) { this.CssClass = "ctxMenu" + " ctxMenu-" + MenuStyle.ToString(); //Load stylesheets into the head block CssManager.AddResource(Page, typeof(ContextMenu), "NCI.Web.UI.WebControls.Menus.Resources.ContextMenu.CTXMenuBase.css"); CssManager.AddResource(Page, typeof(ContextMenu), string.Format("NCI.Web.UI.WebControls.Menus.Resources.ContextMenu.{0}.css", MenuStyle.ToString())); } }
/// <summary> /// The method gets notified from the server control and performs any necessary /// pre-rendering steps prior to saving view state and rendering content /// </summary> /// <param name="e">Contains the event data</param> protected override void OnPreRender(EventArgs e) { // Order is important. // The control's JavaScript component relies on Prototype being present first. PrototypeManager.Load(this.Page); JSManager.AddResource(this.Page, typeof(AutoComplete), "NCI.Web.UI.WebControls.FormControls.Resources.AutoComplete.js"); CssManager.AddResource(this.Page, typeof(AutoComplete), "NCI.Web.UI.WebControls.FormControls.Resources.AutoComplete.css"); // Register this control to require postback handling when the page // is posted back to the server Page.RegisterRequiresPostBack(this); }
private static void PropertyChangedCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs) { var view = dependencyObject as WebView; if (GetResizeToFit(view)) { if (view.Tag == null) { view.ScriptNotify += ViewOnScriptNotify; view.Tag = true; } } SetComputedHeight(view, 0); view.NavigateToString(CssManager.WrapWithCss(dependencyPropertyChangedEventArgs.NewValue as string, GetDisableScroll(dependencyObject))); }
public void AddDownload(DownloadContent down) { var sitedb = this.Manager.SiteDb; string csstext = down.GetString(); if (!String.IsNullOrEmpty(csstext)) { Style style = new Style(); style.Name = UrlHelper.FileName(this.DownloadTask.RelativeUrl); CssManager.ProcessResource(ref csstext, this.DownloadTask.AbsoluteUrl, this.Manager, this.DownloadTask.OwnerObjectId); style.Body = csstext; sitedb.Routes.AddOrUpdate(this.DownloadTask.RelativeUrl, style, this.Manager.UserId); sitedb.Styles.AddOrUpdate(style, this.Manager.UserId); } }
private void ViewModelOnOpenWebView(string html, int id) { //back nav ViewModelLocator.NavMgr.RegisterOneTimeMainOverride(new RelayCommand(() => { ViewModel.WebViewVisibility = false; ViewModel.ArticleIndexVisibility = true; ViewModelLocator.GeneralMain.CurrentStatus = ViewModel.PrevWorkMode != null && ViewModel.PrevWorkMode.Value == ArticlePageWorkMode.Articles ? "Articles" : "News"; ViewModel.CurrentNews = -1; })); // ArticleWebView.NavigateToString(CssManager.WrapWithCss(html)); }
public async Task <ActionResult> MainMenu() { // add some bootstrap specific classes if (Manager.SkinInfo.UsingBootstrap) { Module.CssClass = CssManager.CombineCss(Module.CssClass, "navbar-collapse collapse"); } MenuModel model = new MenuModel { Menu = new MenuComponentBase.MenuData { MenuList = await GetMenu(Module, External : true), Direction = Module.Direction, Orientation = Module.Orientation, HoverDelay = Module.HoverDelay, CssClass = Module.CssClass, ShowPath = Module.ShowPath, }, }; model.Menu.MenuList.LICssClass = Module.LICssClass; return(View(model)); }
public async Task <string> RenderViewAsync(EditModeModule module, EditModeModuleController.Model model) { // <div id='yEditControlDiv'> // action button (with id yEditControlButton) // </div> ModuleAction action = Manager.EditMode ? module.GetAction_SwitchToView() : module.GetAction_SwitchToEdit(); if (action != null) { YTagBuilder tag = new YTagBuilder("div"); tag.Attributes.Add("id", "yEditControlDiv"); if (Manager.SkinInfo.UsingBootstrap && Manager.SkinInfo.UsingBootstrapButtons) { action.CssClass = CssManager.CombineCss(action.CssClass, "btn btn-outline-primary"); } tag.InnerHtml = await action.RenderAsButtonIconAsync("yEditControlButton"); return(tag.ToString(YTagRenderMode.Normal)); } return(null); }
public List<String> Import(ImportSiteMessage message) { Data.Hash importHash = Data.Hash.New(message.ImportHash); Data.Guid subscriptionId = Data.Guid.New(message.SubscriptionId); Boolean deleteExisting = message.DeleteExisting; List<String> status = new List<String>(); byte[] data; AddStatus(importHash, status, "Site import started at " + UtcDateTime.Now.ToString()); CmsSubscription subscription = SubscriptionManager.GetSubscription(subscriptionId); CmsTheme defaultTheme = ThemeManager.Instance.GetDefaultBySite(subscriptionId); //Check if the import-template already exists CmsTemplate template = TemplateManager.Instance.GetTemplate(subscriptionId, "import-template"); if (template == null) { template = new CmsTemplate(); template.Content = "{content}"; template.Name = "import-template"; template.IsGlobalTemplateType = false; template.LastSaved = UtcDateTime.Now; template.SubscriptionGuid = subscriptionId.Value; template.Theme = defaultTheme; TemplateManager.Instance.Save(template); AddStatus(importHash, status, "Successfully created and associated import template to deafult theme"); } IDictionary<ImportType, IList<ImportedItem>> items = this.GetImportedItems(importHash); //Check if we need to delete the existing site if (deleteExisting) { //Erase all of the existing data SubscriptionManager.Erase(subscription.Guid, false, false); SessionProvider.Instance.Close(); SessionProvider.Instance.GetOpenSession(); //Setup the default SiteHelper.Configure(subscription.Guid); } //First, import all of the images IList<ImportedItem> images = items[ImportType.Image]; foreach (ImportedItem image in images) { CmsUrl uri = new CmsUrl(image.Uri); data = SimpleWebClient.GetResponse(uri.ToUri()); ImageManager.Instance.AddImage(subscriptionId, StorageClientConst.RootFolder, uri.Path, image.ContentType, data); AddStatus(importHash, status, "Successfully imported image: " + uri.ToString() + " (" + image.ContentType + ")"); } //Create the sitemap and then add the page itself CmsSitePath root = CmsSiteMap.Instance.GetPath(subscriptionId, CmsSiteMap.RootPath); Dictionary<CmsUrl, int> cssUses = new Dictionary<CmsUrl, int>(); Dictionary<CmsUrl, int> jsUses = new Dictionary<CmsUrl, int>(); IList<ImportedItem> pages = NormalizeImport(items[ImportType.Page]); foreach (ImportedItem page in pages) { try { CmsUrl uri = new CmsUrl(page.Uri); CmsUrlWalker walker = new CmsUrlWalker(uri); while (walker.Next()) { String parent = walker.GetParentPath(); String current = walker.GetIndividualPath(); String fullpath = CmsSiteMap.PathCombine(parent, current); int depth = walker.Depth; if (!walker.IsLast) { //Check if the current path exists, if not, create it if (!CmsSiteMap.Instance.Exists(subscriptionId, fullpath)) CmsSiteMap.Instance.AddChildDirectory(subscriptionId, parent, current); } } String pageName = walker.GetIndividualPath(); CmsPage newpage = GetPage(template.Name, subscription.Culture, pageName, message.ReplacePhoneNumbers, page, cssUses, jsUses); newpage.SubscriptionId = subscriptionId.Value; //Add the page to the cms system PageManager.Instance.AddNewPage(walker.GetParentPath(), pageName, newpage); AddStatus(importHash, status, "Successfully imported page " + page.Uri); } catch (Exception ex) { if (!ex.Message.Contains("404")) Logging.Database.Write("import-site-manager", "Failed to import page: " + page.Uri + ", cause:" + ex.Message + ", stack:" + ex.StackTrace); AddStatus(importHash, status, "Failed to import page " + page.Uri + ", Reason:" + ex.Message); } } //Import the css IList<ImportedItem> css = items[ImportType.Css]; int sortOrder = 0; CssManager cssManager = new CssManager(null); cssManager.SubscriptionId = subscriptionId; foreach (ImportedItem item in css) { CmsUrl uri = new CmsUrl(item.Uri); data = SimpleWebClient.GetResponse(uri.ToUri()); cssManager.Save(defaultTheme.ThemeGuid, uri.Path, data, true, 0); cssManager.UpdateSortInfo(defaultTheme, uri.Path, sortOrder++); AddStatus(importHash, status, "Successfully imported css file: " + uri.ToString()); } //Import the javascript IList<ImportedItem> js = items[ImportType.Javascript]; sortOrder = 0; JavascriptManager jsManager = new JavascriptManager(null); jsManager.SubscriptionId = subscriptionId; foreach (ImportedItem item in js) { CmsUrl uri = new CmsUrl(item.Uri); data = SimpleWebClient.GetResponse(uri.ToUri()); jsManager.Save(defaultTheme.ThemeGuid, uri.Path, data, true, 0); jsManager.UpdateSortInfo(defaultTheme, uri.Path, sortOrder++); AddStatus(importHash, status, "Successfully imported javascript file: " + uri.ToString()); } //Import any documents IList<ImportedItem> documents = items[ImportType.Document]; foreach (ImportedItem item in documents) { CmsUrl uri = new CmsUrl(item.Uri); ContentFileUploadImpl handler = new ContentFileUploadImpl(); String filename = uri.Path; if (ContentFileUploadImpl.IsValidFileType(filename)) { data = SimpleWebClient.GetResponse(uri.ToUri()); handler.Save(subscriptionId, data, uri.Path, true); } } AddStatus(importHash, status, "Site import completed successfully at " + UtcDateTime.Now.ToString()); ImportedItemDao dao = new ImportedItemDao(); dao.DeleteAllByImportHash(importHash); return status; }
private void ViewModelOnUpdatePreview(object sender, string s) { PreviewWebView.NavigateToString(CssManager.WrapWithCss(s)); }
/// <summary> /// Renders the beginning <form> tag with the specified attributes. /// </summary> /// <param name="HtmlAttributes">The HTML attributes to add to the <form> tag.</param> /// <param name="SaveReturnUrl">Defines whether the return URL is saved when the form is submitted.</param> /// <param name="ValidateImmediately">Defines whether client-side validation is immediate (true) or delayed until form submission (false).</param> /// <param name="ActionName">Overrides the default action name.</param> /// <param name="ControllerName">Overrides the default controller name.</param> /// <param name="Pure">TODO: Purpose unclear.</param> /// <param name="Method">The method used to submit the form (get/post)</param> /// <returns>Returns the HTML with the generated <form> tag.</returns> protected async Task <string> RenderBeginFormAsync(object HtmlAttributes = null, bool SaveReturnUrl = false, bool ValidateImmediately = false, string ActionName = null, string ControllerName = null, string Method = "post") { await YetaWFCoreRendering.Render.AddFormsAddOnsAsync(); await Manager.AddOnManager.AddAddOnNamedAsync("YetaWF_Core", "Forms");// standard css, validation strings await Manager.AddOnManager.AddAddOnNamedAsync("YetaWF_ComponentsHTML", "Forms"); Manager.ScriptManager.AddLast("$YetaWF.Forms", "$YetaWF.Forms;");// need to evaluate for side effect to initialize forms Manager.NextUniqueIdPrefix(); if (string.IsNullOrWhiteSpace(ActionName)) { ActionName = GetViewName(); } if (!ActionName.EndsWith(YetaWFViewExtender.PartialSuffix)) { ActionName += YetaWFViewExtender.PartialSuffix; } if (string.IsNullOrWhiteSpace(ControllerName)) { ControllerName = ModuleBase.Controller; } IDictionary <string, object> rvd = YHtmlHelper.AnonymousObjectToHtmlAttributes(HtmlAttributes); if (SaveReturnUrl) { rvd.Add(Basics.CssSaveReturnUrl, ""); } string css = null; if (Manager.CurrentSite.FormErrorsImmed) { css = CssManager.CombineCss(css, "yValidateImmediately"); } css = CssManager.CombineCss(css, Forms.CssFormAjax); rvd.Add("class", css); YTagBuilder tagBuilder = new YTagBuilder("form"); tagBuilder.MergeAttributes(rvd, true); if (ModuleBase.FormAutoComplete) { tagBuilder.Attributes.Add("autocomplete", "on"); } else { tagBuilder.Attributes.Add("autocomplete", "new-password"); } string id = null; if (tagBuilder.Attributes.ContainsKey("id")) { id = (string)tagBuilder.Attributes["id"]; } else { id = Manager.UniqueId(); tagBuilder.Attributes.Add("id", id); } string formAction; #if MVC6 System.IServiceProvider services = HtmlHelper.ActionContext.HttpContext.RequestServices; IUrlHelper urlHelper = services.GetRequiredService <IUrlHelperFactory>().GetUrlHelper(HtmlHelper.ActionContext); formAction = urlHelper.Action(action: ActionName, controller: ControllerName, new { area = HtmlHelper.RouteData.Values["area"] }); #else formAction = UrlHelper.GenerateUrl(null /* routeName */, ActionName, ControllerName, null, RouteTable.Routes, HtmlHelper.RequestContext, true /* includeImplicitMvcValues */); #endif tagBuilder.MergeAttribute("action", formAction, true); tagBuilder.MergeAttribute("method", Method, true); // show errors if already present if (!HtmlHelper.ModelState.IsValid) { Manager.ScriptManager.AddLast($@" var f = $YetaWF.getElementById('{id}'); if ($YetaWF.Forms.hasErrors(f)) $YetaWF.Forms.showErrors(f); "); } return(tagBuilder.ToString(YTagRenderMode.StartTag)); }