예제 #1
0
        /// <summary>
        /// Called by the framework when the component needs to be rendered as HTML.
        /// </summary>
        /// <param name="model">The model being rendered by the component.</param>
        /// <returns>The component rendered as HTML.</returns>
        public async Task <string> RenderAsync(string model)
        {
            // get all available skins
            SkinAccess skinAccess = new SkinAccess();
            List <SelectionItem <string> > list = (from theme in await skinAccess.GetJQueryThemeListAsync() select new SelectionItem <string>()
            {
                Text = theme.Name,
                Tooltip = theme.Description,
                Value = theme.Name,
            }).ToList();

            bool useDefault = !PropData.GetAdditionalAttributeValue <bool>("NoDefault");

            if (useDefault)
            {
                list.Insert(0, new SelectionItem <string> {
                    Text    = __ResStr("default", "(Site Default)"),
                    Tooltip = __ResStr("defaultTT", "Use the site defined default theme"),
                    Value   = "",
                });
            }
            else if (model == null)
            {
                model = await SkinAccess.GetJQueryUIDefaultSkinAsync();
            }

            // display the skins in a drop down
            return(await DropDownListComponent.RenderDropDownListAsync(this, model, list, "yt_jqueryuiskin"));
        }
예제 #2
0
        /// <summary>
        /// Called by components that use Kendo UI to add the basic Kendo UI JavaScript/CSS to the page.
        /// </summary>
        public static async Task UseAsync()
        {
            if (Manager.IsPostRequest)
            {
                return;                       // can't add this while processing a post request
            }
            CoreRendering.ComponentsData cData = CoreRendering.GetComponentsData();
            if (!cData.KendoUIUsed)
            {
                cData.KendoUIUsed = true;

                // Find Kendo UI theme
                SkinAccess skinAccess = new SkinAccess();
                string     skin       = Manager.CurrentPage.KendoUISkin;
                if (string.IsNullOrWhiteSpace(skin))
                {
                    skin = Manager.CurrentSite.KendoUISkin;
                }
                string kendoUITheme = await skinAccess.FindKendoUISkinAsync(skin);

                await Manager.AddOnManager.AddAddOnNamedAsync(AreaRegistration.CurrentPackage.AreaName, "telerik.com.Kendo_UI_Core", kendoUITheme);

                Manager.ScriptManager.AddVolatileOption(AreaRegistration.CurrentPackage.AreaName, "kendoUI", true, Replace: true);
            }
        }
예제 #3
0
        /// <summary>
        /// Adds any skin-specific addons for the current page that are required by the package rendering components and views.
        /// </summary>
        public async Task AddSkinAddOnsAsync()
        {
            SkinAccess skinAccess = new SkinAccess();
            string     skin;

            // add jqueryui theme folder in case we need to dynamically load jqueryui from the client
            // Find the jquery theme+
            skin = Manager.CurrentPage.jQueryUISkin;
            if (string.IsNullOrWhiteSpace(skin))
            {
                skin = Manager.CurrentSite.jQueryUISkin;
            }
            string jqueryUIFolder = await skinAccess.FindJQueryUISkinAsync(skin);

            Manager.ScriptManager.AddVolatileOption(AreaRegistration.CurrentPackage.AreaName, "jqueryUITheme", jqueryUIFolder);

            // add kendoui theme folder in case we need to dynamically load kendoui from the client
            // Find the kendo theme
            skinAccess = new SkinAccess();
            skin       = Manager.CurrentPage.KendoUISkin;
            if (string.IsNullOrWhiteSpace(skin))
            {
                skin = Manager.CurrentSite.KendoUISkin;
            }
            string kendoUITheme = await skinAccess.FindKendoUISkinAsync(skin);

            Manager.ScriptManager.AddVolatileOption(AreaRegistration.CurrentPackage.AreaName, "kendoUITheme", kendoUITheme);
        }
예제 #4
0
        /// <summary>
        /// Called by components that use jQuery UI to add the basic jQuery UI JavaScript/CSS to the page.
        /// </summary>
        public static async Task UseAsync()
        {
            if (Manager.IsPostRequest)
            {
                return;                       // can't add this while processing a post request
            }
            CoreRendering.ComponentsData cData = CoreRendering.GetComponentsData();
            if (!cData.JqueryUIUsed)
            {
                cData.JqueryUIUsed = true;

                await Manager.AddOnManager.AddAddOnNamedAsync(AreaRegistration.CurrentPackage.AreaName, "jqueryui");

                // Find the jquery theme+
                SkinAccess skinAccess = new SkinAccess();
                string     skin       = Manager.CurrentPage.jQueryUISkin;
                if (string.IsNullOrWhiteSpace(skin))
                {
                    skin = Manager.CurrentSite.jQueryUISkin;
                }
                string jqueryUIFolder = await skinAccess.FindJQueryUISkinAsync(skin);

                await Manager.AddOnManager.AddAddOnNamedAsync(AreaRegistration.CurrentPackage.AreaName, "jqueryui-themes", jqueryUIFolder);

                Manager.ScriptManager.AddVolatileOption(AreaRegistration.CurrentPackage.AreaName, "jqueryUI", true, Replace: true);
            }
        }
예제 #5
0
        public async Task <string> RenderAsync(string model)
        {
            // get all available skins
            SkinAccess skinAccess = new SkinAccess();
            List <SelectionItem <string> > list = (from theme in skinAccess.GetHighlightJSThemeList() select new SelectionItem <string>()
            {
                Text = theme.Name,
                Value = theme.Name,
            }).ToList();

            bool useDefault = PropData.GetAdditionalAttributeValue <bool>("NoDefault", false);

            if (useDefault)
            {
                list.Insert(0, new SelectionItem <string> {
                    Text    = this.__ResStr("default", "(Site Default)"),
                    Tooltip = this.__ResStr("defaultTT", "Use the site defined default theme"),
                    Value   = "",
                });
            }
            else if (model == null)
            {
                model = SkinAccess.GetHighlightJSDefaultSkin();
            }

            return(await DropDownListComponent.RenderDropDownListAsync(this, model, list, "yt_yetawf_syntaxhighlighter_highlightjs"));
        }
예제 #6
0
        /// <summary>
        /// Adds any form-specific addons for the current page that are required by the package rendering components and views.
        /// </summary>
        /// <remarks>This is only called if a page contains a form.</remarks>
        public async Task AddFormsAddOnsAsync()
        {
            SkinAccess skinAccess = new SkinAccess();

            if (!Manager.SkinInfo.UsingBootstrap || !Manager.SkinInfo.UsingBootstrapButtons)
            {
                await JqueryUICore.UseAsync(); // using jquery UI buttons
            }
        }
예제 #7
0
        internal static string RenderReplacementSkinsForCollection(string skinCollection)
        {
            SkinAccess   skinAccess             = new SkinAccess();
            PageSkinList skinList               = skinAccess.GetAllPageSkins(skinCollection);
            List <SelectionItem <string> > list = (from skin in skinList orderby skin.Description select new SelectionItem <string>()
            {
                Text = skin.Name,
                Tooltip = skin.Description,
                Value = skin.PageViewName,
            }).ToList();

            // render a new dropdown list
            return(DropDownListEditComponentBase <string> .RenderDataSource(list, null));
        }
예제 #8
0
        public async Task <ActionResult> SkinHighlightJS()
        {
            ConfigData config = await ConfigDataProvider.GetConfigAsync();

            // find theme specific skin
            Package    package    = AreaRegistration.CurrentPackage;
            SkinAccess skinAccess = new SkinAccess();
            string     theme      = skinAccess.FindHighlightJSSkin(config.HighlightJSSkin);
            await Manager.AddOnManager.AddAddOnNamedAsync(package.AreaName, "SkinHighlightJS", theme);

            // add client-side init
            Manager.ScriptManager.AddLast("YetaWF_SyntaxHighlighter_HighlightJS", "YetaWF_SyntaxHighlighter.HighlightJS.init();");

            return(new EmptyResult());
        }
예제 #9
0
        /// <summary>
        /// Called by the framework when the component needs to be rendered as HTML.
        /// </summary>
        /// <param name="model">The model being rendered by the component.</param>
        /// <returns>The component rendered as HTML.</returns>
        public async Task <string> RenderAsync(string model)
        {
            // get all available page skins for this collection
            SkinAccess   skinAccess             = new SkinAccess();
            string       collection             = GetSiblingProperty <string>($"{PropertyName}_Collection");
            PageSkinList skinList               = skinAccess.GetAllPageSkins(collection);
            List <SelectionItem <string> > list = (from skin in skinList orderby skin.Description select new SelectionItem <string>()
            {
                Text = skin.Name,
                Tooltip = skin.Description,
                Value = skin.PageViewName,
            }).ToList();

            // display the skins in a drop down
            return(await DropDownListComponent.RenderDropDownListAsync(this, model, list, "yt_skinname"));
        }
예제 #10
0
        public async Task <ActionResult> SkinSyntaxHighlighter()
        {
            ConfigData config = await ConfigDataProvider.GetConfigAsync();

            // find theme specific skin
            Package    package    = AreaRegistration.CurrentPackage;
            SkinAccess skinAccess = new SkinAccess();
            string     theme      = skinAccess.FindSyntaxHighlighterSkin(config.SyntaxHighlighterSkin);
            await Manager.AddOnManager.AddAddOnNamedAsync(package.AreaName, "SkinSyntaxHighlighter", theme);

            // add client-side init
            string url = VersionManager.GetAddOnNamedUrl(package.AreaName, "SkinSyntaxHighlighter");

            Manager.ScriptManager.AddLast("AlexGorbatchevCom_SyntaxHighlighter", "YetaWF_SyntaxHighlighter.AlexGorbatchevCom.init('" + url + "');");

            return(new EmptyResult());
        }
예제 #11
0
        /// <summary>
        /// Called by the framework when the component needs to be rendered as HTML.
        /// </summary>
        /// <param name="model">The model being rendered by the component.</param>
        /// <returns>The component rendered as HTML.</returns>
        public async Task <string> RenderAsync(SerializableList <SkinDefinition> model)
        {
            HtmlBuilder hb = new HtmlBuilder();

            int        index      = 0;
            SkinAccess skinAccess = new SkinAccess();

            hb.Append($@"
<div id='{ControlId}' class='yt_moduleskins t_edit'>
    {await HtmlHelper.ForEditComponentAsync(Container, PropertyName, null, "Hidden", HtmlAttributes: new { __NoTemplate = true, @class = Forms.CssFormNoSubmit })}");

            foreach (SkinCollectionInfo skinDef in (from s in skinAccess.GetAllSkinCollections() orderby s.CollectionDescription select s).ToList())
            {
                hb.Append($@"
    <div class='t_collection'>");

                SkinDefinition sd       = (from s in model where s.Collection == skinDef.CollectionName select s).FirstOrDefault();
                string         fileName = sd?.FileName;

                ModuleSkinUI ms = new ModuleSkinUI {
                    Collection              = skinDef.CollectionName,
                    FileName                = fileName,
                    FileNameCaption         = skinDef.CollectionDescription,
                    FileName_ModuleSkinList = skinAccess.GetAllModuleSkins(skinDef.CollectionName),
                };

                using (Manager.StartNestedComponent($@"{FieldName}[{index}]")) {
                    hb.Append(await HtmlHelper.ForDisplayAsync(ms, nameof(ms.Collection)));
                    hb.Append(await HtmlHelper.ForLabelAsync(ms, nameof(ms.FileName)));
                    hb.Append(await HtmlHelper.ForEditAsync(ms, nameof(ms.FileName)));
                    hb.Append(ValidationMessage(FieldNamePrefix, nameof(ms.FileName)));
                }

                index++;
                hb.Append($@"
    </div>");
            }

            hb.Append($@"
</div>");
            //Manager.ScriptManager.AddLast($@"new YetaWF_ComponentsHTML.ModuleSkinsEditComponent('{ControlId}');");

            return(hb.ToString());
        }
예제 #12
0
        /// <summary>
        /// Called by the framework when the component needs to be rendered as HTML.
        /// </summary>
        /// <param name="model">The model being rendered by the component.</param>
        /// <returns>The component rendered as HTML.</returns>
        public Task <string> RenderAsync(string model)
        {
            // get all available page skins for this collection
            SkinAccess   skinAccess = new SkinAccess();
            string       collection = GetSiblingProperty <string>($"{PropertyName}_Collection");
            PageSkinList skinList   = skinAccess.GetAllPageSkins(collection);

            string desc = (from skin in skinList where skin.PageViewName == model select skin.Name).FirstOrDefault();

            if (desc == null)
            {
                desc = skinList.First().Description;
            }
            if (string.IsNullOrWhiteSpace(desc))
            {
                return(Task.FromResult <string>(null));
            }
            return(Task.FromResult(HE(desc)));
        }
예제 #13
0
        /// <summary>
        /// Called by the framework when the component needs to be rendered as HTML.
        /// </summary>
        /// <param name="model">The model being rendered by the component.</param>
        /// <returns>The component rendered as HTML.</returns>
        public Task <string> RenderAsync(string model)
        {
            // get all available skins
            SkinAccess skinAccess = new SkinAccess();

            string desc = (from skinColl in skinAccess.GetAllSkinCollections() where model == skinColl.CollectionName select skinColl.CollectionDescription).FirstOrDefault();

            if (desc == null)
            {
                bool useDefault = !PropData.GetAdditionalAttributeValue("NoDefault", false);
                if (useDefault)
                {
                    desc = __ResStr("siteDef", "(Site Default)");
                }
            }
            if (string.IsNullOrWhiteSpace(desc))
            {
                return(Task.FromResult <string>(null));
            }
            return(Task.FromResult(HE(desc)));
        }
예제 #14
0
        /// <summary>
        /// Called by the framework when the component needs to be rendered as HTML.
        /// </summary>
        /// <param name="model">The model being rendered by the component.</param>
        /// <returns>The component rendered as HTML.</returns>
        public async Task <string> RenderAsync(string model)
        {
            // get all available skins
            SkinAccess skinAccess = new SkinAccess();
            List <SelectionItem <string> > list = (from skinColl in skinAccess.GetAllSkinCollections() orderby skinColl.CollectionDescription select new SelectionItem <string>()
            {
                Text = skinColl.CollectionDescription,
                Value = skinColl.CollectionName,
            }).ToList();
            bool useDefault = !PropData.GetAdditionalAttributeValue("NoDefault", false);

            if (useDefault)
            {
                list.Insert(0, new SelectionItem <string> {
                    Text    = __ResStr("siteDef", "(Site Default)"),
                    Tooltip = __ResStr("siteDefTT", "Use the site defined default skin"),
                    Value   = "",
                });
            }
            // display the skins in a drop down
            return(await DropDownListComponent.RenderDropDownListAsync(this, model, list, "yt_skinselection"));
        }
예제 #15
0
        /// <summary>
        /// Called by the framework when the component needs to be rendered as HTML.
        /// </summary>
        /// <param name="model">The model being rendered by the component.</param>
        /// <returns>The component rendered as HTML.</returns>
        public async Task <string> RenderAsync(SerializableList <SkinDefinition> model)
        {
            HtmlBuilder hb = new HtmlBuilder();

            int        index      = 0;
            SkinAccess skinAccess = new SkinAccess();

            hb.Append($@"
<div id='{DivId}' class='yt_moduleskins t_display'>");

            foreach (SkinCollectionInfo skinDef in (from s in skinAccess.GetAllSkinCollections() orderby s.CollectionDescription select s).ToList())
            {
                hb.Append($@"
    <div class='t_collection'>");

                SkinDefinition sd       = (from s in model where s.Collection == skinDef.CollectionName select s).FirstOrDefault();
                string         fileName = sd?.FileName;

                ModuleSkinUI ms = new ModuleSkinUI {
                    FileName                = fileName,
                    FileNameCaption         = skinDef.CollectionDescription,
                    FileName_ModuleSkinList = skinAccess.GetAllModuleSkins(skinDef.CollectionName),
                };

                using (Manager.StartNestedComponent($@"{FieldName}[{index}]")) {
                    hb.Append(await HtmlHelper.ForLabelAsync(ms, nameof(ms.FileName)));
                    hb.Append(await HtmlHelper.ForDisplayAsync(ms, nameof(ms.FileName)));
                }
                index++;
                hb.Append($@"
    </div>");
            }

            hb.Append($@"
</div>");

            return(hb.ToString());
        }