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

This commit is contained in:
Lyubomir Marinov 2016-09-28 07:38:32 -05:00
commit fef95f7cf1
2 changed files with 32 additions and 6 deletions

View File

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

View File

@ -84,6 +84,30 @@ import KeyboardShortcut from '../../keyboardshortcut/keyboardshortcut';
context.putImageData(imgData, 0, 0); context.putImageData(imgData, 0, 0);
}, },
/**
* Sets global handler for all tooltips. Once this function is invoked
* all you need to create new tooltip is to update DOM node with
* appropriate class (ex. "tooltip-n") and "content" attribute.
*/
activateTooltips: function () {
function getTitle () {
return this.getAttribute('content');
}
function getGravity () {
return this.getAttribute('data-tooltip');
}
AJS.$('[data-tooltip]').tooltip({
gravity: getGravity,
title: getTitle,
html: true, // handle multiline tooltips
// two options to prevent tooltips from being stuck:
live: true, // attach listener to document element
hoverable: false // make custom tooltips to behave like native
});
},
/** /**
* Sets the tooltip to the given element. * Sets the tooltip to the given element.
* *
@ -103,13 +127,13 @@ import KeyboardShortcut from '../../keyboardshortcut/keyboardshortcut';
'top-right': 'sw' 'top-right': 'sw'
}; };
element.setAttribute("data-i18n", "[content]" + key); $(element).each(function () {
APP.translation.translateElement($(element)); var el = $(this);
AJS.$(element).tooltip({ el.attr("data-i18n", "[content]" + key)
gravity: positions[position], .attr('data-tooltip', positions[position]);
title: this._getTooltipText.bind(this, element),
html: true APP.translation.translateElement(el);
}); });
}, },