U_Blocker.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. IBM Confidential
  3. OCO Source Materials
  4. IBM Cognos Products: rs
  5. (C) Copyright IBM Corp. 2018
  6. The source code for this program is not published or otherwise divested of its trade secrets, irrespective of what has been deposited with the U.S. Copyright Office.
  7. */
  8. define( [], function() {
  9. var m_divEventBlocker;
  10. var K_iKeyTab = 9;
  11. var f_stopTabKey = function( e )
  12. {
  13. if ( e.keyCode == K_iKeyTab )
  14. {
  15. e.preventDefault();
  16. e.stopPropagation();
  17. }
  18. };
  19. var U_Blocker = {};
  20. /**
  21. * Show a blocker over the entire window to prevent user interaction
  22. * @param {Integer} v_iZIndex z-index that the blocker should be shown at
  23. * @type DIV
  24. * @returns The blocker.
  25. */
  26. U_Blocker.F_ShowEventBlocker = function( v_iZIndex )
  27. {
  28. if ( !m_divEventBlocker )
  29. {
  30. m_divEventBlocker = document.body.appendChild( document.createElement( "DIV" ) );
  31. m_divEventBlocker.onkeydown = f_stopTabKey;
  32. //m_divEventBlocker.className = "clsBlocker";
  33. // Following is equivalent to clsBlocker
  34. m_divEventBlocker.style.position = 'absolute';
  35. m_divEventBlocker.style.left = '0';
  36. m_divEventBlocker.style.top = '0';
  37. m_divEventBlocker.style.width = '100%';
  38. m_divEventBlocker.style.height = '100%';
  39. }
  40. m_divEventBlocker.style.zIndex = v_iZIndex;
  41. m_divEventBlocker.style.visibility = "visible";
  42. return m_divEventBlocker;
  43. };
  44. /**
  45. * Hides the blocker
  46. * @type void
  47. */
  48. U_Blocker.F_HideEventBlocker = function()
  49. {
  50. if ( m_divEventBlocker )
  51. {
  52. m_divEventBlocker.style.visibility = "hidden";
  53. ["onmousedown", "onmouseup", "onmousemove", "onclick", "ondblclick", "onmouseover", "onmouseout"].forEach( function( s ) { this[s] = null; }, m_divEventBlocker );
  54. }
  55. };
  56. return U_Blocker;
  57. });