Skip to content

Commit

Permalink
refactor Messages.js a little
Browse files Browse the repository at this point in the history
  • Loading branch information
YakovL committed Feb 12, 2019
1 parent 0568548 commit 75ac14f
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions js/Messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ function getMessageDiv()
if(!msgArea)
return null;
if(!msgArea.hasChildNodes()) {
var btn = createTiddlyButton(createTiddlyElement(msgArea,"div",null,"messageArea__toolbar messageToolbar"),
'',
config.messages.messageClose.tooltip,
clearMessage,
var toolbar = createTiddlyElement(msgArea,"div",null,"messageArea__toolbar messageToolbar");
var btn = createTiddlyButton(toolbar, '', config.messages.messageClose.tooltip, clearMessage,
"button messageToolbar__button");

btn.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" class="messageToolbar__icon">'+
' <rect width="1" height="13.1" x="4.5" y="-1.6" transform="rotate(-45 5 5)"/>'+
' <rect width="1" height="13.1" x="4.5" y="-1.6" transform="rotate(+45 5 5)"/>'+
'</svg>';
// inline SVG is unsupported in old FireFox
if(window.HTMLUnknownElement && btn.firstChild instanceof window.HTMLUnknownElement) {
btn.innerHTML = config.messages.messageClose.text;
} else {
Expand All @@ -27,19 +27,17 @@ function getMessageDiv()
return createTiddlyElement(msgArea,"div",null,"messageArea__text");
}

function displayMessage(text,linkText)
function displayMessage(text, link)
{
var e = getMessageDiv();
if(!e) {
alert(text);
return;
}
if(linkText) {
var link = createTiddlyElement(e,"a",null,null,text);
link.href = linkText;
link.target = "_blank";
} else {
if(!link) {
e.appendChild(document.createTextNode(text));
} else {
createTiddlyElement(e,"a",null,null,text,{ href: link, target: "_blank" });
}
}

Expand Down

0 comments on commit 75ac14f

Please sign in to comment.