Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import $ from 'jquery';
  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. * Indicates if we're currently in full screen mode.
  30. *
  31. * @return {boolean} {true} to indicate that we're currently in full screen
  32. * mode, {false} otherwise
  33. */
  34. isFullScreen() {
  35. return Boolean(document.fullscreenElement
  36. || document.mozFullScreenElement
  37. || document.webkitFullscreenElement
  38. || document.msFullscreenElement);
  39. },
  40. /**
  41. * Checks if the given DOM element is currently visible. The offsetParent
  42. * will be null if the "display" property of the element or any of its
  43. * parent containers is set to "none". This method will NOT check the
  44. * visibility property though.
  45. * @param {el} The DOM element we'd like to check for visibility
  46. */
  47. isVisible(el) {
  48. return el.offsetParent !== null;
  49. }
  50. };
  51. export default UIUtil;