|
@@ -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;
|