mirror of
https://github.com/twisterarmy/twister-html.git
synced 2025-02-04 19:14:14 +00:00
add fillElemWithTxt() to fill elements with formatted text with bind actions on it
This commit is contained in:
parent
f656997fa4
commit
d33f77a44e
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user