UNPKG

devextreme

Version:

HTML5 JavaScript Component Suite for Responsive Web Development

59 lines (58 loc) 1.7 kB
/** * DevExtreme (core/utils/window.js) * Version: 18.1.3 * Build date: Tue May 15 2018 * * Copyright (c) 2012 - 2018 Developer Express Inc. ALL RIGHTS RESERVED * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/ */ "use strict"; var domAdapter = require("../dom_adapter"); var _hasWindow = "undefined" !== typeof window; var windowObject = _hasWindow && window; if (!windowObject) { windowObject = {}; windowObject.window = windowObject } module.exports = { hasWindow: function() { return _hasWindow }, getWindow: function() { return windowObject }, hasProperty: function(prop) { return this.hasWindow() && prop in windowObject }, defaultScreenFactorFunc: function(width) { if (width < 768) { return "xs" } else { if (width < 992) { return "sm" } else { if (width < 1200) { return "md" } else { return "lg" } } } }, getCurrentScreenFactor: function(screenFactorCallback) { var screenFactorFunc = screenFactorCallback || this.defaultScreenFactorFunc; var windowWidth = domAdapter.getDocumentElement().clientWidth; return screenFactorFunc(windowWidth) }, openWindow: function() { if (this.hasProperty("open")) { return windowObject.open() } return null }, getNavigator: function() { return this.hasWindow() ? windowObject.navigator : { userAgent: "" } } };