Browse Source

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

j8
Lyubomir Marinov 8 years ago
parent
commit
fef95f7cf1
2 changed files with 32 additions and 6 deletions
  1. 2
    0
      modules/UI/UI.js
  2. 30
    6
      modules/UI/util/UIUtil.js

+ 2
- 0
modules/UI/UI.js View File

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

+ 30
- 6
modules/UI/util/UIUtil.js View File

84
         context.putImageData(imgData, 0, 0);
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
      * Sets the tooltip to the given element.
112
      * Sets the tooltip to the given element.
89
      *
113
      *
103
             'top-right': 'sw'
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
 

Loading…
Cancel
Save