Quellcode durchsuchen

Merge branch 'tooltips-global-handler' of https://github.com/m-voloshin/jitsi-meet into m-voloshin-tooltips-global-handler

j8
Lyubomir Marinov vor 8 Jahren
Ursprung
Commit
fef95f7cf1
2 geänderte Dateien mit 32 neuen und 6 gelöschten Zeilen
  1. 2
    0
      modules/UI/UI.js
  2. 30
    6
      modules/UI/util/UIUtil.js

+ 2
- 0
modules/UI/UI.js Datei anzeigen

@@ -340,6 +340,8 @@ UI.initConference = function () {
340 340
     // to the UI (depending on the moderator role of the local participant) and
341 341
     // (2) APP.conference as means of communication between the participants.
342 342
     followMeHandler = new FollowMe(APP.conference, UI);
343
+
344
+    UIUtil.activateTooltips();
343 345
 };
344 346
 
345 347
 UI.mucJoined = function () {

+ 30
- 6
modules/UI/util/UIUtil.js Datei anzeigen

@@ -84,6 +84,30 @@ import KeyboardShortcut from '../../keyboardshortcut/keyboardshortcut';
84 84
         context.putImageData(imgData, 0, 0);
85 85
     },
86 86
 
87
+    /**
88
+     * Sets global handler for all tooltips. Once this function is invoked
89
+     * all you need to create new tooltip is to update DOM node with
90
+     * appropriate class (ex. "tooltip-n") and "content" attribute.
91
+     */
92
+    activateTooltips: function () {
93
+        function getTitle () {
94
+            return this.getAttribute('content');
95
+        }
96
+
97
+        function getGravity () {
98
+            return this.getAttribute('data-tooltip');
99
+        }
100
+
101
+        AJS.$('[data-tooltip]').tooltip({
102
+            gravity: getGravity,
103
+            title: getTitle,
104
+            html: true,      // handle multiline tooltips
105
+            // two options to prevent tooltips from being stuck:
106
+            live: true,      // attach listener to document element
107
+            hoverable: false // make custom tooltips to behave like native
108
+        });
109
+    },
110
+
87 111
     /**
88 112
      * Sets the tooltip to the given element.
89 113
      *
@@ -103,13 +127,13 @@ import KeyboardShortcut from '../../keyboardshortcut/keyboardshortcut';
103 127
             'top-right': 'sw'
104 128
         };
105 129
 
106
-        element.setAttribute("data-i18n", "[content]" + key);
107
-        APP.translation.translateElement($(element));
130
+        $(element).each(function () {
131
+            var el = $(this);
132
+
133
+            el.attr("data-i18n", "[content]" + key)
134
+              .attr('data-tooltip', positions[position]);
108 135
 
109
-        AJS.$(element).tooltip({
110
-            gravity: positions[position],
111
-            title: this._getTooltipText.bind(this, element),
112
-            html: true
136
+            APP.translation.translateElement(el);
113 137
         });
114 138
     },
115 139
 

Laden…
Abbrechen
Speichern