add fillElemWithTxt() to fill elements with formatted text with bind actions on it

This commit is contained in:
Simon Grim 2016-02-22 16:40:04 +05:00
parent f656997fa4
commit d33f77a44e

View File

@ -801,6 +801,27 @@ function openConversationModal(peerAlias, resource) {
});
}
function fillElemWithTxt(elem, txt, htmlFormatMsgOpt) {
var formatted = htmlFormatMsg(txt, htmlFormatMsgOpt);
elem.html(formatted.html);
elem.find('a')
.on('mouseup',
function (event) {
var href = event.target.getAttribute('href');
if (href[0] === '#') {
event.data = {route: href};
routeOnClick(event);
} else
muteEvent(event);
}
)
.on('click', {preventDefault: true}, muteEvent)
;
return formatted;
}
function routeOnClick(event) {
function routeNewTab(event) {