Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. var JitsiPopover = (function () {
  2. /**
  3. * Constructs new JitsiPopover and attaches it to the element
  4. * @param element jquery selector
  5. * @param options the options for the popover.
  6. * @constructor
  7. */
  8. function JitsiPopover(element, options)
  9. {
  10. this.options = {
  11. skin: "white",
  12. content: ""
  13. };
  14. if(options)
  15. {
  16. if(options.skin)
  17. this.options.skin = options.skin;
  18. if(options.content)
  19. this.options.content = options.content;
  20. }
  21. this.elementIsHovered = false;
  22. this.popoverIsHovered = false;
  23. this.popoverShown = false;
  24. element.data("jitsi_popover", this);
  25. this.element = element;
  26. this.template = ' <div class="jitsipopover ' + this.options.skin +
  27. '"><div class="arrow"></div><div class="jitsipopover-content"></div>' +
  28. '<div class="jitsiPopupmenuPadding"></div></div>';
  29. var self = this;
  30. this.element.on("mouseenter", function () {
  31. self.elementIsHovered = true;
  32. self.show();
  33. }).on("mouseleave", function () {
  34. self.elementIsHovered = false;
  35. setTimeout(function () {
  36. self.hide();
  37. }, 10);
  38. });
  39. }
  40. /**
  41. * Shows the popover
  42. */
  43. JitsiPopover.prototype.show = function () {
  44. this.createPopover();
  45. this.popoverShown = true;
  46. };
  47. /**
  48. * Hides the popover
  49. */
  50. JitsiPopover.prototype.hide = function () {
  51. if(!this.elementIsHovered && !this.popoverIsHovered && this.popoverShown)
  52. {
  53. this.forceHide();
  54. }
  55. };
  56. /**
  57. * Hides the popover
  58. */
  59. JitsiPopover.prototype.forceHide = function () {
  60. $(".jitsipopover").remove();
  61. this.popoverShown = false;
  62. };
  63. /**
  64. * Creates the popover html
  65. */
  66. JitsiPopover.prototype.createPopover = function () {
  67. $("body").append(this.template);
  68. $(".jitsipopover > .jitsipopover-content").html(this.options.content);
  69. var self = this;
  70. $(".jitsipopover").on("mouseenter", function () {
  71. self.popoverIsHovered = true;
  72. }).on("mouseleave", function () {
  73. self.popoverIsHovered = false;
  74. self.hide();
  75. });
  76. this.refreshPosition();
  77. };
  78. /**
  79. * Refreshes the position of the popover
  80. */
  81. JitsiPopover.prototype.refreshPosition = function () {
  82. $(".jitsipopover").position({
  83. my: "bottom",
  84. at: "top",
  85. collision: "fit",
  86. of: this.element,
  87. using: function (position, elements) {
  88. var calcLeft = elements.target.left - elements.element.left + elements.target.width/2;
  89. $(".jitsipopover").css({top: position.top, left: position.left, display: "table"});
  90. $(".jitsipopover > .arrow").css({left: calcLeft});
  91. $(".jitsipopover > .jitsiPopupmenuPadding").css({left: calcLeft - 50});
  92. }
  93. });
  94. };
  95. /**
  96. * Updates the content of popover.
  97. * @param content new content
  98. */
  99. JitsiPopover.prototype.updateContent = function (content) {
  100. this.options.content = content;
  101. if(!this.popoverShown)
  102. return;
  103. $(".jitsipopover").remove();
  104. this.createPopover();
  105. };
  106. return JitsiPopover;
  107. })();