office-ui-fabric-react
Version:
Reusable React components for building experiences for Office 365.
63 lines • 2.06 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
var _layersByHostId = {};
var _defaultHostSelector;
/**
* Register a layer for a given host id
* @param hostId Id of the layer host
* @param layer Layer instance
*/
function registerLayer(hostId, layer) {
if (!_layersByHostId[hostId]) {
_layersByHostId[hostId] = [];
}
_layersByHostId[hostId].push(layer);
}
exports.registerLayer = registerLayer;
/**
* Unregister a layer for a given host id
* @param hostId Id of the layer host
* @param layer Layer instance
*/
function unregisterLayer(hostId, layer) {
if (_layersByHostId[hostId]) {
var idx = _layersByHostId[hostId].indexOf(layer);
if (idx >= 0) {
_layersByHostId[hostId].splice(idx, 1);
if (_layersByHostId[hostId].length === 0) {
delete _layersByHostId[hostId];
}
}
}
}
exports.unregisterLayer = unregisterLayer;
/**
* Used for notifying applicable Layers that a host is available/unavailable and to re-evaluate Layers that
* care about the specific host.
*/
function notifyHostChanged(id) {
if (_layersByHostId[id]) {
_layersByHostId[id].forEach(function (layer) { return layer.forceUpdate(); });
}
}
exports.notifyHostChanged = notifyHostChanged;
/**
* Sets the default target selector to use when determining the host in which
* Layered content will be injected into. If not provided, an element will be
* created at the end of the document body.
*
* Passing in a falsey value will clear the default target and reset back to
* using a created element at the end of document body.
*/
function setDefaultTarget(selector) {
_defaultHostSelector = selector;
}
exports.setDefaultTarget = setDefaultTarget;
/**
* Get the default target selector when determining a host
*/
function getDefaultTarget() {
return _defaultHostSelector;
}
exports.getDefaultTarget = getDefaultTarget;
//# sourceMappingURL=Layer.notification.js.map
;