コード例 #1
0
        // Protected Methods (1) 

        protected void Page_Load(object sender, EventArgs e)
        {
            string fileVersion = GetFileVersion();

            foreach (string path in new[] { "libraries/jquery.min", "jquery.signalR-1.1.3.min" }
                     .Select(s => JS_PATH + s + ".js?v=" + fileVersion))
            {
                SPPageContentManager.RegisterScriptFile(Page, path, false, true, "javascript", null);
            }
        }
コード例 #2
0
        public static void RegisterScript(Page page, string[] scripts, bool localizable = false)
        {
            if (page == null)
            {
                return;
            }

            bool debugMode = false;

            try
            {
                string debug = HttpContext.Current.Request.Params["epmdebug"];
                if ((debug ?? string.Empty).ToLower().Equals("true"))
                {
                    debugMode = true;
                }
            }
            catch { }

            var bundledScripts = new[]
            {
                "jquery", "jquery-ui", "UplandV5", "jquery.cookie", "tooltip", "bindWithDelay", "EPM"
            };

            foreach (string script in from script in scripts
                     where !string.IsNullOrEmpty(script)
                     select script.Trim().ToLower()
                     into script
                     where !string.IsNullOrEmpty(script)
                     where !script.Equals("@")
                     where !script.Equals("/")
                     where !script.Equals("@/")
                     select script)
            {
                string scrpt = script.Replace("@", string.Empty);

                if ((from bundledScript in bundledScripts
                     select bundledScript.ToLower()
                     into s
                     select new[] { s, s + ".js", s + ".min", s + ".min.js", s + ".debug.js" }
                     into variations
                     let pieces = scrpt.Split('/')
                                  let currentScript = pieces[pieces.Length - 1]
                                                      where variations.Any(v => v.Equals(currentScript))
                                                      select variations).Any())
                {
                    continue;
                }

                bool defer = !scrpt.Equals("masterpages/uplandv5.master");
                SPPageContentManager.RegisterScriptFile(page, GetScript(script, debugMode), localizable, defer, "javascript", null);
            }
        }