| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 | 
							- /* global $ */
 - var JitsiPopover = (function () {
 -     /**
 -      * The default options
 -      */
 -     const defaultOptions = {
 -         skin: 'white',
 -         content: '',
 -         hasArrow: true,
 -         onBeforePosition: undefined
 -     };
 - 
 -     /**
 -      * Constructs new JitsiPopover and attaches it to the element
 -      * @param element jquery selector
 -      * @param options the options for the popover.
 -      *  - {Function} onBeforePosition - function executed just before
 -      *      positioning the popover. Useful for translation.
 -      * @constructor
 -      */
 -     function JitsiPopover(element, options)
 -     {
 -         this.options = Object.assign({}, defaultOptions, options);
 - 
 -         this.elementIsHovered = false;
 -         this.popoverIsHovered = false;
 -         this.popoverShown = false;
 - 
 -         element.data("jitsi_popover", this);
 -         this.element = element;
 -         this.template = this.getTemplate();
 -         var self = this;
 -         this.element.on("mouseenter", function () {
 -             self.elementIsHovered = true;
 -             self.show();
 -         }).on("mouseleave", function () {
 -             self.elementIsHovered = false;
 -             setTimeout(function () {
 -                 self.hide();
 -             }, 10);
 -         });
 -     }
 - 
 -     /**
 -      * Returns template for popover
 -      */
 -     JitsiPopover.prototype.getTemplate = function () {
 -         let arrow = '';
 -         if (this.options.hasArrow) {
 -             arrow = '<div class="arrow"></div>';
 -         }
 -         return  (
 -             `<div class="jitsipopover ${this.options.skin}">
 -                 ${arrow}
 -                 <div class="jitsipopover__content"></div>
 -             <div class="jitsipopover__menu-padding"></div></div>`
 -         );
 -     };
 - 
 -     /**
 -      * Shows the popover
 -      */
 -     JitsiPopover.prototype.show = function () {
 -         if(!JitsiPopover.enabled)
 -             return;
 -         this.createPopover();
 -         this.popoverShown = true;
 -     };
 - 
 -     /**
 -      * Hides the popover
 -      */
 -     JitsiPopover.prototype.hide = function () {
 -         if(!this.elementIsHovered && !this.popoverIsHovered &&
 -             this.popoverShown) {
 -             this.forceHide();
 -         }
 -     };
 - 
 -     /**
 -      * Hides the popover.
 -      */
 -     JitsiPopover.prototype.forceHide = function () {
 -         $(".jitsipopover").remove();
 -         this.popoverShown = false;
 -     };
 - 
 -     /**
 -      * Creates the popover html.
 -      */
 -     JitsiPopover.prototype.createPopover = function () {
 -         $("body").append(this.template);
 -         let popoverElem = $(".jitsipopover > .jitsipopover__content");
 -         popoverElem.html(this.options.content);
 -         if(typeof this.options.onBeforePosition === "function") {
 -             this.options.onBeforePosition($(".jitsipopover"));
 -         }
 -         var self = this;
 -         $(".jitsipopover").on("mouseenter", function () {
 -             self.popoverIsHovered = true;
 -         }).on("mouseleave", function () {
 -             self.popoverIsHovered = false;
 -             self.hide();
 -         });
 - 
 -         this.refreshPosition();
 -     };
 - 
 -     /**
 -      * Refreshes the position of the popover.
 -      */
 -     JitsiPopover.prototype.refreshPosition = function () {
 -         $(".jitsipopover").position({
 -             my: "bottom",
 -             at: "top",
 -             collision: "fit",
 -             of: this.element,
 -             using: function (position, elements) {
 -                 var calcLeft = elements.target.left - elements.element.left +
 -                     elements.target.width/2;
 -                 $(".jitsipopover").css(
 -                     {top: position.top, left: position.left, display: "table"});
 -                 $(".jitsipopover > .arrow").css({left: calcLeft});
 -                 $(".jitsipopover > .jitsipopover__menu-padding").css(
 -                     {left: calcLeft - 50});
 -             }
 -         });
 -     };
 - 
 -     /**
 -      * Updates the content of popover.
 -      * @param content new content
 -      */
 -     JitsiPopover.prototype.updateContent = function (content) {
 -         this.options.content = content;
 -         if(!this.popoverShown)
 -             return;
 -         $(".jitsipopover").remove();
 -         this.createPopover();
 -     };
 - 
 -     JitsiPopover.enabled = true;
 - 
 -     return JitsiPopover;
 - })();
 - 
 - module.exports = JitsiPopover;
 
 
  |