浏览代码

feat(JitsiPopover): Add onBeforePosition option

master
hristoterezov 8 年前
父节点
当前提交
ea0f0da8a4
共有 3 个文件被更改,包括 26 次插入17 次删除
  1. 18
    12
      modules/UI/util/JitsiPopover.js
  2. 6
    4
      modules/UI/videolayout/ConnectionIndicator.js
  3. 2
    1
      modules/UI/videolayout/RemoteVideo.js

+ 18
- 12
modules/UI/util/JitsiPopover.js 查看文件

1
-/* global $, APP */
1
+/* global $ */
2
 var JitsiPopover = (function () {
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
      * Constructs new JitsiPopover and attaches it to the element
14
      * Constructs new JitsiPopover and attaches it to the element
5
      * @param element jquery selector
15
      * @param element jquery selector
6
      * @param options the options for the popover.
16
      * @param options the options for the popover.
17
+     *  - {Function} onBeforePosition - function executed just before
18
+     *      positioning the popover. Useful for translation.
7
      * @constructor
19
      * @constructor
8
      */
20
      */
9
     function JitsiPopover(element, options)
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
         this.elementIsHovered = false;
25
         this.elementIsHovered = false;
22
         this.popoverIsHovered = false;
26
         this.popoverIsHovered = false;
88
         $("body").append(this.template);
92
         $("body").append(this.template);
89
         let popoverElem = $(".jitsipopover > .jitsipopover__content");
93
         let popoverElem = $(".jitsipopover > .jitsipopover__content");
90
         popoverElem.html(this.options.content);
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
         var self = this;
98
         var self = this;
93
         $(".jitsipopover").on("mouseenter", function () {
99
         $(".jitsipopover").on("mouseenter", function () {
94
             self.popoverIsHovered = true;
100
             self.popoverIsHovered = true;
138
     return JitsiPopover;
144
     return JitsiPopover;
139
 })();
145
 })();
140
 
146
 
141
-module.exports = JitsiPopover;
147
+module.exports = JitsiPopover;

+ 6
- 4
modules/UI/videolayout/ConnectionIndicator.js 查看文件

1
-/* global $, config */
1
+/* global $, APP, config */
2
 /* jshint -W101 */
2
 /* jshint -W101 */
3
 import JitsiPopover from "../util/JitsiPopover";
3
 import JitsiPopover from "../util/JitsiPopover";
4
 import VideoLayout from "./VideoLayout";
4
 import VideoLayout from "./VideoLayout";
265
     this.videoContainer.container.appendChild(
265
     this.videoContainer.container.appendChild(
266
         this.connectionIndicatorContainer);
266
         this.connectionIndicatorContainer);
267
     this.popover = new JitsiPopover(
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
                         "data-i18n='connectionindicator.na'></div>",
270
                         "data-i18n='connectionindicator.na'></div>",
271
-        skin: "black"});
271
+            skin: "black",
272
+            onBeforePosition: el => APP.translation.translateElement(el)
273
+        });
272
 
274
 
273
     // override popover show method to make sure we will update the content
275
     // override popover show method to make sure we will update the content
274
     // before showing the popover
276
     // before showing the popover

+ 2
- 1
modules/UI/videolayout/RemoteVideo.js 查看文件

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

正在加载...
取消
保存