Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework usernotes popup formatting #647

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 25 additions & 26 deletions extension/data/modules/usernotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,14 +329,9 @@ function startUsernotes ({maxChars, showDate, onlyshowInhover}) {
tabs: [{
content: `
<div class="utagger-content">
<table class="utagger-notes">
<tbody>
<tr>
<td class="utagger-notes-td1">Author</td>
<td class="utagger-notes-td2">Note</td>
<td class="utagger-notes-td3"></td></tr>
</tbody>
</table>
<ul class="utagger-notes">

</ul>
<div class="utagger-types">
<div class="utagger-type-list"></div>
</div>
Expand All @@ -361,7 +356,7 @@ function startUsernotes ({maxChars, showDate, onlyshowInhover}) {
});

// defined so we can easily add things to these specific areas after loading the notes.
const $noteList = $popup.find('.utagger-content .utagger-notes tbody'),
const $noteList = $popup.find('.utagger-content ul.utagger-notes'),
$typeList = $popup.find('.utagger-types .utagger-type-list');

// We want to make sure windows fit on the screen.
Expand Down Expand Up @@ -446,36 +441,40 @@ function startUsernotes ({maxChars, showDate, onlyshowInhover}) {
timeString = new Date(note.time).toLocaleString();

// Construct some elements separately
let timeDiv;

let noteLinkElement = '';
if (note.link) {
let noteLink = note.link;
if (TBCore.isNewModmail && !noteLink.startsWith('https://')) {
noteLink = `https://www.reddit.com${noteLink}`;
}
timeDiv = `<div class="utagger-date" id="utagger-date-${i}"><a href="${noteLink}">${timeString}</a></div>`;
} else {
timeDiv = `<div class="utagger-date" id="utagger-date-${i}">${timeString}</div>`;
noteLinkElement = `
<li>
<a href="${noteLink}" class="tb-icons">${TBui.icons.tbSettingLink}</a>
</li>`;
}

let typeSpan = '';
if (info && info.text) {
typeSpan = `<span class="note-type" style="color: ${info.color}">[${TBHelpers.htmlEncode(info.text)}]</span>`;
typeSpan = `<span class="note-type" style="color: ${info.color}">${TBHelpers.htmlEncode(info.text)}</span>`;
}

// Add note to list
$noteList.append(`
<tr class="utagger-note">
<td class="utagger-notes-td1">
<div class="utagger-mod">${note.mod}</div>
${timeDiv}
</td>
<td class="utagger-notes-td2">
${typeSpan}
<li class="utagger-note">
<fieldset class="utagger-note-contents">
<legend>
${typeSpan}
<span class="utager-date" id="utagger-date-${i}">${timeString}</span>
<span class="utagger-mod">by ${note.mod}</span>
</legend>
<span class="note-text">${noteString}</span>
</td>
<td class="utagger-notes-td3"><i class="utagger-remove-note tb-icons tb-icons-negative" data-note-id="${noteId}">${TBui.icons.delete}</i></td>
</tr>
</fieldset>
<ul class="utagger-note-actions">
${noteLinkElement}
<li>
<a href="javascript:;" class="utagger-remove-note tb-icons tb-icons-negative" data-note-id="${noteId}">${TBui.icons.delete}</a>
</li>
</li>
</li>
`);
});
} else {
Expand Down
50 changes: 19 additions & 31 deletions extension/data/styles/usernotes.css
Original file line number Diff line number Diff line change
Expand Up @@ -29,50 +29,38 @@ body.mod-toolbox-rd.mod-toolbox-rd-new-modmail .tb-window a {
}

/* Popup styling */

.mod-toolbox-rd .utagger-popup .right {
float: right;
.mod-toolbox-rd .utagger-popup .utagger-notes .utagger-note-contents {
border: solid 1px rgb(23, 50, 78);
padding: 5px;
margin-bottom: 5px;
min-height: 40px;
}

.mod-toolbox-rd .utagger-popup .left {
float: left;
.mod-toolbox-rd .utagger-popup .utagger-notes .utager-date,
.mod-toolbox-rd .utagger-popup .utagger-notes .utagger-mod {
font-size: 10px;
color: rgb(128, 128, 128);
}

.mod-toolbox-rd .utagger-popup .utagger-date {
font-size: 80%;
.mod-toolbox-rd .utagger-popup .utagger-notes li.utagger-note {
display: grid;
grid-template-columns: auto 20px;
grid-template-rows: auto;
}

.mod-toolbox-rd .utagger-popup .utagger-notes {
width: 100%;
}

.mod-toolbox-rd .utagger-popup .utagger-notes td {
padding: 2px !important;
border: solid 1px #C1BFBF;
vertical-align: top;
}

.mod-toolbox-rd .utagger-popup .utagger-notes-td1 {
width: 65px;
}

.mod-toolbox-rd .utagger-popup .utagger-notes-td3 {
width: 5px;
border: 0;
}

.mod-toolbox-rd .utagger-popup .utagger-notes-td3 a {
color: #C92A2A;
font-weight: bold;
.mod-toolbox-rd .utagger-popup .utagger-notes ul.utagger-note-actions {
margin-top: 7px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}

.mod-toolbox-rd .utagger-popup .utagger-note .note-type {
margin-right: 2px;
}

.mod-toolbox-rd .utagger-popup .utagger-remove-note {
cursor: pointer;
}

.mod-toolbox-rd .utagger-popup .utagger-types {
display: inline-block;
Expand Down