Exemple #1
0
        public SkJsFile GetJsFile(string filename, bool isExternal)
        {
            filename = filename.Replace("/", Sk.DirectorySeparator);
            var file = JsFiles.Where(t => FileEquals(t.JsFile.Filename, filename)).FirstOrDefault();

            if (file == null)
            {
                file = ExternalJsFiles.Where(t => FileEquals(t.JsFile.Filename, filename)).FirstOrDefault();
            }
            if (file == null)
            {
                file = new SkJsFile {
                    JsFile = new JsFile {
                        Filename = filename, Units = new List <JsUnit>()
                    }, Compiler = Compiler
                };
                if (isExternal)
                {
                    file.JsFile.Units.Add(new JsExternalFileUnit {
                        Filename = filename
                    });
                    ExternalJsFiles.Add(file);
                }
                else
                {
                    JsFiles.Add(file);
                }
            }
            return(file);
        }
        /// <summary>
        /// Adds JS file to be added in layout
        /// </summary>
        /// <param name="file">Full path or relative "~/"</param>
        public HtmlResourcesAggregator AddJsFile(string file)
        {
            string fullPath = file.StartsWith("~/") ? VirtualPathUtility.ToAbsolute(file) : file;

            JsFiles.Add(fullPath);
            return(this);
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="runJsOnWindowLoad">是否在window.onload后,再运行js代码</param>
 public JsRunner(bool runJsOnWindowLoad = false)
 {
     if (ServerUrl == null)
     {
         throw new Exception("请先使用静态函数JsRunner.StartVirtualWebServer开启一个服务器");
     }
     _runJsOnWindowLoad = runJsOnWindowLoad;
     JsFiles.AddRange(GlobalJSFiles);
 }
Exemple #4
0
        public ABBPage AddJsFiles(params string[] fileNames)
        {
            if (fileNames == null)
            {
                return(this);
            }

            if (JsFiles == null)
            {
                JsFiles = new List <string>();
            }

            foreach (var fileName in fileNames)
            {
                JsFiles.Add(fileName);
            }
            return(this);
        }