Example #1
0
        public InlineStyleViewModel GetInline(ApiCall call)
        {
            var item = call.WebSite.SiteDb().CssRules.Get(call.ObjectId);

            if (item == null)
            {
                return(null);
            }
            InlineStyleViewModel model = new InlineStyleViewModel();

            model.Id = call.ObjectId;

            model.Declarations = CssService.ParseDeclarationBlock(item.CssText, call.ObjectId);

            return(model);
        }
Example #2
0
        private static CmsCssRuleChanges GetMediaRuleAdded(CssRuleViewModel rule)
        {
            CmsCssRuleChanges change = new CmsCssRuleChanges();

            if (rule.Selector.IndexOf("@media", StringComparison.OrdinalIgnoreCase) == -1)
            {
                change.selectorText = "@media " + rule.Selector;
            }
            else
            {
                change.selectorText = rule.Selector;
            }

            string ruletext = string.Empty;

            foreach (var item in rule.Rules)
            {
                ruletext += "\r\n" + item.Selector + "\r\n{\r\n";
                List <CmsCssDeclaration> declarations = new List <CmsCssDeclaration>();
                if (item.Declarations != null)
                {
                    foreach (var decl in item.Declarations)
                    {
                        declarations.Add(new CmsCssDeclaration()
                        {
                            PropertyName = decl.Name, Value = decl.Value, Important = decl.Important
                        });
                    }
                    ruletext += CssService.SerializeCmsCssDeclaration(declarations);
                }
                ruletext += "\r\n}";
            }

            change.DeclarationText = ruletext;

            return(change);
        }