Exemplo n.º 1
0
        /// <summary>
        /// The add script reference.
        /// </summary>
        /// <param name="name">
        /// The name.
        /// </param>
        /// <param name="path">
        /// The path.
        /// </param>
        public void AddScriptReference(string name, string path)
        {
            ScriptManager.ScriptResourceMapping.AddDefinition(
                name,
                new ScriptResourceDefinition
            {
                Path = YafForumInfo.GetURLToScripts(path)
            });

            this.AddScriptReference(new ScriptReference {
                Name = name
            });
        }
        /// <summary>
        /// Registers a Java Script include using the script manager.
        /// </summary>
        /// <param name="thisControl">
        /// The this Control.
        /// </param>
        /// <param name="name">
        /// The name.
        /// </param>
        /// <param name="relativeScriptsUrl">
        /// The relative Scripts Url.
        /// </param>
        public void RegisterJsScriptsInclude(Control thisControl, string name, string relativeScriptsUrl)
        {
            if (this.PageElementExists(name))
            {
                return;
            }

            ScriptManager.RegisterClientScriptInclude(
                thisControl,
                thisControl.GetType(),
                name,
                YafForumInfo.GetURLToScripts(relativeScriptsUrl));

            this.AddPageElement(name);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Registers the jQuery script library.
        /// </summary>
        private void RegisterJQuery()
        {
            var element = YafContext.Current.CurrentForumPage.TopPageControl;

            if (YafContext.Current.PageElements.PageElementExists("jquery") || Config.DisableJQuery)
            {
                return;
            }

            var registerJQuery = true;

            const string Key = "JQuery-Javascripts";

            // check to see if DotNetAge is around and has registered jQuery for us...
            if (HttpContext.Current.Items[Key] != null)
            {
                var collection = HttpContext.Current.Items[Key] as StringCollection;

                if (collection != null && collection.Contains("jquery"))
                {
                    registerJQuery = false;
                }
            }
            else if (Config.IsDotNetNuke)
            {
                // latest version of DNN (v5) should register jQuery for us...
                registerJQuery = false;
            }

            if (registerJQuery)
            {
                string jqueryUrl;

                // Check if override file is set ?
                if (Config.JQueryOverrideFile.IsSet())
                {
                    jqueryUrl = !Config.JQueryOverrideFile.StartsWith("http") &&
                                !Config.JQueryOverrideFile.StartsWith("//")
                                    ? YafForumInfo.GetURLToScripts(Config.JQueryOverrideFile)
                                    : Config.JQueryOverrideFile;
                }
                else
                {
                    jqueryUrl = YafContext.Current.Get <YafBoardSettings>().JqueryCDNHosted
                                    ? "//ajax.aspnetcdn.com/ajax/jQuery/jquery-2.1.4.min.js"
#if DEBUG
                                    : YafForumInfo.GetURLToScripts("jquery-2.1.4.js");
Exemplo n.º 4
0
        /// <summary>
        /// Handles the PreRender event of the CurrentForumPage control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void CurrentForumPagePreRender([NotNull] object sender, [NotNull] EventArgs e)
        {
            this.RegisterJQuery();

            if (this.PageContext.Vars.ContainsKey("yafForumExtensions"))
            {
                return;
            }

            var version = this.Get <YafBoardSettings>().CdvVersion;

            ScriptManager.ScriptResourceMapping.AddDefinition(
                "yafForumAdminExtensions",
                new ScriptResourceDefinition
            {
                Path      = YafForumInfo.GetURLToScripts($"jquery.ForumAdminExtensions.min.js?v={version}"),
                DebugPath = YafForumInfo.GetURLToScripts($"jquery.ForumAdminExtensions.js?v={version}")
            });

            ScriptManager.ScriptResourceMapping.AddDefinition(
                "yafForumExtensions",
                new ScriptResourceDefinition
            {
                Path      = YafForumInfo.GetURLToScripts($"jquery.ForumExtensions.min.js?v={version}"),
                DebugPath = YafForumInfo.GetURLToScripts($"jquery.ForumExtensions.js?v={version}")
            });

            ScriptManager.ScriptResourceMapping.AddDefinition(
                "FileUploadScript",
                new ScriptResourceDefinition
            {
                Path      = YafForumInfo.GetURLToScripts("jquery.fileupload.comb.min.js"),
                DebugPath = YafForumInfo.GetURLToScripts("jquery.fileupload.comb.js")
            });

            YafContext.Current.PageElements.AddScriptReference(
                this.PageContext.CurrentForumPage.IsAdminPage ? "yafForumAdminExtensions" : "yafForumExtensions");

            this.PageContext.Vars["yafForumExtensions"] = true;
        }
Exemplo n.º 5
0
        /// <summary>
        /// Register the jQueryUI date picker language file.
        /// </summary>
        /// <param name="element">Control element to put in</param>
        /// <param name="currentCulture">The current culture.</param>
        public void RegisterJQueryUILanguageFile(Control element, CultureInfo currentCulture)
        {
            // If registered or told not to register, don't bother
            if (this.PageElementExists("datepickerlang"))
            {
                return;
            }

            string jqueryUILangUrl;

            // Check if override file is set ?
            if (Config.JQueryUIOverrideLangFile.IsSet())
            {
                jqueryUILangUrl = !Config.JQueryUIOverrideLangFile.StartsWith("http") &&
                                  !Config.JQueryUIOverrideLangFile.StartsWith("//")
                                      ? YafForumInfo.GetURLToScripts(Config.JQueryUIOverrideLangFile)
                                      : Config.JQueryUIOverrideLangFile;
            }
            else
            {
                jqueryUILangUrl = YafContext.Current.Get <YafBoardSettings>().JqueryUICDNHosted
                                      ? "//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/i18n/jquery-ui-i18n.min.js"
#if DEBUG
                                      : YafForumInfo.GetURLToScripts("jquery-ui-i18n.js");
Exemplo n.º 6
0
        /// <summary>
        /// Registers the jQuery script library.
        /// </summary>
        private void RegisterJQuery()
        {
            if (YafContext.Current.PageElements.PageElementExists("jquery"))
            {
                return;
            }

            var registerJQuery = true;

            const string Key = "JQuery-Javascripts";

            // check to see if DotNetAge is around and has registered jQuery for us...
            if (HttpContext.Current.Items[Key] != null)
            {
                if (HttpContext.Current.Items[Key] is StringCollection collection && collection.Contains("jquery"))
                {
                    registerJQuery = false;
                }
            }
            else if (Config.IsDotNetNuke)
            {
                // latest version of DNN (v5) should register jQuery for us...
                registerJQuery = false;
            }

            if (registerJQuery)
            {
                string jqueryUrl;

                // Check if override file is set ?
                if (Config.JQueryOverrideFile.IsSet())
                {
                    jqueryUrl = !Config.JQueryOverrideFile.StartsWith("http") &&
                                !Config.JQueryOverrideFile.StartsWith("//")
                                    ? YafForumInfo.GetURLToScripts(Config.JQueryOverrideFile)
                                    : Config.JQueryOverrideFile;
                }
                else
                {
                    jqueryUrl = $"~/forum/Scripts/jquery-{Config.JQueryVersion}.min.js";
                }

                // load jQuery
                // element.Controls.Add(ControlHelper.MakeJsIncludeControl(jqueryUrl));
                ScriptManager.ScriptResourceMapping.AddDefinition(
                    "jquery",
                    new ScriptResourceDefinition
                {
                    Path         = jqueryUrl,
                    DebugPath    = YafForumInfo.GetURLToScripts($"jquery-{Config.JQueryVersion}.js"),
                    CdnPath      = $"//ajax.aspnetcdn.com/ajax/jQuery/jquery-{Config.JQueryVersion}.min.js",
                    CdnDebugPath = $"//ajax.aspnetcdn.com/ajax/jQuery/jquery-{Config.JQueryVersion}.js",
                    CdnSupportsSecureConnection = true        /*,
                                                               * LoadSuccessExpression = "window.jQuery"*/
                });

                YafContext.Current.PageElements.AddScriptReference("jquery");
            }

            YafContext.Current.PageElements.AddPageElement("jquery");
        }