Skip to content

Commit

Permalink
Merge pull request #366 from playcanvas/feature/html-css-assets
Browse files Browse the repository at this point in the history
Support html / css assets
  • Loading branch information
vkalpias committed Jul 23, 2015
2 parents 0525892 + 9f6ff49 commit 494e200
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 0 deletions.
2 changes: 2 additions & 0 deletions build/dependencies.txt
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@
../src/resources/resources_script.js
../src/resources/resources_text.js
../src/resources/resources_texture.js
../src/resources/resources_html.js
../src/resources/resources_css.js
../src/resources/resources_scene.js
../src/resources/resources_hierarchy.js
../src/resources/resources_scenesettings.js
Expand Down
2 changes: 2 additions & 0 deletions src/framework/framework_application.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ pc.extend(pc, function () {
this.loader.addHandler("script", new pc.ScriptHandler(this));
this.loader.addHandler("scene", new pc.SceneHandler(this));
this.loader.addHandler("cubemap", new pc.CubemapHandler(this.graphicsDevice, this.assets, this.loader));
this.loader.addHandler("html", new pc.HtmlHandler());
this.loader.addHandler("css", new pc.CssHandler());
this.loader.addHandler("hierarchy", new pc.HierarchyHandler(this));
this.loader.addHandler("scenesettings", new pc.SceneSettingsHandler(this));

Expand Down
41 changes: 41 additions & 0 deletions src/resources/resources_css.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
pc.extend(pc, function () {
'use strict';

var CssHandler = function () {};

CssHandler.prototype = {
load: function (url, callback) {
pc.net.http.get(url, function (response) {
callback(null, response);
}, {
error: function (status, xhr, e) {
callback(pc.string.format("Error loading css resource: {0} [{1}]", url, status));
}
});
},

open: function (url, data) {
return data;
},

patch: function (asset, assets) {
}
};

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
};
}());
28 changes: 28 additions & 0 deletions src/resources/resources_html.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
pc.extend(pc, function () {
'use strict';

var HtmlHandler = function () {};

HtmlHandler.prototype = {
load: function (url, callback) {
pc.net.http.get(url, function (response) {
callback(null, response);
}, {
error: function (status, xhr, e) {
callback(pc.string.format("Error loading html resource: {0} [{1}]", url, status));
}
});
},

open: function (url, data) {
return data;
},

patch: function (asset, assets) {
}
};

return {
HtmlHandler: HtmlHandler
};
}());

0 comments on commit 494e200

Please sign in to comment.