Enables the manifest to load custom stylesheets outside the js loading
This commit is contained in:
51
src/Umbraco.Web/UI/JavaScript/CssInitialization.cs
Normal file
51
src/Umbraco.Web/UI/JavaScript/CssInitialization.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Manifest;
|
||||
|
||||
namespace Umbraco.Web.UI.JavaScript
|
||||
{
|
||||
internal class CssInitialization
|
||||
{
|
||||
private readonly ManifestParser _parser;
|
||||
|
||||
public CssInitialization(ManifestParser parser)
|
||||
{
|
||||
_parser = parser;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Processes all found manifest files and outputs yepnope.injectcss calls for all css files found in all manifests
|
||||
/// </summary>
|
||||
public string GetStylesheetInitialization()
|
||||
{
|
||||
JArray merged = new JArray();
|
||||
foreach (var m in _parser.GetManifests())
|
||||
{
|
||||
ManifestParser.MergeJArrays(merged, m.StyleSheetInitialize);
|
||||
}
|
||||
|
||||
return ParseMain(merged);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Parses the CssResources.Main and returns a yepnop.injectCss format
|
||||
/// </summary>
|
||||
/// <param name="replacements"></param>
|
||||
/// <returns></returns>
|
||||
internal static string ParseMain(JArray files)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
foreach (var file in files)
|
||||
sb.AppendFormat("{0}yepnope.injectCss('{1}');", Environment.NewLine, file);
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -27,8 +27,8 @@
|
||||
*/
|
||||
|
||||
/* temporary sorter lib, should be updated
|
||||
'lib/angular/angular-ui-sortable.js',*/
|
||||
'lib/jquery/jquery.sortable/jquery.sortable.js',
|
||||
'lib/angular/angular-ui-sortable.js',
|
||||
'lib/jquery/jquery.sortable/jquery.sortable.js',*/
|
||||
|
||||
/* App-wide file-upload helper */
|
||||
'lib/jquery/jquery.upload/js/jquery.fileupload.js',
|
||||
|
||||
Reference in New Issue
Block a user