Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

UIUtil.js 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /* global $ */
  2. /**
  3. * Created by hristo on 12/22/14.
  4. */
  5. const UIUtil = {
  6. /**
  7. * Escapes the given text.
  8. */
  9. escapeHtml(unsafeText) {
  10. return $('<div/>').text(unsafeText)
  11. .html();
  12. },
  13. /**
  14. * Inserts given child element as the first one into the container.
  15. * @param container the container to which new child element will be added
  16. * @param newChild the new element that will be inserted into the container
  17. */
  18. prependChild(container, newChild) {
  19. const firstChild = container.childNodes[0];
  20. let result;
  21. if (firstChild) {
  22. result = container.insertBefore(newChild, firstChild);
  23. } else {
  24. result = container.appendChild(newChild);
  25. }
  26. return result;
  27. },
  28. /**
  29. * Redirects to a given URL.
  30. *
  31. * @param {string} url - The redirect URL.
  32. * NOTE: Currently used to redirect to 3rd party location for
  33. * authentication. In most cases redirectWithStoredParams action must be
  34. * used instead of this method in order to preserve current URL params.
  35. */
  36. redirect(url) {
  37. window.location.href = url;
  38. },
  39. /**
  40. * Indicates if we're currently in full screen mode.
  41. *
  42. * @return {boolean} {true} to indicate that we're currently in full screen
  43. * mode, {false} otherwise
  44. */
  45. isFullScreen() {
  46. return Boolean(document.fullscreenElement
  47. || document.mozFullScreenElement
  48. || document.webkitFullscreenElement
  49. || document.msFullscreenElement);
  50. },
  51. /**
  52. * Checks if the given DOM element is currently visible. The offsetParent
  53. * will be null if the "display" property of the element or any of its
  54. * parent containers is set to "none". This method will NOT check the
  55. * visibility property though.
  56. * @param {el} The DOM element we'd like to check for visibility
  57. */
  58. isVisible(el) {
  59. return el.offsetParent !== null;
  60. }
  61. };
  62. export default UIUtil;