Files
openlayers/src/ol/css.js
Tim Schaub 7f47883c48 Transformed
2017-12-12 06:53:18 -07:00

77 lines
1.4 KiB
JavaScript

/**
* @module ol/css
*/
var _ol_css_ = {};
/**
* The CSS class for hidden feature.
*
* @const
* @type {string}
*/
_ol_css_.CLASS_HIDDEN = 'ol-hidden';
/**
* The CSS class that we'll give the DOM elements to have them selectable.
*
* @const
* @type {string}
*/
_ol_css_.CLASS_SELECTABLE = 'ol-selectable';
/**
* The CSS class that we'll give the DOM elements to have them unselectable.
*
* @const
* @type {string}
*/
_ol_css_.CLASS_UNSELECTABLE = 'ol-unselectable';
/**
* The CSS class for unsupported feature.
*
* @const
* @type {string}
*/
_ol_css_.CLASS_UNSUPPORTED = 'ol-unsupported';
/**
* The CSS class for controls.
*
* @const
* @type {string}
*/
_ol_css_.CLASS_CONTROL = 'ol-control';
/**
* Get the list of font families from a font spec. Note that this doesn't work
* for font families that have commas in them.
* @param {string} The CSS font property.
* @return {Object.<string>} The font families (or null if the input spec is invalid).
*/
_ol_css_.getFontFamilies = (function() {
var style;
var cache = {};
return function(font) {
if (!style) {
style = document.createElement('div').style;
}
if (!(font in cache)) {
style.font = font;
var family = style.fontFamily;
style.font = '';
if (!family) {
return null;
}
cache[font] = family.split(/,\s?/);
}
return cache[font];
};
})();
export default _ol_css_;