Enables the manifest to load custom stylesheets outside the js loading

This commit is contained in:
perploug
2013-10-02 10:54:25 +02:00
parent 727f3a804d
commit ce30153830
6 changed files with 78 additions and 5 deletions

View 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();
}
}
}

View File

@@ -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',