@qooxdoo/framework
Version:
The JS Framework for Coders
120 lines (101 loc) • 3.61 kB
JavaScript
/* ************************************************************************
qooxdoo - the new era of web development
http://qooxdoo.org
Copyright:
2004-2011 1&1 Internet AG, Germany, http://www.1und1.de
License:
MIT: https://opensource.org/licenses/MIT
See the LICENSE file in the project's top-level directory for details.
Authors:
* Daniel Wagner (d_wagner)
************************************************************************ */
/**
* Internal class which contains the checks used by {@link qx.core.Environment}.
* All checks in here are marked as internal which means you should never use
* them directly.
*
* This class contains checks related to Stylesheet objects.
*
* @internal
*/
qx.Bootstrap.define("qx.bom.client.Stylesheet",
{
statics:
{
/**
* Returns a stylesheet to be used for feature checks
*
* @return {StyleSheet} Stylesheet element
*/
__getStylesheet : function()
{
if (!qx.bom.client.Stylesheet.__stylesheet) {
qx.bom.client.Stylesheet.__stylesheet = qx.bom.Stylesheet.createElement();
}
return qx.bom.client.Stylesheet.__stylesheet;
},
/**
* Check for IE's non-standard document.createStyleSheet function.
* In IE9 (standards mode), the typeof check returns "function" so false is
* returned. This is intended since IE9 supports the DOM-standard
* createElement("style") which should be used instead.
*
* @internal
* @return {Boolean} <code>true</code> if the browser supports
* document.createStyleSheet
*/
getCreateStyleSheet : function()
{
return typeof document.createStyleSheet === "object";
},
/**
* Check for stylesheet.insertRule. Legacy IEs do not support this.
*
* @internal
* @return {Boolean} <code>true</code> if insertRule is supported
*/
getInsertRule : function()
{
return typeof qx.bom.client.Stylesheet.__getStylesheet().insertRule === "function";
},
/**
* Check for stylesheet.deleteRule. Legacy IEs do not support this.
*
* @internal
* @return {Boolean} <code>true</code> if deleteRule is supported
*/
getDeleteRule : function()
{
return typeof qx.bom.client.Stylesheet.__getStylesheet().deleteRule === "function";
},
/**
* Decides whether to use the legacy IE-only stylesheet.addImport or the
* DOM-standard stylesheet.insertRule('@import [...]')
*
* @internal
* @return {Boolean} <code>true</code> if stylesheet.addImport is supported
*/
getAddImport : function()
{
return (typeof qx.bom.client.Stylesheet.__getStylesheet().addImport === "object");
},
/**
* Decides whether to use the legacy IE-only stylesheet.removeImport or the
* DOM-standard stylesheet.deleteRule('@import [...]')
*
* @internal
* @return {Boolean} <code>true</code> if stylesheet.removeImport is supported
*/
getRemoveImport : function()
{
return (typeof qx.bom.client.Stylesheet.__getStylesheet().removeImport === "object");
}
},
defer : function (statics) {
qx.core.Environment.add("html.stylesheet.createstylesheet", statics.getCreateStyleSheet);
qx.core.Environment.add("html.stylesheet.insertrule", statics.getInsertRule);
qx.core.Environment.add("html.stylesheet.deleterule", statics.getDeleteRule);
qx.core.Environment.add("html.stylesheet.addimport", statics.getAddImport);
qx.core.Environment.add("html.stylesheet.removeimport", statics.getRemoveImport);
}
});