Browse Source

feat(JitsiPopover): Add onBeforePosition option

master
hristoterezov 8 years ago
parent
commit
ea0f0da8a4

+ 18
- 12
modules/UI/util/JitsiPopover.js View File

@@ -1,22 +1,26 @@
1
-/* global $, APP */
1
+/* global $ */
2 2
 var JitsiPopover = (function () {
3
+    /**
4
+     * The default options
5
+     */
6
+    const defaultOptions = {
7
+        skin: 'white',
8
+        content: '',
9
+        hasArrow: true,
10
+        onBeforePosition: undefined
11
+    };
12
+
3 13
     /**
4 14
      * Constructs new JitsiPopover and attaches it to the element
5 15
      * @param element jquery selector
6 16
      * @param options the options for the popover.
17
+     *  - {Function} onBeforePosition - function executed just before
18
+     *      positioning the popover. Useful for translation.
7 19
      * @constructor
8 20
      */
9 21
     function JitsiPopover(element, options)
10 22
     {
11
-        let { skin, content, hasArrow } = options;
12
-        this.options = {};
13
-        this.options.skin = skin || 'white';
14
-        this.options.content = content || '';
15
-        this.options.hasArrow = true;
16
-
17
-        if (typeof(hasArrow) !== 'undefined') {
18
-            this.options.hasArrow = false;
19
-        }
23
+        this.options = Object.assign({}, defaultOptions, options);
20 24
 
21 25
         this.elementIsHovered = false;
22 26
         this.popoverIsHovered = false;
@@ -88,7 +92,9 @@ var JitsiPopover = (function () {
88 92
         $("body").append(this.template);
89 93
         let popoverElem = $(".jitsipopover > .jitsipopover__content");
90 94
         popoverElem.html(this.options.content);
91
-        APP.translation.translateElement(popoverElem);
95
+        if(typeof this.options.onBeforePosition === "function") {
96
+            this.options.onBeforePosition($(".jitsipopover"));
97
+        }
92 98
         var self = this;
93 99
         $(".jitsipopover").on("mouseenter", function () {
94 100
             self.popoverIsHovered = true;
@@ -138,4 +144,4 @@ var JitsiPopover = (function () {
138 144
     return JitsiPopover;
139 145
 })();
140 146
 
141
-module.exports = JitsiPopover;
147
+module.exports = JitsiPopover;

+ 6
- 4
modules/UI/videolayout/ConnectionIndicator.js View File

@@ -1,4 +1,4 @@
1
-/* global $, config */
1
+/* global $, APP, config */
2 2
 /* jshint -W101 */
3 3
 import JitsiPopover from "../util/JitsiPopover";
4 4
 import VideoLayout from "./VideoLayout";
@@ -265,10 +265,12 @@ ConnectionIndicator.prototype.create = function () {
265 265
     this.videoContainer.container.appendChild(
266 266
         this.connectionIndicatorContainer);
267 267
     this.popover = new JitsiPopover(
268
-        $("#" + this.videoContainer.videoSpanId + " > .connectionindicator"),
269
-        {content: "<div class=\"connection-info\" " +
268
+        $("#" + this.videoContainer.videoSpanId + " > .connectionindicator"), {
269
+            content: "<div class=\"connection-info\" " +
270 270
                         "data-i18n='connectionindicator.na'></div>",
271
-        skin: "black"});
271
+            skin: "black",
272
+            onBeforePosition: el => APP.translation.translateElement(el)
273
+        });
272 274
 
273 275
     // override popover show method to make sure we will update the content
274 276
     // before showing the popover

+ 2
- 1
modules/UI/videolayout/RemoteVideo.js View File

@@ -78,7 +78,8 @@ RemoteVideo.prototype._initPopupMenu = function (popupMenuElement) {
78 78
     let options = {
79 79
         content: popupMenuElement.outerHTML,
80 80
         skin: "black",
81
-        hasArrow: false
81
+        hasArrow: false,
82
+        onBeforePosition: el => APP.translation.translateElement(el)
82 83
     };
83 84
     let element = $("#" + this.videoSpanId + " .remotevideomenu");
84 85
     this.popover = new JitsiPopover(element, options);

Loading…
Cancel
Save