forked from playcanvas/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcss.js
More file actions
52 lines (45 loc) · 1.39 KB
/
css.js
File metadata and controls
52 lines (45 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
pc.extend(pc, function () {
'use strict';
var CssHandler = function () {};
CssHandler.prototype = {
load: function (url, callback) {
pc.http.get(url, function (err, response) {
if (!err) {
callback(null, response);
} else {
callback(pc.string.format("Error loading css resource: {0} [{1}]", url, err));
}
});
},
open: function (url, data) {
return data;
},
patch: function (asset, assets) {
}
};
/**
* @function
* @name pc.createStyle
* @description Creates a <style> DOM element from a string that contains CSS
* @param {String} cssString A string that contains valid CSS
* @example
* var css = 'body {height: 100;}';
* var style = pc.createStyle(css);
* document.head.appendChild(style);
* @returns {Element} The style DOM element
*/
var createStyle = function (cssString) {
var result = document.createElement('style');
result.type = 'text/css';
if (result.styleSheet) {
result.styleSheet.cssText = cssString;
} else {
result.appendChild(document.createTextNode(cssString));
}
return result;
};
return {
CssHandler: CssHandler,
createStyle: createStyle
};
}());