Bloom.Book.HtmlDom.RemoveModeStyleSheets C# (CSharp) Method

RemoveModeStyleSheets() public method

public RemoveModeStyleSheets ( ) : void
return void
        public void RemoveModeStyleSheets()
        {
            foreach(XmlElement linkNode in RawDom.SafeSelectNodes("/html/head/link"))
            {
                var href = linkNode.GetAttribute("href");
                if(string.IsNullOrEmpty(href))
                {
                    continue;
                }

                var fileName = Path.GetFileName(href);
                if(fileName.Contains("edit") || fileName.Contains("preview"))
                {
                    linkNode.ParentNode.RemoveChild(linkNode);
                }
            }
            // If present, remove the editMode attribute that tells use which mode we're editing in (original or translation)
            var body = RawDom.SafeSelectNodes("/html/body")[0] as XmlElement;
            if(body.HasAttribute("editMode"))
                body.RemoveAttribute("editMode");
        }

Usage Example

Example #1
0
 //while in Bloom, we could have and edit style sheet or (someday) other modes. But when stored,
 //we want to make sure it's ready to be opened in a browser.
 private void MakeCssLinksAppropriateForStoredFile(HtmlDom dom)
 {
     dom.RemoveModeStyleSheets();
     dom.AddStyleSheet("previewMode.css");
     dom.AddStyleSheet("basePage.css");
     EnsureHasLinksToStylesheets(dom);
     dom.SortStyleSheetLinks();
     dom.RemoveFileProtocolFromStyleSheetLinks();
 }
All Usage Examples Of Bloom.Book.HtmlDom::RemoveModeStyleSheets