[Stylesheets] Add style sheet loader

Add style sheet loader and move style sheets inclusion
out of index.html. WTD-591.
This commit is contained in:
Victor Woeltjen 2015-01-14 17:01:52 -08:00
parent 04ee5bbbb5
commit fcab62b498
3 changed files with 55 additions and 17 deletions

View File

@ -3,23 +3,6 @@
<head lang="en">
<meta charset="UTF-8">
<title></title>
<link rel="stylesheet"
type="text/css",
href="platform/commonUI/general/res/css/normalize.min.css">
<link rel="stylesheet"
type="text/css",
href="platform/commonUI/general/res/css/theme-espresso.css">
<link rel="stylesheet"
type="text/css",
href="platform/commonUI/general/res/css/items.css">
<link rel="stylesheet"
type="text/css",
href="platform/commonUI/general/res/css/tree.css">
<script type="text/javascript"
src="platform/framework/lib/require.js"
data-main="platform/framework/src/Main.js">

View File

@ -3,6 +3,30 @@
"description": "General UI elements, meant to be reused across modes.",
"resources": "res",
"extensions": {
"runs": [
{
"implementation": "StyleSheetLoader.js",
"depends": [ "stylesheets[]", "$document" ]
}
],
"stylesheets": [
{
"stylesheetUrl": "css/normalize.min.css",
"priority": "mandatory"
},
{
"stylesheetUrl": "css/theme-espresso.css",
"priority": 1000
},
{
"stylesheetUrl": "css/items.css",
"priority": 901
},
{
"stylesheetUrl": "css/tree.css",
"priority": 900
}
],
"templates": [
{
"key": "bottombar",

View File

@ -0,0 +1,31 @@
/*global define*/
define(
["angular"],
function (angular) {
"use strict";
function StyleSheetLoader(stylesheets, $document) {
var head = $document.find('head');
function addStyleSheet(stylesheet) {
var link = angular.element('<link>'),
path = [
stylesheet.bundle.path,
stylesheet.bundle.resources,
stylesheet.stylesheetUrl
].join("/");
link.attr("rel", "stylesheet");
link.attr("type", "text/css");
link.attr("href", path);
head.append(link);
}
stylesheets.forEach(addStyleSheet);
}
return StyleSheetLoader;
}
);