示例#1
0
        public JavaScriptResult Application()
        {
            var files  = JsInitialization.OptimizeScriptFiles(HttpContext, JsInitialization.GetPreviewInitialization());
            var result = JsInitialization.GetJavascriptInitialization(HttpContext, files, "umbraco.preview");

            return(JavaScript(result));
        }
示例#2
0
        public JsonNetResult GetManifestAssetList()
        {
            JArray GetAssetList()
            {
                var initJs  = new JsInitialization(_manifestParser);
                var initCss = new CssInitialization(_manifestParser);
                var assets  = new List <string>();

                assets.AddRange(initJs.OptimizeBackOfficeScriptFiles(HttpContext, Enumerable.Empty <string>()));
                assets.AddRange(initCss.GetStylesheetFiles(HttpContext));
                return(new JArray(assets));
            }

            //cache the result if debugging is disabled
            var result = HttpContext.IsDebuggingEnabled
                ? GetAssetList()
                : AppCaches.RuntimeCache.GetCacheItem <JArray>(
                "Umbraco.Web.Editors.BackOfficeController.GetManifestAssetList",
                GetAssetList,
                new TimeSpan(0, 2, 0));

            return(new JsonNetResult(JsonNetResult.DefaultJsonSerializerSettings)
            {
                Data = result, Formatting = Formatting.None
            });
        }
        public JsonNetResult GetManifestAssetList()
        {
            Func <JArray> getResult = () =>
            {
                var plugins   = new DirectoryInfo(Server.MapPath("~/App_Plugins"));
                var parser    = new ManifestParser(plugins, ApplicationContext.ApplicationCache.RuntimeCache);
                var initJs    = new JsInitialization(parser);
                var initCss   = new CssInitialization(parser);
                var jsResult  = initJs.GetJavascriptInitializationArray(HttpContext, new JArray());
                var cssResult = initCss.GetStylesheetInitializationArray(HttpContext);
                ManifestParser.MergeJArrays(jsResult, cssResult);
                return(jsResult);
            };

            //cache the result if debugging is disabled
            var result = HttpContext.IsDebuggingEnabled
                ? getResult()
                : ApplicationContext.ApplicationCache.RuntimeCache.GetCacheItem <JArray>(
                typeof(BackOfficeController) + "GetManifestAssetList",
                () => getResult(),
                new TimeSpan(0, 10, 0));

            return(new JsonNetResult {
                Data = result, Formatting = Formatting.Indented
            });
        }
        public JavaScriptResult Application()
        {
            var initJs = new JsInitialization(_manifestParser);
            var initCss = new CssInitialization(_manifestParser);

            var files = initJs.OptimizeBackOfficeScriptFiles(HttpContext, JsInitialization.GetDefaultInitialization());
            var result = JsInitialization.GetJavascriptInitialization(HttpContext, files, "umbraco");
            result += initCss.GetStylesheetInitialization(HttpContext);

            return JavaScript(result);
        }
示例#5
0
        public static IHtmlString AngularValueTinyMceAssets(this HtmlHelper html)
        {
            var ctx   = new HttpContextWrapper(HttpContext.Current);
            var files = JsInitialization.OptimizeTinyMceScriptFiles(ctx);

            var sb = new StringBuilder();

            sb.AppendLine(@"app.value(""tinyMceAssets"",");
            sb.AppendLine(JsonConvert.SerializeObject(files));
            sb.AppendLine(@");");


            return(html.Raw(sb.ToString()));
        }
示例#6
0
        public void Parse_Main()
        {
            var result = JsInitialization.ParseMain(new[] { "[World]", "Hello" });

            Assert.AreEqual(@"LazyLoad.js([World], function () {
    //we need to set the legacy UmbClientMgr path
    UmbClientMgr.setUmbracoPath('Hello');

    jQuery(document).ready(function () {

        angular.bootstrap(document, ['umbraco']);

    });
});", result);
        }
        public JavaScriptResult Application()
        {
            var plugins = new DirectoryInfo(Server.MapPath("~/App_Plugins"));
            var parser  = new ManifestParser(plugins, ApplicationContext.ApplicationCache.RuntimeCache);
            var initJs  = new JsInitialization(parser);
            var initCss = new CssInitialization(parser);

            //get the legacy ActionJs file references to append as well
            var legacyActionJsRef = new JArray(GetLegacyActionJs(LegacyJsActionType.JsUrl));

            var result = initJs.GetJavascriptInitialization(HttpContext, JsInitialization.GetDefaultInitialization(), legacyActionJsRef);

            result += initCss.GetStylesheetInitialization(HttpContext);

            return(JavaScript(result));
        }
        public void Parse_Main()
        {
            var result = JsInitialization.WriteScript("[World]", "Hello", "Blah");

            Assert.AreEqual(@"LazyLoad.js([World], function () {
    //we need to set the legacy UmbClientMgr path
    if ((typeof UmbClientMgr) !== ""undefined"") {
        UmbClientMgr.setUmbracoPath('Hello');
    }

    jQuery(document).ready(function () {

        angular.bootstrap(document, ['Blah']);

    });
});".StripWhitespace(), result.StripWhitespace());
        }
示例#9
0
        public void Get_Default_Init()
        {
            var init = JsInitialization.GetDefaultInitialization();

            Assert.IsTrue(init.Any());
        }