public ActionResult Create()
        {
            if (!CheckPermission(ListsPermissions.ManageLists))
            {
                return(new HttpUnauthorizedResult());
            }

            WorkContext.Breadcrumbs.Add(T("Manage Lists"), Url.Action("Index", new { area = Constants.Areas.Lists }));
            WorkContext.Breadcrumbs.Add(T("Create"));

            var model = new ListModel
            {
                Enabled  = true,
                PageSize = 10
            };

            var result = new ControlFormResult <ListModel>(model)
            {
                Title                = T("Create List").Text,
                UpdateActionName     = "Update",
                ShowBoxHeader        = false,
                FormWrapperStartHtml = Constants.Form.FormWrapperStartHtml,
                FormWrapperEndHtml   = Constants.Form.FormWrapperEndHtml
            };

            result.ExcludeProperty(x => x.Sorting);
            result.ExcludeProperty(x => x.CssClass);
            result.ExcludeProperty(x => x.SummaryTemplate);
            result.ExcludeProperty(x => x.DetailTemplate);

            return(result);
        }
        public ActionResult Manage()
        {
            WorkContext.Breadcrumbs.Add(T("Account"));
            WorkContext.Breadcrumbs.Add(T("Manage"));

            var user  = WorkContext.CurrentUser;
            var model = new UserModel
            {
                UserName = user.UserName,
                Email    = user.Email
            };
            var accountInfo = new ControlFormResult <UserModel>(model)
            {
                Title                = T("Account Info"),
                ReadOnly             = true,
                ShowCancelButton     = false,
                ShowBoxHeader        = false,
                IconHeader           = "fa fa-lg fa-fw fa-user",
                CssClass             = "col-md-4",
                FormWrapperStartHtml = Constants.Form.FormWrapperStartHtml,
                FormWrapperEndHtml   = Constants.Form.FormWrapperEndHtml
            };

            accountInfo.ExcludeProperty(x => x.SuperUser);
            accountInfo.ExcludeProperty(x => x.IsLockedOut);

            accountInfo.AddAction(addToTop: false).HasText(T("Change Password")).HasUrl(Url.Action("ChangePassword")).HasButtonStyle(ButtonStyle.Primary);

            return(accountInfo);
        }
Exemple #3
0
        public ActionResult Create()
        {
            if (!CheckPermission(StandardPermissions.FullAccess))
            {
                return(new HttpUnauthorizedResult());
            }

            var result = new ControlFormResult <LanguageModel>(new LanguageModel {
                Active = true
            })
            {
                Title                = T("Create Language"),
                UpdateActionName     = "Update",
                ShowBoxHeader        = false,
                FormWrapperStartHtml = Constants.Form.FormWrapperStartHtml,
                FormWrapperEndHtml   = Constants.Form.FormWrapperEndHtml
            };

            result.RegisterFileUploadOptions("ImageFlag.FileName", new ControlFileUploadOptions
            {
                AllowedExtensions = "jpg,jpeg,png,gif"
            });

            var cultures = CultureInfo.GetCultures(CultureTypes.SpecificCultures);

            result.RegisterExternalDataSource(x => x.CultureCode, cultures.ToList().OrderBy(x => x.DisplayName).ToDictionary(k => k.Name, v => v.DisplayName));

            var themeManager = WorkContext.Resolve <IThemeManager>();

            result.RegisterExternalDataSource(x => x.Theme, themeManager.GetInstalledThemes());

            result.ExcludeProperty(x => x.CultureCode2);

            return(result);
        }
        public virtual ActionResult ChangePassword(int userId)
        {
            if (!CheckPermission(StandardPermissions.FullAccess))
            {
                throw new NotAuthorizedException();
            }

            var user = membershipService.GetUser(userId);

            var model = new ChangePasswordModel
            {
                UserName = user.UserName,
                Email    = user.Email
            };

            var retult = new ControlFormResult <ChangePasswordModel>(model)
            {
                Title                = T("Change Password").Text,
                ShowBoxHeader        = false,
                IconHeader           = "fa fa-lg fa-fw fa-user",
                FormWrapperStartHtml = Constants.Form.FormWrapperStartHtml,
                FormWrapperEndHtml   = Constants.Form.FormWrapperEndHtml
            };

            retult.ExcludeProperty(x => x.OldPassword);

            return(retult);
        }
        public override ActionResult BuildEditor(Controller controller, WorkContext workContext, ControlFormResult <IWidget> form)
        {
            var mediaService = workContext.Resolve <IMediaService>();

            form.RegisterExternalDataSource("PhotosFolder", mediaService.GetMediaFolders());

            var oldCaptions = new List <FileCaption>();

            if (Captions != null)
            {
                oldCaptions.AddRange(Captions);
                Captions.Clear();
            }
            else
            {
                Captions = new List <FileCaption>();
            }

            if (!string.IsNullOrEmpty(PhotosFolder))
            {
                var files = mediaService.GetMediaFiles(PhotosFolder).Where(IsPhotoFile).OrderBy(x => x.Name);
                Captions.AddRange(files.Select(file => oldCaptions.FirstOrDefault(x => x.FileName == file.Name)
                                               ?? new FileCaption {
                    FileName = file.Name
                }));
            }
            else
            {
                form.ExcludeProperty("Captions");
            }

            return(base.BuildEditor(controller, workContext, form));
        }
Exemple #6
0
        public ActionResult Edit(int id)
        {
            if (!CheckPermission(StandardPermissions.FullAccess))
            {
                return(new HttpUnauthorizedResult());
            }

            LanguageModel model = languageService.GetById(id);

            model.CultureCode2 = model.CultureCode;

            var result = new ControlFormResult <LanguageModel>(model)
            {
                Title                = T("Edit Language"),
                UpdateActionName     = "Update",
                ShowBoxHeader        = false,
                FormWrapperStartHtml = Constants.Form.FormWrapperStartHtml,
                FormWrapperEndHtml   = Constants.Form.FormWrapperEndHtml
            };

            if (model.CultureCode == siteSettings.DefaultLanguage)
            {
                result.ExcludeProperty(x => x.Active);
                result.AddHiddenValue("Active", "true");
            }

            result.RegisterFileUploadOptions("ImageFlag.FileName", new ControlFileUploadOptions
            {
                AllowedExtensions = "jpg,jpeg,png,gif"
            });

            var themeManager = WorkContext.Resolve <IThemeManager>();

            result.RegisterExternalDataSource(x => x.Theme, themeManager.GetInstalledThemes());

            result.ExcludeProperty(x => x.CultureCode);
            result.AddHiddenValue("CultureCode", model.CultureCode);

            return(result);
        }
        public ActionResult Edit(int id)
        {
            if (!CheckPermission(ListsPermissions.ManageLists))
            {
                return(new HttpUnauthorizedResult());
            }

            var record = listFieldService.GetById(id);
            var list   = record.List ?? listService.GetById(record.ListId);

            WorkContext.Breadcrumbs.Add(T("Manage Lists"), Url.Action("Index", "List", new { area = Constants.Areas.Lists }));
            WorkContext.Breadcrumbs.Add(list.Name);
            WorkContext.Breadcrumbs.Add(T("Fields"), Url.Action("Index", new { area = Constants.Areas.Lists }));
            WorkContext.Breadcrumbs.Add(record.Name);
            WorkContext.Breadcrumbs.Add(T("Edit"));

            var settings = new SharpSerializerXmlSettings
            {
                IncludeAssemblyVersionInTypeName = false,
                IncludeCultureInTypeName         = false,
                IncludePublicKeyTokenInTypeName  = false
            };

            var sharpSerializer = new SharpSerializer(settings);

            var field = (IListField)sharpSerializer.DeserializeFromString(record.FieldProperties);

            if (field.Id == 0)
            {
                field.Id = id;
            }

            var result = new ControlFormResult <IListField>(field, field.GetType())
            {
                Title                = T("Edit Field").Text,
                UpdateActionName     = "Update",
                ShowBoxHeader        = false,
                FormWrapperStartHtml = Constants.Form.FormWrapperStartHtml,
                FormWrapperEndHtml   = Constants.Form.FormWrapperEndHtml
            };

            result.ExcludeProperty(x => x.Name);

            result.AddHiddenValue("Name", record.Name);
            result.AddHiddenValue("FieldType", GetFullTypeName(field.GetType()));

            return(result);
        }
        public ActionResult Create(int?pageId)
        {
            if (!CheckPermission(WidgetPermissions.ManageWidgets))
            {
                return(new HttpUnauthorizedResult());
            }

            WorkContext.Breadcrumbs.Add(T("Widgets"), Url.Action("Index"));
            WorkContext.Breadcrumbs.Add(T("Create"));

            var model = new WidgetModel {
                Title = "", PageId = pageId
            };

            var result = new ControlFormResult <WidgetModel>(model)
            {
                Title                = T("Create Widget").Text,
                UpdateActionName     = "Update",
                ShowCloseButton      = true,
                IsAjaxSupported      = true,
                ShowBoxHeader        = false,
                FormWrapperStartHtml = Constants.Form.FormWrapperStartHtml,
                FormWrapperEndHtml   = Constants.Form.FormWrapperEndHtml
            };

            result.ExcludeProperty(x => x.Enabled);

            var widgets = WorkContext.Resolve <IEnumerable <IWidget> >();

            var widgetTypes = widgets.Select(x => new { x.Name, Type = GetFullTypeName(x.GetType()) }).OrderBy(x => x.Name).ToDictionary(x => x.Type, x => x.Name);

            result.RegisterExternalDataSource(x => x.WidgetType, widgetTypes);

            var zoneService = WorkContext.Resolve <IZoneService>();
            var zones       = zoneService.GetRecords().ToDictionary(x => x.Id, x => x.Name);

            result.RegisterExternalDataSource(x => x.ZoneId, zones);

            return(result);
        }
Exemple #9
0
        public ActionResult Edit(int id)
        {
            WorkContext.Breadcrumbs.Add(new Breadcrumb {
                Text = T("Quản lý chuyên mục"), Url = "#"
            });
            WorkContext.Breadcrumbs.Add(new Breadcrumb {
                Text = T("Sửa thông tin chuyên mục"), Url = Url.Action("Index")
            });

            var             service   = WorkContext.Resolve <ICategoriesService>();
            var             records   = service.GetRecords(x => x.Id == id || x.RefId == id);
            CategoriesModel model     = records.First(x => x.Id == id);
            var             modelType = model.GetType();

            var result = new ControlFormResult <CategoriesModel>(model);

            result.Title            = this.T("Sửa thông chuyên mục");
            result.FormMethod       = FormMethod.Post;
            result.Layout           = ControlFormLayout.Tab;
            result.UpdateActionName = "Update";
            result.ShowCancelButton = false;
            result.ShowBoxHeader    = false;

            result.ExcludeProperty(x => x.Alias);
            result.ExcludeProperty(x => x.Name);
            result.ExcludeProperty(x => x.ShortName);
            result.ExcludeProperty(x => x.Url);
            result.ExcludeProperty(x => x.Tags);
            result.ExcludeProperty(x => x.Notes);
            result.ExcludeProperty(x => x.Description);
            result.ExcludeProperty(x => x.Tags);

            var mainTab           = result.AddTabbedLayout("Thông tin chính");
            var mainGroup         = mainTab.AddGroup();
            var allFields         = modelType.GetProperties(BindingFlags.Instance | BindingFlags.Public);
            var controlAttributes = new Dictionary <string, ControlFormAttribute>();

            foreach (var propertyInfo in allFields)
            {
                var controlAttribute = propertyInfo.GetCustomAttribute <ControlFormAttribute>(true);
                if (controlAttribute == null)
                {
                    continue;
                }
                mainGroup.Add(propertyInfo.Name);
                controlAttribute.PropertyInfo = propertyInfo;
                controlAttribute.PropertyType = propertyInfo.PropertyType;
                controlAttributes.Add(propertyInfo.Name, controlAttribute);
            }

            var languageManager = WorkContext.Resolve <ILanguageManager>();
            var languages       = languageManager.GetActiveLanguages(Constants.ThemeDefault, false);
            var listHidden      = new List <string>
            {
                "Id", "OrderBy", "MenuOrderBy", "ParentId",
                "HasChilden", "IsHome", "IsActived",
                "IsDeleted", "IsDisplayMenu", "IsDisplayFooter"
            };

            if (languages.Count > 0)
            {
                foreach (var language in languages)
                {
                    var languageTab       = result.AddTabbedLayout(language.Name);
                    var languageGroup     = languageTab.AddGroup();
                    var widgetForLanguage = records.FirstOrDefault(x => x.LanguageCode == language.CultureCode) ?? model;

                    foreach (var controlAttribute in controlAttributes)
                    {
                        if (listHidden.Contains(controlAttribute.Key))
                        {
                            continue;
                        }

                        var key   = controlAttribute.Key + "." + language.CultureCode;
                        var value = controlAttribute.Value.PropertyInfo.GetValue(widgetForLanguage);
                        result.AddProperty(key, controlAttribute.Value.ShallowCopy(), value);
                        languageGroup.Add(key);
                    }
                }
            }
            result.RegisterExternalDataSource(x => x.ParentId, BindCategories());

            result.AddAction().HasText(T("Add Images")).HasUrl(Url.Action("Edit", "AdminImages", new { id = 0, cateId = model.Id, articlesId = 0 })).HasButtonStyle(ButtonStyle.Info);
            result.AddAction().HasText(this.T("Clear")).HasUrl(this.Url.Action("Edit", RouteData.Values.Merge(new { id = 0 }))).HasButtonStyle(ButtonStyle.Success);
            result.AddAction().HasText(this.T("Back")).HasUrl(this.Url.Action("Index")).HasButtonStyle(ButtonStyle.Danger);

            return(result);
        }
        public ActionResult Translate(int id, string cultureCode)
        {
            if (!CheckPermission(PagesPermissions.ManagePages))
            {
                return(new HttpUnauthorizedResult());
            }

            PageModel model = pageService.GetPageByLanguage(id, cultureCode);

            WorkContext.Breadcrumbs.Add(T("Pages"), Url.Action("Index", new { area = Constants.Areas.Pages }));
            if (model != null)
            {
                WorkContext.Breadcrumbs.Add(model.Title);
            }

            WorkContext.Breadcrumbs.Add(T("Translate"));
            WorkContext.Breadcrumbs.Add(cultureCode);

            var showSaveAndContinue = false;

            if (model == null)
            {
                model                     = pageService.GetById(id);
                model.Id                  = 0;
                model.CultureCode         = cultureCode;
                model.RefId               = id;
                ViewData.ModelState["Id"] = new ModelState {
                    Value = new ValueProviderResult(Guid.Empty, Guid.Empty.ToString(), null)
                };
            }
            else
            {
                ViewData.ModelState["Id"] = new ModelState {
                    Value = new ValueProviderResult(model.Id, model.Id.ToString(), null)
                };
                showSaveAndContinue = true;
            }

            var result = new ControlFormResult <PageModel>(model)
            {
                Title                = T("Translate Page").Text,
                UpdateActionName     = "Update",
                CssClass             = "form-edit-page",
                ShowBoxHeader        = false,
                FormWrapperStartHtml = Constants.Form.FormWrapperStartHtml,
                FormWrapperEndHtml   = Constants.Form.FormWrapperEndHtml
            };

            result.AssignGridLayout(x => x.Id, 0, 0);
            result.AssignGridLayout(x => x.CultureCode, 0, 0);
            result.AssignGridLayout(x => x.RefId, 0, 0);
            result.AssignGridLayout(x => x.Title, 0, 0);
            result.AssignGridLayout(x => x.MetaKeywords, 1, 0);
            result.AssignGridLayout(x => x.IsEnabled, 0, 1);
            result.AssignGridLayout(x => x.MetaDescription, 1, 1);
            result.AssignGridLayout(x => x.BodyContent, 0, 2, 2);

            result.ExcludeProperty(x => x.Slug);
            result.AddHiddenValue("Slug", model.Slug);

            result.ExcludeProperty(x => x.Theme);
            result.AddHiddenValue("Theme", model.Theme);

            result.ExcludeProperty(x => x.CssClass);
            result.AddHiddenValue("CssClass", model.CssClass);

            result.ExcludeProperty(x => x.ShowOnMenuId);
            if (model.ShowOnMenuId.HasValue)
            {
                result.AddHiddenValue("ShowOnMenuId", model.ShowOnMenuId.Value.ToString());
            }

            if (showSaveAndContinue)
            {
                result.AddAction(true, true, false).HasText(T("Save & Continue")).HasName("SaveAndContinue").HasButtonStyle(ButtonStyle.Info);
            }

            // Page tags
            var tags = pageTagService.GetRecords();

            if (tags.Count > 0)
            {
                result.AddHiddenValue("RichtextCustomTags", JsonConvert.SerializeObject(tags.Select(x => new[] { x.Name, "[%" + x.Name + "%]" })));
            }

            return(result);
        }
        public ActionResult Edit(int id)
        {
            if (!CheckPermission(WidgetPermissions.ManageWidgets))
            {
                return(new HttpUnauthorizedResult());
            }

            var widgetService = WorkContext.Resolve <IWidgetService>();
            var records       = widgetService.GetRecords(x => x.Id == id || x.RefId == id);
            var widgets       = widgetService.GetWidgets(records);
            var widget        = widgets.First(x => x.Id == id);
            var widgetType    = widget.GetType();

            WorkContext.Breadcrumbs.Add(T("Widgets"), Url.Action("Index"));
            WorkContext.Breadcrumbs.Add(widget.Title);
            WorkContext.Breadcrumbs.Add(T("Edit"));

            var result = new ControlFormResult <IWidget>(widget, widgetType)
            {
                Title                = T("Edit Widget").Text,
                UpdateActionName     = "Update",
                Layout               = ControlFormLayout.Tab,
                ShowCloseButton      = true,
                IsAjaxSupported      = false,
                ShowBoxHeader        = false,
                FormWrapperStartHtml = Constants.Form.FormWrapperStartHtml,
                FormWrapperEndHtml   = Constants.Form.FormWrapperEndHtml
            };

            result.AddHiddenValue("WidgetType", GetFullTypeName(widget.GetType()));
            if (widget.PageId.HasValue)
            {
                result.AddHiddenValue("PageId", widget.PageId.Value.ToString());
            }

            var mainTab           = result.AddTabbedLayout("Widget Settings");
            var mainGroup         = mainTab.AddGroup();
            var allFields         = widgetType.GetProperties(BindingFlags.Instance | BindingFlags.Public);
            var controlAttributes = new Dictionary <string, ControlFormAttribute>();

            foreach (var propertyInfo in allFields)
            {
                var controlAttribute = propertyInfo.GetCustomAttribute <ControlFormAttribute>(true);
                if (controlAttribute == null)
                {
                    continue;
                }
                mainGroup.Add(propertyInfo.Name);
                controlAttribute.PropertyInfo = propertyInfo;
                controlAttribute.PropertyType = propertyInfo.PropertyType;
                controlAttributes.Add(propertyInfo.Name, controlAttribute);
            }

            result.ExcludeProperty(x => x.Localized);
            if (!widget.HasTitle)
            {
                result.ExcludeProperty(x => x.ShowTitleOnPage);
            }

            var languageManager = WorkContext.Resolve <ILanguageManager>();
            var languages       = languageManager.GetActiveLanguages(Constants.ThemeDefault, false);

            if (languages.Count > 1)
            {
                foreach (var language in languages)
                {
                    var languageTab       = result.AddTabbedLayout(language.Name);
                    var languageGroup     = languageTab.AddGroup();
                    var widgetForLanguage = widgets.FirstOrDefault(x => x.CultureCode == language.CultureCode) ??
                                            widget.ShallowCopy();

                    foreach (var controlAttribute in controlAttributes)
                    {
                        if (controlAttribute.Key == "Id")
                        {
                            continue;
                        }

                        var key   = controlAttribute.Key + "." + language.CultureCode;
                        var value = controlAttribute.Value.PropertyInfo.GetValue(widgetForLanguage);
                        result.AddProperty(key, controlAttribute.Value.ShallowCopy(), value);
                        languageGroup.Add(key);
                    }

                    if (!widget.HasTitle)
                    {
                        result.ExcludeProperty("Title." + language.CultureCode);
                        result.ExcludeProperty("ShowTitleOnPage." + language.CultureCode);
                    }
                }
            }

            var zoneService = WorkContext.Resolve <IZoneService>();
            var zones       = zoneService.GetRecords().ToDictionary(x => x.Id, x => x.Name);

            result.RegisterExternalDataSource(x => x.ZoneId, zones);

            return(widget.BuildEditor(this, WorkContext, result));
        }
        public ActionResult Edit(int id)
        {
            WorkContext.Breadcrumbs.Add(new Breadcrumb {
                Text = T("Quản lý tuyển dụng"), Url = "#"
            });
            WorkContext.Breadcrumbs.Add(new Breadcrumb {
                Text = T("Sửa thông tin tuyển dụng"), Url = Url.Action("Index")
            });

            var records            = service.GetRecords(x => x.Id == id || x.RefId == id);
            RecruitmentModel model = records.First(x => x.Id == id);
            var modelType          = model.GetType();

            if (string.IsNullOrEmpty(model.Contents) || model.Contents.Trim() == "<br />")
            {
                var viewRenderer = new ViewRenderer {
                    Context = ControllerContext
                };
                var viewTemplate = viewRenderer.RenderPartialView(string.Format(Extensions.Constants.ViewRecruitmentTemplate, WorkContext.CurrentCulture), null);
                model.Contents = viewTemplate;
            }

            var result = new ControlFormResult <RecruitmentModel>(model);

            result.Title            = this.T("Sửa thông tin tuyển dụng");
            result.FormMethod       = FormMethod.Post;
            result.Layout           = ControlFormLayout.Tab;
            result.UpdateActionName = "Update";
            result.ShowCancelButton = false;
            result.ShowBoxHeader    = false;

            result.ExcludeProperty(x => x.Alias);
            result.ExcludeProperty(x => x.Contents);
            result.ExcludeProperty(x => x.Position);
            result.ExcludeProperty(x => x.Summary);
            result.ExcludeProperty(x => x.Title);
            result.ExcludeProperty(x => x.TimeWork);

            var mainTab           = result.AddTabbedLayout("Thông tin chính");
            var mainGroup         = mainTab.AddGroup();
            var allFields         = modelType.GetProperties(BindingFlags.Instance | BindingFlags.Public);
            var controlAttributes = new Dictionary <string, ControlFormAttribute>();

            foreach (var propertyInfo in allFields)
            {
                var controlAttribute = propertyInfo.GetCustomAttribute <ControlFormAttribute>(true);
                if (controlAttribute == null)
                {
                    continue;
                }
                mainGroup.Add(propertyInfo.Name);
                controlAttribute.PropertyInfo = propertyInfo;
                controlAttribute.PropertyType = propertyInfo.PropertyType;
                controlAttributes.Add(propertyInfo.Name, controlAttribute);
            }

            var languageManager = WorkContext.Resolve <ILanguageManager>();
            var languages       = languageManager.GetActiveLanguages(Constants.ThemeDefault, false);
            var listHidden      = new List <string>
            {
                "Id", "CategoryId", "IsDeleted", "FinishDate"
            };

            if (languages.Count > 0)
            {
                foreach (var language in languages)
                {
                    var languageTab       = result.AddTabbedLayout(language.Name);
                    var languageGroup     = languageTab.AddGroup();
                    var widgetForLanguage = records.FirstOrDefault(x => x.LanguageCode == language.CultureCode) ?? model;

                    foreach (var controlAttribute in controlAttributes)
                    {
                        if (listHidden.Contains(controlAttribute.Key))
                        {
                            continue;
                        }

                        var key   = controlAttribute.Key + "." + language.CultureCode;
                        var value = controlAttribute.Value.PropertyInfo.GetValue(widgetForLanguage);
                        result.AddProperty(key, controlAttribute.Value.ShallowCopy(), value);
                        languageGroup.Add(key);
                    }
                }
            }
            result.AddAction().HasText(this.T("Thêm mới")).HasUrl(this.Url.Action("Create")).HasButtonStyle(ButtonStyle.Success);
            result.AddAction().HasText(this.T("Back")).HasUrl(this.Url.Action("Index")).HasButtonStyle(ButtonStyle.Danger);

            result.RegisterExternalDataSource(x => x.CategoryId, y => BindCategories());

            return(result);
        }
Exemple #13
0
        public ActionResult AddOrEditSublayer(string tag, string id)
        {
            var model = new SublayerModel {
                Id = id, Tag = tag
            };

            var result = new ControlFormResult <SublayerModel>(model)
            {
                Title            = T("Sublayer"),
                UpdateActionName = "UpdateSublayer"
            };

            if (string.Equals(tag, "img", StringComparison.InvariantCultureIgnoreCase))
            {
                result.ExcludeProperty(x => x.HtmlContent);
                result.ExcludeProperty(x => x.FontFamily);
                result.ExcludeProperty(x => x.FontSize);
                result.ExcludeProperty(x => x.Color);
            }
            else
            {
                result.ExcludeProperty(x => x.ImageSource);
            }

            if (!string.IsNullOrEmpty(id))
            {
                var script = new StringBuilder();

                script.AppendLine(@"function colorToHex(color) {
                    if(!color) return '';
                    if (color.substr(0, 1) === '#') {
                        return color;
                    }
                    var digits = /(.*?)rgb\((\d+), (\d+), (\d+)\)/.exec(color); if(!digits) return color;

                    var red = parseInt(digits[2]);
                    var green = parseInt(digits[3]);
                    var blue = parseInt(digits[4]);

                    var rgb = blue | (green << 8) | (red << 16);
                    return digits[1] + '#' + rgb.toString(16);
                };");
                script.AppendLine(@"function getStyleValue(style, name){
                    var split = style.split(';');
                    for(var i = 0; i < split.length; i++){
                        if(split[i].indexOf(name + ':') == 0){
                            return $.trim(split[i].replace(name + ':', ''));
                        }
                    }
                    return '';
                }");

                script.AppendFormat("var element = $('#{0}', window.parent.document);", id);
                script.Append("var elementStyle = element.prop('style');");
                script.Append("var style = element.attr('style');");
                script.Append("$('#Top').val(element.css('top'));");
                script.Append("$('#Left').val(element.css('left'));");
                script.Append("$('#BackgroundColor').val(colorToHex(elementStyle[$.camelCase('backround-color')]));");
                script.Append("$('#SlideDirection').val(getStyleValue(style, 'slidedirection'));");
                script.Append("$('#SlideOutDirection').val(getStyleValue(style, 'slideoutdirection'));");
                script.Append("$('#DurationIn').val(getStyleValue(style, 'durationin'));");
                script.Append("$('#DurationOut').val(getStyleValue(style, 'durationout'));");
                script.Append("$('#EasingIn').val(getStyleValue(style, 'easingin'));");
                script.Append("$('#EasingOut').val(getStyleValue(style, 'easingout'));");
                script.Append("$('#RotateIn').val(getStyleValue(style, 'rotatein'));");
                script.Append("$('#RotateOut').val(getStyleValue(style, 'rotateout'));");

                if (string.Equals(tag, "img", StringComparison.InvariantCultureIgnoreCase))
                {
                    script.Append("$('#ImageSource').val(element.attr('src'));");
                    script.Append("$('#ImageSource_UploadList').html(element.attr('src'));");
                }
                else
                {
                    script.Append("$('#HtmlContent').val(element.html());");
                    script.Append("$('#FontFamily').val(elementStyle[$.camelCase('font-family')]);");
                    script.Append("$('#FontSize').val(elementStyle[$.camelCase('font-size')]);");
                    script.Append("$('#Color').val(colorToHex(elementStyle[$.camelCase('color')]));");
                }
                var scriptRegister = new ScriptRegister(WorkContext);
                scriptRegister.IncludeInline(script.ToString());

                result.AddAction(true)
                .HasName("Delete")
                .HasButtonStyle(ButtonStyle.Danger)
                .HasText(T("Delete"))
                .HasIconCssClass("cx-icon cx-icon-remove")
                .HasValue(id);
            }

            result.RegisterExternalDataSource(x => x.SlideDirection, "left", "right", "top", "bottom", "fade");
            result.RegisterExternalDataSource(x => x.SlideOutDirection, "left", "right", "top", "bottom", "fade");

            var easings = new[] { "linear", "swing", "easeInQuad", "easeOutQuad", "easeInOutQuad", "easeInCubic", "easeOutCubic", "easeInOutCubic", "easeInQuart", "easeOutQuart", "easeInOutQuart", "easeInQuint", "easeOutQuint", "easeInOutQuint", "easeInExpo", "easeOutExpo", "easeInOutExpo", "easeInSine", "easeOutSine", "easeInOutSine", "easeInCirc", "easeOutCirc", "easeInOutCirc", "easeInElastic", "easeOutElastic", "easeInOutElastic", "easeInBack", "easeOutBack", "easeInOutBack", "easeInBounce", "easeOutBounce", "easeInOutBounce" };

            result.RegisterExternalDataSource(x => x.EasingIn, easings);
            result.RegisterExternalDataSource(x => x.EasingOut, easings);

            return(result);
        }