UI plugin API: Support IE-compatible CSS loading If browser is IE < 9, use document.createStyleSheet to properly load plugin's CSS dynamically.
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/5b74b4d6 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/5b74b4d6 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/5b74b4d6 Branch: refs/heads/object_store Commit: 5b74b4d6fe68e81d76ce8743c017201212f0d7aa Parents: 732566e Author: Brian Federle <brian.fede...@citrix.com> Authored: Tue May 7 15:44:28 2013 -0700 Committer: Brian Federle <brian.fede...@citrix.com> Committed: Tue May 7 15:44:59 2013 -0700 ---------------------------------------------------------------------- ui/scripts/plugins.js | 19 ++++++++++++------- 1 files changed, 12 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5b74b4d6/ui/scripts/plugins.js ---------------------------------------------------------------------- diff --git a/ui/scripts/plugins.js b/ui/scripts/plugins.js index 122f4a0..6a886ba 100644 --- a/ui/scripts/plugins.js +++ b/ui/scripts/plugins.js @@ -20,15 +20,20 @@ } var loadCSS = function(path) { - var $link = $('<link>'); + if (document.createStyleSheet) { + // IE-compatible CSS loading + document.createStyleSheet(path); + } else { + var $link = $('<link>'); - $link.attr({ - rel: 'stylesheet', - type: 'text/css', - href: path - }); + $link.attr({ + rel: 'stylesheet', + type: 'text/css', + href: path + }); - $('head').append($link); + $('html head').append($link); + } }; $.extend(cloudStack.pluginAPI, {