12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- 'use strict';
- /**
- * Licensed Materials - Property of IBM
- * IBM Cognos Products: BI
- * (C) Copyright IBM Corp. 2019
- * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- */
- /**
- * This helper is needed to work past inconsistencies in dialog blocker class names between our legacy code
- * and the ba-ui-toolkit dialog blocker which is triggered from some dialogs and interactions
- */
- define(['jquery'], function ($) {
- return {
- dialogBlockerClasses: ['dialogBlocker', 'ba-common-dialog__blockerCell'],
- /**
- * Check if any dialog blockers are open
- * @returns {Boolean} checks if the document has any active elements with any dialog blocker class
- */
- isShowingDialogBlocker: function isShowingDialogBlocker() {
- return this.dialogBlockerClasses.some(function (className) {
- return document.getElementsByClassName(className).length > 0;
- });
- },
- /**
- * @returns {DOMElement} blocker
- */
- createBlocker: function createBlocker() {
- var $blocker = document.createElement('div');
- $blocker.classList.add('dialogBlocker');
- $blocker.setAttribute('tabindex', '-1');
- return $blocker;
- },
- /**
- * Same as createBlocker but wraps the returned ele in a jq wrapper for api consistency in core
- * @returns {jqElement}
- */
- getJqBlocker: function getJqBlocker() {
- return this._wrapEleInJq(this.createBlocker());
- },
- /**
- * This is a non declarative convenience function to keep the API in core and its use of jq consistent
- * @param {*} parent jqEle or dom ele
- * @param {*} $blocker (optional) jqEle or dom ele
- * @returns {jqElement} a wrapped blocker element ref
- */
- show: function show(parent, $blocker) {
- if (!$blocker) {
- $blocker = this.createBlocker();
- } else if ($blocker.length > 0) {
- $blocker = $blocker[0];
- }
- parent = parent.length ? parent[0] : parent; // convert jq eles to normal dom eles
- parent.appendChild($blocker);
- return this._wrapEleInJq($blocker);
- },
- _wrapEleInJq: function _wrapEleInJq(domEle) {
- return $(domEle);
- }
- };
- });
- //# sourceMappingURL=DialogBlocker.js.map
|